cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f1 bootloader write memory command

omaroski
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you, the issue was with the parity set to NONE instead of EVEN!