@@ -68,11 +68,32 @@ INPUT("processor.o")
68
68
OPTIONAL("libmchp_peripheral.a")
69
69
OPTIONAL("libmchp_peripheral_32MX460F512L.a")
70
70
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
+
71
88
/*************************************************************************
72
89
* For interrupt vector handling
73
90
*************************************************************************/
74
91
PROVIDE (_vector_spacing = 0x00000001 );
92
+ #ifdef BOOTLOADER
75
93
_ebase_address = 0x9FC01000;
94
+ #else
95
+ _ebase_address = 0x9D001000 + BL_LENGTH;
96
+ #endif
76
97
77
98
/*************************************************************************
78
99
* Memory Address Equates
@@ -83,12 +104,21 @@ _ebase_address = 0x9FC01000;
83
104
* _DBG_CODE_SIZE -- In-circuit Debug Executive size
84
105
* _GEN_EXCPT_ADDR -- General Exception Vector
85
106
*************************************************************************/
107
+ #ifdef BOOTLOADER
86
108
_RESET_ADDR = 0xBFC00000;
87
109
_BEV_EXCPT_ADDR = 0xBFC00380;
88
110
_DBG_EXCPT_ADDR = 0xBFC00480;
89
111
_DBG_CODE_ADDR = 0xBFC02000;
90
112
_DBG_CODE_SIZE = 0xFF0;
91
113
_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
92
122
93
123
/*************************************************************************
94
124
* Memory Regions
@@ -104,11 +134,19 @@ _GEN_EXCPT_ADDR = _ebase_address + 0x180;
104
134
*************************************************************************/
105
135
MEMORY
106
136
{
107
- kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000
137
+ #ifdef BOOTLOADER
138
+ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = BL_LENGTH
108
139
kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x970
109
140
exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x1000
110
141
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490
111
142
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
112
150
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
113
151
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
114
152
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
0 commit comments