2024-11-14 07:16 PM - last edited on 2024-11-15 05:24 AM by Amel NASRI
Hi,
I have a custom PCB where I am attempting to bootload an STM32G071CBU6 (using an STM32U575).
I am using the bootloader while developing for uploading development builds, so it is being used often. The G0 seems to occasionally, randomly, stop responding and clock stretch indefinitely while the firmware is being written to the MCU. Sometimes this is remedied by resetting the chip and starting the bootloading process over again, sometimes I have to power cycle the whole board, and there have been a couple of instances now where even power cycling would not fix it, and I would have to erase the chip using an STLink.
The problem almost always presents as the host MCU reading back a non-valid ACK byte (according to AN4221) - I've seen 0x4D most recently which does not match 0x79 for ACK, 0x1F for NACK, or 0x76 for BUSY. It is usually the first response when polling for an ACK after writing a block of byte to memory. If the host MCU tries to read again, the G0 will clock stretch indefinitely.
Invalid read byte
Subsequent read:
And the G0 will need to be reset to release the I2C lines. We have verified it is the G0 pulling the lines low and not the host MCU by looking at the analog voltage - the U5 seems to have a stronger driver and will pull the lines 50-100mV lower than the G0.
Here is the start to the "Write No-Stretch" command right before the above reads:
The memory address is correct, and the G0 is responding with ACKs appropriately.
It's strange because sometimes it takes an 30+ bootloads before it happens, then can happen 10 times in a row or even be unrecoverable without a programmer (which is the case that worries me, as that would be a disaster for a board in production).
The bootloading process that I'm following is as described in AN4221 and AN2606, using no stretch I2C commands:
Is there something that the host MCU may be doing incorrectly to cause this problem? I've uploaded Saleae Logic 2 captures of the start and end of a failed bootloading (just cutting out most of the actual firmware data) if anyone would like to look at the logic trace.