PIC32MZ Bootloader Still Not Working
I have been working on getting this bootloader working for too long now, still can't figure it out. It is essentially the same as the one I've been using in PIC32MX695s, very reliably. That product uses the legacy non-harmony TCPIP stack, and XC32 v1.33.
This project is a newer version of that same product, using a PIC32MZ2048EFM144, with MPLABX v5.05, XC32 v2.10, and the Oryx non-harmony stack.
Most of the application is done, using 53% code space, and works well. From the application I can upload the unified hex file into SPI flash and check it pretty thoroughly. On apply, I set a code in a location in SPI flash, then force a reset. Reset goes to the bootloader and, if it finds the code, applies the hex file. If not, it skips straight to the application.
The problem is that if it applies the hex file it will then jump to the app, as it should, but only the first few lines of main() will execute before resetting back to the bootloader (to start programming again). This is the same hex file that runs fine if the bootloader doesn't run. I have changed just about everything I can think of but it always gets the same result (or worse).
I've included the linker scripts and bootloader code, maybe someone will spot the problem right away. I've run out of ideas.
BTW, these linker scripts are sort of cobbled together from items here on the forums. They could probably be improved. Also, I'm limited to 5 files attached so I left out the .h files. Here are some relevant defines in Bootloader.h:
#define APP_FLASH_BASE_ADDRESS 0x9D000000
#define APP_FLASH_END_ADDRESS 0x9D200000 //
/* Address of the Flash from where the application starts executing */
#define USER_APP_RESET_ADDRESS 0x9D000000
#define FLASH_PAGE_SIZE 4096
#define DEV_CONFIG_REG_BASE_ADDRESS 0xBFC0FF40
#define DEV_CONFIG_REG_END_ADDRESS 0xBFC6FFC0