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

 

22 REPLIES 22

0x7F [0x79] Initial training pattern to auto-baud, 8E1

0x31 0xCE [0x79] Command

0x00 0x00 0x88 0x00 0x88 [0x79] Address

0x03 0x00 0x00 0x00 0x00 0x03 [0x79] Data

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

I think the protocol for STM8S uses reply mode. UM0560 - STM8 bootloader Section 2.1.1 - The host must reply to all the bytes sent from the bootloader. Otherwise first 0xFF sent would be the first byte of 4 bytes address and the checksum would be wrong, which is not the case.

@I just saw that stm8 is restarted after Host sends data.
any reason to do it restarted?

Watchdog? Writing to the wrong area causing a fault?

Perhaps use the Flash Demonstrator or ST tools to program via the loader, and monitor the COM port traffic.

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

Invalid opcode reset. Missing the erase/write routines.

the bootloader version is reading from stm8 is 0x13, so I wrote Routines file: E_W_ROUTINEs_32K_ver_1.3.s19
is it correct?
I am using stm8s-discovery (stm8s105C6)

AA1
Senior III

.s19 file is not a binary file. How do you wrote RAM erase/write routines to RAM.

If above step is ok, other possibility is watchdog as Tesla DeLorean already said. Do you have watchdog enable by hardware in options bytes?

 

Hi @AA1 ,
I don't use Watchdog.

I am writing content of routines file to RAM starting at address 0x0000A0. should it be correct?

If you don't' use watchdog, invalid opcode reset seems the only possibility. And this happens because code at address 0x0000A0 is invalid. Show me the first bytes at address 0x0000A0.

 

Hi @AA1 ,

pls see it in image below. 
S00F000044656275 is 16 bytes wrote to 0x0000A0

thaonguyen_0-1717598029468.png