M0AGX / LB9MG

Amateur radio and embedded systems

  • Today I learned: How to read address zero on RISC-V

    I have been working on a "yet another" flashloader with standard flash operations like readback and blank checks. The chip has flash mapped starting from address 0x0 so I wrote the code with obvious pointers like uint32_t *p = 0x0;. I built the code with gcc like countless times before but I did not get the behaviour I expected. The only thing "special" this time was that the CPU was a RISC-V.

    Read more...

  • Story from the trenches - uninitialized RAM is not random (enough)

    This is another story from the world of "it can't happen". A device was undergoing final testing that spanned many days in different simulated conditions. The testing included power cycling whenever the conditions were changed. Once in a very long while, on the order of maybe once per week, the device failed to communicate with the test equipment.

    Read more...

  • Things you should know about the stack on Cortex-M

    The stack is one of the "invisible" parts of almost every C implementation. It comes into view usually when something goes wrong. On a PC with an operating system in a "good" bad case the application will crash in an obvious way but issues with the stack can also lead to security vulnerabilities. On bare-metal embedded systems stack overflows can manifest themselves as "silent" data corruption (in the worst case) or obvious crashes/resets (in the "good" case). I will focus on the bare-metal Cortex-M use case.

    Understanding stack usage is also crucial to knowing how much "free" RAM is there left in an embedded system.

    Read more...

  • Bug of the day: missing entry point

    This is a tale of a strange bug I ran into when doing my first ever SAM E70 project. A new MCU. A new type of product. A custom PCB. What could possibly go wrong? 🙂

    Spoiler: Not strange. Not a bug.

    Read more...

  • Implementing a LIN slave on STM32L011

    LIN bus is a communication standard that originated in the automotive industry but is slowly gaining ground in other areas. It is less known than CAN, RS-485, I2C, SPI or USB but has some significant advantages when it comes to developing really cheap and simple devices that have to be …

    Read more...

  • Home Assistant and HAN port electricity meter

    All modern electricity meters in Norway have a local interface called the HAN port. It allows you to read out live data from the meter using your own hardware. Even though all electricity suppliers these days provide apps that show you your usage they rarely do it in real-time and …

    Read more...

  • Interview questions for embedded engineers

    This is an article about technical questions that can be asked in an interview for an embedded systems engineer that I have "standardized on" after doing multiple interviews. It does not cover other topics like how to do the initial screening, task assignments, soft skills, or "fantastic beasts, where to find them and how to retain them".

    Read more...

  • What is inside a Mean Well DIN rail power supply

    I bought a small power supply in DIN rail form factor to provide 12V for the Waveshare RS485 to Ethernet converter mounted in my breaker panel. The exact model is HDR-15-12.

    Installation is trivial as it only has 2 screw terminals for the AC input and 2 for the DC …

    Read more...

  • Scheduling posts with Pelican

    Pelican has no facility for scheduling posts. However, it is very easy to do it with basic shell scripting and cron. I started by adding Scheduled: yes field to the draft post. Read more...

  • Practical comparison of ARM compilers

    My inspiration for this article was this thread in r/embedded. There are still many myths and misconception when it comes to the simple questions "Which compiler should I use?" or "Which compiler is the best?". I will try to share my practical experience with GCC, Clang and IAR on …

    Read more...