cancel
Showing results for 
Search instead for 
Did you mean: 

STM8 bootloader UART write memory

thaonguyen
Associate II

Hello,
I am developing a firmware for a host device to flash STM8S via UART.
My issue is when I send a write command, STM8 didn't response anything.
- Host sends write command: 0x31 0xCE, STM8 responsed ACK 0x79 . Host replies 0xFF
- Host sends 5 bytes address and checksum: 0x00 0x00 0x88 0x00 0x88, STM8 responsed ACK 0x79. Host replies 0xFF

- Host sends 6 bytes (1 byte: number of data, 4 bytes data and 1 byte checksum): 0x03 0x00 0x00 0x00 0x00 0x03

 STM8 didn't reply anything.
I attached serial capture image.
Please help me. it took me a long time to check it

thaonguyen_0-1717408740348.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

As I said before, .S19 file is not a binary file, and this is the problem. .S19 is an ASCII file. Code is in hexadecimal and each line begins with an 'S' and an address. You can't read the file as is and send it to MCU. Search in Internet for .s19 file format.

 

View solution in original post

22 REPLIES 22
AA1
Senior III

Maybe it is missing the erase/write routines. See UM0560 - STM8 bootloader, section 3.8.1 RAM erase/write routines.

Also STM8S bootloader uses reply mode. Section 2.1.1 - The host must reply to all the bytes sent from the bootloader. I think 0xFF is the reply to 0x79. Maybe this works but reply byte should be the same as received. In this case 0x79.

Hi @AA1 ,
I am sure that wrote RAM erase/write rountines to RAM start at address 0x0000A0, and I read back data is correct.
I just changed to reply same byte received, but it doesn't change, you can see image attached.
could you recheck this issue to help me?

thaonguyen_0-1717437941169.png

 

UART settings is 1 start bit, 8 data bit, no parity bit, 1 stop bit?

 

Right

Try to send a wrong checksum and verify if there is a response with NACK.

 

AA1
Senior III

Also try UART settings 1 start bit, 8 data bit, even parity, 1 stop bit.

Why do you keep sending these 0xFF bytes?

Sending them after the command likely means it's expecting 256 bytes of data, not 4 bytes.

Also the protocol want's EVEN PARITY, ie 8E1, like the STM32 equivalent

https://www.st.com/resource/en/user_manual/um0560-stm8-bootloader-stmicroelectronics.pdf

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

Hi @AA1 ,
I tried with wrong checksum then STM8 repsonses NACK
I also tried to use parity even bit but no change.

Hi @Tesla DeLorean ,
I am developing using UM560 document.
my stm8 is stm8s105 (stm8s-discovery). I wrote both 128 bytes and 256 bytes and it still isn't working.

pls help me with any idea.