Code Monkey home page Code Monkey logo

mspsim's Introduction

MSPSim version 0.9x

MSPSim is a Java-based instruction level emulator of the MSP430 series microprocessor and emulation of some sensor networking platforms. Supports loading of IHEX and ELF firmware files, and has some tools for monitoring stack, setting breakpoints, and profiling.

System requirements

You need a recent Java to run MSPSim. Java 11 or newer is recommended. The current version of MSPSim also requires ant for compiling.

Building MSPSim

You will build MSPSim by typing

ant

Running examples

Run the default example on the ESB node emulator by typing:

ant runesb

(here you can pass the PIR with the mouse and click on the user button to get reaction from the example application).

Run the default example on the Sky node emulator by typing:

ant runsky

(this is a leds-blinker only and does not react to any mouse movements or button clicks).

Main Features

  • Instruction level emulation of MSP430 microprocessor
  • Supports loading of ELF and IHEX files
  • Easy to add external components that emulates external HW
  • Supports monitoring of registers, adding breakpoints, etc.
  • Built-in profiling of executed code
  • Statistics for various components modes (on/off, LPM modes, etc).
  • Emulates some external hardware such as TR1001 and CC2420.
  • Command Line Interface, CLI, for setting up breakpoints and output to files or windows.
  • GDB remote debugging support (initial)
  • What is emulated of the MSP430
  • CPU (instruction level simulation)
  • Timer A/B subsystem
  • USARTs
  • Digital I/O
  • Multiplication unit
  • Basic A/D subsystem (not complete)
  • Watchdog

Limitations of the emulation (some of them) on version 0.9x

  • Currently, the emulator runs as if it can use all memory as RAM (e.g. flash writes, etc not supported)
  • No DMA implementation
  • Timer system not 100% emulated

mspsim's People

Contributors

adamdunkels avatar cmorty avatar joakimeriksson avatar mmuman avatar nfi avatar pabigot avatar pjonsson avatar remyleone avatar simonduq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mspsim's Issues

CC2420 and probably others: CCA_MODE / CCA_HYST not evaluated

Is not evaluated. The default mode is 3 -> Signal strength + data, but only the signal strength is evaluated (mode 1). This can have a significant impact with high CCA thesholds.
CCA_HYST is not evaluated, which however isn't that bad as long as there is no noise-model.

Instruction Decoding - Possible Issue

Hello guys! Today I was running a bunch of code with mspsim and I faced an unexpected behavior of the simulator. If you look carefully at the image, it can be seen that Register 7 (R7) is submitted to a byte swap operation (PC=0xFC66h), and there is nothing abnormal at this point. By analyzing two lines below (PC=0xFC6E) it can be seen that the same register is rolled right. If I'm not wrong, the expected value to be stored at Register 7 was 0x5200 but for some reason mspsim stored a null value at it. However, by analyzing the instruction bytes at the left, it can be seen that they actually refer to SXT R7 and not RRA.W R7. Considering that the instruction executed was SXT, the result is reasonable. I think it won't change at the end but I'd like to report this tiny possible issue. I'm using mspsim 0.97 at Ubuntu 13.10.

screen shot 2014-04-03 at 14 08 13

CC2420 timing diff with hardware

There is a timing difference between a real cc2420 and MSPSim: the time between a call to NETSTACK_RADIO.transmit() (with the radio OFF) and the end of the SFD is, on hardware, about 456 usec. In MSPSim it is 369 usec.

What is needed is to add an extra 87 usec delay in MSPSim before every transmission.

make test complains about missing MCU header

Hi

'make test' fails while complaining about unknown MCU. For compilation -mmcu=msp430x1611 is given, but this (generic) cpu type is not listed in msp430.h and leads to the warning.

