LPC2378 IAP flash erase problem

I am working on a bootloader for an LPC2378, using the SparkFun USB Bootloader tutorial as an example.

I have been able to write to flash but have trouble erasing.

If I manually erase the flash with the debugger then I am able to write to flash.

However, I have not been able to erase the flash with the IAP function.

It seems to hang up whenever that function is called.

  • I have moved the stack because the IAP functions use the top 32 bytes of RAM.

  • I know the erase works in sectors.

What simple thing am I missing?

Thanks

Rooster:
I have been able to write to flash but have trouble erasing.

What simple thing am I missing?

Are you aware you have to call the IAP function PrepareSectors before you call EraseSectors?

Also, make sure you identify any error codes returned by the IAP functions. These might help you work out what is going wrong.

Yes, I was preparing the sectors, thanks for the response Chris.

Anyway, it mysteriously started working.

I didn’t change anything (that I know of).

I’m glad it is working, but I hate it when you don’t know why.

Also, the bootloader itself is working great.

It reads a bin file off of an SD card, flashes it and then executes it.

Very handy!