cancel
Showing results for 
Search instead for 
Did you mean: 

write flash fail via i2c bootloader

YLU.2
Associate II

Recently I'm using STM32G051 and try to write flash via i2c bootloader.

Below are my steps:

  1. Use STM32CubeProgrammer to set nBOOT0_SEL = 1 / nBoot0 = 0 /nBoot1 = 1 to enter BL mode
  2. Disconnect ST link, and use i2c host tool (Aardvark) to send i2c write (no-stretch) command 0x32, 0xcd
  3. Read 1 byte, get ACK (0x79) frame successfully.
  4. Send 5 bytes start address(0x08000000) with XOR checksum (0x08)
  5. Read 1 byte, get ACK (0x79) frame successfully.
  6. send 10 bytes writeLength(0x08), data(0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88), checksum (0x80)
  7. Problem here!! read 1 byte and expect to get ACK(0x79) or BUSY(0x76), but I saw CLK is stretched at 9th bit of address phase:
    _legacyfs_online_stmicro_images_0693W00000bikrMQAQ.png

I've checked all read/write protection are disabled via STM32Programmer, and I can access read flash and erase flash successfully, only write process fail. Is any one have encounter similar issue and tell me if my procedure is not correct?

Many thanks.

6 REPLIES 6
Kamil Duljas
Senior III

Hi,

flash memory start form address 0x0800 0000 not 0x0008 0000. You passed addres that is marked as reserved.


_legacyfs_online_stmicro_images_0693W00000bilVgQAI.png

Dudo
YLU.2
Associate II

Hi Kamil,

Sorry for my typo, I've written the start address with 0x08000000 and the XOR checksum (0x08)

And still have the issue.

Thanks.

YenLu

Kamil Duljas
Senior III

Ok 🙂 Next question, were you send bootloader address ? in application note i see other adressess than yours. What is this sequention 0x32 0xcd?


_legacyfs_online_stmicro_images_0693W00000bilulQAA.png

Dudo
YLU.2
Associate II

Hi Kamil,

I omitted the i2c address byte when I described the step above. I've read/write the address 0x62 and everything is fine until waiting the ack response for data written. The sequence (0x32, 0xcd) is No-Stretch Write Memory command which is described in AN4221:


_legacyfs_online_stmicro_images_0693W00000bimpwQAA.png 

Kamil Duljas
Senior III

@YLU.2​ did you resolve problem?

Dudo
YLU.2
Associate II

Yes,

for 8 byte write, I should send 0x07, 0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88, 0x8f

after correct the format, I get ack and write the memory successfully.