tenbaht / sduino

An Arduino-like programming API for the STM8
http://tenbaht.github.io/sduino/
GNU Lesser General Public License v2.1
349 stars 213 forks source link

STM8S001 is locked and cannot be progammed anymore #101

Open YoYo1846 opened 4 years ago

YoYo1846 commented 4 years ago

Hello,

I'm prototyping around the low cost 8 pins stm8s001 / stm8l001 I'm using a stm8s103 board definition in arduino, since it's the same family.

This chip is different than the other ones in the familly since it doesn't have any RST pin to start the programming thru the SWIM pin.

Unfortunately, in your code (wiring-init.c), the first thing done is disabling this pin, which lock forever the chip from beeing programmed :


void init() {

ifndef ENABLE_SWIM

// free the SWIM pin to be used as a general I/O-Pin
CFG->GCR = CFG_GCR_SWD;

endif

[...]

Of course, it could be possible to disable this code using the CFLAG ENABLE_SWIM but I'm not sure it is possible in arduino

Are you aware of this limitation for the stm8s001 / stm8l001 and therefore, is there a plan to change the default configuration in wiring-init.c ?

Thanks, YoYo

YoYo1846 commented 4 years ago

Recommandations :

Recommendation for SWIM pin (pin #8) sharing As the NRST pin is not available on this device, if the SWIM pin should be used with the I/O pin functionality, it is recommended to add a ~5 seconds delay in the firmware before changing the functionality on the pin with SWIM functions. This action allows the user to set the device into SWIM mode after the device power on and to be able to reprogram the device. If the pin with SWIM functionality is set to I/O mode immediately after the device reset, the device is unable to connect through the SWIM interface and it gets locked forever. This initial delay can be removed in the final (locked) code.

tenbaht commented 3 years ago

Thank you for mentioning this. Adding proper support for the '001 is needed. So far I don't have one for testing, but I will get some.

smartswitchsio commented 3 years ago

Kindly add stm8s001 support in board section

thinhx2 commented 3 years ago

FB_IMG_1605798920609 Try this one Vcap+gnd for reset . information from here : https://m.facebook.com/groups/1059092380768771/permalink/3428871193790866/

rtek1000 commented 1 year ago

Hello,

I already had similar problem with PIC12F675.

I left the WDT with a very short time, and also disabled the RESET.

But with a lot of effort I managed to reprogram this PIC, making pulses on the power line (cycling the power off and on again, but it must not cause a short circuit, or it may cause voltage spikes), to force the RESET synchronized with the programmer.

I don't know if this can solve the STM8S001 problem, but I leave here the report for those who use PIC at least.

I̶ ̶a̶m̶ ̶t̶r̶y̶i̶n̶g̶ ̶t̶o̶ ̶d̶i̶s̶a̶b̶l̶e̶ ̶S̶W̶I̶M̶ ̶a̶s̶ ̶i̶t̶ ̶i̶s̶ ̶t̶h̶e̶ ̶o̶n̶l̶y̶ ̶f̶r̶e̶e̶ ̶p̶i̶n̶ ̶o̶n̶ ̶t̶h̶e̶ ̶W̶1̶2̶0̶9̶ ̶t̶h̶e̶r̶m̶o̶s̶t̶a̶t̶ ̶b̶o̶a̶r̶d̶ ̶(̶S̶T̶M̶8̶S̶0̶0̶3̶)̶,̶ ̶a̶n̶d̶ ̶i̶t̶ ̶w̶o̶u̶l̶d̶ ̶b̶e̶ ̶n̶i̶c̶e̶ ̶t̶o̶ ̶h̶a̶v̶e̶ ̶s̶o̶m̶e̶ ̶w̶a̶y̶ ̶t̶o̶ ̶e̶x̶p̶o̶r̶t̶ ̶t̶h̶e̶ ̶d̶a̶t̶a̶.̶

P.S.: SWIM was actually disabled, but the W1209 pin is used on the display.

rtek1000 commented 1 year ago

I found this:

Pg 58:

HVP If this option is checked, the programmer uses the “high” voltage at pin P for communication with the device. This allows you to program a device with the external RESET signal switched off

Pg 57:

Programming method • HVP Traditional programming will be applied using a voltage of 8 V to 13 V at pin P.

Pg 9:

HVP (High Voltage Programming) is a programming mode in which a higher voltage than the power-supply voltage is applied to pin P in the initial phase.

Settings Associated with AVR and 8051 Microcontrollers

Did ST put this option in STM8S001?