A simulator to boost embedded software productivity
Intro
This is an idea I've had for quite a while and have created limited-scope versions for a few customers. The idea is that developing software (any software) is challenging and often frustrating. Developing software for embedded devices is often much more challenging and frustrating. The extra time spent waiting for edit/compile/run cycles and more limited tooling hurts productivity. The simulators I've created allow you to work on Arduino projects as native MacOS/iOS projects.
What's the benefit?
Using the Apple tools, specifically Xcode and Instruments, I'm able to run/debug/profile my code much quicker and with a much friendlier set of tools. For my own work, the productivity boost has been tremendous. My Arduino imaging and video codecs (JPEGDEC, JPEGENC, PNGDEC, PNGENG, AnimatedGIF, pl_mpeg, TIFF_G4, G4_ENC) were all written, debugged and profiled on the Mac as a native MacOS app. It would have been impossible to optimize the code to the level I have without the Instruments profiler. There are obviously big differences in optimizing code for Arm64 compared to ESP32, but the principals are the same and the majority of the 'hot spots' and improvements are identical. Debuggers and profilers exist for some embedded platforms, but no one can argue that they are more productive to use compared to working in Xcode.
Where's the rub?
With any simulated environment, there are limitations and behavioral differences. If you need to work on precise hardware timing issues or MCU sleep optimizations, then this simulator won't be much help. This isn't an emulator, it's a simulator - your code is compiled to run on x64/aarch64 Apple hardware. This simulator is for people working on projects which display graphics, process data, interact with users or other generic "computerish" things which can be simulated in a way which presents a functional alternative to working directly on the target device.
Why Simulate Arduino?
I work on a wide variety of target platforms for different clients. Some MCU vendors force me to use their custom developer tools, but many can work from within the Arduino ecosystem. The benefit to me is that I can write code once and test the same code on a variety of MCUs, all by simply selecting a different hardware target in the IDE. This is especially valuable for writing and testing my codec libraries. I've used this same type of MacOS simulator project to optimize embedded Linux code and more 'exotic' platforms. The important elements are: a virtual display (LCD, eink, OLED, etc), user input (touch, simulated buttons, simulated GPIO) and the Xcode/Instruments debugger/profiler to work on the code. It's flexible enough to simulate a lot of the work that embedded developers need.
What does it look like?
In the video clip below, the Xcode project is seen in the background with an iPhone simulator in the foreground. The iPhone is running my AnimatedGIF library example on a simulated ESP32+ILI9341 board (unthrottled). I created the Xcode simulator project to target iOS because this allows it to run natively on iPhones, iPads and Mac aarch64 desktops, as well as device simulators like in the video. If you want, you could demo your ESP32 product on your personal iPhone too.
Do I have to change my Arduino code to work in the simulator?
How do I get hold of it?
I am a big believer in open source software and support it through my many thousands of hours of work in my large collection of open source repos. This particular project is destined to remain closed source. From working with a few customers, it's pretty clear that each customer needs custom hardware to be simulated to fit their needs. It's not reasonable for me to write a simulation of every display, sensor and input device in the hopes that it covers the maximum number of customer needs. It is reasonable to write a specific hardware simulator for each customer that needs one and pays for it. Please contact me directly if you're interested in using this type of simulator to save you time and frustration (bitbank@pobox.com).
Comments
Post a Comment