
据 Hackaday 报道,开发者 Daniel Mangum 近日撰文描述了调试基于 Cortex-M33 的 nRF54LM20 微控制器时遇到的怪事:读写的几个场景起初看起来都正常,随后 GDB 调试器却「愉快地」返回表明前一次操作没成功的数值——真相是它返回了过期的缓存值。
Mangum 对这款 MCU 的内部机制做了非常底层的技术拆解,尤其是其加密功能与用于存储敏感信息的密钥管理单元(KMU)。最有意思的规避方法是:显式指定访问端口、内存地址及其他参数即可绕过缓存。他使用的 JLinkGDBServer 支持 ReadMemAP 命令,直接走 AHB-AP 端口读取返回的是正确值,而 GDB 常规的 x 命令读到的仍是缓存旧值。
那么问题出在哪一层缓存?直接读 AHB-AP 一切正常,嫌疑落在 J-Link 软件自身的缓存上——随后一次关闭 J-Link 缓存的运行确实一切正常。报道提醒:SEGGER 的 J-Link 此前还出过硬件层面的尴尬问题(USB-C 兼容性),这次的软件缓存 bug 足以让人在浪费大量调试时间后「掀桌」。幸运的是 Mangum 很快识破并找到了绕过方法,但并非人人都有这样的运气。
本文来源:https://hackaday.com/2026-09-27/when-the-debugger-lies-with-stale-cache-values/
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。
According to a report by Hackaday, developer Daniel Mangum recently wrote about a strange issue encountered while debugging the nRF54LM20 microcontroller based on Cortex-M33: several read/write scenarios initially seemed normal, but then the GDB debugger "cheerfully" returned values indicating that the previous operation had not succeeded—the truth was that it had returned stale cached values.
Mangum performed a very low-level technical breakdown of this MCU's internal mechanisms, especially its cryptographic functions and the key management unit (KMU) used to store sensitive information. The most interesting workaround was to explicitly specify the access port, memory address, and other parameters to bypass the cache. The JLinkGDBServer he used supports the ReadMemAP command; reading directly via the AHB-AP port returned the correct values, while GDB's normal x command still read the stale cached values.
So which cache layer was the problem? Direct reads via AHB-AP worked fine, so the suspicion fell on the J-Link software's own cache—and indeed, a subsequent run with the J-Link cache disabled worked perfectly. The report reminds us: SEGGER's J-Link has previously had embarrassing hardware-level issues (USB-C compatibility), and this software cache bug is enough to make someone "flip the table" after wasting a lot of debugging time. Fortunately, Mangum quickly identified the issue and found a workaround, but not everyone is so lucky.
