SiLabs CP210x USB Adapters For The Win

A year and a half ago, I wrote up a post lamenting the problems caused by counterfeit USB to serial adapter chips.

One of the primary issues was the inability to tell the adapters apart on the USB device tree when hooked up to the same computer. (There were, of course, other problems.)

Amazingly, after revisiting the thought recently, I discovered that any of the cheap adapters built atop the Silicon Labs CP210x chipset would in fact allow you to set the serial number to a value of your choosing!

Continue reading SiLabs CP210x USB Adapters For The Win

Stack, Heap, and Thread Crash Hunting in mbed OS

ARM mbed OS derives its thread management capabilities from ARM’s RTX realtime operating system.

When a thread crashes due to a stack overflow or other HardFaults, it can be unclear what code is causing the issue. Also unclear is how the threads are initially created, as ARM mbed OS defines its stack sizes via a handful of preprocessor #defines and linker provides which aren’t well documented at all.

Here are some notes on the things I’ve had to figure out by reading the source.

Continue reading Stack, Heap, and Thread Crash Hunting in mbed OS

Flash-based Configuration Data Using The ld Linker

Here is an easy way to store and use configuration data in the flash memory of a microcontroller.

This places the configuration data at a specific absolute memory address and uses no special pragmas to enable read access.

This is a slight reworking and consolidation of what MCU on Eclipse suggests, and slightly easier than marking variables with __attribute__((section(".etwas"))) all the time, though that is useful in other cases. Also, the SEGGER J-Link debugger on my development kit was always erasing the configuration data (as I’d placed it between other code and data, at a pretty low flash address), which was the opposite of the problem MCU on Eclipse was having. So, I needed a way to protect specific flash regions from getting erased, as Kinetis Design Studio has no easy options for this.

Continue reading Flash-based Configuration Data Using The ld Linker