Skip to content

Commit 20b13ee

Browse files
committed
bootloader: Modify PIC32MX460F512L linker script for bootloader use
Add the variables and configuration necessary for booloader and bootloaded application operation.
1 parent 8398841 commit 20b13ee

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

apps/bootloader/firmware/gld/p32MX460F512L.ld

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,32 @@ INPUT("processor.o")
6868
OPTIONAL("libmchp_peripheral.a")
6969
OPTIONAL("libmchp_peripheral_32MX460F512L.a")
7070

71+
/* Definitions used for bootloader */
72+
#define SPECIAL 0x3000 /* includes boot mem, exception mem, debug exec mem */
73+
#define BL_LENGTH 0x4000 /* Length of bootloader's main flash component */
74+
75+
/* Variables to pass into the bootloader. All addresses are virtual.
76+
These represent the base and length of the user or application
77+
flash memory. */
78+
_APP_BASE = 0x9D000000 + BL_LENGTH;
79+
_APP_LENGTH = 0x80000 - BL_LENGTH;
80+
_FLASH_BLOCK_SIZE = 0x1000; /* From the datasheet */
81+
_CONFIG_WORDS_BASE = 0x1fc02ff0;
82+
_CONFIG_WORDS_TOP = 0x1fc03ff0;
83+
84+
#if !defined(BOOTLOADER) && !defined(BOOTLOADER_APP)
85+
#error "Must define BOOTLOADER or BOOTLOADER_APP to use this linker script"
86+
#endif
87+
7188
/*************************************************************************
7289
* For interrupt vector handling
7390
*************************************************************************/
7491
PROVIDE(_vector_spacing = 0x00000001);
92+
#ifdef BOOTLOADER
7593
_ebase_address = 0x9FC01000;
94+
#else
95+
_ebase_address = 0x9D001000 + BL_LENGTH;
96+
#endif
7697

7798
/*************************************************************************
7899
* Memory Address Equates
@@ -83,12 +104,21 @@ _ebase_address = 0x9FC01000;
83104
* _DBG_CODE_SIZE -- In-circuit Debug Executive size
84105
* _GEN_EXCPT_ADDR -- General Exception Vector
85106
*************************************************************************/
107+
#ifdef BOOTLOADER
86108
_RESET_ADDR = 0xBFC00000;
87109
_BEV_EXCPT_ADDR = 0xBFC00380;
88110
_DBG_EXCPT_ADDR = 0xBFC00480;
89111
_DBG_CODE_ADDR = 0xBFC02000;
90112
_DBG_CODE_SIZE = 0xFF0;
91113
_GEN_EXCPT_ADDR = _ebase_address + 0x180;
114+
#elif defined(BOOTLOADER_APP)
115+
_RESET_ADDR = 0xBD000000 + BL_LENGTH;
116+
_BEV_EXCPT_ADDR = 0xBD000380 + BL_LENGTH;
117+
_DBG_EXCPT_ADDR = 0xBD000480 + BL_LENGTH;
118+
_DBG_CODE_ADDR = 0xBD002000 + BL_LENGTH;
119+
_DBG_CODE_SIZE = 0xFF0;
120+
_GEN_EXCPT_ADDR = _ebase_address + 0x180;
121+
#endif
92122

93123
/*************************************************************************
94124
* Memory Regions
@@ -104,11 +134,19 @@ _GEN_EXCPT_ADDR = _ebase_address + 0x180;
104134
*************************************************************************/
105135
MEMORY
106136
{
107-
kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000
137+
#ifdef BOOTLOADER
138+
kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = BL_LENGTH
108139
kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x970
109140
exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x1000
110141
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490
111142
debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0xFF0
143+
#else
144+
kseg0_program_mem (rx) : ORIGIN = 0x9D000000+BL_LENGTH+SPECIAL, LENGTH = 0x80000 - BL_LENGTH - SPECIAL
145+
kseg0_boot_mem : ORIGIN = 0x9D000490+BL_LENGTH, LENGTH = 0x970
146+
exception_mem : ORIGIN = 0x9D001000+BL_LENGTH, LENGTH = 0x1000
147+
kseg1_boot_mem : ORIGIN = 0xBD000000+BL_LENGTH, LENGTH = 0x490
148+
debug_exec_mem : ORIGIN = 0xBD002000+BL_LENGTH, LENGTH = 0xFF0
149+
#endif
112150
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
113151
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
114152
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4

0 commit comments

Comments
 (0)