@@ -6,7 +6,7 @@ Boards can setup reserved flash with _ld_reserved_flash_size in board.ld. */
66
77ENTRY (Reset_Handler)
88
9- code_size = 1M ;
9+ code_size = 2M ;
1010_ld_default_stack_size = 20K;
1111
1212/* Default reserved flash to nothing. */
2222 FLASH_IVT (rx) : ORIGIN = 0x60001000 , LENGTH = 4K
2323 /* Place the ISRs 48k in to leave room for the bootloader when it is available. */
2424 FLASH_FIRMWARE (rx) : ORIGIN = 0x6000C000 , LENGTH = code_size - 48K
25- FLASH_FATFS (r) : ORIGIN = 0x60100000 , LENGTH = _ld_flash_size - code_size - _ld_reserved_flash_size
25+ FLASH_FATFS (r) : ORIGIN = 0x60000000 + code_size , LENGTH = _ld_flash_size - code_size - _ld_reserved_flash_size
2626 /* Teensy uses the last bit of flash for recovery. */
27- RESERVED_FLASH : ORIGIN = 0x60100000 + _ld_flash_size - _ld_reserved_flash_size, LENGTH = _ld_reserved_flash_size
27+ RESERVED_FLASH : ORIGIN = 0x60000000 + code_size + _ld_flash_size - _ld_reserved_flash_size, LENGTH = _ld_reserved_flash_size
2828 OCRAM (rwx) : ORIGIN = 0x20200000 , LENGTH = ram_size - 64K
2929 DTCM (x) : ORIGIN = 0x20000000 , LENGTH = 32K
3030 ITCM (x) : ORIGIN = 0x00000000 , LENGTH = 32K
@@ -55,21 +55,42 @@ SECTIONS
5555 .text :
5656 {
5757 . = ALIGN (4 );
58- __VECTOR_TABLE = .;
59- __VECTOR_RAM = .;
60- _ld_isr_table = .;
61-
62- KEEP (*(.isr_vector )) /* Startup code */
6358 *(EXCLUDE_FILE (
6459 *fsl_flexspi.o
60+ *dcd_ci_hs.o
61+ *tusb_fifo.o
62+ *usbd.o
63+ *string0.o
64+ *py/nlr*.o
65+ *py/obj.o
66+ *py/gc.o
67+ *py/map.o
68+ *py/runtime.o
69+ *py/objboundmeth.o
70+ *py/objtype.o
6571 ) .text *) /* .text* sections (code) */
66- *(.rodata *) /* .rodata* sections (constants, strings, etc.) */
72+
73+ /* Keep USB processing functions out of RAM because we don't know which will be used.
74+ We try to only keep USB interrupt related functions. */
75+ *dcd_ci_hs.o (.text .process_ *_request .text .dcd_edpt * .text .dcd_init .text .dcd_set_address )
76+ *usbd.o (.text .process_ *_request .text .process_ [gs]et* .text .tud_ * .text .usbd_ * .text .configuration_reset .text .invoke_ *)
77+
78+ /* Anything marked cold/unlikely should be in flash. */
79+ *(.text .unlikely .*)
80+
81+ *(EXCLUDE_FILE (
82+ *dcd_ci_hs.o
83+ *py/objboundmeth.o
84+ *py/objtype.o
85+ ) .rodata *) /* .rodata* sections (constants, strings, etc.) */
6786 . = ALIGN (4 );
6887 } > FLASH_FIRMWARE
6988
7089 .ARM.exidx :
7190 {
91+ __exidx_start = .;
7292 *(.ARM .exidx *)
93+ __exidx_end = .;
7394 *(.gnu .linkonce .armexidx .*)
7495 _etext = .; /* define a global symbol at end of code */
7596 __etext = .; /* define a global symbol at end of code */
@@ -81,7 +102,6 @@ SECTIONS
81102 {
82103 . = ALIGN (4 );
83104 *(.data *) /* .data* sections */
84- *fsl_flexspi.o (.text *)
85105 . = ALIGN (4 );
86106 } > OCRAM AT> FLASH_FIRMWARE
87107 _ld_ocram_data_destination = ADDR (.data );
@@ -93,7 +113,7 @@ SECTIONS
93113 {
94114 . = ALIGN (4 );
95115
96- *(.bss *)
116+ *(SORT_BY_ALIGNMENT ( SORT_BY_NAME ( .bss *)) )
97117 *(COMMON)
98118
99119 . = ALIGN (4 );
@@ -103,22 +123,50 @@ SECTIONS
103123 _ld_heap_start = _ld_ocram_bss_start + _ld_ocram_bss_size;
104124 _ld_heap_end = ORIGIN (OCRAM) + LENGTH (OCRAM);
105125
106- .itcm :
126+
127+ .itcm : ALIGN (4 )
107128 {
108129 . = ALIGN (4 );
109130 *(.itcm .*)
110-
131+ *fsl_flexspi.o (.text *)
132+ *dcd_ci_hs.o (.text *)
133+ *tusb_fifo.o (.text *)
134+ *py/objboundmeth.o (.text *)
135+ *py/objtype.o (.text *)
136+ *py/obj.o (.text *)
137+ *py/gc.o (.text *)
138+ *py/map.o (.text *)
139+ *py/nlr*.o (.text *)
140+ *py/runtime.o (.text *)
141+ *(.text .process_ *_isr .text .dcd_event_ * .text .osal_queue *)
142+ *string0.o (.text *)
111143 . = ALIGN (4 );
112144 } > ITCM AT> FLASH_FIRMWARE
113145 _ld_itcm_destination = ADDR (.itcm );
114146 _ld_itcm_flash_copy = LOADADDR (.itcm );
115147 _ld_itcm_size = SIZEOF (.itcm );
116148
149+ /* Align for 256 ISR entries */
150+ .isr_vector : ALIGN (4 * 256 )
151+ {
152+ . = ALIGN (4 );
153+ KEEP (*(.isr_vector )) /* Startup code */
154+ . = ALIGN (4 );
155+ } > ITCM AT> FLASH_FIRMWARE
156+ _ld_isr_destination = ADDR (.isr_vector );
157+ _ld_isr_flash_copy = LOADADDR (.isr_vector );
158+ _ld_isr_size = SIZEOF (.isr_vector );
159+ /* Used by the bootloader to start user code. */
160+ __VECTOR_TABLE = LOADADDR (.isr_vector );
161+
117162 .dtcm_data :
118163 {
119164 . = ALIGN (4 );
120165
121166 *(.dtcm_data .*)
167+ *dcd_ci_hs.o (.rodata *)
168+ *py/objboundmeth.o (.rodata *)
169+ *py/objtype.o (.rodata *)
122170
123171 . = ALIGN (4 );
124172 } > DTCM AT> FLASH_FIRMWARE
@@ -139,7 +187,7 @@ SECTIONS
139187 _ld_dtcm_bss_start = ADDR (.dtcm_bss );
140188 _ld_dtcm_bss_size = SIZEOF (.dtcm_bss );
141189
142- .stack :
190+ .stack (NOLOAD) :
143191 {
144192 . = ALIGN (8 );
145193 _ld_stack_bottom = .;
0 commit comments