gicking / stm8gal

PC tool for uplading hexfiles to the STM8 microcontroller via UART or SPI , using the built-in ROM bootloader. Works under Windows and Posix operating systems
Apache License 2.0
80 stars 21 forks source link

Cannot program STM8S105K6 anymore #11

Closed roybaer closed 5 years ago

roybaer commented 5 years ago

I cannot program my STM8S105K6-based boards anymore, which used to work.

Versions prior to 1d91c125705a6a1a41ec84a33b4a8f2c39ae2de8:

> ./stm8gal -p /dev/ttyUSB0 -u 2 -R 1 -w /tmp/arduino_build_28225/Blink.ino.hex  

stm8gal (v1.2.0 beta)
  load Intel hex file 'Blink.ino.hex' ... ok (2.7kB)
  reset STM8 and press <return>
  open serial port '/dev/ttyUSB0' with 230.4kBaud ... ok
  synchronize ... ok (ACK)
  determine device ... ok (STM8S; 32kB flash; BSL v1.3)
  Uploading RAM routines ... ok (304B from 0x00a0)
  write 2.7kB (0x8000 to 0x8aa5) ... ok   
  read 2.7kB (0x8000 to 0x8aa4) ... ok
  verify memory ... ok
  activate bootloader ... ok
  jump to address 0x8000 ... ok
done with program

1d91c125705a6a1a41ec84a33b4a8f2c39ae2de8 and later:

> ./stm8gal -p /dev/ttyUSB0 -u 2 -R 1 -w /tmp/arduino_build_28225/Blink.ino.hex 

stm8gal (v1.2.0 beta)
  load Intel hex file 'Blink.ino.hex' ... ok (2.7kB)
  reset STM8 and press <return>
  open serial port '/dev/ttyUSB0' with 230.4kBaud ... ok
  synchronize ... 

error in 'bsl_sync()': no response from BSL, exit!

They are connected via a CH340G USB-to-serial interface on the same board and I'm using Linux.

gicking commented 5 years ago

hi roybaer,

sorry for the late reply, but I had to dig deep to find my USB<->UART adapter again. Anyway, now I have a setup with PC <-> STMS-Discovery. The latter has a STM8S105C6, which is the closest I have to your STM8S105K6 board. Unfortunately I cannot reproduce the bug as both versions work :-(

branch master:

./stm8gal -p /dev/ttyUSB1 -b 19200 -w main.ihx -V 3 -u 2

stm8gal (v1.1.8)
  load Intel hex file 'main.ihx' ... ok (441B)
  reset STM8 and press <return>
  open serial port '/dev/ttyUSB1' with 19.2kBaud ... ok
  synchronize ... ok (ACK)
  determine device ... ok (STM8S; 128kB flash; BSL v2.1)
  Uploading RAM routines ... ok (352B from 0x00a0)
  write 441B (0x8000 to 0x81b9) ... ok   
  read 441B (0x8000 to 0x81b8) ... ok
  verify memory ... ok
  activate bootloader ... ok
  jump to address 0x8000 ... ok
done with program

branch develop:

./stm8gal -p /dev/ttyUSB1 -b 19200 -w main.ihx -v 3

stm8gal (v1.3.0 beta)
  reset STM8 and press <return>
  open serial port '/dev/ttyUSB1' with 19.2kBaud ... done
  synchronize ... done (ACK)
  check UART mode ... done (2-wire reply)
  get device info ... done (STM8S; 128kB flash; BSL v2.1)
  upload RAM routines ... done (352B in 0x00a0 - 0x01ff)
  load 'main.ihx' ... done (1074B)
  convert Intel HEX file ... done (441B in 0x8000 - 0x81a0)
  write 441B / 441B in 0x8000 to 0x81b8 ... done   
  read 441B / 441B from 0x8000 to 0x81b8 ... done   
  verify memory ... done
  jump to address 0x8000 ... done
done with program

I will today check all other boards / STM8-variants I have and let you know. Independently, could you provide a source for your sduino_uno board which seems to show the issue with the new version? Actually I was planning to order one anyway, so no harm done there. Nice work! :-)

PS: can you please re-check using the parameters as above: low baudrate, auto-detect mode, high verbosity

gicking commented 5 years ago

Update:

I checked the below boards with branch develop, auto-detect UART-mode (default), and 230kBaud. Launch as: ./stm8gal -p /dev/ttyUSB1 -b 230400 -w main.ihx

Can you please check again

As said, I don't get any further here right now, sorry!

gicking commented 5 years ago

hi roybaer, fixed it (hopefully). Can you please check branch develop again and provide feedback? Thanks in advance!

The bug was a stupid & vs | copy & paste error in get_port_attributes(). This led to RTS and DTR being always active. My boards don't have DTR connected which is why I didn't see it before. But your sduino UNO is reset by DTR, which led to the observed loss of communication.

Thanks again for pointing this out, and also for the really nice board! Have a great day :-)

roybaer commented 5 years ago

I can confirm that this solved the problem.

gicking commented 5 years ago

:-)

I'll merge the changes back to main branch