ARM SWO ITM Console Bidirectional Standard I/O Retargeting

The ARM Cortex M architecture has many features which are underused, probably simply because engineers are not aware of it. SWO (Single Wire Output) is a single trace pin of the ARM Cortex-M CoreSight debug block. trace pin uses the ITM (Instruction Trace Macrocell) on ARM Cortex. It provides a serial output channel, at a high speed higher than the usual UART, because it is clocked at half or a quarter of the core clock frequency, depending on the core and implementation.

As such, it is an ideal high speed output channel to send text or data to the host. This is how it is usually used, but what is unknown to many: it can be used in a bidirectional way with the help of the debugger.

The topic of this article: how to redirect standard I/O like printf() or scanf() using the SWO ITM console: means both sending *and* receiving data over the SWO debug channel: that way I can use it as a kind of UART with a single pin only.

Continue reading

Which Embedded GCC Standard Library? newlib, newlib-nano, …

When developing with C or C++ an application, then you mostly focus on your own code. You don’t want to bother with the details how input/output functions like printf() or scanf(), and you might just use these functions and helpers and that’s it.

The implementation is part of the ‘C Standard Library’ (or C++ Standard Library). In the world of Linux, this is usually the ‘glibc’ or ‘GNU C Library, and one usually link with ‘libc’. That provides the implementation of printf(), or use ‘libm’ if using math functions like sin() or cos().

In the embedded world, things are much more complex, with plethora of choices, for example in the MCUXpresso IDE:

Library Selection in MCUXpresso IDE
Continue reading

NXP MCUXpresso IDE 11.7.0

It is the exam and grading time at the university, and the same time I’m preparing the lectures and labs for the new semester starting mid of February. I’m always heading for using the latest and greatest tools in my labs. A few days ago, NXP released the new version of the MCUXpresso IDE, version 11.7.0. Time to check it out…

NXP MCUXpresso IDE 11.7.0
Continue reading

Controlling an EV Charger with Modbus RTU

The year 2022 is coming to an end, and I have spent some time today on a little side project. It is about making an Electrical Vehicle (EV) wallbox charger accessible over Modbus RTU. It is not finished yet, and I plan to publish more articles on it, but I can share that I’m able to access and control the Heidelberg EV charger with a Raspberry Pi Pico W (Dual Core Cortex M0+), NXP K22FN512 (Cortex M4F) and LPC845 (Single Core Cortex M0+):

Continue reading

McuOnEclipse Components: 29-Dec-2022 Release

I’m pleased to announce a new release of the McuOnEclipse Processor Expert components, available on SourceForge.


Continue reading

Fixing “REENT malloc succeeded” Assertion

One little nasty assertion in the GNU standard library appeared a few days ago, kind out of nowhere, reporting “REENT malloc succeeded”:

Obviously it was caused by the call to srand() which sets the ‘seed’ for the standard library (pseudo) random number generator. The assertion happens as well later for calling the rand() function.

Continue reading

Add extra Storage to the Raspberry Pi Pico with W25Q128 and LittleFS

The RP2040 Pico board comes with 2 MByte onboard FLASH memory. While this is plenty of space for many embedded applications, sometimes it needed to have more storage space. Having the ability to adding an extra SPI FLASH memory with a useful file system comes in handy in such situations. This makes the RP2040 ideal for data logger applications or otherwise store a large amount of data. In this article I’ll show you how to add an extra 16 MByte of memory to the Raspberry Pi Pico board, running FreeRTOS, a command line shell and using LittleFS as the file system.

Continue reading

Energy Crisis in Europe: Optimizing a Building from 4.5 to 2.4 MWh

With the war in the Ukraine, energy prices in Europe reached new record levels. This initially affected the gas price which does not affect me directly. But it had a big impact on the price for electrical energy too. In my village, the price for electrical energy is now at 0.45 CHF/kWh, starting October 1st 2022. It is twice as much as what it used to be, and three times more what it used to be the price for the energy at night time.

Saving energy always makes a lot of sense, now even more, both for the environment and directly saving money. Luckily, I started thinking about optimizing the electrical energy used in my house back in 2021, and now in 2022 it really pays off: The daily average of 16 kWh/day (including heating and cooling) came down to 7 kWh/day, or from 4.5 MWh/year down to 2.4 MWh/year, or a reduction of 47%.

There were different areas contributing to this very positive result:

The above graph shows the changes in the different categories, from 2021 (blue, 4.5 MWh) to 2022 (orange, 2.4 MWh).

Continue reading

Installing eGit into CodeWarrior Development Studio for MCU v11.1

Sometimes it can be a challenge to update or add plugins to older software or Eclipse versions. The ‘CodeWarrior for MCU’ from NXP is legacy and replaced by the newer MCUXpresso IDE and tools, but I continue to use CodeWarrior for our older projects, and it still works fine after all the years and Windows host updates. However, trying to install from the standard eGit Update site fails:

Continue reading