Jump to content
HanzZ

QSimKit - MSP430 simulator

Recommended Posts

Hi,

 

as my diploma thesis I'm writting MSP430 simulator called QSimKit. It's not finished yet, but it's in state when it's starting to be useful and I would like to get more people to test it, share their opinions, find bugs and basically to create community of people interested in MSP430 simulation.

 

Releases:

At first some facts about QSimKit:

  • It's written under GPLv2+ in C++/Qt, has been tested on Linux or Windows together with msp430gcc.
  • It supports peripherals (as plugins) written in C++ or Python. Currently there's LED, oscillator, button and HD44708 LCD (not fully implemented yet).
  • MCUs are plugins too and theoretically it's possible to add support for more MCUs (not just MSP430).
  • It can support all MSP430 variants, but only few are supported right now, because I haven't created package data for all MSP430 variants yet.

In graphical user interface (Check screenshot), you can do following:

  • Add peripherals, connect them to MCU.
  • See the source code of program you are simulating together with Dwarf debugging data (you can see the value of local variables for example) and current instruction.
  • Step the simulation, add breakpoints based on PC register or value of memory.
  • Track pins in oscilloscope-like view.
  • See the registers and other important values from MCU (frequency, BasicClock registers, ...)

MSP430 MCU plugin can do following:

  • Load ELF/A43 code.
  • Supports all instructions.
  • Supports BasicClock module (TImerA/TimerB).
  • Support for USCI-SPI [NEW in 0.0.3]
  • Support for USART-SPI [NEW in 0.0.3]
  • Initial USI support (just SPI mode).

Peripherals:

  • Button
  • LCD - HD44708 (only initial support)
  • LED
  • Crystal Oscillator
  • SD Card (only initial support) [NEW in 0.0.2]

 

As I stated earlier, it's not finished yet, but some testers to help me testing are welcome. I can also help anyone who would like to help with development. There is no development documentation yet, but if you tell me what you would like to do, I can write relevant docs to help you.

 

If you think you have found a bug or you have some feature request, please create ticket on GitHub, I don't want this forum thread to be an issue tracker. You can also find me on IRC in #qsimkit at freenode or as HanzZ in #43oh channel.

Share this post


Link to post
Share on other sites

Nice.  How fast can it run?

 

That depends on the complexity of the project. It's discrete simulation running in single thread where every peripheral generates events which have to be handled. With more events, simulation is slower. It's also configured to eat just 60% of your PC CPU right now.

 

There are places which can be optimized. Those optimizations could make it much more faster (For example SMCLK generates events based on its frequency even when there is no peripheral which needs so high frequency - it has for example divider 8. In this case SMCLK could be simulated with its_frequency/8, which would mean 8x less simulation events == much more faster simulation). I plan to do those optimizations, but for now I'm working on SPI support, but this is definitely on my TODO list.

 

To give you some numbers:

 

In LCD simulation (MSP430 + LCD), 0.1 seconds in simulation time takes 1 second in real-time on my machine.

 

LCD simulation with external oscillators connected to MSP430 (oscillators generate events at 8Mhz and 32Khz), it is 0.02 seconds of simulation time per 1 second in real-time. Again, possible optimization here is to not send "zeros and ones" from external oscillator to MSP430 based on its frequency, but only tell MSP430 something like "this is oscillator connected to this PIN with frequency N". That way, it would run as fast as the version without external oscillators.

 

So, to sum it up, simulation speed is considered and I have ideas for optimizations in my head, but for now this wasn't priority. For diploma thesis I need at least working SPI and I will work on these optimizations later :).

Share this post


Link to post
Share on other sites

Hi,

 

after some time (and vacation) I had some time for QSimKit again and I've released version 0.0.2. Check first post for more information about QSimKit.

 

Changes in version 0.0.2:

 

QSimKit GUI:

  • Save projects with .qsp extension
  • Lot of DWARF debugging symbols loading improvements
  • Auto-reload A43/ELF files when they change

