Hunting a Ghostly Embedded Bug: Error -22
2025-01-26

The Tweede golf team encountered a frustrating bug in their embedded Rust software for the nRF9160 microcontroller, resulting in Error::NrfError(-22) when sending data to a server. After weeks of investigation, they traced the issue to the libmodem library's initialization function. A pointer to a stack-allocated configuration struct was used after the struct was destroyed, causing unintended writes to the shared memory region configuration and resulting in a data length of 0. Adding `black_box` and using watchpoints ultimately located and fixed the bug. The team highlighted the benefits of using Rust for embedded development to prevent such low-level errors.
Development