I have written a PIC32MX bootloader application. I would like to tell the linker to put it completely in the boot memory, so that all program space is kept for the final application.
Currently, the what I think are the relevant parts of my .ld
file look like this:
_RESET_ADDR = 0xBFC00000;
_BEV_EXCPT_ADDR = (0xBFC00000 + 0x380);
_DBG_EXCPT_ADDR = (0xBFC00000 + 0x480);
_DBG_CODE_ADDR = 0xBFC02000;
_DBG_CODE_SIZE = 0xFF0 ;
_GEN_EXCPT_ADDR = _ebase_address + 0x180;
MEMORY
{
kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x10000 /* All C Files will be located here */
kseg0_boot_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 /* This memory region is dummy */
exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x200 /* Interrupt vector table */
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
config0 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x2FF0 /* C Startup code */
kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x8000
sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0xFF0
configsfrs : ORIGIN = 0xBFC02FF0, LENGTH = 0x10
}
This is the default generated linker script, for a PIC32MX695F512H, although the length of some sections may have changed - the memory layout of the chip is on page 61 of the datasheet.
Should I simply change the ORIGIN
and LENGTH
of kseg0_program_mem
to the values of kseg0_boot_mem
and tell the linker to allow for overlapping sections? That doesn't feel that clean. Is there a way to tell the linker to put the application code not in kseg0_program_mem
but in kseg0_boot_mem
?