Bootloader UART: NACK to mass erase in extended erase memory command
Hello,
We are currently using an homemade software to program our mcu. It has been tested on an STM32L4. While I am using it on an STM32L0 with the same version of the ST bootloader (V3.1). It returns an error during the erase step. The mcu responds with a NACK to a special mass erase command (0xFFFF) after acknowledging the extended memory erase command (0x44). I checked that the command was supported after doing a get (0x00).The communication recorded in hex is attached and commented. Technical details on the environment are given at the end.
The solutions I have already tried:
1. Page by page erase
The mcu returns an ACK and the page is erased (controlled with stm32CubeProgrammer) This solution is slower and causes compatibility problems in our software because we need to know the size of the flash. Nevertheless, it shows that the memory is not in protected mode.
2. Activate and deactivate the read protection
This sequence causes the flash to be erased. It is fast but looks more like a hack than a real solution. Also, I would prefer to use the same command for all MCUs with the same bootloader version. If I can't solve this problem, I will probably keep this. Is it recommended? Are there any side effects?
3. Disable read before erase protection
In case I was wrong and the memory was indeed protected, I tried to unprotect it before sending the extended memory erase command. The result is the same. We get a NACK for the mass erase.
Thank you in advance for your help
Best regards
Louison
Technical details about the environment:
MCU : STM32L052K8U6, bootloader version 3.1
UART info : baud rate 9600, parity even, 8bits , 1 stop bit.
Application note used: AN3155 USART protocol used in the STM32 bootloader
Communication record in hex :
7F /* origin PC : starting frame */
79 /* origin MCU: ACK */
02 FD /* origin PC : get chip id + CRC */
01 XX XX 79 /* origin MCU: chip id + ACK */
00 FF /* origin PC : Get version and cmd */
79 /* origin MCU: ACK */
0B /* origin MCU: number of bytes */
31 /* origin MCU: Bootloader version */
00 01 02 11 21 31 44 63 73 82 92 79
/* origin MCU: Available command
* 0x44 : Extended Erase Memory command
* is in the list
* + ACK */
44 BB /* origin PC : extended erase memory cmd + CRC */
79 /* origin MCU: ACK */
FF FF 00/* origin PC : 0xFFFF = Mass erase + CRC */
1F /* origin MCU: NACK -> ERROR ! */