2023-10-17 08:37 AM
Hi All,
In the reference manual for the BlueNRG-LP Cortex M0+ microcontroller (RM0479), it states both page and mass erase functionality for the flash controller. But, only one "ERASE" command is given (0x11), which appears to be for page erase.
Does anyone know if there is a command for mass erase (erasing the whole flash in one operation) and if so what it is?
Looking at the source code for OpenOCD, it appears it could be 0x22. But, as this isn't stated in the manual, it would be nice if someone could confirm this.
Many Thanks,
Paul
2023-10-19 05:36 AM
Welcome @PStinson, to the community!
Well, the RM0479 shows the functions that can be used sensibly from the user programme. However, a mass erase would also delete the user programme, which means that one has to access the BlueNRG-LP again via the boot loader anyway.
For this reason, a mass erase only makes sense from the boot loader, which is also described in AN5471, section 3.7.
Does this answer your question?
Regards
/Peter
2023-10-24 02:37 AM
Hello Peter,
Thank you for responding to my query. I agree that calling a mass erase from code stored in flash would not be sensible.
In this case, I am planning to access the device and the flash controller registers using SWD. I believe it should be alright then to perform a mass erase(?). Indeed, if readout protection was previously applied, it appears it may be necessary when programming new firmware.
Are you able to confirm the command used to initiate a mass erase? I presume the UART bootloader is using this command internally and so it must exist.
Regards,
Paul
2023-10-24 02:44 AM
As already mentioned in the AN5471, a mass erase is possible via the UART boot loader:
the bootloader receives one byte that contains N, the number of pages to be erased – 1.
N= 255 is reserved for mass erase request. [...]
Regards
/Peter
2023-10-24 02:55 AM
Sorry, the way I phrased that last question was ambiguous. I meant to ask: Are you able to confirm the command that should be written to the flash controller "COMMAND" register in order to initiate a mass erase?
I am not planning to use the UART boot loader.
As I said before, it appears from the OpenOCD source code it could be 0x22, but some clarification on this would be appreciated.
Thank you,
Paul
2023-10-24 03:04 AM
No, I can't confirm 0x22 as a command for mass erase.
2023-10-24 03:28 AM
Okay, I understand.
Will it be possible for someone tell me if/how I can perform a mass erase manually via SWD? Or is the UART boot loader the only way to do this?
2024-01-25 11:39 PM
Hi Paul,
Did you solve the issue? I'm trying to mass erase from production code do disable readout protection and make processor programable again.
ST says that calling mass erase from application doesn't make sense but according to es0532 rev5 ch 1.6 bootloader is not available.
And because CPU goes to low power mode immediatelly after reset, update with JTAG is very unreliable.
Time ago I debug bootloader to find why reset source register is always empty so I can try with mass erase too
Thanks,
Miroslav
2024-01-26 01:39 AM
Hello Miroslav,
Once I had hardware available, I tried using 0x22 in the flash command register and it seemed to mass erase the device (as far as I can tell). I never received any confirmation of this being valid though, so try it at your own risk.
Kind Regards,
Paul
2024-01-26 01:42 AM
Hello Paul,
Thanks for response, I'll try.
Br,
Miroslav