Embedded Systems Weekly #116
Tags: cpp, c, zig, rust
Published: 2022-09-02 10:31:52

I remember an experience, years ago, where I strangely felt that the target I was debugging was a living entity. I don't know if I'm the only one who already felt that, but It was just like the evil serial spiders in the header. Something, somewhere was playing with me. You already had this feeling, didn't you?

Can you share this email? This is the best way to support Embedsys Weekly.
Share via [email](mailto:?subject=Check%20out%20Embedsys%20Weekly%20newsletter&body=I%20found%20this%20newsletter%20on%20embedded%20systems.%20I%20think%20it%20could%20interest%20you%0Ahttps%3A%2F%2Fembedsysweekly.com%2F).
Thank you and **happy reading!**

## Articles 
[Embedded Logging Case Study: From C to Shining C++](https://youtu.be/Dt0vx-7e_B0)
[Luke Valenty](https://twitter.com/lukevalenty) presents the huge work done by Intel firmware team to manage to log detailed information at runtime using as few as possible memory, CPU and bandwidth. To get the best logging system possible, a lot is done at compile-time leveraging C++ template metaprogramming.

[Designing a Better strcpy](https://saagarjha.com/blog/2020/04/12/designing-a-better-strcpy/)
Even though we love our C string functions, I believe that we have to face the truth and avoid most of them. They are too much error-prone and consequently lead to catastrophic failures. This article does a reasonable analysis of what is available against a list of 5 properties that a "good"
string function should have.

[Crabs All the Way Down: Running Rust on Logic Gates](https://zdimension.fr/crabs-all-the-way-down/)
I rarely read articles as wide and deep than this one.
Tom Niget makes and simulates a CPU that supports most of the ARM Thumb instruction set. Then he jumps through many hoops to showcase several applications: a plotter, a BASIC interpreter/REPL, a webserver, a terminal emulator... Impressive! All the
[ARM/Thumb CPU and code is open source](https://github.com/zdimension/parm_extended).

[Packed structs in Zig make bit/flag sets trivial](https://devlog.hexops.com/2022/packed-structs-in-zig/)
In the issue #106, I selected an article that highlights the benefits of using
[Zig to build C binaries](https://embedsysweekly.com/106-reverse-car-can-bus-embedded-ziglang/). This time I discovered with this article how versatile Zig can be. Mix the possibility to declare arbitrary bit-width integers (what about a u28, a u13 or a u1), with good compilation time validations, and you get the most powerful packed structs implementation that I know.

[Demystifying the LFSR](https://www.moria.us/articles/demystifying-the-lfsr/)
LFSR (Linear Feedback Shift Register) is the most used pseudorandom bits generator for systems missing an external source of randomness. This article explains the mathematics that makes LSFR a good enough PRNG for these cases.

[Catching sanitizer errors programmatically](https://lemire.me/blog/2022/08/20/catching-sanitizer-errors-programmatically/)
In their recent versions both gcc and clang compilers added sanitizer functionalities. These are built-in features to detect memory leaks, out of bounds accesses or undefined behavior usage in your code. This article shows how to execute custom code when an error is detected by the sanitizer.

## Tools / Libraries
[Open Source Autopilot for Drone Developers](https://px4.io/)
PX4 is an advanced and open source autopilot flight stack for drones. PX4 can flight completely autonomously for pre-programmed missions, or, obviously, it can help a pilot who remote-controls the drone. It runs on [NuttX](https://nuttx.apache.org/) RTOS.

## Jobs
[Gyro-Stabilized Systems, Software Engineer, Full-time, Grass Valley, CA](https://jobs.embedsysweekly.com/job/m8N7kZq9/software-engineer)
As the industry leader in stabilization technology, GSS offers an inspiring and purpose-driven workplace with the opportunity to create leading-edge technology platforms utilized worldwide.

## Misc
[Replicant: Reproducing a Fault Injection Attack on the Trezor One](https://voidstarsec.com/blog/replicant-part-1)
This article does a great job at introducing the reader to fault injection. What is a fault injection? What are the common technics to do a fault injection? By the end of the article, you'll get answers to these questions and, of course, all the details on how to apply them on the Trezor One. A second part is planned to show how the same attack can be done with the [PicoEMP](https://github.com/newaetech/chipshouter-picoemp), a low-cost Electromagnetic Fault Injection (EMFI) tool.