Skip to content

Commit a001f5e

Browse files
Split IRAM into 2 linker sections to move std::fcn
Callbacks need to be placed in IRAM when being called from an IRQ (like the SPISlave callbacks). This can be done by hacking the std::functional header and making every single specialization of the template into an IRAM section, which would take a lot of space for no benefit in the majority of cases. The alternate is to specify the single instantiation types/operators required, but the problem is the flash segment matcher would match them before the IRAM section was begun, and rules for them would just not be applied. Get around this by splitting the IRAM section definition into .text and .text1. This is linker syntactic sugar and does not actually change the on-chip layout. But it does allow us to put the exception vectors at the required absolute addresses and add single functions to IRAM.
1 parent 2e75e88 commit a001f5e

File tree

1 file changed

+41
-30
lines changed

1 file changed

+41
-30
lines changed

tools/sdk/ld/eagle.app.v6.common.ld.h

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,44 @@ SECTIONS
9393
#include "eagle.app.v6.common.ld.vtables.h"
9494
#endif
9595

96+
/* IRAM is split into .text and .text1 to allow for moving specific */
97+
/* functions into IRAM that would be matched by the irom0.text matcher */
98+
.text : ALIGN(4)
99+
{
100+
_stext = .;
101+
_text_start = ABSOLUTE(.);
102+
*(.UserEnter.text)
103+
. = ALIGN(16);
104+
*(.DebugExceptionVector.text)
105+
. = ALIGN(16);
106+
*(.NMIExceptionVector.text)
107+
. = ALIGN(16);
108+
*(.KernelExceptionVector.text)
109+
LONG(0)
110+
LONG(0)
111+
LONG(0)
112+
LONG(0)
113+
. = ALIGN(16);
114+
*(.UserExceptionVector.text)
115+
LONG(0)
116+
LONG(0)
117+
LONG(0)
118+
LONG(0)
119+
. = ALIGN(16);
120+
*(.DoubleExceptionVector.text)
121+
LONG(0)
122+
LONG(0)
123+
LONG(0)
124+
LONG(0)
125+
. = ALIGN (16);
126+
*(.entry.text)
127+
*(.init.literal)
128+
*(.init)
129+
130+
/* Special functions/templates that need to be in IRAM (SPI/IRQ callbacks/etc. here */
131+
*(.text._ZNKSt8functionIFvvEEclEv) /* std::function<void ()>::operator()() const */
132+
} >iram1_0_seg :iram1_0_phdr
133+
96134
.irom0.text : ALIGN(4)
97135
{
98136
_irom0_text_start = ABSOLUTE(.);
@@ -163,37 +201,10 @@ SECTIONS
163201
_flash_code_end = ABSOLUTE(.);
164202
} >irom0_0_seg :irom0_0_phdr
165203

166-
.text : ALIGN(4)
204+
205+
206+
.text1 : ALIGN(4)
167207
{
168-
_stext = .;
169-
_text_start = ABSOLUTE(.);
170-
*(.UserEnter.text)
171-
. = ALIGN(16);
172-
*(.DebugExceptionVector.text)
173-
. = ALIGN(16);
174-
*(.NMIExceptionVector.text)
175-
. = ALIGN(16);
176-
*(.KernelExceptionVector.text)
177-
LONG(0)
178-
LONG(0)
179-
LONG(0)
180-
LONG(0)
181-
. = ALIGN(16);
182-
*(.UserExceptionVector.text)
183-
LONG(0)
184-
LONG(0)
185-
LONG(0)
186-
LONG(0)
187-
. = ALIGN(16);
188-
*(.DoubleExceptionVector.text)
189-
LONG(0)
190-
LONG(0)
191-
LONG(0)
192-
LONG(0)
193-
. = ALIGN (16);
194-
*(.entry.text)
195-
*(.init.literal)
196-
*(.init)
197208
*(.literal .text .iram.literal .iram.text .iram.text.* .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
198209
#ifdef VTABLES_IN_IRAM
199210
*(.rodata._ZTV*) /* C++ vtables */

0 commit comments

Comments
 (0)