cancel
Showing results for 
Search instead for 
Did you mean: 

UART bootloader doesn't answer after successful read unprotect command

LLouf
Associate II

Hello,

I have a problem with the bootloader on a Nucleo G071RB. I have no problem reaching the bootloader to download some new firmware in UART, after a reset and Boot0 pin set as it should, the bootloader responds to messages send through UART : when sending the begin command it is acked, same for the command to get version and read protection status and the readout unprotect command too. The problem is, after sending this last one, it simply stops responding after sending the two ACKs of the readout unprotect command. I've tried with the begin command and the write unprotect command, it doesn't answer, there's no ACK or NACK, it just sends nothing.

It is also worth mentioning that the firmware that was present on the Nucleo board isn't erased as it continues to run after a reset in normal execution mode.

I have logged the response of the get version and read protection status and I have the following result which seems a bit odd : 0x79 0x31 0x00 0x00 0x79. So I have the two ACKS, the version is 3.1 but the option bytes set to zero doesn't feel right.

In the firmware on the STM that has ran at least once, I have the following code to enable bootloader selection with Boot0 pin :

FLASH_OBProgramInitTypeDef flash_ob_program_init, flash_ob_program_set;
    HAL_FLASHEx_OBGetConfig(&flash_ob_program_init);
 
    if ((flash_ob_program_init.USERConfig & FLASH_OPTR_nBOOT1) != OB_BOOT1_SYSTEM ||
        (flash_ob_program_init.USERConfig & FLASH_OPTR_nBOOT_SEL) != OB_BOOT0_FROM_PIN) {
        HAL_FLASH_Unlock();
        HAL_FLASH_OB_Unlock();
        flash_ob_program_set.OptionType = OPTIONBYTE_USER;
        flash_ob_program_set.USERType = FLASH_OPTR_nBOOT1 | FLASH_OPTR_nBOOT_SEL;
        flash_ob_program_set.USERConfig = OB_BOOT1_SYSTEM | OB_BOOT0_FROM_PIN;
        HAL_FLASHEx_OBProgram(&flash_ob_program_set);
        HAL_FLASH_OB_Launch();
    }

So maybe there's something wrong there but I don't see what. Any ideas where it could come from ?

Best regards,

Laurent Louf

2 REPLIES 2
LLouf
Associate II

Digging a bit deeper, I've read the option bytes directly from the STM and the results seem fine :

WRPArea 0x000007d2
WRPStartOffset 0x0000003f
WRPEndOffset   0x00000000
RDPLevel 0x000000aa
USERConfig 0x3e4ffe00
PCROPConfig 0x00000067
PCROP1AStartAddr 0x0801fe00
PCROP1AEndAddr   0x080001ff
PCROP1BStartAddr 0x0801fe00
PCROP1BEndAddr   0x080001ff

So there's no write protection (start > end), the read protection level is zero and the proprietary code protection is deactivated (start > end)

malte.vesper
Associate II

Might be to late, but just a wild guess: Did you reenter boot0 mode? The write unprotect resets the chip (""At the end of the Write Unprotect command, the bootloader transmits the ACK byte, and generates a system reset to take into account the new configuration of the option byte." - AN3155, 3.10 Write unprotect command).
So you have to make sure that Boot0 pin is still set and got through the boot 0 init again (send 0x7F byte...)