2024-06-03 02:59 AM
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
Solved! Go to Solution.
2024-06-03 12:37 PM
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
2024-06-03 12:40 PM
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.
2024-06-03 12:45 PM
@I just saw that stm8 is restarted after Host sends data.
any reason to do it restarted?
2024-06-03 12:52 PM
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.
2024-06-03 01:00 PM
Invalid opcode reset. Missing the erase/write routines.
2024-06-03 01:06 PM - edited 2024-06-03 01:11 PM
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)
2024-06-04 10:20 AM
.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?
2024-06-05 12:13 AM
Hi @AA1 ,
I don't use Watchdog.
I am writing content of routines file to RAM starting at address 0x0000A0. should it be correct?
2024-06-05 05:58 AM
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.
2024-06-05 07:35 AM