Skip to content

Commit d28981b

Browse files
committed
Added linker scripts for MX695 to core
1 parent 4179f52 commit d28981b

File tree

2 files changed

+307
-0
lines changed

2 files changed

+307
-0
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/* Default linker script, for normal executables */
2+
OUTPUT_FORMAT("elf32-tradlittlemips")
3+
OUTPUT_ARCH(pic32mx)
4+
ENTRY(_reset)
5+
/*
6+
* Provide for a minimum stack and heap size
7+
* - _min_stack_size -/* Default linker script, for normal executables */
8+
OUTPUT_FORMAT("elf32-tradlittlemips")
9+
OUTPUT_ARCH(pic32mx)
10+
ENTRY(_reset)
11+
/*
12+
* Provide for a minimum stack and heap size
13+
* - _min_stack_size - represents the minimum space that must be made
14+
* available for the stack. Can be overridden from
15+
* the command line using the linker's --defsym option.
16+
* - _min_heap_size - represents the minimum space that must be made
17+
* available for the heap. Can be overridden from
18+
* the command line using the linker's --defsym option.
19+
*/
20+
EXTERN (_min_stack_size _min_heap_size)
21+
PROVIDE(_min_stack_size = 0x800) ;
22+
PROVIDE(_min_heap_size = 0x800) ;
23+
24+
/*************************************************************************
25+
* Processor-specific object file. Contains SFR definitions.
26+
*************************************************************************/
27+
INPUT("processor.o")
28+
29+
/*************************************************************************
30+
* Memory Regions
31+
*
32+
* Memory regions without attributes cannot be used for orphaned sections.
33+
* Only sections specifically assigned to these regions can be allocated
34+
* into these regions.
35+
*************************************************************************/
36+
MEMORY
37+
{
38+
exception_mem : ORIGIN = 0x9D000000, LENGTH = 0x1000
39+
kseg0_program_mem (rx) : ORIGIN = 0x9D001000, LENGTH = 0x7E000
40+
kseg0_eeprom_mem : ORIGIN = 0x9D07F000, LENGTH = 0x1000
41+
kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x970
42+
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490
43+
debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0xFF0
44+
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 4
45+
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 4
46+
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 4
47+
config0 : ORIGIN = 0xBFC02FFC, LENGTH = 4
48+
kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000
49+
sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
50+
configsfrs : ORIGIN = 0xBFC02FF0, LENGTH = 0x10
51+
}
52+
53+
/*************************************************************************
54+
* Memory Address Equates
55+
*************************************************************************/
56+
_ebase_address = ORIGIN(exception_mem);
57+
_IMAGE_PTR_TABLE = _ebase_address + 0x0F8;
58+
_IMAGE_HEADER_ADDR = _ebase_address + 0x0FC;
59+
_GEN_EXCPT_ADDR = _ebase_address + 0x180;
60+
_RESET_ADDR = ORIGIN(kseg1_boot_mem);
61+
_EEPROM_ADDR = ORIGIN(kseg0_eeprom_mem);
62+
_BEV_EXCPT_ADDR = 0xBFC00380;
63+
_DBG_EXCPT_ADDR = 0xBFC00480;
64+
_DBG_CODE_ADDR = ORIGIN(debug_exec_mem);
65+
66+
/*************************************************************************
67+
* Bootloader program directives.
68+
*
69+
* _IMAGE_TYPE
70+
*
71+
* image type:
72+
*/
73+
74+
_imageReserved = 0x00000000 ;
75+
_imageMPIDE = 0x00000001 ; /* This is a normal MPIDE sketch */
76+
_imageBootFlashBootloader = 0x00000002 ; /* This is a boot flash bootloader */
77+
_imageProgramFlashBootloader = 0x00000004 ; /* This is a program flash bootloader */
78+
_imageSplitFlashBootloader = 0x00000008 ; /* This has bootloader code in both boot and program flash */
79+
80+
/*
81+
* Instructions for the bootloader
82+
*/
83+
84+
_imageFullFlashEraseLess4KEEProm = 0x00010000 ; /* The original bootloader method of erasing all of program flash except the last 4K reserved for eeprom */
85+
_imageJustInTimeFlashErase = 0x00020000 ; /* Only flash pages written too needed by the sketch is erased */
86+
_imageLinkerSpecifiedFlashErase = 0x00040000 ; /* The linker defines the flash range to erase */
87+
_imageFullFlashErase = 0x00080000 ; /* All of flash is erased */
88+
_imageExecutionJumpAddress = 0x01000000 ; /* the bootloader will jump to the execution jump address immediately after programming */
89+
_imageExecutionJumpToFirstInFlash = 0x02000000 ; /* the bootloader will jump to the first sketch loaded in flash ignoring the execution jump address immediately after programming */
90+
91+
/*
92+
* _IMAGE_FLASH_SIZE
93+
*
94+
* Typically _imageJustInTimeFlashErase is selected to just erase the pages
95+
* of flash that code is written too; thus leaving all other flash pages untouched.
96+
*
97+
* If _imageLinkerSpecifiedFlashErase set, then the range
98+
* starting from _ebase_address for _IMAGE_FLASH_SIZE bytes are erased.
99+
*
100+
* If _imageFullFlashErase is specified, than the whole flash
101+
* as known by the bootloader will be erased. This will erase eeprom as well
102+
*
103+
* if _imageFullFlashEraseLess4KEEProm is set, all of flash less the last 4K is
104+
* erased, this is the old default. This bit could be set to make a program flash bootloader
105+
* erasing everything but the old flash. If NOTHING is set, this will be the default as this is the old behavior.
106+
*
107+
* _JUMP_ADDR
108+
*
109+
* This is the address that the bootloader will jump to start execution
110+
* of the sketch. This is almost always _RESET_ADDR.
111+
*
112+
* However, you can specify an alternate entry execution point for example
113+
* if you have alternate starup code that, say, shared
114+
* the runtime with other sketches or needed some kind of specific handling
115+
*
116+
* Immediately after programming (avrdude upload) the bootloader will typically
117+
* jump to the just loaded sketch, no matter where it was loaded in flash.
118+
* _imageExecutionJumpToFirstInFlash will tell the bootloader to jump to the first
119+
* sketch in flash even if the just loaded one is not at the beginning of flash.
120+
* This is useful when programming sketches in slots of flash and then always
121+
* jumping to the program-flash loader (vector sketch) as if the board was just reset.
122+
* This bit does not effect jumping to a sketch already in flash after reset.
123+
* As of today, after reset, the first program in flash will always be jumped to.
124+
*
125+
*************************************************************************/
126+
_IMAGE_TYPE = _imageMPIDE | _imageJustInTimeFlashErase | _imageExecutionJumpAddress;
127+
_IMAGE_FLASH_SIZE = LENGTH(exception_mem) + LENGTH(kseg0_program_mem);
128+
_JUMP_ADDR = _RESET_ADDR;
129+
130+
SECTIONS
131+
{
132+
.config_BFC02FF0 : {
133+
LONG(0x3AFFFFFF)
134+
} > config3
135+
.config_BFC02FF4 : {
136+
LONG(0xFFF879D9)
137+
} > config2
138+
.config_BFC02FF8 : {
139+
LONG(0xFF6ACD5B)
140+
} > config1
141+
.config_BFC02FFC : {
142+
LONG(0x7FFFFFFE)
143+
} > config0
144+
}
145+
146+
SECTIONS
147+
{
148+
.bev_excpt _BEV_EXCPT_ADDR :
149+
{
150+
KEEP(*(.bev_handler))
151+
} > kseg1_boot_mem
152+
153+
.dbg_excpt _DBG_EXCPT_ADDR (NOLOAD) :
154+
{
155+
. += (DEFINED (_DEBUGGER) ? 0x8 : 0x0);
156+
} > kseg1_boot_mem
157+
158+
.dbg_code _DBG_CODE_ADDR (NOLOAD) :
159+
{
160+
. += (DEFINED (_DEBUGGER) ? LENGTH(debug_exec_mem) : 0x0);
161+
} > debug_exec_mem
162+
163+
/* Boot Sections */
164+
.reset _RESET_ADDR :
165+
{
166+
KEEP(*(.reset))
167+
} > kseg1_boot_mem
168+
}
169+
170+
/* From here out every linker script is the same, so just include it */
171+
/*INCLUDE "chipKIT-application-COMMON.ld"*/
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/* Default linker script, for normal executables */
2+
OUTPUT_FORMAT("elf32-tradlittlemips")
3+
OUTPUT_ARCH(pic32mx)
4+
ENTRY(_reset)
5+
/*
6+
* Provide for a minimum stack and heap size
7+
* - _min_stack_size - represents the minimum space that must be made
8+
* available for the stack. Can be overridden from
9+
* the command line using the linker's --defsym option.
10+
* - _min_heap_size - represents the minimum space that must be made
11+
* available for the heap. Can be overridden from
12+
* the command line using the linker's --defsym option.
13+
*/
14+
EXTERN (_min_stack_size _min_heap_size)
15+
PROVIDE(_min_stack_size = 0x800) ;
16+
PROVIDE(_min_heap_size = 0x800) ;
17+
18+
/*************************************************************************
19+
* Processor-specific object file. Contains SFR definitions.
20+
*************************************************************************/
21+
INPUT("processor.o")
22+
OPTIONAL("libmchp_peripheral_32MX695F512L.a")
23+
24+
/*************************************************************************
25+
* Memory Regions
26+
*
27+
* Memory regions without attributes cannot be used for orphaned sections.
28+
* Only sections specifically assigned to these regions can be allocated
29+
* into these regions.
30+
*************************************************************************/
31+
MEMORY
32+
{
33+
exception_mem : ORIGIN = 0x9D000000, LENGTH = 0x1000
34+
kseg0_program_mem (rx) : ORIGIN = 0x9D001000, LENGTH = 0x7E000
35+
kseg0_eeprom_mem : ORIGIN = 0x9D07F000, LENGTH = 0x1000
36+
kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0
37+
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0
38+
debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0
39+
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 4
40+
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 4
41+
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 4
42+
config0 : ORIGIN = 0xBFC02FFC, LENGTH = 4
43+
kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000
44+
sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
45+
configsfrs : ORIGIN = 0xBFC02FF0, LENGTH = 0x10
46+
}
47+
48+
/*************************************************************************
49+
* Memory Address Equates
50+
*************************************************************************/
51+
_ebase_address = ORIGIN(exception_mem);
52+
_IMAGE_PTR_TABLE = _ebase_address + 0x0F8;
53+
_IMAGE_HEADER_ADDR = _ebase_address + 0x0FC;
54+
_GEN_EXCPT_ADDR = _ebase_address + 0x180;
55+
_RESET_ADDR = ORIGIN(kseg0_program_mem);
56+
_EEPROM_ADDR = ORIGIN(kseg0_eeprom_mem);
57+
_BEV_EXCPT_ADDR = 0xBFC00380;
58+
_DBG_EXCPT_ADDR = 0xBFC00480;
59+
_DBG_CODE_ADDR = ORIGIN(debug_exec_mem);
60+
61+
/*************************************************************************
62+
* Bootloader program directives.
63+
*
64+
* _IMAGE_TYPE
65+
*
66+
* image type:
67+
*/
68+
69+
_imageReserved = 0x00000000 ;
70+
_imageMPIDE = 0x00000001 ; /* This is a normal MPIDE sketch */
71+
_imageBootFlashBootloader = 0x00000002 ; /* This is a boot flash bootloader */
72+
_imageProgramFlashBootloader = 0x00000004 ; /* This is a program flash bootloader */
73+
_imageSplitFlashBootloader = 0x00000008 ; /* This has bootloader code in both boot and program flash */
74+
75+
/*
76+
* Instructions for the bootloader
77+
*/
78+
79+
_imageFullFlashEraseLess4KEEProm = 0x00010000 ; /* The original bootloader method of erasing all of program flash except the last 4K reserved for eeprom */
80+
_imageJustInTimeFlashErase = 0x00020000 ; /* Only flash pages written too needed by the sketch is erased */
81+
_imageLinkerSpecifiedFlashErase = 0x00040000 ; /* The linker defines the flash range to erase */
82+
_imageFullFlashErase = 0x00080000 ; /* All of flash is erased */
83+
_imageExecutionJumpAddress = 0x01000000 ; /* the bootloader will jump to the execution jump address immediately after programming */
84+
_imageExecutionJumpToFirstInFlash = 0x02000000 ; /* the bootloader will jump to the first sketch loaded in flash ignoring the execution jump address immediately after programming */
85+
86+
/*
87+
* _IMAGE_FLASH_SIZE
88+
*
89+
* Typically _imageJustInTimeFlashErase is selected to just erase the pages
90+
* of flash that code is written too; thus leaving all other flash pages untouched.
91+
*
92+
* If _imageLinkerSpecifiedFlashErase set, then the range
93+
* starting from _ebase_address for _IMAGE_FLASH_SIZE bytes are erased.
94+
*
95+
* If _imageFullFlashErase is specified, than the whole flash
96+
* as known by the bootloader will be erased. This will erase eeprom as well
97+
*
98+
* if _imageFullFlashEraseLess4KEEProm is set, all of flash less the last 4K is
99+
* erased, this is the old default. This bit could be set to make a program flash bootloader
100+
* erasing everything but the old flash. If NOTHING is set, this will be the default as this is the old behavior.
101+
*
102+
* _JUMP_ADDR
103+
*
104+
* This is the address that the bootloader will jump to start execution
105+
* of the sketch. This is almost always _RESET_ADDR.
106+
*
107+
* However, you can specify an alternate entry execution point for example
108+
* if you have alternate starup code that, say, shared
109+
* the runtime with other sketches or needed some kind of specific handling
110+
*
111+
* Immediately after programming (avrdude upload) the bootloader will typically
112+
* jump to the just loaded sketch, no matter where it was loaded in flash.
113+
* _imageExecutionJumpToFirstInFlash will tell the bootloader to jump to the first
114+
* sketch in flash even if the just loaded one is not at the beginning of flash.
115+
* This is useful when programming sketches in slots of flash and then always
116+
* jumping to the program-flash loader (vector sketch) as if the board was just reset.
117+
* This bit does not effect jumping to a sketch already in flash after reset.
118+
* As of today, after reset, the first program in flash will always be jumped to.
119+
*
120+
*************************************************************************/
121+
_IMAGE_TYPE = _imageMPIDE | _imageJustInTimeFlashErase | _imageExecutionJumpAddress;
122+
_IMAGE_FLASH_SIZE = LENGTH(exception_mem) + LENGTH(kseg0_program_mem);
123+
_JUMP_ADDR = _RESET_ADDR;
124+
125+
SECTIONS
126+
{
127+
/* Boot Sections */
128+
.reset _RESET_ADDR :
129+
{
130+
KEEP(*(.reset))
131+
} > kseg0_program_mem
132+
}
133+
134+
/* From here out every linker script is the same, so just include it */
135+
/*INCLUDE "chipKIT-application-COMMON.ld"*/
136+

0 commit comments

Comments
 (0)