I increased the interrupt priority of the USB, and I now have my bootloader state machine reaching the end : all the data is read from the USB stick, and written in the PIC32 flash (which I double checked by reading the entire flash with my ICD4).
But I still have a last issue : when jumping to the app, my PIC32 seem to freeze. Again, using the exact same code with the SD card, I have no problem.
I know that it's not related to my memory map, as the linker script forces the APP to start at 0x1D016000, which allows enough space for my bootloader (0x11500).
Also, the configuration bits are the same in the APP and the Bootloader.
I have some ideas in mind, but I can't figure out what's wrong...
- Do I need to free anything in RAM before jumping to the app ?
- Should I de-initialize the USB before jumping to the app ? If so, how ?
- Should the app start by doing something special ?
I tried adding some code before jumping to the app, but it did not help ...
// Set default to APP_FLASH_START_ADDRESS
fptr = (void (*)(void))APP_FLASH_START_ADDRESS;
// Disable Global Interrupts
// Jump to Application