-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths32_linker.ld
More file actions
160 lines (135 loc) · 4.66 KB
/
s32_linker.ld
File metadata and controls
160 lines (135 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* Linker script for S32K358 with FreeRTOS
* Configured to use ITCM, DTCM, SRAM, and Flash memory regions.
*/
/* Defining memory regions */
MEMORY
{
/* ITCM: Queues and performance-critical data */
ITCM0 (RWX) : ORIGIN = 0x00000000, LENGTH = 64K
ITCM2 (RWX) : ORIGIN = 0x00010000, LENGTH = 64K
/* PFLASH: Main program */
PFLASH (RX) : ORIGIN = 0x00400000, LENGTH = 8M
/* DFLASH: Non-volatile data */
DFLASH (RW) : ORIGIN = 0x10000000, LENGTH = 128K
/* DTCM: Stack, heap, and critical data */
DTCM0 (RW) : ORIGIN = 0x20000000, LENGTH = 128K
DTCM2 (RW) : ORIGIN = 0x21800000, LENGTH = 128K
/* SRAM: Generic data */
SRAM_STDBY (RW) : ORIGIN = 0x20400000, LENGTH = 64K /* SRAM Standby */
SRAM0 (RW) : ORIGIN = 0x20410000, LENGTH = 192K /* Remaining SRAM0 */
SRAM1 (RW) : ORIGIN = 0x20440000, LENGTH = 256K
SRAM2 (RW) : ORIGIN = 0x20480000, LENGTH = 256K
/* Combined SRAM region */
SRAM (RW) : ORIGIN = 0x20400000, LENGTH = 704K /* Total SRAM */
/* Flash UTEST */
UTEST (RX) : ORIGIN = 0x1B000000, LENGTH = 8K
}
/* Minimum size for heap and stack */
_Min_Heap_Size = 0x2000; /* Increased to 8 KB for more dynamic memory */
_Min_Stack_Size = 0x800; /* Increased to 2 KB for better task handling */
/* Initial stack pointer */
_estack = ORIGIN(DTCM2) + LENGTH(DTCM2);
/* Linker Sections */
SECTIONS
{
/* ISR Vector Table */
.isr_vector :
{
__vector_table = .;
KEEP(*(.isr_vector))
. = ALIGN(4);
} > ITCM0
/* Readonly code and data section */
.text :
{
__coderom_start__ = .;
*(.text*) /* Code */
*(.rodata*) /* Read-only data */
*(.constdata*) /* Constant data */
_etext = .; /* End of text section */
KEEP(*(.init)) /* Initialization code */
} > PFLASH
/* Initialized data (RAM) */
.data :
{
. = ALIGN(8);
_sdata = .; /* Start of initialized data in RAM */
*(.data) /* Initialized global/static variables */
*(.data.*) /* Section-specific initialized data */
*(vtable) /* Vector table */
_edata = .; /* End of initialized data in RAM */
} > DTCM0 AT > PFLASH
/* Symbols for copying from FLASH to RAM */
_sidata = LOADADDR(.data); /* Load address (FLASH) of .data */
/* Uninitialized data (RAM) */
.bss :
{
. = ALIGN(8);
_sbss = .; /* Start of uninitialized data */
*(.bss) /* Uninitialized global/static variables */
*(.bss.*) /* Section-specific uninitialized data */
_ebss = .; /* End of uninitialized data */
} > DTCM0
/* Standby RAM */
.standby_ram :
{
. = ALIGN(8);
*(.standby_ram) /* Data specific to standby mode */
} > SRAM_STDBY
/* Test data */
.utest :
{
KEEP(*(.utest)) /* Test-related data */
} > UTEST
/* Heap */
.heap :
{
. = ALIGN(8);
PROVIDE(end = .); /* End of all sections */
PROVIDE(_end = .);
_heap_bottom = .; /* Start of heap */
. = . + _Min_Heap_Size; /* Allocate minimum heap size */
_heap_top = .; /* End of heap */
} > DTCM0
/* Stack */
.stack :
{
. = ALIGN(8);
__stack_start__ = .; /* Start of stack */
. = . + _Min_Stack_Size; /* Allocate minimum stack size */
__stack_end__ = .; /* End of stack */
} > DTCM2
/* Privileged code/data (used by FreeRTOS MPU port) */
.privileged_functions :
{
__privileged_functions_start__ = .;
*(.privileged_functions) /* Privileged functions */
__privileged_functions_end__ = .;
} > PFLASH
.privileged_data :
{
__privileged_data_start__ = .;
*(.privileged_data) /* Privileged data */
__privileged_data_end__ = .;
} > SRAM
/* System call handlers */
.syscalls :
{
__syscalls_flash_start__ = .;
*(.syscalls) /* System call handlers */
__syscalls_flash_end__ = .;
} > PFLASH
/* Symbol definitions for FreeRTOS MPU */
__SRAM_segment_start__ = ORIGIN(SRAM);
__SRAM_segment_end__ = ORIGIN(SRAM) + LENGTH(SRAM);
__FLASH_segment_start__ = ORIGIN(PFLASH);
__FLASH_segment_end__ = ORIGIN(PFLASH) + LENGTH(PFLASH);
/* Assertions for safety */
ASSERT(__stack_end__ <= ORIGIN(DTCM2) + LENGTH(DTCM2), "Stack overflow in DTCM2!")
ASSERT(_heap_top <= ORIGIN(DTCM0) + LENGTH(DTCM0), "Heap overflow in DTCM0!")
}
/* Entry point */
ENTRY(Reset_Handler)
/* Initial stack pointer */
PROVIDE(_stack = _estack);