2023-12-21 06:54 AM
Hi everyone,
I am using an STM32h7 to program an STM32L151 using the system bootloader through usart.
When I ask for the supported commands, I get that the erase command is between them but, surprisingly, when I try to use it I get a nack.
Then I read that some MCUs do not support the erase command and so my first question is: does the STM32L151 support the erase (or extended erase) command?
Then I tried to erase the flash enabling and then disabling the RDP level 1, that is working but, after this operation, I find also the option bytes changed respect to the default (I read {0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000} instead of {0xFF5500AA, 0xff0700F8, 0xffff0000, 0xffff0000, 0xffff0000} at address 0x1FF80000).
So at the moment my firmware update process is working but, instead of sending a single erase command I have to:
- set RDP level 1
- restart the uP
- set RDP level 0
- restart the uP
- re-write default option bytes
- restart the uP
My second question is: am I doing something wrong or is expected to follow these steps the perform a flash erase?
Thank you,
regards
Arianna
Solved! Go to Solution.
2024-01-09 06:53 AM
I have the reply I was looking for:
the extended erase command is supported, but only for the single page erase, i.e. it is not possible to perform the 'special erase' described in the application note AN3155:
Here there are the byte sequences:
2023-12-21 07:12 AM - edited 2023-12-21 07:12 AM
> is expected to follow these steps the perform a flash erase?
No, there's no reason to set RDP=1 then to 0 to do a flash erase.
The bootloader versions are given in AN2606 for your chip. "STM32L151" is not specific enough to tell.
The GET command can be used to determine supported commands.
Note that ERASE and EXTENDED ERASE are mutually exclusive. Your bootloader will support one of them. Probably EXTENDED ERASE is the only one supported.
2023-12-21 07:28 AM
Hi, thank you for your reply.
I am using an STM32L151RET6.
With the GET command I get that the erase command is supported, but when I try to use it a get immediately a nack.
I tried the RDP workaround following this thread: Bootloader UART: NACK to mass erase in extended er... - STMicroelectronics Community
If you have any other hint, it would be appreciated.
Regards
2023-12-21 07:59 AM
The link you have is pretty conclusive, it just isn't supported here, bizarrely. Bummer.
> I checked and this device (as well as for example STM32L1 series) do not implement the mass erase in the bootloader. The BL code space was simply too small on this device to fit the mass erase. Sorry.
Should be able to do page-by-page erase though.
2023-12-21 10:16 AM
>>With the GET command I get that the erase command is supported, but when I try to use it a get immediately a nack.
Ok, but what would help everyone here would be the exact byte sequences, and responses you observe when interacting with the system boot loader.
The boot loader is fussy about syntax, and has a smaller subset of commands when RDP is enabled.
Erase will be further complicated by write protection settings, explicit, and inferred.
My approach in these situations would be to debug and disassemble the loader to understand it's specific objection, and how well that relates to the AN3155 docs for the protocol.
2024-01-09 06:53 AM
I have the reply I was looking for:
the extended erase command is supported, but only for the single page erase, i.e. it is not possible to perform the 'special erase' described in the application note AN3155:
Here there are the byte sequences: