STM32 Open Bootloader USB I/Fbug
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