make test
(cd tests && make)
make[1]: Entering directory `.../src/mspsim/tests'
msp430-gcc -I. -DWITH_ASCII -Wall -mmcu=msp430x1611 -g -Os -DAUTOSTART_ENABLE -c cputest.c -o cputest.co
In file included from cputest.c:44:0:
/usr/lib/gcc/msp430/4.6.3/../../../../msp430/include/msp430.h:813:2: warning: #warning Unable to identify and include MCU header, use -mmcu=MCU [-Wcpp]

using this software:
mspsim last version from git
gcc version 4.6.3 20120301 (mspgcc LTS 20120406 unpatched) (GCC)
Ubuntu 14.04 LTS

Problems with Memory.AccessMode.BYTE

Some Components like Timer support only 16 Bit access for read and write. When Memory.AccessMode.BYTE is used the values of the odd addresses are incorrect.

Packet distribution with NetworkConnection won't work

In current(commit f2facc2) MSPSim,
NetworkConnection won't work properly.

I utilized an example program of Contiki-OS as follows;
Source code: /home/user/contiki/examples/ipv6/simple-udp-rpl/broadcast-example.c
And I created firmware for sky mote with following command,
make TARGET=sky broadcast-example

A mote executing this program sends 4 bytes of UDP message "Test"
to link-local allnodes multicast address with certain interval.
And, whenever the mote receives packets, it prints a message on USART1 Port Output.
I executed two MSPSims on a Instant Contiki 2.7 (Modified on 2013-11-15) which is running on VMware Fusion 6 Pro.
The command and option is as follows;
java -jar PATH_TO_MSPSIM/mspsim.jar PATH_TO_FIRMWARE/broadcast-example.sky -enableNetwork

In my understanding,
NetworkConnection encapsulates outgoing packets of CC2420 in TCP segments
and distributes the segments to other MSPSims through the loopback interface (e.g. lo).

I have captured packets on the loopback interface "lo" with Wireshark.
It shows that two MSPSims establishes TCP connection,
but no packet follows after this communication.

In addition,
I tried to distribute packets with using older MSPSims(commit 4b841fb).
Receiving packets are dropped in most cases
because RadioState of CC2420 is often being IDLE.
I guess this is not problem of NetworkConnection,
but motes with CC2420 rarely receives the distributed packets.

Please tell me if I use the wrong way.

Thanks.

mspsim on sourceforge

I was wondering what the status is of mspsim on sourceforge?

As the latest source code is only available on Github I would suggest making this clear on the sourceforge project page. This way, users don't spend unnecessary time on deprecated code.

No CCU Interrupt when tccr=65535

if(counter<tccr)... in Timer.java is not working if counter is wrapped

A solution is to use the "bigcounter".
Calculate bigcounter
Subtraction tccr-bigCounter
Wrap the result with modulo Operation (the current timer wrap value)
=> get the correct div

Also the timer in Updown Mode results in problems.

I probably solve all in my fork.

Loading External ELF Files on MSPSim

Hello There! I recently strated using mspsim and I'm really struggling to get some of its functionalities. It is said that it "Supports loading of IHEX and ELF firmware files" but for some reason I didn't manage to find out how can I do it. What I'm really trying to do is to embed msp assembly code to the processor's core and watch to its behavior. I don't actually need any kind of peripheral devices nor RTOS for my purpose. Is my intent suitable to mspsim? How can I embed such an assembly code on the simulador?

I know that it's not the way it is done, but I'm currently trying to simply update memory locations during debug over one of those demo programs that come with the build. However, I'm not even able to make my mset requests get commited. Is there a way to load simple memory files instead of a whole funcional program?

Thank you very much!

SUB Instruction Status Flag Interpretation

Hello guys! Today I was debugging a little software with MSPSIM and I really got stuck while trying to understand the effects of the status flags after subtraction operations with the simulator. I was performing a set of operations right in the registers (R4 and R14) and the two following operations were performed in a row:

SUB.B #0x0002, R14; R14 was loaded with 0x0000 -> Expected Status Flags: SR: -N--
SUB.B #0x0002, R4; R4 was loaded with 0x00FF -> Expected Status Flags: SR: -N-C

Results: R14 -> 0x00FE; R4 -> 0x00FD

The simulator successfully stores the correct results at the registers however, when performing these operations, I've noticed that it sets the Carry bit as a result of the first instruction which I believe may lead to unexpected behaviors. This is so, because a SUB instruction is performed by MSP430 CPU as a sum of the two's complement representation of the source, with the destination (and storing the result at the destination afterwards), like this: dst <- dst + [not(src) + 1]. Taking this into account, I believe that a carry (borrow) can't be generated as result of the first subtraction. I'll try to demonstrate below:

2'b                 ->   0 0 0 0   0 0 1 0 
One's Complement    ->   1 1 1 1   1 1 0 1 

                                       1 <-----Carry
Two's Complement    ->   1 1 1 1   1 1 0 1 
                       + 0 0 0 0   0 0 0 1 
                         -----------------
                         1 1 1 1   1 1 1 0 <-- 0x00FE

Subtraction         ->   0 0 0 0   0 0 0 0
                       + 1 1 1 1   1 1 1 0
                         -----------------
                         1 1 1 1   1 1 1 0 <-- 0x00FE (namely -2)

At the cluttered diagram I've shown above, neither the 'Two's complement' operation nor the sum itself generates a carry out and thus the status bit could not be set. I'm not sure if my assumptions are correct, so I'd really appreciate a little help to understand what's happening on these bit operations. Remember that I'm performing byte-wise operations and I've not yet tested the same code with word-size operands.
Thank you very much!

*PS: I don't know if this is the best place to ask such kind of question but I couldn't manage to find other place ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.