2020-05-25 01:55 AM
I tried to set the option byte via write memory command using the address: 0x1FFF7800, but it don't work it always returns a NACK. If I try to read from this address no problem occurs.
I also tried to read FLASH_CR (0x4002 2014) and to write FLASH_KEYR (0x4002 2008 ) but with no success.
Is it even possible to set nBOOT_SEL, nBOOT1, nBOOT0 via bootloader I2C protocol??
2020-05-28 12:51 AM
So I found a way to set the user_configuration nBOOT_SEL, nBOOT1 and nBOOT0 with the bootloader I2C protocol. If you take a look to the memory map you, you can see block 0: Code. Thats the memory space where you have access to from bootloader mode. At address 0x1FFF 7800 you will find also a register called option bytes. It's not necessary to unlock the flash and after that the flash for the option bytes with the magic numbers specified in datasheet. That's very confusing, if you read the description in "FLASH option bytes".
The right way is to use the write memory command and to use the address 0x1FFF 7800. There I always got a NACK back, thats because of the wrong amount of bytes I send to this memory address. As specified in datasheet it's necessary to send 64 bits instead of 32 bits. The upper 32 bits are the complemented (inverted) option bytes and the lower 32 bits the normal option bytes.
For me it's also not clear what the send order have to look like. It's important to use the right sequence. I made a mistake and one of my MCU don't work anymore, caused by sending the wrong sequence of option bytes
So here a summery:
Send command frame
Wait for ACK
Send data frame: (Total of 4 Bytes)
Start address and checksum
Wait for ACK
Send data frame: (Total of 10 bytes:)
number of data bytes: 7 (N=8 (bytes) amount = N-1)
datas: Send with this order byte0, byte1, byte2, byte3,( byte0^0xFF), ...., (byte3^0xFF)
checksum: XOR all together from number of data bytes till (byte3^0xFF)
Wait for ACK
Good luck :grinning_face: