Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stlinkv2 stm8l unlock #98

Closed
wants to merge 6 commits into from

Conversation

sjborley
Copy link

This aims to fix unlocking the STM8L. I've tested it on STM8L052R8 but it ought for other STM8L devices. Only fixed this for the stlinkv2. I've trying to fix for stlink too but without success, so have omitted those changes.

Also noted, that the EEPROM read and write appears to be working for this device, although I'm not aware I did anything that would have affected this. I just tested it.

@DKrepsky
Copy link

DKrepsky commented Apr 9, 2018

Tested this PR with STM8L151K4 and worked as expected.

Thanks

@lkord
Copy link

lkord commented Apr 24, 2018

Tested with STM8L151G6 and unlock is working. Thank You. I was trying earlier and did not accomplish this.
Why do You put 0x01 into buf[10]? This seems to be BROWNOUT Reset ON. With Off (0x00) it is also working.

@B4Me
Copy link

B4Me commented Jun 21, 2018

I have made a pull of the changes by @sjborley , but cant get my STM8L052C6, unlocked
Does anyone else have a hint of what I can do to get the unlocking to work ?

@lkord
Copy link

lkord commented Jun 21, 2018

@B4Me show the command You use and error You get

@B4Me
Copy link

B4Me commented Jun 22, 2018

@lkord Here are my commands:
sudo ./stm8flash -c stlinkv2 -p stm8l052c6 -u

Determine OPT area
Due to its file extension (or lack thereof), "Workaround" is considered as RAW BINARY format!
Unlocked device. Option bytes reset to default state.
Bytes written: 13

sudo ./stm8flash -c stlinkv2 -p stm8l052c6 -s flash -w calib.ihx

Determine FLASH area
Due to its file extension (or lack thereof), "calib.ihx" is considered as INTEL HEX format!
20628 bytes at 0x8000... Tries exceeded

@lkord
Copy link

lkord commented Jun 22, 2018

@B4Me after first operation. Can You read OPT Bytes?:
sudo ./stm8flash -c stlinkv2 -p stm8l052c6 -s opt -r OB.hex -b 13
See in datasheet what should appear on first byte? 0xAA or 0x00?
Workaround for unlock can be (but not tested on this part):

  1. Unlock with STVP
  2. Download OPTION BYTES sectors to *.hex file
  3. Write (change -r to -w from command above) that file to opt area to unlock. Can do same things to lock.

I have never seen *.ihx files before. Did You mean *.hex?

@B4Me
Copy link

B4Me commented Jun 28, 2018

Hi @lkord
Sorry for the delay, had an accident, so first had time now.
After running unlock, and reading out opt bytes I get:
AA 00 00 00 00 00 00

But I still cant write to the device after a reset of the power.
The issue as I see it, are in the syntax, flash AA, read EOP, flash AA, read EOP
I dont think the code is correct yet
But I dont know what to change yet.

I have to be able to do it through linux, sadly, so using STVP, isnt an option, as its for a production rig, where everything needs to run from a single box, running on raspberry pi

@lkord
Copy link

lkord commented Jul 18, 2018

@B4Me

  1. According to datasheet the uC is unlocked 0xAA in 0x4800 address,
  2. Unlock code You can find in stlinkv2.c but in sborley branch for STM8L,
  3. The STVP solution is to read bytes to a .hex file just once and then use it as an input file, no need for Windows and STVP,
  4. Last question: I have never seen *.ihx files before. Did You mean *.hex?

@spth
Copy link
Collaborator

spth commented May 20, 2020

4. Last question: I have never seen *.ihx files before. Did You mean *.hex?

These are just alternative file endings for the same Intel Hex type of file, like .jpg and .jpeg for JPEG.

@spth
Copy link
Collaborator

spth commented Sep 19, 2021

I think we now have working STM8L unlock support in master?
If yes, can this pull request be closed or is there still something left here that we want in master?

@spth
Copy link
Collaborator

spth commented Feb 22, 2024

Closing, out of date.

@spth spth closed this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants