cancel
Showing results for 
Search instead for 
Did you mean: 

A couple of bootloader issues.

anders23
Associate II
Posted on June 03, 2015 at 16:58

On the STM32F429 Discovery I have managed to boot into the bootloader to upgrade the image in flash via I2C. I still have two issues I (or you) need to solve, however.

1. Flash erase.

At first I tried a mass erase of bank 1. That makes the I2C bus busy for ~27 seconds, before I get a Remote I/O error (from linux ioctl) and a NACK.

Then I decided to erase only certain sections. I've managed to erase the 4 sections I need, but only if I do them one by one. If my I2C transaction sets up erase of > 1 section I immediately get a NACK. I've read and reread the instructions on the ERASE command, and can't find anything wrong with my messages.

2. GO

I write my binary image to flash (0x08000000), read it back and verify with a CRC. Then I issue the GO command with the address 0x08000000 and get an ACK from the bootloader, but the image does not start. If I run my program again it does the same, so it is still in the bootloader. If I power off, remove the boot0 pull-up and power on again, it starts from flash with the image I wrote.

#i2c #bootloader #flash
3 REPLIES 3
Posted on June 03, 2015 at 21:10

2) Put some code in the ResetHandler to signal via a GPIO, or USART, to confirm if it doesn't actually get there. Assume the System Loader has a WatchDog running, and kick it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
anders23
Associate II
Posted on June 04, 2015 at 13:09

1. It seems there is something about this I have not understood about timing/timeouts. Erasing one by one worked well until I needed to erase 5 sectors. 4x16kB and 1x64kB.

erase; wait up until 5 seconds for ack => sector 4 fails

erase; sleep 3 seconds; wait up until 5 seconds for ack => sector 0 fails

erase; sleep 1 seconds; wait up until 5 seconds for ack => it works

It seems that if I wait for too long, the bootloader gives up on me. If I try once a second to read an ack over i2c, the sector fails.

anders23
Associate II
Posted on June 04, 2015 at 15:18

AN2606 says:

In erase memory command and read-out unprotect command, the duration of flash

operation should be taken into consideration when implementing the host side. After

sending the code of pages to be erased, the host should wait until the bootloader device

performs page erasing to complete the remaining steps of erase command.

I'm not quite sure I have understood it correctly, but I added some delays based on the typ/max erase time for the different sector types, and it started working. No erase issues, and my applications starts when I give it a GO as well..

int waitms;

if (sector < 4)         waitms = 400;

else if (sector < 5)  waitms = 1200;

else                        waitms = 2000;

       

waitMs(waitms);