stm32f1 bootloader write memory command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-22 3:39 AM
Hello,
i'm trying to implement firmware upgrade in my Windows application via USART for stm32f103 following AN3155. My issue is with the Write Command. More specifically:
- if i send 1 byte of user data at time it works, it's just slow cause i have to introduce 1ms delay or shorter between each write (or it stucks and i get no message from the bootloader):
//PSEUDO CODE:
for (i=0 to N_byte){
USB_Out_Buffer[0] = FirmwareBytes[current_chunk_num, i];
USB_write(1); //sends 1 byte
delayms(1);
}
- if i send the whole 256 byte block (or lower) it stucks after sending the checksum and i get no message from the bootloader:
//PSEUDO CODE:
for (i=0 to N_byte){
USB_Out_Buffer[i] = FirmwareBytes[current_chunk_num, i];
}
USB_write(N_byte+1); //sends 256 bytes
I'm using USART on PA9, PA10. i tried everything, reduce baudrate, adding delay etc.
Any idea what could be the issue?
Solved! Go to Solution.
- Labels:
-
STM32F1 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-22 12:42 PM - edited ‎2025-06-22 12:42 PM
Not sure what USB library you're using, but USB isn't typically a ONE byte interface, packets typically at least 64-bytes.
For a serial connection you should perhaps open the COM port with CreateFile() and use WriteFile() to move data over the interface. You should be able to send blocks of data, be it the command, or the address/checksum
You shouldn't need delays. The STM32 needs EVEN parity.
For an example of AN3155, perhaps look at STM32FLASH or the Firmware Updater for the Arduino MKR WAN 1300 on GitHub
Perhaps walk the protocol through with something like REALTERM in HEX mode
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-22 12:42 PM - edited ‎2025-06-22 12:42 PM
Not sure what USB library you're using, but USB isn't typically a ONE byte interface, packets typically at least 64-bytes.
For a serial connection you should perhaps open the COM port with CreateFile() and use WriteFile() to move data over the interface. You should be able to send blocks of data, be it the command, or the address/checksum
You shouldn't need delays. The STM32 needs EVEN parity.
For an example of AN3155, perhaps look at STM32FLASH or the Firmware Updater for the Arduino MKR WAN 1300 on GitHub
Perhaps walk the protocol through with something like REALTERM in HEX mode
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-23 6:01 AM
Seems like it's a problem on PC-side.
Hook up TX to RX and see if you're actually sending what you think. Probably a buffering issue. Maybe USB_write can only take one packet at a time, or maybe it's buffering until it receives a null or newline or something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-24 9:41 AM
Thank you, the issue was with the parity set to NONE instead of EVEN!
