Search code examples
cbineepromstm8

stm8flash .bin file for EEPROM write


I am attempting to write values directly to the eeprom space on a stm8 micro controller. I don't want to write a program that does this that I flash onto the chip. But i want to write directly to it. The command to do this is in unix is such:

./stm8flash -c stlinkv2 -p stm8l151f2 -s eeprom -w myfile.bin

My question that I have searched high and low for is how do I make the myfile.bin and what would it look like, is this just C code that I write that assigns the value to the register I pick and then use some compiler that can output to a .bin file? I have done eeprom read/writes within programs but never directly written to eeprom space.The only information I would like to store is information about the product, usage information that can be looked up after. 50 Bytes of data max I would guess.


Solution

  • The easiest thing to do was to first read the file like so:

    ./stm8flash -c stlinkv2 -p stm8l151f2 -s eeprom -r myfile.bin
    

    Then once that was done I used @thebusybee idea of using a hex editor, I opened the read file (GHex was the editor I used). Using the editor I made my changes and wrote the file using:

    ./stm8flash -c stlinkv2 -p stm8l151f2 -s eeprom -w myfile.bin
    

    This seems to be working well but the data doesn't match perfectly after a second read, hmm may be a different problem.