Skip to content

Commit fb03d9b

Browse files
committed
esp32: add linker script with flash cache support
Now two linker scripts are available: one with flash cache suport, one without. Signed-off-by: Gautier Seidel <[email protected]>
1 parent 74fad89 commit fb03d9b

File tree

3 files changed

+524
-257
lines changed

3 files changed

+524
-257
lines changed

arch/xtensa/soc/esp32/linker.ld

+4-257
Original file line numberDiff line numberDiff line change
@@ -15,262 +15,9 @@
1515
#define _ASMLANGUAGE
1616

1717
#include <autoconf.h>
18-
#include <linker/sections.h>
19-
#include <linker/linker-defs.h>
20-
#include <linker/linker-tool.h>
2118

22-
#define RAMABLE_REGION dram0_0_seg :dram0_0_phdr
23-
/** "ROMABLE_REGION" name is used to be compatible with common-*.ld scripts.
24-
However, due to the esp32 architecture, it is mapped to the instruction
25-
ram area */
26-
#define ROMABLE_REGION iram0_0_seg :iram0_0_phdr
27-
28-
PROVIDE ( __stack = 0x3ffe3f20 );
29-
30-
PROVIDE ( esp32_rom_uart_tx_one_char = 0x40009200 );
31-
PROVIDE ( esp32_rom_uart_rx_one_char = 0x400092d0 );
32-
PROVIDE ( esp32_rom_uart_attach = 0x40008fd0 );
33-
PROVIDE ( esp32_rom_intr_matrix_set = 0x4000681c );
34-
PROVIDE ( esp32_rom_gpio_matrix_in = 0x40009edc );
35-
PROVIDE ( esp32_rom_gpio_matrix_out = 0x40009f0c );
36-
PROVIDE ( esp32_rom_Cache_Flush = 0x40009a14 );
37-
PROVIDE ( esp32_rom_Cache_Read_Enable = 0x40009a84 );
38-
PROVIDE ( esp32_rom_ets_set_appcpu_boot_addr = 0x4000689c );
39-
40-
MEMORY
41-
{
42-
iram0_0_seg(RX): org = 0x40080000, len = 0x20000
43-
iram0_2_seg(RX): org = 0x400D0018, len = 0x330000-18
44-
dram0_0_seg(RW): org = 0x3FFB0000, len = 0x2c200
45-
drom0_0_seg(R): org = 0x3F400010, len = 0x800000
46-
rtc_iram_seg(RWX): org = 0x400C0000, len = 0x2000
47-
rtc_slow_seg(RW): org = 0x50000000, len = 0x1000
48-
#ifdef CONFIG_GEN_ISR_TABLES
49-
IDT_LIST(RW): org = 0x3ebfe010, len = 0x2000
19+
#if (CONFIG_ESP32_FLASH_CACHE == 1)
20+
#include "linker_flash_cache.ld"
21+
#else
22+
#include "linker_no_flash_cache.ld"
5023
#endif
51-
}
52-
53-
PHDRS
54-
{
55-
iram0_0_phdr PT_LOAD;
56-
dram0_0_phdr PT_LOAD;
57-
}
58-
59-
/* Default entry point: */
60-
PROVIDE ( _ResetVector = 0x40000400 );
61-
ENTRY(CONFIG_KERNEL_ENTRY)
62-
63-
_rom_store_table = 0;
64-
65-
PROVIDE(_memmap_vecbase_reset = 0x40000450);
66-
PROVIDE(_memmap_reset_vector = 0x40000400);
67-
68-
SECTIONS
69-
{
70-
/* RTC fast memory holds RTC wake stub code,
71-
including from any source file named rtc_wake_stub*.c
72-
*/
73-
.rtc.text :
74-
{
75-
. = ALIGN(4);
76-
*(.rtc.literal .rtc.text)
77-
*rtc_wake_stub*.o(.literal .text .literal.* .text.*)
78-
} >rtc_iram_seg
79-
80-
/* RTC slow memory holds RTC wake stub
81-
data/rodata, including from any source file
82-
named rtc_wake_stub*.c
83-
*/
84-
.rtc.data :
85-
{
86-
_rtc_data_start = ABSOLUTE(.);
87-
*(.rtc.data)
88-
*(.rtc.rodata)
89-
*rtc_wake_stub*.o(.data .rodata .data.* .rodata.* .bss .bss.*)
90-
_rtc_data_end = ABSOLUTE(.);
91-
} > rtc_slow_seg
92-
93-
/* RTC bss, from any source file named rtc_wake_stub*.c */
94-
.rtc.bss (NOLOAD) :
95-
{
96-
_rtc_bss_start = ABSOLUTE(.);
97-
*rtc_wake_stub*.o(.bss .bss.*)
98-
*rtc_wake_stub*.o(COMMON)
99-
_rtc_bss_end = ABSOLUTE(.);
100-
} > rtc_slow_seg
101-
102-
/* Send .iram0 code to iram */
103-
.iram0.vectors : ALIGN(4)
104-
{
105-
/* Vectors go to IRAM */
106-
_init_start = ABSOLUTE(.);
107-
/* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */
108-
. = 0x0;
109-
KEEP(*(.WindowVectors.text));
110-
. = 0x180;
111-
KEEP(*(.Level2InterruptVector.text));
112-
. = 0x1c0;
113-
KEEP(*(.Level3InterruptVector.text));
114-
. = 0x200;
115-
KEEP(*(.Level4InterruptVector.text));
116-
. = 0x240;
117-
KEEP(*(.Level5InterruptVector.text));
118-
. = 0x280;
119-
KEEP(*(.DebugExceptionVector.text));
120-
. = 0x2c0;
121-
KEEP(*(.NMIExceptionVector.text));
122-
. = 0x300;
123-
KEEP(*(.KernelExceptionVector.text));
124-
. = 0x340;
125-
KEEP(*(.UserExceptionVector.text));
126-
. = 0x3C0;
127-
KEEP(*(.DoubleExceptionVector.text));
128-
. = 0x400;
129-
*(.*Vector.literal)
130-
131-
*(.UserEnter.literal);
132-
*(.UserEnter.text);
133-
. = ALIGN (16);
134-
*(.entry.text)
135-
*(.init.literal)
136-
*(.init)
137-
_init_end = ABSOLUTE(.);
138-
139-
/* This goes here, not at top of linker script, so addr2line finds it last,
140-
and uses it in preference to the first symbol in IRAM */
141-
_iram_start = ABSOLUTE(0);
142-
} GROUP_LINK_IN(ROMABLE_REGION)
143-
144-
145-
146-
.iram0.text :
147-
{
148-
/* Code marked as running out of IRAM */
149-
_iram_text_start = ABSOLUTE(.);
150-
*(.iram1 .iram1.*)
151-
152-
*(.literal.*_int_handler .text.*_int_handler)
153-
*(.literal.*_irq_spurious .text.*_irq_spurious)
154-
*(.literal.*i2c_esp32_isr .text.*i2c_esp32_isr)
155-
156-
kernel/libkernel.a(.literal .text .literal.* .text.*)
157-
*(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
158-
_iram_text_end = ABSOLUTE(.);
159-
} GROUP_LINK_IN(ROMABLE_REGION)
160-
161-
.dram0.data :
162-
{
163-
_data_start = ABSOLUTE(.);
164-
*(.data)
165-
*(.data.*)
166-
*(.gnu.linkonce.d.*)
167-
*(.data1)
168-
*(.sdata)
169-
*(.sdata.*)
170-
*(.gnu.linkonce.s.*)
171-
*(.sdata2)
172-
*(.sdata2.*)
173-
*(.gnu.linkonce.s2.*)
174-
KEEP(*(.jcr))
175-
*(.dram1 .dram1.*)
176-
KEEP(*(SW_ISR_TABLE))
177-
_data_end = ABSOLUTE(.);
178-
. = ALIGN(4);
179-
} GROUP_LINK_IN(RAMABLE_REGION)
180-
181-
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,ALIGN(4))
182-
{
183-
_rodata_start = ABSOLUTE(.);
184-
*(.rodata)
185-
*(.rodata.*)
186-
*(.gnu.linkonce.r.*)
187-
*(.rodata1)
188-
__XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
189-
KEEP (*(.xt_except_table))
190-
KEEP (*(.gcc_except_table))
191-
*(.gnu.linkonce.e.*)
192-
*(.gnu.version_r)
193-
KEEP (*(.eh_frame))
194-
/* C++ constructor and destructor tables, properly ordered: */
195-
KEEP (*crtbegin.o(.ctors))
196-
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
197-
KEEP (*(SORT(.ctors.*)))
198-
KEEP (*(.ctors))
199-
KEEP (*crtbegin.o(.dtors))
200-
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
201-
KEEP (*(SORT(.dtors.*)))
202-
KEEP (*(.dtors))
203-
/* C++ exception handlers table: */
204-
__XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
205-
*(.xt_except_desc)
206-
*(.gnu.linkonce.h.*)
207-
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
208-
*(.xt_except_desc_end)
209-
*(.dynamic)
210-
*(.gnu.version_d)
211-
. = ALIGN(4); /* this table MUST be 4-byte aligned */
212-
213-
__devconfig_start = .;
214-
*(".devconfig.*")
215-
KEEP(*(SORT_BY_NAME(".devconfig*")))
216-
__devconfig_end = .;
217-
218-
__net_l2_start = .;
219-
*(".net_l2.init")
220-
KEEP(*(SORT_BY_NAME(".net_l2.init*")))
221-
__net_l2_end = .;
222-
223-
_rodata_end = ABSOLUTE(.);
224-
} GROUP_LINK_IN(RAMABLE_REGION)
225-
226-
227-
/* Shared RAM */
228-
.dram0.bss (NOLOAD) :
229-
{
230-
. = ALIGN (8);
231-
_bss_start = ABSOLUTE(.);
232-
*(.dynsbss)
233-
*(.sbss)
234-
*(.sbss.*)
235-
*(.gnu.linkonce.sb.*)
236-
*(.scommon)
237-
*(.sbss2)
238-
*(.sbss2.*)
239-
*(.gnu.linkonce.sb2.*)
240-
*(.dynbss)
241-
*(.bss)
242-
*(.bss.*)
243-
*(.share.mem)
244-
*(.gnu.linkonce.b.*)
245-
*(COMMON)
246-
. = ALIGN (8);
247-
_bss_end = ABSOLUTE(.);
248-
} GROUP_LINK_IN(RAMABLE_REGION)
249-
250-
SECTION_DATA_PROLOGUE(_NOINIT_SECTION_NAME, (NOLOAD),)
251-
{
252-
. = ALIGN (8);
253-
*(.noinit)
254-
*(".noinit.*")
255-
. = ALIGN (8);
256-
_heap_start = ABSOLUTE(.);
257-
} GROUP_LINK_IN(RAMABLE_REGION)
258-
259-
#ifdef CONFIG_GEN_ISR_TABLES
260-
#include <linker/intlist.ld>
261-
#endif
262-
263-
.flash.text :
264-
{
265-
_irom_text_start = ABSOLUTE(.);
266-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
267-
*(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */
268-
*(.fini.literal)
269-
*(.fini)
270-
*(.gnu.version)
271-
_irom_text_end = ABSOLUTE(.);
272-
} >iram0_2_seg
273-
274-
#include <linker/common-ram.ld>
275-
276-
}

0 commit comments

Comments
 (0)