multithreadingsimulationvirtualizationthreadx

How to simulate ThreadX application on Windows OS


I have an application using ThreadX 5.1 as the kernel. The Image is flashed on to a hardware running an ARM 9 processor.

I'm trying to build a Simulator for the application that can be run on Windows (say XP, 32-bit).

Is there any way I can make it run on Windows, without modifying the entire source code to start calling win32 system calls?


Solution

  • Yes you can if you are willing to put in the work.

    First observe that each threadx system call has an equivalent posix call except for events. So your threadx program can run as a single process using posix threads, mutexes, etc.

    Events can be handled by an external library (there are a few out there).

    If you find this difficult in windows then the simplest thing to do is set up a linux vm. I use an ubuntu vm running on Virtual Box. It is very easy to set up. All you will need is the cdt version of eclipse.

    Next you need to stub out all of your low level system calls. This is also easier than you might think. For example, if you have a SPI driver to read and write to flash, you can replace your flash with a big array which is quite easy to work with at this level.

    Having said all this, you may get more mileage if your threadx application is modular. Then you can test each module on it's own and you don't need to mess with threads, etc. As a first approximation this may give you what you need without going the distance to port the whole thing to run under posix.

    I have done this successfully in the past and developed a full set of unit tests for a module that allowed me to develop and test it (on my mac) before going to the target. Development is much faster and reliable this way.

    Another option you may want to consider is to find a qemu project that supports your microprocessor. With some work you can develop a complete simulator for your platform and then run the real firmware under the emulator.

    Good luck.