adafruit / Adafruit_nRF52_Bootloader

USB-enabled bootloaders for the nRF52 BLE SoC chips
MIT License
427 stars 380 forks source link

Support for Errata 249 on revision 3 nrf52840 chips #325

Open jeffc opened 3 months ago

jeffc commented 3 months ago

Is your feature request related to a problem? Please describe.

Revision 3 of the nrf52 line (revision 2 for the 52833, 52811, and 52805) are subject to errata 249, which changes the behavior of the debug port. This makes it impossible to use a SWD or JTAG debugger on these boards, even if the UICR->APPROTECT register is set properly (to 0x5A, where older boards required 0xFF), without a change in the firmware or bootloader to also set APPROTECT->DISABLE.

This affects at least the nrf52840 dongles (pca10059) being sold right now, and will likely affect more and more boards as the revision 3 chips become more widespread.

Describe the solution you'd like

The lastest version of the nrf5 SDK, v17.1.0, includes system_nrf52_approtect.h and a relevant entry in the nrf52_erratas.h. Even though this bootloader is based on the older SDK11, this function seems pretty self-contained and straightforward to backport.

It would also be great to add a Makefile flag that caused the generated .hex file to automatically set the UICR register appropriately if the bootloader is flashed via debug after a full-flash erase (the only time the UICR register can be set), but that is more of a wishlist/quality-of-life feature that might be difficult to implement in any sort of intuitive way.

Describe alternatives you've considered

It would be possible to just tell users to include the errata information in their application and not make the bootloader responsible for setting the APPROTECT->DISABLE register. This would mean that the bootloader can never be debugged on newer chips, though, even if the userspace application can (though it might be possible for an application to set the register and then soft-reset into the bootloader without clearing it; I'm not positive if that works).

Additional context

This request stems from a thread I started in the nordic devzone here