2023-04-29 02:54 PM
Hi everybody,
I am using the STM8S003F3P6 development board (little blue one bought from AliExpress) and I am trying to program it using ST-LINK V2 (also bought on AliExpress).
I wrote the code using STVD and now I would like to program the MCU. I tried to follow the "standard" procedure to program the microcontoller but it doesn't work. The ST Visual Programmer displays the following error:
Error: The device is protected
I searched for the solution in internet, and everybody says that I have to unlock the Read Out Protection. Those bits were already set to 0, but I cleared them anyway.
This should have solved my problem, but unlikely the problem is still there.
I read the datasheet and I didn't find any solution. I want to say that I tried programming another chip (same microcontroller model, same ST-LINK, same software tools) and everything works perfectly. Can someone help me please?
Thanks,
Lorenzo
2023-04-30 12:26 PM
Welcome, @RomanoLorenzo, to the community!
There can be two serious problems, since you also bought the ST-LINK/v2 from Aliexpress, which is pretty much a little colored metal box and therefore a fake or counterfeit, right?
But since you can program similar types with the presumed fake, it must inevitably have to do with the STM8, which is probably a counterfeit, as they are very often found on Aliexpress.
So you should contact Aliexpress and try to exchange the board or claim your money back.
Hope that helps?
Regards
/Peter
2023-05-03 08:02 AM
Thanks Peter for your answer,
The ST-LINK/v2 is 100% fake, it is based on the Geehy APM32F103C8T6 microcontroller, but luckily it works fine.
I tried programming the STM8 again and again, but still doesn't work. I thin you are right; it must be fake!
I will try again, and if i won't be able to program it I will try to decap the chip in order to find out more.
Meanwhile if anybody knows anything more, i appreciate every kind of advice.
Thanks,
Lorenzo
2024-12-19 02:28 AM - edited 2024-12-19 03:29 AM
Hi Lorenzo,
I had the same problem: 5pcs of STM8S003F3P6 & ST-Link V2 from Ali and ST Visual Programmer (STVP) answers 'Protected device' for IC just from the tape carrier.
And the marking of the 1st pin has some strange view: the marking ring is not smooth as in previous ICs, but as burned.
I opened 'OPTION BYTES' tab in STVP, selected 'Read Out Protection Off' and executed Program \ Current Tab.
This is obvious step for Protected Device, but I had not such a problem with new STM8 before, so I tried to PROGRMA MEMORY, read it or read OPTION BYTES, but not to write OPTION BYTES as the 1st step.
After this the programming functions ran correctly.
For programming it's enough to solder 5 pins of STM8S003F3P6:
pin 9 to 3.3V of ST-Link
pin 7 to GND
pin 4 to SWCLK
pin 18 to SWIM
pin 8 - capacitor 0.1uF to GND.
This is enough & obligatory for PROGRAMMING.
Best regards, Vadim
2024-12-25 11:27 PM - edited 2024-12-25 11:30 PM
Addition to previous post.
I tested the 2nd STM8S003F3P6 purchased on aliexpress. It was also protected.
It is interesting: after loading Option bytes to unprotect uC, the Program memory appears to be not empty.
I've checked normal uC (not from aliexpress):
-set protection in option bytes,
-tried to read it (Option bytes and Program memory) & got the message that uC is protected,
-canceled protection
-tried to read it again & got empty Program memory - as it should be.
It seems, something to be wrong with protection in my STM8 from ali.
2024-12-27 04:41 PM - edited 2024-12-27 04:44 PM
Sounds like fake chips. If you're interested in trying one more thing, and if you have access to a Linux environment (or can use Linux Subsystem for Windows, or install Linux packages on MacOS), you can also try stm8flash, the "-u" option looks promising.
Failing that, you can try reading the saving the existing option bytes to disk, manually changing over, and writing back:
stm8flash -c stlinkv2 -p stm8s003f3 -s opt -r opt.bin # save to disk
# ...edit opt.bin in hex editor of choice, to clear ROP
stm8flash -c stlinkv2 -p stm8s003f3 -s opt -w opt.bin # save to device
Keep in mind that unlike all other option bytes the ROP (read out protection) option byte is stored only once - there is no complementary NOPTx byte for ROP. Also, although your questions the other responses here imply it, ROP must be programmed via SWIM - not "on the fly."
I searched for the solution in internet, and everybody says that I have to unlock the Read Out Protection. Those bits were already set to 0, but I cleared them anyway...I read the datasheet and I didn't find any solution...
If you're still interested in looking at what the official documentation says about it, it's in datasheet, DS7147, section 8 (and Table 13 at the bottom of the first page in section 8); and in the reference manual, RM0016, under section 4.5.1 "Readout protection".