-
-
Notifications
You must be signed in to change notification settings - Fork 75
The erase-all flag erases entire chip unnecessarily on nrf5340 which affects performance #406
Comments
I have tested the suggested fix above on an nrf5340-dk but, unfortunately, I do not have an nrf52840-dk rev 3 to test with. |
Hi @ninjasource, thank you for your report. Two observations:
|
My sincere apologies for the late reply, I have been away. @Urhengulas, I ran the chip erase function. Oddly enough the nrf5340 still needs that This completes successfully on the nrf52840 in about half a second so this confirms your observation (in point 1):
To answer point 2, this completes on the nrf5340 after 34 seconds although on most runs it simply times out:
So I guess the issue is with the probe-rs chip |
I also ran probe-run with the |
Can you verify which version of the nRF52 you have? Apparently some later revisions changed how flash erasing works. |
I think you can attach files by either drag-and-drop or by clicking on the bottom edge of the text input field. And I just tried and was able to upload a zip file. |
Can you please report the issue to |
Describe the bug
Hi, I am using the latest version of probe-run (built from git) to flash my nrf5340-dk. When using
probe-run --chip nRF5340_xxAA --erase-all
for a cargo runner the process erases the entire flash area every time which takes about 35 seconds. It does this regardless or weather or not it needs to. I believe that the nrf5340 requires an erasure of certain flash areas after power on or hard reset to unlock the device before a debugger like probe-run can work with it. If you don't do this you get the following error message from probe-run:An operation could not be performed because it lacked the permission to do so: erase_all
The
probe-rs-cli
tool has a flag calledallow-erase-all
which will only erase appropriate flash areas if required. That means that erasing the entire chip is not required once it has already been powered up and unlocked (power cycle or hard reset ends this). Additionally, I noticed thatprobe-rs-cli
only requires an additional 10ms to flash the device upon power up so I don't believe that it erases the entire chip, or if it does, it is many times faster than probe-run at doing it.Looking at the code, I see that when the
--erase-all
flag is passed toprobe-run
the-allow-erase-all
permission is set when interacting withprobe-rs
. Redundantly, I believe, theprobe-run
tool is also performing a full erasure of the chip before flashing.To Reproduce
Steps to reproduce the behavior:
TLDR: Use the following runner in cargo config:
probe-run --chip nRF5340_xxAA --erase-all
.cargo/config.toml
src/main.rs
memory.x
Cargo.toml
Plug in an nrf5340-dk or equivalent and run the program with
cargo run --release
(Optional) Install
probe-rs-cli
and uncomment the other runners configured in config.toml to se how they runExample output when run with the
--verbose
flagThe main issue if there is a 35 second delay between this line:
and this line
When powering up the device for the first time and using the probe-rs-cli tool I get the following output:
As can be seen, it runs in under a second.
Suggested fix
I would like to suggest that we remove the following code in the flash function of
main.rs:164
since probe-rs already handles this:I would also like to suggest that the flag be renamed to
allow-erase-all
which I think is more appropriate. Please let me know and I can create a PR but this is such a tiny fix that one of the maintainers might want to just throw it in quickly.David
The text was updated successfully, but these errors were encountered: