Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Erase-all flash option #368

Closed
huntc opened this issue Dec 11, 2022 · 7 comments · Fixed by #380
Closed

Erase-all flash option #368

huntc opened this issue Dec 11, 2022 · 7 comments · Fixed by #380
Labels
difficulty: easy Pretty easy to solve priority: low Low priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes type: enhancement Enhancement or feature request

Comments

@huntc
Copy link
Contributor

huntc commented Dec 11, 2022

Would an option to erase all flash be considered generally useful? The gen 3 nRF52 boards have AP Protect enabled by default, so it might be handy for an optional erase all to enable subsequent flashing.

@Urhengulas
Copy link
Member

Are you talking about probe_rs::flashing::erase_all(session: &mut Session) -> Result<(), FlashError> (link), or something else?

@huntc
Copy link
Contributor Author

huntc commented Dec 12, 2022

Are you talking about probe_rs::flashing::erase_all(session: &mut Session) -> Result<(), FlashError> (link), or something else?

I think so. I’m not familiar with the internals of probe-rs, but I’m suggesting the equivalent of nrfjprog —recover, which also resets UICR.

@Urhengulas Urhengulas added this to Incoming in Issue Triage via automation Dec 13, 2022
@Urhengulas Urhengulas added type: enhancement Enhancement or feature request good first issue difficulty: easy Pretty easy to solve priority: low Low priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes labels Dec 13, 2022
@Urhengulas
Copy link
Member

Urhengulas commented Feb 5, 2023

@huntc Can you please try it out if it works as expected? Please install and execute probe-run like this:

$ cargo install --git https://github.com/knurling-rs/probe-run --branch erase-all
$ probe-run --chip nRF52840_xxAA --erase-all ./path/to/elf
$ #                ^^^^^^^^^^^^^ adapt this to your chip

I've added a call to probe_rs::flashing::erase_all just before downloading the binary to flash.

@huntc
Copy link
Contributor Author

huntc commented Feb 6, 2023

Thanks @Urhengulas ! I've tested it and get the following:

probe-run --chip nRF52840_xxAA --erase-all target/thumbv7em-none-eabihf/release/evse
(HOST) INFO  flashing program (37 pages / 148.00 KiB)
(HOST) INFO  success!
Error: Overflow error: Attempting to add 2 bytes to Register value 0xfffffffe

Should we be concerned about that error? I'm using an nRF52840-DK (gen 3).

@huntc
Copy link
Contributor Author

huntc commented Feb 6, 2023

Oh, actually if the device becomes protected (as per the previous run, above), then I get the following:

probe-run --chip nRF52840_xxAA --erase-all ../nrf-boot/target/thumbv7em-none-eabihf/release/evse-boot
Error: A ARM specific error occured.

Caused by:
    An operation could not be performed because it lacked the permission to do so: erase_all

An --erase-all shouldn't require that permission ,and I can certainly erase the flash via nrfjprog still.

@Urhengulas
Copy link
Member

Urhengulas commented Feb 7, 2023

@huntc It probably is my mistake. When creating the session, I forgot to call the probe_rs::Permissions::allow_erase_all(). Can you please reinstall probe-run from the branch and try again with both protection turned on and off?

If that does not work there is also probe_rs::Session::sequence_erase_all we can try.

@huntc
Copy link
Contributor Author

huntc commented Feb 8, 2023

Hey @Urhengulas - all now appears well! I can flash the device with AP, and then subsequently use --erase-all to flash again. Nice work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
difficulty: easy Pretty easy to solve priority: low Low priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes type: enhancement Enhancement or feature request
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants