Skip to main content
Associate
October 17, 2023
Question

BlueNRG-LP: Flash controller mass erase command?

  • October 17, 2023
  • 6 replies
  • 2442 views

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

This topic has been closed for replies.

6 replies

Peter BENSCH
Technical Moderator
October 19, 2023

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

PStinsonAuthor
Associate
October 24, 2023

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

Peter BENSCH
Technical Moderator
October 24, 2023

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

PStinsonAuthor
Associate
October 24, 2023

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

Peter BENSCH
Technical Moderator
October 24, 2023

No, I can't confirm 0x22 as a command for mass erase.

PStinsonAuthor
Associate
October 24, 2023

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?

MHavl
Associate II
January 26, 2024

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

PStinsonAuthor
Associate
January 26, 2024

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

MHavl
Associate II
January 26, 2024

Hello Paul,

Thanks for response, I'll try.

Br,

Miroslav