From 4dcef8930199f19f1bd0f36563e18c7c0c7df07a Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Fri, 2 Oct 2015 16:11:00 +0300 Subject: [PATCH] Update espressif platform // Resolve #296, #297 --- platformio/boards/espressif.json | 2 +- platformio/builder/scripts/espressif.py | 91 ++++++++++++++----- .../builder/scripts/frameworks/arduino.py | 2 +- 3 files changed, 69 insertions(+), 26 deletions(-) diff --git a/platformio/boards/espressif.json b/platformio/boards/espressif.json index 100517a11f..e9017d2ed6 100644 --- a/platformio/boards/espressif.json +++ b/platformio/boards/espressif.json @@ -3,7 +3,7 @@ "build": { "core": "esp8266", "extra_flags": "-DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DESP8266", - "f_cpu": "80000000L", + "f_cpu": "40000000L", "ldscript": "esp8266.flash.512k.ld", "mcu": "esp8266", "variant": "generic" diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 09c7196b79..d713a8975b 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -31,7 +31,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 ASPPFLAGS=["-x", "assembler-with-cpp"], CFLAGS=[ - "-std=c99", + "-std=gnu99", "-Wpointer-arith", "-Wno-implicit-function-declaration", "-Wl,-EL", @@ -76,9 +76,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 "-cb", "$UPLOAD_SPEED", "-cp", "$UPLOAD_PORT", "-ca", "0x00000", - "-cf", "${SOURCES[0]}", - "-ca", "0x40000" if "FRAMEWORK" not in env else "0x10000", - "-cf", "${SOURCES[1]}" + "-cf", "$SOURCE" ], UPLOADCMD='$UPLOADER $UPLOADERFLAGS', @@ -86,23 +84,35 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 PROGSUFFIX=".elf" ) +if "FRAMEWORK" in env: + env.Append( + LINKFLAGS=[ + "-Wl,-wrap,system_restart_local", + "-Wl,-wrap,register_chipv6_phy" + ] + ) + env.Append( BUILDERS=dict( ElfToBin=Builder( action=" ".join([ "$UPLOADER", + "-eo", join("$PLATFORMFW_DIR", "bootloaders", + "eboot", "eboot.elf"), + "-bo", "$TARGET", + "-bm", "dio", + "-bf", "${BOARD_OPTIONS['build']['f_cpu'][:2]}", + "-bz", str(int(env.get("BOARD_OPTIONS", {}).get( + "upload", {}).get("maximum_size") / 1024)) + "K", + "-bs", ".text", + "-bp", "4096", + "-ec", "-eo", "$SOURCES", - "-bo", "${TARGETS[0]}", - "-bm", "qio", - "-bf", "40", - "-bz", "512K", + "-bs", ".irom0.text", "-bs", ".text", "-bs", ".data", "-bs", ".rodata", - "-bc", "-ec", - "-eo", "$SOURCES", - "-es", ".irom0.text", "${TARGETS[1]}", - "-ec", "-v" + "-bc", "-ec" ]), suffix=".bin" ) @@ -119,13 +129,43 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 join("$PIOPACKAGES_DIR", "sdk-esp8266", "include"), "$PROJECTSRC_DIR" ], - LIBPATH=[join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib")] + LIBPATH=[join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib")], + BUILDERS=dict( + ElfToBin=Builder( + action=" ".join([ + "$UPLOADER", + "-eo", "$SOURCES", + "-bo", "${TARGETS[0]}", + "-bm", "qio", + "-bf", "40", + "-bz", "512K", + "-bs", ".text", + "-bs", ".data", + "-bs", ".rodata", + "-bc", "-ec", + "-eo", "$SOURCES", + "-es", ".irom0.text", "${TARGETS[1]}", + "-ec", "-v" + ]), + suffix=".bin" + ) + ) ) env.Replace( LDSCRIPT_PATH=join( "$PIOPACKAGES_DIR", "sdk-esp8266", "ld", "eagle.app.v6.ld"), LIBS=["c", "gcc", "phy", "pp", "net80211", "lwip", "wpa", "main", - "json", "upgrade", "smartconfig", "pwm", "at", "ssl"] + "json", "upgrade", "smartconfig", "pwm", "at", "ssl"], + UPLOADERFLAGS=[ + "-vv", + "-cd", "ck", + "-cb", "$UPLOAD_SPEED", + "-cp", "$UPLOAD_PORT", + "-ca", "0x00000", + "-cf", "${SOURCES[0]}", + "-ca", "0x40000", + "-cf", "${SOURCES[1]}" + ] ) # @@ -139,17 +179,20 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 # if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = [ - join("$BUILD_DIR", "firmware_00000.bin"), - join("$BUILD_DIR", "firmware_%s.bin" % - ("40000" if "FRAMEWORK" not in env else "10000")) - ] + if "FRAMEWORK" not in env: + target_firm = [ + join("$BUILD_DIR", "firmware_00000.bin"), + join("$BUILD_DIR", "firmware_40000.bin") + ] + else: + target_firm = join("$BUILD_DIR", "firmware.bin") else: - target_firm = env.ElfToBin( - [join("$BUILD_DIR", "firmware_00000"), - join("$BUILD_DIR", "firmware_%s" % - ("40000" if "FRAMEWORK" not in env else "10000"))], target_elf) - + if "FRAMEWORK" not in env: + target_firm = env.ElfToBin( + [join("$BUILD_DIR", "firmware_00000"), + join("$BUILD_DIR", "firmware_40000")], target_elf) + else: + target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) # # Target: Print binary size diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index 8d321880a9..69e00df3db 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -47,7 +47,7 @@ CPPPATH=[join("$PLATFORMFW_DIR", "sdk", "include")], LIBPATH=[join("$PLATFORMFW_DIR", "sdk", "lib")], LIBS=["smartconfig", "pp", "main", "wpa", "lwip", - "net80211", "phy", "hal", "gcc", "m"] + "net80211", "wps", "crypto", "phy", "hal", "gcc", "m"] ) env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR)