cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader on STM32F0

EArsanaci
Associate

Summary: A 10-character message is sent through the interface (It uses RS485). Then, the first character, "h," is received by the processor and verified. If it is confirmed to be the character "h," the remaining 9 characters are received. After verifying the accuracy of the received 9 characters, they are sent back to the interface for two-way verification. If the 9 characters are verified by the interface, the software parses the firmware file and sends it to the processor. The processor writes the parsed software to the specified section in the flash memory. After the processor restarts, the bootloader software runs first, and then, after 1 second, it jumps to the flash memory area where the parsed main software is loaded and starts runningç However these code works for only debug ly debug mode. When I loaded the Release mode, GUI interface cahth the nothing from microporessor. GUI interface was written with Python. 

I tried many things. Decrease or increase microprocessor's frequency. Receiving 2 times the character of the received message and finding the desired message from the received characters etc.

while (1)
{

//check to recieve mode
HAL_GPIO_WritePin(iap_lib.rs485_gpio, iap_lib.rs485_DR_pin, GPIO_PIN_RESET);
HAL_UART_Receive(iap_lib.rs485_uart, receivedmessage, 1, 1000);

if (receivedmessage[0] == 'h')
{
HAL_UART_Receive(iap_lib.rs485_uart, receivedmessage, 9, 1000);
status = strcmp(receivedmessage,hello_message);

if (status == 0){
HAL_GPIO_WritePin(iap_lib.rs485_gpio, iap_lib.rs485_DR_pin, GPIO_PIN_SET);
HAL_UART_Transmit(iap_lib.rs485_uart, receivedmessage, 9, 1000);
HAL_Delay(1000);
HAL_GPIO_WritePin(iap_lib.rs485_gpio, iap_lib.rs485_DR_pin, GPIO_PIN_RESET);
Ymodem_Receive(&file_size, iap_lib);
}
else
{/* Keep the user application running */
main_app();
}
}

else if (receivedmessage[0] == 'r')
{
HAL_UART_Receive(iap_lib.rs485_uart,receivedmessage, 9, 1000);
status2 = strcmp((char *)receivedmessage, reset_comsett_message);
if (status2 == 0)
{
uint32_t new_ID = 0xA5000201;
HAL_GPIO_WritePin(iap_lib.rs485_gpio, iap_lib.rs485_DR_pin, GPIO_PIN_SET);
HAL_UART_Transmit(iap_lib.rs485_uart, receivedmessage, 9, 1000);
HAL_Delay(1000);
uint32_t sourceAddress = 0x0800FC00; // Start address of the desired flash page
uint32_t destinationAddress = (uint32_t)destinationArray; // Get the address of the destination array
copyPageToStruct(&IDPage);
writeStructToFlash(&IDPage);
HAL_GPIO_WritePin(iap_lib.rs485_gpio, iap_lib.rs485_DR_pin, GPIO_PIN_RESET);
}

else
{/* Keep the user application running */
main_app();
}
}

0 REPLIES 0