Skip to content

Commit

Permalink
Merge branch 'release/v0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Feb 22, 2017
2 parents ecf0ebc + 0924036 commit c3e3a5c
Show file tree
Hide file tree
Showing 35 changed files with 2,092 additions and 78 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ python:
env:
- PLATFORMIO_PROJECT_DIR=examples/arduino-blink
- PLATFORMIO_PROJECT_DIR=examples/arduino-wifiscan
- PLATFORMIO_PROJECT_DIR=examples/espidf-ble-adv
- PLATFORMIO_PROJECT_DIR=examples/espidf-coap-server
- PLATFORMIO_PROJECT_DIR=examples/espidf-hello-world
- PLATFORMIO_PROJECT_DIR=examples/espidf-http-request
- PLATFORMIO_PROJECT_DIR=examples/simba-blink
- PLATFORMIO_PROJECT_DIR=examples/espidf-peripherals-uart
- PLATFORMIO_PROJECT_DIR=examples/espidf-storage-sdcard
- PLATFORMIO_PROJECT_DIR=examples/pumbaa-blink
- PLATFORMIO_PROJECT_DIR=examples/simba-blink

install:
- pip install -U https://github.com/platformio/platformio/archive/develop.zip
Expand Down
6 changes: 5 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ environment:
matrix:
- PLATFORMIO_PROJECT_DIR: "examples/arduino-blink"
- PLATFORMIO_PROJECT_DIR: "examples/arduino-wifiscan"
- PLATFORMIO_PROJECT_DIR: "examples/espidf-ble-adv"
- PLATFORMIO_PROJECT_DIR: "examples/espidf-coap-server"
- PLATFORMIO_PROJECT_DIR: "examples/espidf-hello-world"
- PLATFORMIO_PROJECT_DIR: "examples/espidf-http-request"
- PLATFORMIO_PROJECT_DIR: "examples/simba-blink"
- PLATFORMIO_PROJECT_DIR: "examples/espidf-peripherals-uart"
- PLATFORMIO_PROJECT_DIR: "examples/espidf-storage-sdcard"
- PLATFORMIO_PROJECT_DIR: "examples/pumbaa-blink"
- PLATFORMIO_PROJECT_DIR: "examples/simba-blink"

