-
Notifications
You must be signed in to change notification settings - Fork 747
nrf52: support new access port protection mechanism on new nRF52 chips #3422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This requires knowing the variant of the chip, so we also need to make the variant ficr functions crate-public.
I added functionality to now set the approtect field in the UICR in the startup component. I also refactored how we check for which variant in uicr.rs when disabling the approtect function. I tested this PR on a new board and an old board (nrf52840dk) and both work. |
What's wrong with netlify? Something in this PR? |
Yea the error is Log:
|
chips/nrf52/src/approtect.rs
Outdated
|
||
//! Access port protection | ||
//! | ||
//! https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fdif.html&cp=5_0_0_3_7_1&anchor=register.DISABLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here <url>
chips/nrf52/src/approtect.rs
Outdated
/// (software). For older variants this is just a no-op. | ||
/// | ||
/// - https://devzone.nordicsemi.com/f/nordic-q-a/96590/how-to-disable-approtect-permanently-dfu-is-needed | ||
/// - https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/working-with-the-nrf52-series-improved-approtect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two here <url>
What? This tool can tell these are URLs so it can give us errors informing us it needs us to tell it these are URLs? What problem is this solving, rustdoc? |
I think this is just a lint being treated as an error, see bare_urls |
apparently rustdoc notifies us that it has detected urls which we didn't tell it are urls so we can tell it they are urls. thanks rustdoc.
2200560
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is great! I'm yet to test it as I didn't have access to my (old) nRF52840DK.
I added a minor change which exhaustively lists all the chip variants for which the SwDisable
switch is not required. This is to prevent the scenario where a new revision would be supported at first (because it matches on the Unspecified
variant), and someone adds a definition for it to the ficr
module, which would then implicitly break it in a non-obvious way due to the default match. Having the exhaustive list ensures that the compiler yells at us when this match
diverges from the ficr::Variant
enum definition.
Ready? |
bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Pull Request Overview
It seems like recently nordic got bad press for having a vulnerability in how they disable jtag access, so newer versions of the nrf52840 change how they restrict jtag access, which essentially restricts jtag by default. This PR adds support to disable the protection so we can use and reprogram newer nRFs without re-flashing every time.
This requires setting both a "HW" register (aka in flash), and a "SW" register (aka in RAM) to 0x5a. The HW register can just be done once. The SW register needs to be done on every boot. Note, this is only for the new versions. So this code checks the variant and only includes it on the new variant.
Testing Strategy
Running tock on a new nrf52840dk board.
TODO or Help Wanted
Still need to set the UICR, or for now runningnrfjprog --recover
works.Documentation Updated
/docs
, or no updates are required.Formatting
make prepush
.