MSP430:

  • Add support for USI-SPI (tested with SD card)

Peripherals:

  • Add basic SD card peripheral

 

The main features planned for the next version are SPI communication using USCI and probably way to view memory in hexedit-like window.

Share this post


Link to post
Share on other sites

FWIW, I tried compiling the latest from git under FreeBSD:

tingo@kg-core1$ uname -a
FreeBSD kg-core1.kg4.no 8.4-STABLE FreeBSD 8.4-STABLE #0 r253646: Thu Jul 25 10:12:31 UTC 2013     root@kg-core1.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64

cmake complains that it can't find PythonQt, which I find strange (but I'm not a Qt expert):

tingo@kg-core1$ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug
-- Found Qt4: /usr/local/bin/qmake-qt4 (found version "4.8.4")
CMake Warning at CMakeLists.txt:33 (find_package):
  Found package configuration file:

    /usr/home/tingo/work/qsimkit/cmake_modules/PythonQtConfig.cmake

  but it set PythonQt_FOUND to FALSE so package "PythonQt" is considered to
  be NOT FOUND.


-- Using bundled PythonQt for Qt-4.8
-- Found Qt4: /usr/local/bin/qmake-qt4 (found version "4.8.4")
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/home/tingo/work/qsimkit

and make fails:


tingo@kg-core1$ make
[ 20%] Built target PythonQt
[ 48%] Built target qsimkit
[ 58%] Built target simkitperipheral
[ 58%] Built target oscillator
[ 58%] Generating moc_ui_PathDialog.cxx
/usr/home/tingo/work/qsimkit/QSimKit/MCU/MSP430/ui_PathDialog.h:0: Note: No relevant classes found. No output generated.
Scanning dependencies of target msp430
[ 58%] Building CXX object QSimKit/MCU/MSP430/CMakeFiles/msp430.dir/moc_ui_PathDialog.cxx.o
Linking CXX shared library libmsp430.so
[ 97%] Built target msp430
[ 98%] Building CXX object Tests/CMakeFiles/simkit_test.dir/CPU/BasicClock/BlinkingLedTimer.cpp.o
/usr/home/tingo/work/qsimkit/Tests/CPU/BasicClock/BlinkingLedTimer.cpp:1:33: error: cppunit/TestFixture.h: No such file or directory
/usr/home/tingo/work/qsimkit/Tests/CPU/BasicClock/BlinkingLedTimer.cpp:2:45: error: cppunit/extensions/HelperMacros.h: No such file or directory
/usr/home/tingo/work/qsimkit/Tests/CPU/BasicClock/BlinkingLedTimer.cpp:127: error: 'CPPUNIT_NS' has not been declared
/usr/home/tingo/work/qsimkit/Tests/CPU/BasicClock/BlinkingLedTimer.cpp:127: error: expected `{' before 'TestFixture'
/usr/home/tingo/work/qsimkit/Tests/CPU/BasicClock/BlinkingLedTimer.cpp:127: error: function definition does not declare parameters
/usr/home/tingo/work/qsimkit/Tests/CPU/BasicClock/BlinkingLedTimer.cpp:355: error: expected constructor, destructor, or type conversion before ';' token
*** Error code 1

Stop in /zs/tingo/work/qsimkit.
*** Error code 1

Stop in /zs/tingo/work/qsimkit.
*** Error code 1

Stop in /zs/tingo/work/qsimkit.

which probably isn't surprising.

Share this post


Link to post
Share on other sites

 

cmake complains that it can't find PythonQt, which I find strange (but I'm not a Qt expert):

 

The error message about PythonQt is false positive. It uses bundled PythonQt from "3rdparty" directory in this case. I have fixed this in latest git commit and this error message is no longer printed.

 

 

and make fails:

 

Please try it with latest git. I think I have committed fix for this make fail. If it still won't work, paste "cmake" output again please. Before testing again, please remove "CMakeCache.txt" from root qsimkit directory.

Share this post


Link to post
Share on other sites

After pulling the latest changes (note to self "git pull in working directory) and removing "CMakeCache.txt" it builds.

And it starts up too. Yay!

There are a couple of error messages in the console output:

tingo@kg-core1$ ./QSimKit/qsimkit
Trying to load MCUs from   QDir( "/zs/tingo/work/qsimkit/QSimKit/MCU" , nameFilters = { * },  QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )  
Error loading "/zs/tingo/work/qsimkit/QSimKit/MCU/MSP430/msp430.so" "No such file or directory"
Error loading "/zs/tingo/work/qsimkit/QSimKit/MCU/MSP430/msp430.dll" "No such file or directory"
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/Button/button.py"
adding peripheral "button"
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/LCD/lcd.py"
adding peripheral "lcd"
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/LED/libled.py"
adding peripheral "libled"
Error loading "/zs/tingo/work/qsimkit/QSimKit/Peripherals/Oscillator/oscillator.dll" "No such file or directory"
Error loading "/zs/tingo/work/qsimkit/QSimKit/Peripherals/Oscillator/oscillator.so" "No such file or directory"
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/SD/sd.py"
adding peripheral "sd"

If I check for files, I find these:

tingo@kg-core1$ pwd
/home/tingo/work/qsimkit
tingo@kg-core1$ ll QSimKit/MCU/MSP430/*msp430*
-rwxr-xr-x  1 tingo  users  - 18799170 Sep 17 17:13 QSimKit/MCU/MSP430/libmsp430.so*
tingo@kg-core1$ ll QSimKit/Peripherals/Oscillator/*osci*
-rwxr-xr-x  1 tingo  users  - 1125848 Sep 17 17:12 QSimKit/Peripherals/Oscillator/liboscillator.so*

Not sure if that is important or not.
 

Share this post


Link to post
Share on other sites

Try again with latest commit. I had some "#ifdef Q_OS_LINUX" there to distinguish between UNIX-like systems and Windows which is not good, because this condition is not true on *BSD. It should now try to load "libmsp430.so" instead of "msp430.so"

 

update: and thanks for testing of course :)

Share this post


Link to post
Share on other sites

Well, git pull just said that I'm up to date:

tingo@kg-core1$ git pull
Already up-to-date.

But I rebuilt anyway, and now I get this:

tingo@kg-core1$ ./QSimKit/qsimkit
Trying to load MCUs from   QDir( "/zs/tingo/work/qsimkit/QSimKit/MCU" , nameFilters = { * },  QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )  
Error loading "/zs/tingo/work/qsimkit/QSimKit/MCU/MSP430/msp430.so" "The file '/zs/tingo/work/qsimkit/QSimKit/MCU/MSP430/msp430.so' is not a valid Qt plugin."
Error loading "/zs/tingo/work/qsimkit/QSimKit/MCU/MSP430/msp430.dll" "The file '/zs/tingo/work/qsimkit/QSimKit/MCU/MSP430/msp430.dll' is not a valid Qt plugin."
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/Button/button.py"
adding peripheral "button"
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/LCD/lcd.py"
adding peripheral "lcd"
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/LED/libled.py"
adding peripheral "libled"
Error loading "/zs/tingo/work/qsimkit/QSimKit/Peripherals/Oscillator/oscillator.dll" "The file '/zs/tingo/work/qsimkit/QSimKit/Peripherals/Oscillator/oscillator.dll' is not a valid Qt plugin."
Error loading "/zs/tingo/work/qsimkit/QSimKit/Peripherals/Oscillator/oscillator.so" "The file '/zs/tingo/work/qsimkit/QSimKit/Peripherals/Oscillator/oscillator.so' is not a valid Qt plugin."
Loaded peripheral: "/zs/tingo/work/qsimkit/QSimKit/Peripherals/SD/sd.py"
adding peripheral "sd"

and of course it is a bit hard to use the simulator when I can't load a MCU. :-)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...