Skip to main content
Visitor II
July 9, 2024
Question

STM32 Open Bootloader USB I/Fbug

  • July 9, 2024
  • 1 reply
  • 777 views

In attempting to figure out how to stay in the bootloader loop while exchanging packets with the USB DFU tool I came across as what looks like an unintentionally undeleted line of code.

Here is the code:

static void OPENBL_USART_Go(void)
{
 uint32_t address;
 uint32_t mem_area;

 /* Check memory protection then send adequate response */
 if (OPENBL_MEM_GetReadOutProtectionStatus() != RESET)
 {
 OPENBL_USART_SendByte(NACK_BYTE);
 }
 else
 {
 OPENBL_USART_SendByte(ACK_BYTE);

 /* Get memory address */
 if (OPENBL_USART_GetAddress(&address) == NACK_BYTE)
 {
 OPENBL_USART_SendByte(NACK_BYTE);
 }
 else
 {
 /* Check if received address is valid or not */
 mem_area = OPENBL_MEM_GetAddressArea(address);

 if ((mem_area != FLASH_AREA) && (mem_area != RAM_AREA))
 {
 OPENBL_USART_SendByte(NACK_BYTE);
 }
 else
 {
 /* If the jump address is valid then send ACK */
 OPENBL_USART_SendByte(ACK_BYTE);

 OPENBL_MEM_JumpToAddress(address);
 }
 }
 }
}

It looks like the statement on line 13 should be deleted.  If we don't it's going to send both an ack and either an ack or a nak, for one received message.  This is in the OpenBootloader repo, in the ST-Micro supplied file Source/OpenBootloader/Middlewares/ST/OpenBootloader/Modules/USART/openbl_usart_cmd.c

 

    This topic has been closed for replies.

    1 reply

    Super User
    July 9, 2024

    That particular ACK acknowledges protection is not active and the host can send the address. It's not a bug. It's in the UART protocol document here:

    TDK_0-1720568682642.png

    Multiple ACKs can be and often are within the same command.

    cd00264342-usart-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf