2024-07-09 04:23 PM
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
2024-07-09 04:45 PM - edited 2024-07-09 04:46 PM
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:
Multiple ACKs can be and often are within the same command.
cd00264342-usart-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf