With semihosting I can use standard I/O function like printf() and I can read and write data on the host through the debug connection. If used with care, this is a great feature especially for unit testing.
In the OOP world, global objects get initialized with a constructor and destroyed at the end with a destructor. Interestingly, the GNU gcc has attributes to mark functions as constructor and destructors, which can greatly simply system startup and shutdown, even if not using C++.
C Function marked as Constructor and called before main()
With the GNU gcc compiler, I can mark functions with an attribute, so they get called before entering main() or after exit of main(). The attribute works both in C and C++, but it especially useful in C to initialize modules in an automated way.
It is interesting to see that modern tools and agile development workflows are getting more and more into the embedded world. CI/CD is a strategy where code changes to an application get automatically integrated, tested and released automatically into a production environment.
I have lots of hardware and debug probes on my desk, and I discussed using nicknames for debug probes to better identify them.
‘Green’ and ‘Yellow’ Robots and J-Link Probes
So far so good. At that time of the previous article, it was possible to assign nicknames to J-Link debug probes, but not to use the nickname instead of the USB serial number. Well, SEGGER was fast again, and responded with a new J-Link software pack version 7.92d which implements that features: I can now use the nickname to connect to a debug probe :-).
Sometimes I have a wish. Not every time it gets fulfilled. But this time I’m lucky and happy developer. A few days ago I wrote about the LPC4322-based SEGGER OB (on-board) J-Link firmware. It works great, but the board requires another USB cable to power the target board.
Rolf Segger contacted me, and a few days later I had a J-Link firmware with a ‘power-on’ feature:
That way, only one USB cable is needed. All what you need to do is to update the firmware.
Developing for an embedded target means using a certain version of GNU compiler, debugger and other tools. The challenge gets bigger if working with multiple different tool chains and environments.
Conda in VS Code
Conda is package, dependency and environment management tool. While it is heavily used for Python and Data Science development, it is surprisingly working very well to set up and managing environments for embedded development. Conda is great for managing non-Python dependencies and setups.
Going with the factory default can be fine. But an upgrade could give a performance boost plus added functionality. Many of the NXP i.MX RT evaluation boards have an LPC4322 based debug circuit on it. One example for this is the i.MX RT1010 board.
NXP i.MX RT1010 EVK
On such boards, one of the first steps I do is: upgrading the firmware and change it to a better option: improved speed, SWO support plus avoiding issues with the USB MSD device.
In my previous article I showed how to import, build and debug MCUXpresso SDK projects in VS Code. In my lectures and labs we are using a robot based on the NXP Kinetis K22FX512 ARM Cortex-M4F microcontroller, and there is only the v2.13.0 SDK available.
Sumo Robot with K22FX512
The software on the robot uses the latest NXP MCUXpresso SDK v2.3.1. The he Eclipse based MCUXpresso IDE 11.8.0 works fine with all the 2.x SDKs, up to the latest 2.13.0 one.