install:
- cmd: git submodule update --init --recursive
Expand Down
227 changes: 185 additions & 42 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
https://github.com/espressif/esp-idf
"""

from os import listdir
from os.path import isdir, join
from os import listdir, walk
from os.path import basename, isdir, isfile, join

from SCons.Script import DefaultEnvironment

Expand All @@ -35,36 +35,115 @@
"framework-espidf")


def parse_mk(path):
result = {}
variable = None
multi = False
with open(path) as fp:
for line in fp.readlines():
line = line.strip()
if not line or line.startswith("#"):
continue
# remove inline comments
if " # " in line:
line = line[:line.index(" # ")]
if not multi and "=" in line:
variable, line = line.split("=", 1)
if variable.endswith((":", "+")):
variable = variable[:-1]
variable = variable.strip()
line = line.strip()
if not variable or not line:
continue
multi = line.endswith('\\')
if multi:
line = line[:-1].strip()
if variable not in result:
result[variable] = []
result[variable].extend([l.strip() for l in line.split()])
if not multi:
variable = None
return result


def build_component(path):
envsafe = env.Clone()
src_filter = "+<*> -<test> -<tests>"
if isfile(join(path, "component.mk")):
params = parse_mk(join(path, "component.mk"))
if params.get("COMPONENT_PRIV_INCLUDEDIRS"):
inc_dirs = params.get("COMPONENT_PRIV_INCLUDEDIRS")
envsafe.Prepend(
CPPPATH=[join(path, d) for d in inc_dirs])
if params.get("CFLAGS"):
envsafe.Append(CCFLAGS=params.get("CFLAGS"))
if params.get("COMPONENT_OBJS"):
src_filter = "-<*>"
for f in params.get("COMPONENT_OBJS"):
src_filter += " +<%s>" % f.replace(".o", ".c")
elif params.get("COMPONENT_SRCDIRS"):
src_filter = "-<*>"
src_dirs = params.get("COMPONENT_SRCDIRS")
if "." in src_dirs:
src_dirs.remove(".")
src_filter += " +<*.c*>"
for f in src_dirs:
src_filter += " +<%s/*.c*>" % f

return envsafe.BuildLibrary(
join("$BUILD_DIR", "%s" % basename(path)), path,
src_filter=src_filter
)


def build_espidf_bootloader():
envsafe = env.Clone()
envsafe.Append(CPPDEFINES=[("BOOTLOADER_BUILD", 1)])
envsafe.Replace(
CPPDEFINES=["ESP_PLATFORM", ("BOOTLOADER_BUILD", 1)],

LIBPATH=[
join(FRAMEWORK_DIR, "components", "esp32", "ld"),
join(FRAMEWORK_DIR, "components", "esp32", "lib"),
join(FRAMEWORK_DIR, "components", "bootloader", "src", "main")
],

LINKFLAGS=[
"-Os",
"-nostdlib",
"-Wl,-static",
"-u", "call_user_start_cpu0",
"-Wl,-static",
"-Wl,--gc-sections",
"-T", "esp32.bootloader.ld",
"-T", "esp32.rom.ld"
"-T", "esp32.rom.ld",
"-T", "esp32.bootloader.rom.ld"
]
),

envsafe.Append(CCFLAGS=["-fstrict-volatile-bitfields"])
envsafe.Append(
CPPPATH=[
join(FRAMEWORK_DIR, "components", "esp32")
]
)

envsafe.Replace(
LIBS=[
envsafe.BuildLibrary(
join("$BUILD_DIR", "bootloaderSupport"),
join(FRAMEWORK_DIR, "components", "bootloader_support")
),
envsafe.BuildLibrary(
join("$BUILD_DIR", "bootloaderLog"),
join(FRAMEWORK_DIR, "components", "log")
), "gcc"
),
envsafe.BuildLibrary(
join("$BUILD_DIR", "bootloaderSPIFlash"),
join(FRAMEWORK_DIR, "components", "spi_flash"),
src_filter="-<*> +<spi_flash_rom_patch.c>"
),
envsafe.BuildLibrary(
join("$BUILD_DIR", "bootloaderMicroEcc"),
join(FRAMEWORK_DIR, "components", "micro-ecc"),
src_filter="+<*> -<micro-ecc/test>"
),
"rtc", "gcc", "stdc++"
]
)

Expand All @@ -80,27 +159,53 @@ def build_espidf_bootloader():
env.Prepend(
CPPPATH=[
join("$PROJECTSRC_DIR"),
join(FRAMEWORK_DIR, "components", "nghttp", "include"),
join(FRAMEWORK_DIR, "components", "nghttp", "port", "include"),
join(FRAMEWORK_DIR, "components", "xtensa-debug-module", "include"),
join(FRAMEWORK_DIR, "components", "app_update", "include"),
join(FRAMEWORK_DIR, "components", "bootloader_support", "include"),
join(FRAMEWORK_DIR, "components",
"bootloader_support", "include_priv"),
join(FRAMEWORK_DIR, "components", "bt", "include"),
join(FRAMEWORK_DIR, "components", "coap", "port", "include"),
join(FRAMEWORK_DIR, "components", "coap", "port", "include", "coap"),
join(FRAMEWORK_DIR, "components", "coap", "libcoap", "include"),
join(FRAMEWORK_DIR, "components", "coap",
"libcoap", "include", "coap"),
join(FRAMEWORK_DIR, "components", "cxx", "include"),
join(FRAMEWORK_DIR, "components", "driver", "include"),
join(FRAMEWORK_DIR, "components", "driver", "include", "driver"),
join(FRAMEWORK_DIR, "components", "esp32", "include"),
join(FRAMEWORK_DIR, "components", "ethernet", "include"),
join(FRAMEWORK_DIR, "components", "expat", "include", "expat"),
join(FRAMEWORK_DIR, "components", "expat", "port", "include"),
join(FRAMEWORK_DIR, "components", "fatfs", "src"),
join(FRAMEWORK_DIR, "components", "freertos", "include"),
join(FRAMEWORK_DIR, "components", "freertos", "include", "freertos"),
join(FRAMEWORK_DIR, "components", "json", "include"),
join(FRAMEWORK_DIR, "components", "json", "port", "include"),
join(FRAMEWORK_DIR, "components", "log", "include"),
join(FRAMEWORK_DIR, "components", "newlib", "include"),
join(FRAMEWORK_DIR, "components", "nvs_flash", "include"),
join(FRAMEWORK_DIR, "components", "spi_flash", "include"),
join(FRAMEWORK_DIR, "components", "tcpip_adapter", "include"),
join(FRAMEWORK_DIR, "components", "lwip", "include", "lwip"),
join(FRAMEWORK_DIR, "components", "lwip", "include", "lwip", "port"),
join(FRAMEWORK_DIR, "components", "lwip", "include", "lwip", "posix"),
join(FRAMEWORK_DIR, "components", "expat", "include", "expat"),
join(FRAMEWORK_DIR, "components", "expat", "port", "include"),
join(FRAMEWORK_DIR, "components", "json", "include"),
join(FRAMEWORK_DIR, "components", "json", "port", "include"),
join(FRAMEWORK_DIR, "components", "lwip", "apps", "ping"),
join(FRAMEWORK_DIR, "components", "mbedtls", "port", "include"),
join(FRAMEWORK_DIR, "components", "mbedtls", "include"),
join(FRAMEWORK_DIR, "components", "mbedtls", "port", "include")
join(FRAMEWORK_DIR, "components", "mdns", "include"),
join(FRAMEWORK_DIR, "components", "micro-ecc", "micro-ecc"),
join(FRAMEWORK_DIR, "components", "newlib", "include"),
join(FRAMEWORK_DIR, "components", "newlib", "platform_include"),
join(FRAMEWORK_DIR, "components", "nghttp", "include"),
join(FRAMEWORK_DIR, "components", "nghttp", "port", "include"),
join(FRAMEWORK_DIR, "components", "nvs_flash", "include"),
join(FRAMEWORK_DIR, "components", "openssl", "include"),
join(FRAMEWORK_DIR, "components", "openssl", "include", "internal"),
join(FRAMEWORK_DIR, "components", "openssl", "include", "platform"),
join(FRAMEWORK_DIR, "components", "openssl", "include", "openssl"),
join(FRAMEWORK_DIR, "components", "sdmmc", "include"),
join(FRAMEWORK_DIR, "components", "spi_flash", "include"),
join(FRAMEWORK_DIR, "components", "tcpip_adapter", "include"),
join(FRAMEWORK_DIR, "components", "ulp", "include"),
join(FRAMEWORK_DIR, "components", "vfs", "include"),
join(FRAMEWORK_DIR, "components", "wpa_supplicant", "include"),
join(FRAMEWORK_DIR, "components", "wpa_supplicant", "port", "include")
],

LIBPATH=[
Expand All @@ -113,25 +218,51 @@ def build_espidf_bootloader():
],

LIBS=[
"hal", "crypto", "core", "net80211", "phy", "rtc", "pp", "wpa",
"smartconfig", "btdm_app", "m", "c", "gcc"
"btdm_app", "hal", "coexist", "core", "net80211", "phy", "rtc", "pp",
"wpa", "wpa2", "wps", "smartconfig", "m", "c", "gcc", "stdc++"
]
)

env.Append(
LIBSOURCE_DIRS=[
join(FRAMEWORK_DIR, "libraries")
for root, dirs, _ in walk(join(
FRAMEWORK_DIR, "components", "bt", "bluedroid")):
for d in dirs:
if (d == "include"):
env.Append(CPPPATH=[join(root, d)])


env.Prepend(
CFLAGS=["-Wno-old-style-declaration"],

CPPDEFINES=[
"WITH_POSIX",
("IDF_VER", '\\"%s\\"' %
platform.get_package_version("framework-espidf"))
],

CCFLAGS=[
"-Wall",
"-Werror=all",
"-Wno-error=deprecated-declarations",
"-Wextra",
"-Wno-unused-parameter",
"-Wno-sign-compare",
"-Wno-error=unused-function"
],

LIBSOURCE_DIRS=[join(FRAMEWORK_DIR, "libraries")]
)

env.Append(
LINKFLAGS=[
"-u", "__cxa_guard_dummy",
"-T", "esp32.common.ld",
"-T", "esp32.rom.ld",
"-T", "esp32.peripherals.ld"
],

UPLOADERFLAGS=[
"0x1000", join("$BUILD_DIR", "bootloader.bin"),
"0x4000", join("$BUILD_DIR", "partitions_table.bin"),
"0x8000", join("$BUILD_DIR", "partitions_table.bin"),
"0x10000"
]
)
Expand All @@ -142,14 +273,14 @@ def build_espidf_bootloader():

partition_table = env.Command(
join("$BUILD_DIR", "partitions_table.bin"),
join(FRAMEWORK_DIR, "components",
"partition_table", "partitions_singleapp.csv"),
'"$PYTHONEXE" "%s" -q $SOURCE $TARGET' % join(
FRAMEWORK_DIR, "components", "partition_table", "gen_esp32part.py")
)
join(FRAMEWORK_DIR, "components", "partition_table",
"partitions_singleapp.csv"),
env.VerboseAction('"$PYTHONEXE" "%s" -q $SOURCE $TARGET' % join(
FRAMEWORK_DIR, "components", "partition_table", "gen_esp32part.py"),
"Generating partitions $TARGET"))

env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)

env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)

#
# Generate linker script
Expand All @@ -158,8 +289,9 @@ def build_espidf_bootloader():
linker_script = env.Command(
join("$BUILD_DIR", "esp32_out.ld"),
join(FRAMEWORK_DIR, "components", "esp32", "ld", "esp32.ld"),
"$CC -I$PROJECTSRC_DIR -C -P -x c -E $SOURCE -o $TARGET"
)
env.VerboseAction(
"$CC -I$PROJECTSRC_DIR -C -P -x c -E $SOURCE -o $TARGET",
"Generating LD script $TARGET"))

env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)

Expand All @@ -177,16 +309,27 @@ def build_espidf_bootloader():
libs = []

ignore_dirs = (
"bootloader", "esptool_py", "idf_test", "newlib", "partition_table")
"bootloader",
"bootloader_support",
"esptool_py",
"idf_test",
"partition_table",
"nghttp",
"spi_flash"
)

for d in listdir(join(FRAMEWORK_DIR, "components")):
if d in ignore_dirs:
continue
if isdir(join(FRAMEWORK_DIR, "components", d)):
libs.append(env.BuildLibrary(
join("$BUILD_DIR", "%s" % d),
join(FRAMEWORK_DIR, "components", d),
src_filter="+<*> -<test>"
))
component_dir = join(FRAMEWORK_DIR, "components", d)
if isdir(component_dir):
libs.append(build_component(component_dir))


libs.append(env.BuildLibrary(
join("$BUILD_DIR", "spi_flash"),
join(FRAMEWORK_DIR, "components", "spi_flash"),
src_filter="+<*> -<test>"
))

env.Prepend(LIBS=libs)
2 changes: 0 additions & 2 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def _get_board_f_flash(env):
"-g3",
"-nostdlib",
"-Wpointer-arith",
"-Wno-error=unused-function",
"-Wno-error=unused-but-set-variable",
"-Wno-error=unused-variable",
"-mlongcalls",
Expand Down Expand Up @@ -162,7 +161,6 @@ def _get_board_f_flash(env):
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")])
env.AlwaysBuild(target_upload)


#
# Default targets
#
Expand Down
3 changes: 3 additions & 0 deletions examples/espidf-ble-adv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pioenvs
.clang_complete
.gcc-flags.json
Loading

0 comments on commit c3e3a5c

Please sign in to comment.