Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optionally move float emulation code into iram #8958

Merged
merged 14 commits into from
Nov 12, 2023
153 changes: 153 additions & 0 deletions boards.txt

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions doc/ideoptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ See our issue tracker in regards to default version selection.

Notice that 3.x.x is provided **as-is** and remains **experimental**.

Soft-float location
~~~~~~~~~~~~~~~~~~~

- ``in rom``: This provides more space in IRAM but disallow using floating operations inside ISRs. This is the default for some years.
- ``in iram``: Floats can be used in ISRs, cost is ~1KB IRAM.

SSL Support
~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion package/package_esp8266com_index.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,4 @@
]
}
]
}
}
9 changes: 6 additions & 3 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ build.spiffs_start=
build.spiffs_end=
build.spiffs_blocksize=

# soft float location
build.iramfloat=-DFP_IN_IROM

# Fully qualified file names for processing sketch global options
globals.h.source.fqfn={build.source.path}/{build.project_name}.globals.h
commonhfile.fqfn={build.core.path}/CommonHFile.h
Expand All @@ -79,7 +82,7 @@ compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -D_GNU_S
compiler.libraries.ldflags=

compiler.c.cmd=xtensa-lx106-elf-gcc
compiler.c.flags=-c "{compiler.warning_flags}-cflags" -std=gnu17 {build.stacksmash_flags} -g -free -fipa-pta -Werror=return-type -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.mmuflags} {build.non32xferflags}
compiler.c.flags=-c "{compiler.warning_flags}-cflags" -std=gnu17 {build.stacksmash_flags} -g -free -fipa-pta -Werror=return-type -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.mmuflags} {build.non32xferflags} {build.iramfloat}

compiler.S.cmd=xtensa-lx106-elf-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls "-I{runtime.tools.xtensa-lx106-elf-gcc.path}/include/"
Expand All @@ -90,7 +93,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig -lairkiss -lwpa2 {build.stdcpp_lib} -lm -lc -lgcc

compiler.cpp.cmd=xtensa-lx106-elf-g++
compiler.cpp.flags=-c "{compiler.warning_flags}-cppflags" {build.stacksmash_flags} -g -free -fipa-pta -Werror=return-type -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 {build.stdcpp_level} -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.mmuflags} {build.non32xferflags}
compiler.cpp.flags=-c "{compiler.warning_flags}-cppflags" {build.stacksmash_flags} -g -free -fipa-pta -Werror=return-type -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 {build.stdcpp_level} -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.mmuflags} {build.non32xferflags} {build.iramfloat}

compiler.as.cmd=xtensa-lx106-elf-as

Expand Down Expand Up @@ -128,7 +131,7 @@ recipe.hooks.prebuild.2.pattern="{runtime.tools.python3.path}/python3" -I "{runt
recipe.hooks.linking.prelink.1.pattern="{runtime.tools.python3.path}/python3" -I "{runtime.tools.mkdir}" -p "{build.path}/ld_h/"
recipe.hooks.linking.prelink.2.pattern="{runtime.tools.python3.path}/python3" -I "{runtime.tools.cp}" "{runtime.platform.path}/tools/sdk/ld/{build.flash_ld}" "{build.path}/ld_h/local.eagle.flash.ld.h"
recipe.hooks.linking.prelink.3.pattern="{compiler.path}{compiler.c.cmd}" -CC -E -P {build.vtable_flags} {build.mmuflags} "{build.path}/ld_h/local.eagle.flash.ld.h" -o "{build.path}/local.eagle.flash.ld"
recipe.hooks.linking.prelink.4.pattern="{compiler.path}{compiler.c.cmd}" -CC -E -P {build.vtable_flags} {build.mmuflags} "{runtime.platform.path}/tools/sdk/ld/eagle.app.v6.common.ld.h" -o "{build.path}/local.eagle.app.v6.common.ld"
recipe.hooks.linking.prelink.4.pattern="{compiler.path}{compiler.c.cmd}" {build.iramfloat} -CC -E -P {build.vtable_flags} {build.mmuflags} "{runtime.platform.path}/tools/sdk/ld/eagle.app.v6.common.ld.h" -o "{build.path}/local.eagle.app.v6.common.ld"

## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -D{build.sdk}=1 -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_BOARD_ID="{_id}" {build.led} {build.flash_flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
Expand Down
14 changes: 14 additions & 0 deletions tools/boards.txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,17 @@ def sdk ():

################################################################

def float_in_iram ():
return { 'iramfloat': collections.OrderedDict([
('.menu.iramfloat.no', 'in rom (default)'),
mcspr marked this conversation as resolved.
Show resolved Hide resolved
('.menu.iramfloat.no.build.iramfloat', '-DFP_IN_IROM'),
('.menu.iramfloat.yes', 'in iram (for ISRs)'),
mcspr marked this conversation as resolved.
Show resolved Hide resolved
('.menu.iramfloat.yes.build.iramfloat', '-DFP_IN_IRAM'),
])
}

################################################################

def all_boards ():

if boardsgen or boardslocalgen:
Expand Down Expand Up @@ -1709,6 +1720,7 @@ def all_boards ():
macros.update(led('led', led_default, range(0,led_max+1)))
macros.update(led('led216', 2, { 16 }))
macros.update(sdk())
macros.update(float_in_iram())

if boardfilteropt or excludeboards:
print('#')
Expand Down Expand Up @@ -1754,6 +1766,7 @@ def all_boards ():
print('menu.stacksmash=Stack Protection')
print('menu.wipe=Erase Flash')
print('menu.sdk=NONOS SDK Version')
print('menu.iramfloat=Soft-float location')
mcspr marked this conversation as resolved.
Show resolved Hide resolved
print('menu.ssl=SSL Support')
print('menu.mmu=MMU')
print('menu.non32xfer=Non-32-Bit Access')
Expand Down Expand Up @@ -1791,6 +1804,7 @@ def all_boards ():
macrolist += speeds[default_speed]

macrolist += [ 'autoflash' ]
macrolist += [ 'iramfloat' ]

for block in macrolist:
for optname in macros[block]:
Expand Down
10 changes: 10 additions & 0 deletions tools/sdk/ld/eagle.app.v6.common.ld.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ SECTIONS

/* all functional callers are placed in IRAM (including SPI/IRQ callbacks/etc) here */
*(.text._ZNKSt8functionIF*EE*) /* std::function<any(...)>::operator()() const */

#ifdef FP_IN_IRAM
*libgcc.a:*f2.o(.literal .text)
*libgcc.a:*f3.o(.literal .text)
*libgcc.a:*fsi.o(.literal .text)
*libgcc.a:*fdi.o(.literal .text)
*libgcc.a:*ifs.o(.literal .text)
*libgcc.a:*idf.o(.literal .text)
#endif

} >iram1_0_seg :iram1_0_phdr

.irom0.text : ALIGN(4)
Expand Down