0
votes

I am making a USB Bootloader for PIC24FJ128GC006 and I am going to map part of the flash memory for the Bootloader and the Application code. I added the linker script from Microchip MLA v2015_08 usb device bootloader to my PIC24FJ code file.
In the linker file, the __BOOTLOADER must be defined in order to access the 0x400 address region.

    #ifdef __BOOTLOADER   
       program (xr)   : ORIGIN = 0x400,         LENGTH = 0x35BE
    #else
       program (xr)   : ORIGIN = 0x4002,         LENGTH = 0x117F4
    #endif

In the main.c of my bootloader code, I have already #define __BOOTLOADER, but when I program the bootloader code to the PIC using ICD3 and check the program memory by using the PIC Memory Views of MPLAB Window Toolbar, the data is written to the 0x4002 address and not in the 0x400.
What can be the problem?

1

1 Answers

0
votes

Okay. I have solved my problem above. You should write #define __BOOTLOADER in the linker file, not in main.c. Another problem has risen though. In my code file dashboard, it indicates there that I have used 97% of the program memory after defining the __BOOTLOADER. So my question is that, can I remove some codes in the linker file to decrease the used program memory? If yes, how can I know what to remove in the vector tables?