mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Split IRAM into 2 linker sections to move std::fcn (#5922)
* 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. * Add .text1 segment to space used calculation in IDE * All functional callers are now placed in IRAM * Write out the .text1 segment to the BIN The extra segment name needs to be placed into the output binary as well, or else only the init code gets stored and none of the real app is present. This leads to an infinite boot loop. This change adds in the segment to the generated image.
This commit is contained in:
parent
fa0db2e3ab
commit
0f4c9f7103
@ -117,7 +117,7 @@ recipe.output.save_file={build.project_name}.{build.variant}.bin
|
|||||||
|
|
||||||
## Compute size
|
## Compute size
|
||||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||||
recipe.size.regex=^(?:\.irom0\.text|\.text|\.data|\.rodata|)\s+([0-9]+).*
|
recipe.size.regex=^(?:\.irom0\.text|\.text|\.text1|\.data|\.rodata|)\s+([0-9]+).*
|
||||||
recipe.size.regex.data=^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*
|
recipe.size.regex.data=^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*
|
||||||
#recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
|
#recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ def main():
|
|||||||
|
|
||||||
out = open(args.out, "wb")
|
out = open(args.out, "wb")
|
||||||
write_bin(out, args.eboot, ['.text'], 4096, args.flash_mode, args.flash_size, args.flash_freq, args.path)
|
write_bin(out, args.eboot, ['.text'], 4096, args.flash_mode, args.flash_size, args.flash_freq, args.path)
|
||||||
write_bin(out, args.app, ['.irom0.text', '.text', '.data', '.rodata'], 0, args.flash_mode, args.flash_size, args.flash_freq, args.path)
|
write_bin(out, args.app, ['.irom0.text', '.text', '.text1', '.data', '.rodata'], 0, args.flash_mode, args.flash_size, args.flash_freq, args.path)
|
||||||
out.close()
|
out.close()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -93,6 +93,44 @@ SECTIONS
|
|||||||
#include "eagle.app.v6.common.ld.vtables.h"
|
#include "eagle.app.v6.common.ld.vtables.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* IRAM is split into .text and .text1 to allow for moving specific */
|
||||||
|
/* functions into IRAM that would be matched by the irom0.text matcher */
|
||||||
|
.text : ALIGN(4)
|
||||||
|
{
|
||||||
|
_stext = .;
|
||||||
|
_text_start = ABSOLUTE(.);
|
||||||
|
*(.UserEnter.text)
|
||||||
|
. = ALIGN(16);
|
||||||
|
*(.DebugExceptionVector.text)
|
||||||
|
. = ALIGN(16);
|
||||||
|
*(.NMIExceptionVector.text)
|
||||||
|
. = ALIGN(16);
|
||||||
|
*(.KernelExceptionVector.text)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
. = ALIGN(16);
|
||||||
|
*(.UserExceptionVector.text)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
. = ALIGN(16);
|
||||||
|
*(.DoubleExceptionVector.text)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
LONG(0)
|
||||||
|
. = ALIGN (16);
|
||||||
|
*(.entry.text)
|
||||||
|
*(.init.literal)
|
||||||
|
*(.init)
|
||||||
|
|
||||||
|
/* all functional callers are placed in IRAM (including SPI/IRQ callbacks/etc) here */
|
||||||
|
*(.text._ZNKSt8functionIF*EE*) /* std::function<any(...)>::operator()() const */
|
||||||
|
} >iram1_0_seg :iram1_0_phdr
|
||||||
|
|
||||||
.irom0.text : ALIGN(4)
|
.irom0.text : ALIGN(4)
|
||||||
{
|
{
|
||||||
_irom0_text_start = ABSOLUTE(.);
|
_irom0_text_start = ABSOLUTE(.);
|
||||||
@ -163,37 +201,10 @@ SECTIONS
|
|||||||
_flash_code_end = ABSOLUTE(.);
|
_flash_code_end = ABSOLUTE(.);
|
||||||
} >irom0_0_seg :irom0_0_phdr
|
} >irom0_0_seg :irom0_0_phdr
|
||||||
|
|
||||||
.text : ALIGN(4)
|
|
||||||
|
|
||||||
|
.text1 : ALIGN(4)
|
||||||
{
|
{
|
||||||
_stext = .;
|
|
||||||
_text_start = ABSOLUTE(.);
|
|
||||||
*(.UserEnter.text)
|
|
||||||
. = ALIGN(16);
|
|
||||||
*(.DebugExceptionVector.text)
|
|
||||||
. = ALIGN(16);
|
|
||||||
*(.NMIExceptionVector.text)
|
|
||||||
. = ALIGN(16);
|
|
||||||
*(.KernelExceptionVector.text)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
. = ALIGN(16);
|
|
||||||
*(.UserExceptionVector.text)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
. = ALIGN(16);
|
|
||||||
*(.DoubleExceptionVector.text)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
LONG(0)
|
|
||||||
. = ALIGN (16);
|
|
||||||
*(.entry.text)
|
|
||||||
*(.init.literal)
|
|
||||||
*(.init)
|
|
||||||
*(.literal .text .iram.literal .iram.text .iram.text.* .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
*(.literal .text .iram.literal .iram.text .iram.text.* .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||||
#ifdef VTABLES_IN_IRAM
|
#ifdef VTABLES_IN_IRAM
|
||||||
*(.rodata._ZTV*) /* C++ vtables */
|
*(.rodata._ZTV*) /* C++ vtables */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user