PIC32MX - Application UART interrupt not working when jumped to from Bootloader
I have created a bootloader for the PIC32MX270F512L on our custom board. This was based off the SD Card bootloader example and adapted to update the program flash with a binary image stored in external flash. The bootloader checks for a separate register stored in the external flash (which is updated by the app) to determine if program flash update should commence and the address where the binary image is stored. If this register does not exist, it will jump to the application if present, otherwise program the factory image which is always stored at a known address.
I believe I have been able to successfully erase/program the application using the bootloader but the UART interrupt does not seem to be working. I have tried 'loading' the application with the bootloader so I could debug them both, and after jumping to the application code, was able to step through to the main while loop that just looks for incoming UART data from the PC terminal. The application works fine when programmed on its own without the linker file.
My first thought was that it has something to do with the IVT not being properly addressed and there is an issue with my linker file. However, I created a basic timer interrupt driven LED blink app and programmed that using the bootloader which seems works fine so its not all interrupts that are the problem...I then added UART to the test app but this failed to work. Again, if programmed on its own, it works fine!
I have made sure my config registers are the same between bootloader and application and also disable all interrupts before jumping to the application (using __builtin_disable_interrupts()).
I have the linker files setup so that the bootloader IVT is at the start of program flash (0x9D000000) and 12KB is allocated for my bootloader code just after. The application IVT and startup code base address is adjacent to this with the rest of the flash left for the application code. This is my first time doing a bootloader and found the process of updating the linker files not so straight forward so there could well be some issues there. I have attached them for comment.
Also my bootloader reset address is set as follows:
#define PROGRAM_FLASH_END_ADRESS (0x9D000000+BMXPFMSZ-1)
//-------User configurable macros begin---------
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
/* APP_FLASH_BASE_ADDRESS and APP_FLASH_END_ADDRESS reserves program Flash for the application*/
1)The memory regions kseg0_program_mem, kseg0_boot_mem, exception_mem and
kseg1_boot_mem of the application linker script must fall with in APP_FLASH_BASE_ADDRESS
2)The base address and end address must align on 4K address boundary */
#define APP_FLASH_BASE_ADDRESS 0x9D005000
#define APP_FLASH_END_ADDRESS PROGRAM_FLASH_END_ADRESS
#define APP_PROG_MEM_OFFSET 0x5000
/* Address of the Flash from where the application starts executing */
/* Rule: Set APP_FLASH_BASE_ADDRESS to _RESET_ADDR value of application linker script*/
// For PIC32MX1xx and PIC32MX2xx Controllers only
#define USER_APP_RESET_ADDRESS (0x9D004000 + 0x1000)
#define DEV_CONFIG_REG_BASE_ADDRESS 0x9FC00BF0
#define DEV_CONFIG_REG_END_ADDRESS 0x9FC00BFF
I feel like there may be something very simple I am overlooking here. Is anyone able to shed some light on this?