Close

STM8L101: some new findings

A project log for eForth for cheap STM8S gadgets

Turn cheap modules from AliExpress into interactive development kits!

thomasThomas 09/19/2020 at 13:080 Comments

Using the methods described in the previous log entry, I tried programming the STM8L101, and using STM8-GDB and OpenOCD already proves to be *very* useful!

Connecting with OpenOCD works. I first used openocd -f interface/st-link.cfg -f target/stm8l152.cfg -c "init" -c "reset halt"). but it turned out that the that target configuration uses 128 bytes block size - Low Density devices have 64 bytes block size - and programming failed after the 5th block (setting breakpoints with GDB and inspecting memory with x/i helped a lot).

I'm now using the following OpenOCD configuration (stored as target/stm8l101.cfg):

#config script for STM8L101

set FLASHEND 0x9FFF
set BLOCKSIZE 0x40

proc stm8_reset_rop {} {
   mwb 0x4800 0xaa
   mwb 0x4800 0xaa
   reset halt
}

source [find target/stm8l.cfg]

With this file programming an STM8L101F3P6 chip actually works!

I made a trimmed-down STM8 eForth board configuration without background task but running it results in a reset

(gdb) run

Starting program: /home/thomas/source/stm8s/stm8ef/out/STM8L101F3/STM8L101F3.elf 
Remote debugging using localhost:3333
0x00008bd2 in ?? ()
Loading section SSEG, size 0x1 lma 0x1
Loading section HOME, size 0x73 lma 0x8000
Loading section GSINIT, size 0x1a lma 0x8073
Loading section GSFINAL, size 0x3 lma 0x808d
Loading section CODE, size 0x1152 lma 0x8090
Start address 0x8073, load size 4579
Transfer rate: 7 KB/sec, 915 bytes/write.
(gdb) 
Program stopped.
0x00008000 in ?? ()

 I tentatively set a breakpoints and single stepped execution until I learned that returning from a LITERAL (implemented with TRAP) doesn't work. That's very good (and very fast!) progress :-)

Discussions