Emulating FreeRTOS on Android

It would be nice to test my FreeRTOS app on a device with an ARM processor, instead of emulating ARM on an Intel platform. For general command-line programs on ARM, emulation can easily be avoided by running them in Termux on my Android phone. So for FreeRTOS programs, is there any kind of SOC emulator for Android that executes code natively on the ARM processor, while for example emulating the hardware components of a Cortex M3 device?

My assumption is that all instructions in an M3 are also available in my Cortex A72, except maybe recent extensions like Helium. If that’s not correct, then is there any advantage to emulating FreeRTOS on an ARM processor, or is it just as well to emulate on my Intel desktop where more resources available?

In my experience, doing testing off platform has two good options.

If your target platform has a good emulator, then run the emulator on your Windows / Linux computer. The emulator uses your powerful X86 processor to run your code compiled to the target ARM processor. Doing this, you may be limited by what peripherals are able to be emulated.

The majority of your application should be portable code, so compile and run directly to X86. FreeRTOS has Windows / Linux ports to support this. This will require you to create mock code for whatever peripherals you interface with.

What advantage do you see in running on Android?

Sounds like x86 will be the best option, if the emulator supports enough features. In any case, there’s no reason to consider Android for emulation, if FreeRTOS can run directly on x86.

Mainly what has been a problem in my experience is cross-ISA emulation, which for larger apps can get unreasonably slow, and also tends to have execution anomalies. Normally everything is correct, but there are execution characteristics that are highly unlikely to occur on target hardware–e.g., extremely regular thread ordering. That kind of thing isn’t an issue in virtualization, so presumably an x86 emulator would be equally reliable.

Take a look at FreeRTOS Windows Port For Visual Studio or Eclipse and MingW - FreeRTOS™ and Posix/Linux Simulator Demo for FreeRTOS using GCC - FreeRTOS™ for information on the Windows / Linux ports. I personally prefer to test by compiling directly to X86 because my projects interface with a lot of custom hardware that is not really feasible to run on an emulator.

There is always limits to what you can test in simulation. Both of those pages make clear that the timing characteristics of running FreeRTOS under a non-realtime OS will be worse than running on the real target.