Browse Source

.ld scripts refactoring (#1559)

* initial ldscripts refactoring

* add missing menu options

* board for 2.3.0 and 2.4.2

* test with core 2.5.0

* typo

* ...same typo in other boards.local.txt

* generate boards.local.txt from common template

* Depend on file presence instead of platform version

* sdk selection

* Override only relevant entries

* generate ldscripts

* formatting

* unused

* fix section scope

* fix linker script comment and build getting stuck

* py2 compat

platformio from pip still does not support py3

* add TODO for py3

* chmod +x, remove leading newline

* comment with real spiffs size

* fixup! chmod +x, remove leading newline

* regenerate all ldscripts

* Preventive fix of spiffs_end calculation

* update arg parsing

* generate only 2.3.0 and latest

* readme for boards.local.txt

* Update ldscript readme

* unique flash sizes

* fix sub

* line break

* correct way to get framework path

* Alias for _FS_... symbols

* unused 2m1m1s

* bump?

* show travis logs

* ensure latest toolchain for travis

* check platform packages when building
master
Max Prokhorov 4 years ago
committed by GitHub
parent
commit
437424aaac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 844 additions and 87 deletions
  1. +1
    -0
      .travis.yml
  2. +0
    -19
      code/eagle.flash.1m0m1s.ld
  3. +0
    -19
      code/eagle.flash.1m0m2s.ld
  4. +0
    -19
      code/eagle.flash.512k0m1s.ld
  5. +15
    -1
      code/extra_script_pre.py
  6. +32
    -5
      code/extra_scripts.py
  7. +2
    -2
      code/platformio.ini
  8. +39
    -0
      dist/arduino_ide/2.3.0/boards.local.txt
  9. +24
    -0
      dist/arduino_ide/README.md
  10. +39
    -0
      dist/arduino_ide/latest/boards.local.txt
  11. +181
    -0
      dist/boards_local_txt.py
  12. +8
    -0
      dist/ld/README.md
  13. +30
    -0
      dist/ld/latest/eagle.flash.1m0m1s.ld
  14. +30
    -0
      dist/ld/latest/eagle.flash.1m0m2s.ld
  15. +30
    -0
      dist/ld/latest/eagle.flash.2m1m4s.ld
  16. +30
    -0
      dist/ld/latest/eagle.flash.4m1m4s.ld
  17. +30
    -0
      dist/ld/latest/eagle.flash.4m3m4s.ld
  18. +30
    -0
      dist/ld/latest/eagle.flash.512k0m1s.ld
  19. +30
    -0
      dist/ld/pre_2.5.0/eagle.flash.1m0m1s.ld
  20. +30
    -0
      dist/ld/pre_2.5.0/eagle.flash.1m0m2s.ld
  21. +17
    -7
      dist/ld/pre_2.5.0/eagle.flash.2m1m4s.ld
  22. +17
    -8
      dist/ld/pre_2.5.0/eagle.flash.4m1m4s.ld
  23. +17
    -7
      dist/ld/pre_2.5.0/eagle.flash.4m3m4s.ld
  24. +30
    -0
      dist/ld/pre_2.5.0/eagle.flash.512k0m1s.ld
  25. +181
    -0
      dist/ldscript_gen.py
  26. +1
    -0
      pre-commit

+ 1
- 0
.travis.yml View File

@ -9,6 +9,7 @@ cache:
- "~/.platformio"
install:
- pip install -U platformio
- pio platform update -p
- npm install -g npm@latest
- cd code && npm ci && cd ..
env:


+ 0
- 19
code/eagle.flash.1m0m1s.ld View File

@ -1,19 +0,0 @@
/* Flash Split for 1M chips, no SPIFFS, 1 sector for EEPROM */
/* sketch 999KB */
/* eeprom 4KB */
/* reserved 16KB */
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xf9ff0
}
PROVIDE ( _SPIFFS_start = 0x402FB000 );
PROVIDE ( _SPIFFS_end = 0x402FB000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
INCLUDE "../ld/eagle.app.v6.common.ld"

+ 0
- 19
code/eagle.flash.1m0m2s.ld View File

@ -1,19 +0,0 @@
/* Flash Split for 1M chips, no SPIFFS, 2 sectors for EEPROM */
/* sketch 995KB */
/* eeprom 8KB */
/* reserved 16KB */
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xf8ff0
}
PROVIDE ( _SPIFFS_start = 0x402FA000 );
PROVIDE ( _SPIFFS_end = 0x402FA000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
INCLUDE "../ld/eagle.app.v6.common.ld"

+ 0
- 19
code/eagle.flash.512k0m1s.ld View File

@ -1,19 +0,0 @@
/* Flash Split for 512K chips, no SPIFFS, 1 sector for EEPROM */
/* sketch 487KB */
/* eeprom 4KB */
/* reserved 16KB */
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0x79ff0
}
PROVIDE ( _SPIFFS_start = 0x4027B000 );
PROVIDE ( _SPIFFS_end = 0x4027B000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
INCLUDE "../ld/eagle.app.v6.common.ld"

code/extra_script_libdeps.py → code/extra_script_pre.py View File

@ -7,6 +7,7 @@ import sys
TRAVIS = os.environ.get("TRAVIS")
PIO_PLATFORM = env.PioPlatform()
class ExtraScriptError(Exception):
@ -57,11 +58,24 @@ def get_shared_libdeps_dir(section, name):
opt = cfg.get(section, name)
if not opt in env.GetProjectOption("lib_extra_dirs"):
raise ExtraScriptError("lib_extra_dirs must contain {}.{}".format(section, name))
raise ExtraScriptError(
"lib_extra_dirs must contain {}.{}".format(section, name)
)
return os.path.join(env["PROJECT_DIR"], opt)
def ensure_platform_updated():
if PIO_PLATFORM.are_outdated_packages():
print("updating platform packages", file=sys.stderr)
PIO_PLATFORM.update_packages()
# latest toolchain is still optional with PIO (TODO: recheck after 2.6.0!)
ensure_platform_updated()
# to speed-up build process, install libraries in either global or local shared storage
if os.environ.get("ESPURNA_PIO_SHARED_LIBRARIES"):
if TRAVIS:
storage = None

+ 32
- 5
code/extra_scripts.py View File

@ -8,6 +8,9 @@ import click
Import("env", "projenv")
PIO_PLATFORM = env.PioPlatform()
FRAMEWORK_DIR = PIO_PLATFORM.get_package_dir("framework-arduinoespressif8266")
# ------------------------------------------------------------------------------
# Utils
# ------------------------------------------------------------------------------
@ -44,6 +47,31 @@ def print_filler(fill, color=Color.WHITE, err=False):
out = sys.stderr if err else sys.stdout
print(clr(color, fill * width), file=out)
def ldscript_inject_libpath():
# espressif8266@1.5.0 did not append this directory into the LIBPATH
libpath_sdk = os.path.join(FRAMEWORK_DIR, "tools", "sdk", "ld")
env.Append(LIBPATH=[libpath_sdk])
libpath_base = os.path.join("$PROJECT_DIR", "..", "dist", "ld")
env.Append(LIBPATH=[
os.path.join(libpath_base, "pre_2.5.0")
])
# local.eagle.app.v6.common.ld exists only with Core >2.5.0
def check_local_ld(target ,source, env):
local_ld = env.subst(os.path.join("$BUILD_DIR", "ld", "local.eagle.app.v6.common.ld"))
if os.path.exists(local_ld):
env.Prepend(LIBPATH=[
os.path.join(libpath_base, "latest")
])
env.AddPreAction(
os.path.join("$BUILD_DIR", "firmware.elf"),
check_local_ld
)
# ------------------------------------------------------------------------------
# Callbacks
# ------------------------------------------------------------------------------
@ -97,18 +125,16 @@ def patch_lwip():
if "lwip_gcc" not in env["LIBS"]:
return
platform = env.PioPlatform()
framework_dir = platform.get_package_dir("framework-arduinoespressif8266")
toolchain_prefix = os.path.join(platform.get_package_dir("toolchain-xtensa"), "bin", "xtensa-lx106-elf-")
toolchain_prefix = os.path.join(PIO_PLATFORM.get_package_dir("toolchain-xtensa"), "bin", "xtensa-lx106-elf-")
patch_action = env.VerboseAction(" ".join([
"-patch", "-u", "-N", "-d",
os.path.join(framework_dir, "tools", "sdk", "lwip"),
os.path.join(FRAMEWORK_DIR, "tools", "sdk", "lwip"),
os.path.join("src", "core", "tcp_out.c"),
env.subst(os.path.join("$PROJECT_DIR", "..", "dist", "patches", "lwip_mtu_issue_1610.patch"))
]), "Patching lwip source")
build_action = env.VerboseAction(" ".join([
"make", "-C", os.path.join(framework_dir, "tools", "sdk", "lwip", "src"),
"make", "-C", os.path.join(FRAMEWORK_DIR, "tools", "sdk", "lwip", "src"),
"install",
"TOOLS_PATH={}".format(toolchain_prefix),
"LWIP_LIB=liblwip_gcc.a"
@ -130,6 +156,7 @@ projenv.ProcessUnFlags("-w")
# 2.4.0 and up
remove_float_support()
ldscript_inject_libpath()
# two-step update hint when using 1MB boards
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size)


+ 2
- 2
code/platformio.ini View File

@ -30,7 +30,7 @@ arduino_core_develop = https://github.com/platformio/platform-espressif8266#deve
arduino_core_git = https://github.com/platformio/platform-espressif8266#feature/stage
platform = ${common.arduino_core_2_3_0}
platform_latest = ${common.arduino_core_2_4_2}
platform_latest = ${common.arduino_core_2_5_2}
# ------------------------------------------------------------------------------
# FLAGS: DEBUG
@ -90,7 +90,7 @@ framework = arduino
board_build.flash_mode = dout
monitor_speed = 115200
upload_speed = 115200
extra_scripts = pre:extra_script_libdeps.py, extra_scripts.py
extra_scripts = pre:extra_script_pre.py, extra_scripts.py
lib_extra_dirs =
${common.shared_libdeps_dir}


+ 39
- 0
dist/arduino_ide/2.3.0/boards.local.txt View File

@ -0,0 +1,39 @@
#version=2.3.0
menu.float_support=scanf and printf float support
generic.menu.FlashSize.1M1S=1M (1 EEPROM Sector, no SPIFFS)
generic.menu.FlashSize.1M1S.build.flash_size=1M
generic.menu.FlashSize.1M1S.build.flash_size_bytes=0x100000
generic.menu.FlashSize.1M1S.build.flash_ld=eagle.flash.1m0m1s.ld
generic.menu.FlashSize.1M1S.build.spiffs_pagesize=256
generic.menu.FlashSize.1M1S.upload.maximum_size=1023984
generic.menu.FlashSize.1M1S.build.rfcal_addr=0xFC000
generic.menu.FlashSize.2M4S=2M (4 EEPROM Sectors, 1M SPIFFS)
generic.menu.FlashSize.2M4S.build.flash_size=2M
generic.menu.FlashSize.2M4S.build.flash_size_bytes=0x200000
generic.menu.FlashSize.2M4S.build.flash_ld=eagle.flash.2m1m4s.ld
generic.menu.FlashSize.2M4S.build.spiffs_pagesize=256
generic.menu.FlashSize.2M4S.upload.maximum_size=1044464
generic.menu.FlashSize.2M4S.build.rfcal_addr=0x1FC000
generic.menu.FlashSize.4M1M4S=4M (4 EEPROM Sectors, 1M SPIFFS)
generic.menu.FlashSize.4M1M4S.build.flash_size=4M
generic.menu.FlashSize.4M1M4S.build.flash_size_bytes=0x400000
generic.menu.FlashSize.4M1M4S.build.flash_ld=eagle.flash.4m1m4s.ld
generic.menu.FlashSize.4M1M4S.build.spiffs_pagesize=256
generic.menu.FlashSize.4M1M4S.upload.maximum_size=1044464
generic.menu.FlashSize.4M1M4S.build.rfcal_addr=0x3FC000
generic.menu.FlashSize.4M3M4S=4M (4 EEPROM Sectors, 3M SPIFFS)
generic.menu.FlashSize.4M3M4S.build.flash_size=4M
generic.menu.FlashSize.4M3M4S.build.flash_size_bytes=0x400000
generic.menu.FlashSize.4M3M4S.build.flash_ld=eagle.flash.4m3m4s.ld
generic.menu.FlashSize.4M3M4S.build.spiffs_pagesize=256
generic.menu.FlashSize.4M3M4S.upload.maximum_size=1044464
generic.menu.FlashSize.4M3M4S.build.rfcal_addr=0x3FC000
generic.menu.float_support.disabled=Disabled (Recommended)
generic.menu.float_support.disabled.build.float=
generic.menu.float_support.enabled=Enabled
generic.menu.float_support.enabled.build.float=-u _printf_float -u _scanf_float
generic.compiler.cpp.extra_flags=-DNO_GLOBAL_EEPROM -DMQTT_MAX_PACKET_SIZE=400

+ 24
- 0
dist/arduino_ide/README.md View File

@ -0,0 +1,24 @@
# boards.local.txt for ESPurna
Additional flash layouts to support multiple EEPROM sectors
### Installation
Place boards.local.txt into Arduino hardware directory, in the same directory as the boards.txt file. Depending on platform and ESP8266 installation method, it is one of:
- Linux (boards manager): `~/.arduino15/packages/esp8266/hardware/esp8266/<version>`
- Linux (git): `~/Arduino/hardware/esp8266com/esp8266/`
- Windows (boards manager): `%LOCALAPPDATA%\Arduino15\packages\esp8266\hardware\esp8266\<version>`
- Windows (git): `~\Documents\Arduino\hardware\esp8266com\esp8266\`
- macOS (boards manager): `~/Library/Arduino15/packages/esp2866/hardware/esp8266/<version>`
- macOS (git): `<application-directory>/Arduino.app/Contents/Java/hardware/esp8266com/esp8266`
Use `2.3.0/boards.local.txt` for Core version 2.3.0
Use `latest/boards.local.txt` for all the others
### Arduino documentation
https://arduino-esp8266.readthedocs.io/en/latest/installing.html
https://www.arduino.cc/en/Hacking/Preferences
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardslocaltxt

+ 39
- 0
dist/arduino_ide/latest/boards.local.txt View File

@ -0,0 +1,39 @@
#version=latest
menu.float_support=scanf and printf float support
generic.menu.eesz.1M1S=1M (1 EEPROM Sector, no SPIFFS)
generic.menu.eesz.1M1S.build.flash_size=1M
generic.menu.eesz.1M1S.build.flash_size_bytes=0x100000
generic.menu.eesz.1M1S.build.flash_ld=eagle.flash.1m0m1s.ld
generic.menu.eesz.1M1S.build.spiffs_pagesize=256
generic.menu.eesz.1M1S.upload.maximum_size=1023984
generic.menu.eesz.1M1S.build.rfcal_addr=0xFC000
generic.menu.eesz.2M4S=2M (4 EEPROM Sectors, 1M SPIFFS)
generic.menu.eesz.2M4S.build.flash_size=2M
generic.menu.eesz.2M4S.build.flash_size_bytes=0x200000
generic.menu.eesz.2M4S.build.flash_ld=eagle.flash.2m1m4s.ld
generic.menu.eesz.2M4S.build.spiffs_pagesize=256
generic.menu.eesz.2M4S.upload.maximum_size=1044464
generic.menu.eesz.2M4S.build.rfcal_addr=0x1FC000
generic.menu.eesz.4M1M4S=4M (4 EEPROM Sectors, 1M SPIFFS)
generic.menu.eesz.4M1M4S.build.flash_size=4M
generic.menu.eesz.4M1M4S.build.flash_size_bytes=0x400000
generic.menu.eesz.4M1M4S.build.flash_ld=eagle.flash.4m1m4s.ld
generic.menu.eesz.4M1M4S.build.spiffs_pagesize=256
generic.menu.eesz.4M1M4S.upload.maximum_size=1044464
generic.menu.eesz.4M1M4S.build.rfcal_addr=0x3FC000
generic.menu.eesz.4M3M4S=4M (4 EEPROM Sectors, 3M SPIFFS)
generic.menu.eesz.4M3M4S.build.flash_size=4M
generic.menu.eesz.4M3M4S.build.flash_size_bytes=0x400000
generic.menu.eesz.4M3M4S.build.flash_ld=eagle.flash.4m3m4s.ld
generic.menu.eesz.4M3M4S.build.spiffs_pagesize=256
generic.menu.eesz.4M3M4S.upload.maximum_size=1044464
generic.menu.eesz.4M3M4S.build.rfcal_addr=0x3FC000
generic.menu.float_support.disabled=Disabled (Recommended)
generic.menu.float_support.disabled.build.float=
generic.menu.float_support.enabled=Enabled
generic.menu.float_support.enabled.build.float=-u _printf_float -u _scanf_float
generic.compiler.cpp.extra_flags=-DNO_GLOBAL_EEPROM -DMQTT_MAX_PACKET_SIZE=400

+ 181
- 0
dist/boards_local_txt.py View File

@ -0,0 +1,181 @@
#!/usr/bin/env python
# adapted boards.txt.py from esp8266/Arduino
# - single board definition, ldscripts
# - portable boards.local.txt for 2.3.0 and up
import os
import argparse
import sys
import collections
# TODO: drop after platform.io supports python 3
if sys.version < (3, 2):
import string
_format = string.Formatter().vformat
def format_map(tmpl, f_map):
return _format(tmpl, None, f_map)
else:
def format_map(tmpl, f_map):
return tmpl.format_map(f_map)
class VersionedSubstitution(collections.MutableMapping):
def __init__(self, substitutions, targets, *args, **kwargs):
self._targets = targets
self._version = None
self._store = substitutions.copy()
self.update(dict(*args, **kwargs))
def set_version(self, version):
self._version = version
def __getitem__(self, key):
if self._version in self._targets:
return self._store[key]
return key
def __setitem__(self, key, value):
self._store[key] = value
def __delitem__(self, key):
del self._store[key]
def __iter__(self):
return iter(self._store)
def __len__(self):
return len(self._store)
BOARDS_LOCAL = {
"global": collections.OrderedDict(
[("menu.float_support", "scanf and printf float support")]
),
"flash_size": collections.OrderedDict(
[
(".menu.{eesz}.1M1S", "1M (1 EEPROM Sector, no SPIFFS)"),
(".menu.{eesz}.1M1S.build.flash_size", "1M"),
(".menu.{eesz}.1M1S.build.flash_size_bytes", "0x100000"),
(".menu.{eesz}.1M1S.build.flash_ld", "eagle.flash.1m0m1s.ld"),
(".menu.{eesz}.1M1S.build.spiffs_pagesize", "256"),
(".menu.{eesz}.1M1S.upload.maximum_size", "1023984"),
(".menu.{eesz}.1M1S.build.rfcal_addr", "0xFC000"),
(".menu.{eesz}.2M4S", "2M (4 EEPROM Sectors, 1M SPIFFS)"),
(".menu.{eesz}.2M4S.build.flash_size", "2M"),
(".menu.{eesz}.2M4S.build.flash_size_bytes", "0x200000"),
(".menu.{eesz}.2M4S.build.flash_ld", "eagle.flash.2m1m4s.ld"),
(".menu.{eesz}.2M4S.build.spiffs_pagesize", "256"),
(".menu.{eesz}.2M4S.upload.maximum_size", "1044464"),
(".menu.{eesz}.2M4S.build.rfcal_addr", "0x1FC000"),
(".menu.{eesz}.4M1M4S", "4M (4 EEPROM Sectors, 1M SPIFFS)"),
(".menu.{eesz}.4M1M4S.build.flash_size", "4M"),
(".menu.{eesz}.4M1M4S.build.flash_size_bytes", "0x400000"),
(".menu.{eesz}.4M1M4S.build.flash_ld", "eagle.flash.4m1m4s.ld"),
(".menu.{eesz}.4M1M4S.build.spiffs_pagesize", "256"),
(".menu.{eesz}.4M1M4S.upload.maximum_size", "1044464"),
(".menu.{eesz}.4M1M4S.build.rfcal_addr", "0x3FC000"),
(".menu.{eesz}.4M3M4S", "4M (4 EEPROM Sectors, 3M SPIFFS)"),
(".menu.{eesz}.4M3M4S.build.flash_size", "4M"),
(".menu.{eesz}.4M3M4S.build.flash_size_bytes", "0x400000"),
(".menu.{eesz}.4M3M4S.build.flash_ld", "eagle.flash.4m3m4s.ld"),
(".menu.{eesz}.4M3M4S.build.spiffs_pagesize", "256"),
(".menu.{eesz}.4M3M4S.upload.maximum_size", "1044464"),
(".menu.{eesz}.4M3M4S.build.rfcal_addr", "0x3FC000"),
]
),
"float_support": collections.OrderedDict(
[
(".menu.float_support.disabled", "Disabled (Recommended)"),
(".menu.float_support.disabled.build.float", ""),
(".menu.float_support.enabled", "Enabled"),
(
".menu.float_support.enabled.build.float",
"-u _printf_float -u _scanf_float",
),
]
),
}
BOARD = "generic"
MENUS = ["flash_size", "float_support"]
CORE_VERSIONS = ["2.3.0", "latest"]
EXTRA_FLAGS = [
(".compiler.cpp.extra_flags", "-DNO_GLOBAL_EEPROM -DMQTT_MAX_PACKET_SIZE=400")
]
SUBSTITUTIONS = VersionedSubstitution(
dict(eesz="FlashSize", wipe="FlashErase", baud="UploadSpeed", vt="VTable"),
["2.3.0"],
)
def generate_boards_txt(args, sub=SUBSTITUTIONS):
versions = args.versions
if args.version:
versions = [args.version]
for version in versions:
sub.set_version(version)
result = ["#version={}\n\n".format(version)]
result.extend("{}={}\n".format(k, v) for k, v in BOARDS_LOCAL["global"].items())
result.append("\n")
# print("{} unused:".format(version, set(BOARDS_LOCAL.keys()) - set(MENUS[version])))
# continue
for menu in MENUS:
section = []
for k, v in BOARDS_LOCAL[menu].items():
k = format_map(k, sub)
section.append(BOARD + "=".join([k, v]))
result.append("\n".join(section))
result.append("\n\n")
if EXTRA_FLAGS:
result.extend(("{}{}={}".format(BOARD, k, v)) for k, v in EXTRA_FLAGS)
f_path = os.path.join(args.directory, version, "boards.local.txt")
f_dir, _ = os.path.split(f_path)
if not os.path.exists(f_dir):
os.makedirs(f_dir)
with open(f_path, "w") as f:
for part in result:
f.write(part)
f.write("\n")
def print_versions(args):
for version in CORE_VERSIONS:
print("- {}".format(version))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--directory", default="arduino_ide")
subparsers = parser.add_subparsers(title="commands")
parser_versions = subparsers.add_parser("versions", help="list supported versions")
parser_versions.set_defaults(command=print_versions)
parser_generate = subparsers.add_parser("generate", help="")
parser_generate.add_argument("version", nargs="?")
parser_generate.set_defaults(command=generate_boards_txt, versions=CORE_VERSIONS)
args = parser.parse_args()
args.command(args)

+ 8
- 0
dist/ld/README.md View File

@ -0,0 +1,8 @@
# ESP8266 linker scripts with additional EEPROM sectors
### Installation
Depending on ESP8266 version, use files from either `Pre 2.5.0` or `latest`
Reference [../arduino_ide/README.md](../arduino_ide/README.md) about ESP8266 package location
Copy all \*.ld files into the `<esp8266-package>/tools/sdk/ld` directory

+ 30
- 0
dist/ld/latest/eagle.flash.1m0m1s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 999KB
fs: 0KB
eeprom: 4KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xf9ff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x402fb000 );
PROVIDE ( _SPIFFS_end = 0x402fb000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "local.eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/latest/eagle.flash.1m0m2s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 995KB
fs: 0KB
eeprom: 8KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xf8ff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x402fa000 );
PROVIDE ( _SPIFFS_end = 0x402fa000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "local.eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/latest/eagle.flash.2m1m4s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 1019KB
fs: 992KB
eeprom: 16KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xfeff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x40300000 );
PROVIDE ( _SPIFFS_end = 0x403f8000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "local.eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/latest/eagle.flash.4m1m4s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 1019KB
fs: 992KB
eeprom: 16KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xfeff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x40500000 );
PROVIDE ( _SPIFFS_end = 0x405f8000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "local.eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/latest/eagle.flash.4m3m4s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 1019KB
fs: 3040KB
eeprom: 16KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xfeff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x40300000 );
PROVIDE ( _SPIFFS_end = 0x405f8000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "local.eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/latest/eagle.flash.512k0m1s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 487KB
fs: 0KB
eeprom: 4KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0x79ff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x4027b000 );
PROVIDE ( _SPIFFS_end = 0x4027b000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "local.eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/pre_2.5.0/eagle.flash.1m0m1s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 999KB
fs: 0KB
eeprom: 4KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xf9ff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x402fb000 );
PROVIDE ( _SPIFFS_end = 0x402fb000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/pre_2.5.0/eagle.flash.1m0m2s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 995KB
fs: 0KB
eeprom: 8KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xf8ff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x402fa000 );
PROVIDE ( _SPIFFS_end = 0x402fa000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "eagle.app.v6.common.ld"

code/eagle.flash.2m1m4s.ld → dist/ld/pre_2.5.0/eagle.flash.2m1m4s.ld View File

@ -1,8 +1,8 @@
/* Flash Split for 2M chips, ~1M SPIFFS, 4 sectors for EEPROM */
/* sketch 1019KB */
/* spiffs 992KB */
/* eeprom 16KB */
/* reserved 16KB */
/*
sketch: 1019KB
fs: 992KB
eeprom: 16KB
*/
MEMORY
{
@ -12,9 +12,19 @@ MEMORY
irom0_0_seg : org = 0x40201010, len = 0xfeff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x40300000 );
PROVIDE ( _SPIFFS_end = 0x403F8000 );
PROVIDE ( _SPIFFS_end = 0x403f8000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );
INCLUDE "../ld/eagle.app.v6.common.ld"
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "eagle.app.v6.common.ld"

code/eagle.flash.4m1m4s.ld → dist/ld/pre_2.5.0/eagle.flash.4m1m4s.ld View File

@ -1,9 +1,8 @@
/* Flash Split for 4M chips, ~1M for SPIFFS, 4 sectors for EEPROM */
/* sketch 1019KB */
/* empty/ota? 2048KB */
/* spiffs 992KB */
/* eeprom 16KB */
/* reserved 16KB */
/*
sketch: 1019KB
fs: 992KB
eeprom: 16KB
*/
MEMORY
{
@ -13,9 +12,19 @@ MEMORY
irom0_0_seg : org = 0x40201010, len = 0xfeff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x40500000 );
PROVIDE ( _SPIFFS_end = 0x405F8000 );
PROVIDE ( _SPIFFS_end = 0x405f8000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );
INCLUDE "../ld/eagle.app.v6.common.ld"
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "eagle.app.v6.common.ld"

code/eagle.flash.4m3m4e.ld → dist/ld/pre_2.5.0/eagle.flash.4m3m4s.ld View File

@ -1,8 +1,8 @@
/* Flash Split for 4M chips, ~3M for SPIFFS, 4 sectors for EEPROM */
/* sketch 1019KB */
/* spiffs 3040KB */
/* eeprom 16KB */
/* reserved 16KB */
/*
sketch: 1019KB
fs: 3040KB
eeprom: 16KB
*/
MEMORY
{
@ -12,9 +12,19 @@ MEMORY
irom0_0_seg : org = 0x40201010, len = 0xfeff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x40300000 );
PROVIDE ( _SPIFFS_end = 0x405F8000 );
PROVIDE ( _SPIFFS_end = 0x405f8000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );
INCLUDE "../ld/eagle.app.v6.common.ld"
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "eagle.app.v6.common.ld"

+ 30
- 0
dist/ld/pre_2.5.0/eagle.flash.512k0m1s.ld View File

@ -0,0 +1,30 @@
/*
sketch: 487KB
fs: 0KB
eeprom: 4KB
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0x79ff0
}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = 0x4027b000 );
PROVIDE ( _SPIFFS_end = 0x4027b000 );
PROVIDE ( _SPIFFS_page = 0x0 );
PROVIDE ( _SPIFFS_block = 0x0 );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE "eagle.app.v6.common.ld"

+ 181
- 0
dist/ldscript_gen.py View File

@ -0,0 +1,181 @@
#!/usr/bin/env python
import os
import argparse
import logging
from collections import defaultdict
from math import trunc
FORMAT = "%(asctime)-15s %(message)s"
log = logging.getLogger("ldscript-get")
logging.basicConfig(format=FORMAT)
# mapping from esp8266/tools/boards.txt.py:
# sketch | reserved | empty | fs | eeprom | rf-cal | sdk-wifi-settings
# ...... | 4112B | ..... | ...... | ...... | 16 KB
IROM0_SPI_FLASH_START = 0x40200000
IROM0_RESERVED_SKETCH_SIZE = 0x1010
IROM0_RESERVED_SDK_SIZE = 0x4000
SIZE = {512: 0x80000, 1024: 0x100000, 2048: 0x200000, 3072: 0x300000, 4096: 0x400000}
# supported sizes
# flash (bytes), fs (bytes), eeprom (sectors)
VARIANTS = [
[SIZE[512], 0, 1],
[SIZE[1024], 0, 1],
[SIZE[1024], 0, 2],
[SIZE[2048], SIZE[1024], 4],
[SIZE[4096], SIZE[1024], 4],
[SIZE[4096], SIZE[3072], 4],
]
def size_suffix(size):
if size >= SIZE[1024] or not size:
size = trunc(size / SIZE[1024])
suffix = "m"
else:
size = trunc(size / 1024)
suffix = "k"
return size, suffix
def variant_name(variant):
tmpl = "{flash_size}{flash_suffix}{fs_size}{fs_suffix}{sectors}s"
flash_size, fs_size, sectors = variant
flash_size, flash_suffix = size_suffix(flash_size)
fs_size, fs_suffix = size_suffix(fs_size)
return tmpl.format(
flash_size=flash_size,
flash_suffix=flash_suffix,
fs_size=fs_size,
fs_suffix=fs_suffix,
sectors=sectors,
)
TEMPLATE = """\
/*
sketch: {size_kb}KB
fs: {fs_size_kb}KB
eeprom: {eeprom_size_kb}KB
*/
MEMORY
{{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = {size:#x}
}}
/*
Provide both _SPIFFS_ and _FS_ to be compatible with 2.3.0...2.6.0+ and
any library that is using old _SPIFFS_...
*/
PROVIDE ( _SPIFFS_start = {fs_start:#x} );
PROVIDE ( _SPIFFS_end = {fs_end:#x} );
PROVIDE ( _SPIFFS_page = {fs_page:#x} );
PROVIDE ( _SPIFFS_block = {fs_block:#x} );
PROVIDE ( _FS_start = _SPIFFS_start );
PROVIDE ( _FS_end = _SPIFFS_end );
PROVIDE ( _FS_page = _SPIFFS_page );
PROVIDE ( _FS_block = _SPIFFS_block );
INCLUDE \"{include}\"
"""
def flash_map(flashsize, fs, sectors):
reserved = IROM0_RESERVED_SKETCH_SIZE
sdk_reserved = IROM0_RESERVED_SDK_SIZE
eeprom_size = 0x1000 * sectors
fs_end = IROM0_SPI_FLASH_START + (flashsize - sdk_reserved - eeprom_size)
fs_page = 0x100
if flashsize <= SIZE[1024]:
max_upload_size = (flashsize - (fs + eeprom_size + sdk_reserved)) - reserved
fs_start = IROM0_SPI_FLASH_START + fs_end - fs
fs_block = 4096
else:
max_upload_size = 1024 * 1024 - reserved
fs_start = IROM0_SPI_FLASH_START + (flashsize - fs)
if fs < SIZE[512]:
fs_block = 4096
else:
fs_block = 8192
if not fs:
fs_block = 0
fs_page = 0
fs_start = fs_end
# Adjust FS_end to be a multiple of the block size
# ref: https://github.com/esp8266/Arduino/pull/5989
if fs:
fs_end = fs_block * ((fs_end - fs_start) // fs_block) + fs_start
result = {
"size": max_upload_size,
"size_kb": int(max_upload_size / 1024),
"eeprom_size_kb": int(eeprom_size / 1024),
"fs_size_kb": int((fs_end - fs_start) / 1024),
"fs_start": fs_start,
"fs_end": fs_end,
"fs_page": fs_page,
"fs_block": fs_block,
}
return result
def render(variant, legacy):
name = variant_name(variant)
name = "eagle.flash.{}.ld".format(name)
ld_include = "local.eagle.app.v6.common.ld"
ld_dir = "ld/latest"
if legacy:
ld_include = "eagle.app.v6.common.ld"
ld_dir = "ld/pre_2.5.0"
path = os.path.join(ld_dir, name)
log.info("render %s (INCLUDE %s)", name, ld_include)
with open(path, "w") as f:
f.write(TEMPLATE.format(include=ld_include, **flash_map(*variant)))
def render_all():
for variant in VARIANTS:
render(variant, True)
render(variant, False)
if __name__ == "__main__":
variants = {variant_name(x): x for x in VARIANTS}
choices = ["all"]
choices.extend(variants.keys())
parser = argparse.ArgumentParser()
parser.add_argument("--legacy", action="store_true", default=False)
parser.add_argument("--verbose", action="store_true", default=False)
parser.add_argument("variant", choices=choices)
args = parser.parse_args()
if args.verbose:
log.setLevel(logging.DEBUG)
if args.variant == "all":
render_all()
else:
render(variants[args.variant], args.legacy)

+ 1
- 0
pre-commit View File

@ -27,6 +27,7 @@ except ImportError:
from fileinput import FileInput
# TODO: drop after platform.io supports python 3
# https://github.com/python/cpython/commit/6cb7b659#diff-78790b53ff259619377058acd4f74672
if sys.version_info[0] < 3:
class FileInputCtx(FileInput):


Loading…
Cancel
Save