STM8 read out protection

Hi all, someone can explain how to enable read out protection on STM8?
I’m using this environment but i have no idea on how to set up read protection

[env:stm8sblue]
platform = ststm8
board = stm8sblue
framework = arduino

upload_protocol = stlinkv2

Thank you!

platform-ststm8 has no provisions for activating the ROP in a simple way. The reference manual states that the ROP option byte has to be programmed to 0xaa for ROP to be active. Per e.g. this MCU’s datasheet page 42, the OPT0 byte stores this value and is the first of the option bytes.

I would start by trying to reading out the current option bytes with the tools PlatformIO uses. For your STM8S103F3P6 for example

C:\Users\<user>\.platformio\packages\tool-stm8flash\stm8flash.exe -c stlinkv2 -p stm8s103?3 -s opt -b 11 -r option_bytes.bin

(If opt does not work, use the direct address 0x4800)

Otherwise, use ST’s tools (STVP-STM8 - ST Visual Programmer STM8 - STMicroelectronics).

1 Like