Closed not-fl3 closed 8 months ago
The STM8L050J3 i s marked "ok" in the README.md, so it apparently is working for some users. So is the STM8S001J3. If I remember correctly, I used stm8flash for the latter myself a few years ago.
The STM8L050J3 i s marked "ok" in the README.md, so it apparently is working for some users. So is the STM8S001J3. If I remember correctly, I used stm8flash for the latter myself a few years ago.
yeah, it is marked OK, so highly likely I am doing something wrong
But I figured I'll better leave this as a PR, I spent way too much time trying to google this cursed error 0x05 :D
Just in case, I'll leave the steps to reproduce the problem:
Also note that stm8flash's espstlink
has this stalling step (that's where I gleaned the code)
I have an stm8L050J3 and cannot reproduce this behavior. I am able to read and write the flash of this chip even with reset tied to 3.3v. (stm8L050J3 doesn't have reset)
Don't have the STM8S001J3 so i can't test it on that...
I have an stm8L050J3 and cannot reproduce this behavior. I am able to read and write the flash of this chip even with reset tied to 3.3v. Don't have the STM8S001J3 so i can't test it on that...
somehow with my stm8L050J3 I can flash it only once. If its the same firmware again - it will successfully "flash" (cause nothing will be actually written to the flash due to diffs), but if its a different firmware - it will give an error...
Ok. I've seen it now as well. It seems to really depend on what you attempt to write. section 3.6 of the datasheet gives some good hints as to why. in any case its not a good idea to have the core running while writing to flash.
Your changes seem to fix the issue. But I'm not sure if it's ok to do that for all the chips... It also probably doesn't need to be done on every page but only once
I had problems flashing a TSDZ2 motor from linux, got the SWIM 0x05 error every time. This patched fixed it!
I have no idea what I'm doing really so cant provide much information, using a ready made cable with a stlinkv2 built into it. The part number passed to stm8flash is "stm8s105?6"
Tested on stm8s005?6 and fixed the issue! Thanks a lot
Note that I am not exactly sure what I am doing and I can't be sure that this change does not break things.
The problem I encountered - stm8flash always failed with error
0x05
when trying to flash a controller without NRST pin(specifically STM8L050J3) or with NRST pin disconnected(tested with Stm8s103f3 with NRST disconnected from ST-LINK).Before this fix writing to FLASH_NCR2 never succeeded, resulting in flashing error 0x05:
One possible workaround was - skip writing to
FLASH_CR2/FLASH_NCR2 and flash memory in "bytes" mode - with
block_size1 in
stm8.c`. It worked on STM8L050 perfectly, but super slow.According to https://www.st.com/resource/en/programming_manual/pm0051-how-to-program-stm8s-and-stm8a-flash-program-memory-and-data-eeprom-stmicroelectronics.pdf
They say "recommended", but somehow it is actually necessary?