Closed martin-kaiser closed 9 months ago
gentle ping
@spth Could you have a look at this patch?
This fix has worked for me with an STM8L151G6.
I've had a look at the code; I think this should be fine. The sizeof(c)
looks a bit odd though, after all it is 1 by the definition of a byte.
I've had a look at the code; I think this should be fine. The
sizeof(c)
looks a bit odd though, after all it is 1 by the definition of a byte.
Thanks for reviewing the patch.
My hope was that sizeof(c) shows more clearly which parameter is the buffer length. But I have no strong opinion about this. I've just pushed an updated patch that uses 1 instead of sizeof(c).
Fix the mechanism to remove the readout protection (ROP) of an STM8L chipset.
ST's document PM0054 describes the unlock procedure in section 4.1: "To unprotect the device, the ROP must be written twice: the first write, with any value, launches a global erase which includes the option byte; the second write, 0xAA, unprotects the device, and then the 0xAA value remains in the ROP byte."
The definition of ROP_STM8L has a comment that matches the description in PM0054. It also says that we have to write 0xAA into the ROP option byte twice.
My tests showed that this double 0xAA write actually sets the ROP option byte to 0xAA and resets all other option bytes to their default values. There's no need to clear the other option bytes manually. part->option_bytes_size is now unused for ROP_STM8L...