Update build script for espidf framework
This commit is contained in:
@@ -20,7 +20,8 @@ Espressif IoT Development Framework for ESP32 MCU
|
||||
https://github.com/espressif/esp-idf
|
||||
"""
|
||||
|
||||
from os import listdir
|
||||
import sys
|
||||
from os import listdir, makedirs
|
||||
from os.path import isdir, join
|
||||
|
||||
from SCons.Script import DefaultEnvironment
|
||||
@@ -37,20 +38,45 @@ assert isdir(FRAMEWORK_DIR)
|
||||
|
||||
|
||||
def generate_ld_script():
|
||||
exec_command([
|
||||
if not isdir(env.subst("$BUILD_DIR")):
|
||||
makedirs(env.subst("$BUILD_DIR"))
|
||||
result = exec_command([
|
||||
join(platform.get_package_dir("toolchain-xtensa32")
|
||||
or "", "bin", env.subst("$CC")),
|
||||
"-I", join(env.subst("$ESPIDF_DIR"), "config"),
|
||||
"-I", env.subst("$PROJECTSRC_DIR"),
|
||||
"-C", "-P", "-x", "c", "-E",
|
||||
join(env.subst("$ESPIDF_DIR"), "components",
|
||||
"esp32", "ld", "esp32.ld"),
|
||||
"-o", join(env.subst("$ESPIDF_DIR"), "components",
|
||||
"esp32", "ld", "esp32_out.ld")
|
||||
"-o", join(env.subst("$BUILD_DIR"), "esp32_out.ld")
|
||||
])
|
||||
|
||||
if result['returncode'] != 0:
|
||||
sys.stderr.write(
|
||||
"Cannot create linker script! %s" % result['err'])
|
||||
env.Exit(1)
|
||||
|
||||
|
||||
def generate_ptable():
|
||||
if not isdir(env.subst("$BUILD_DIR")):
|
||||
makedirs(env.subst("$BUILD_DIR"))
|
||||
|
||||
result = exec_command([
|
||||
env.subst("$PYTHONEXE"),
|
||||
join(env.subst("$ESPIDF_DIR"), "components",
|
||||
"partition_table", "gen_esp32part.py"),
|
||||
"-q", join(env.subst("$ESPIDF_DIR"), "components",
|
||||
"partition_table", "partitions_singleapp.csv"),
|
||||
join(env.subst("$BUILD_DIR"), "partitions_table.bin"),
|
||||
])
|
||||
|
||||
if result['returncode'] != 0:
|
||||
sys.stderr.write(
|
||||
"Cannot create partition table! %s" % result['err'])
|
||||
env.Exit(1)
|
||||
|
||||
env.Prepend(
|
||||
CPPPATH=[
|
||||
join(FRAMEWORK_DIR, "config"),
|
||||
join("$PROJECTSRC_DIR"),
|
||||
join(FRAMEWORK_DIR, "components", "nghttp", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "nghttp", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "components", "bt", "include"),
|
||||
@@ -76,10 +102,11 @@ env.Prepend(
|
||||
|
||||
LIBPATH=[
|
||||
join(FRAMEWORK_DIR, "components", "esp32"),
|
||||
join(FRAMEWORK_DIR, "components", "esp32", "ld"),
|
||||
join(FRAMEWORK_DIR, "components", "esp32", "lib"),
|
||||
join(FRAMEWORK_DIR, "components", "bt", "lib"),
|
||||
join(FRAMEWORK_DIR, "components", "newlib", "lib"),
|
||||
join(FRAMEWORK_DIR, "components", "esp32", "ld")
|
||||
"$BUILD_DIR"
|
||||
],
|
||||
|
||||
LIBS=[
|
||||
@@ -105,6 +132,7 @@ env.Append(
|
||||
#
|
||||
|
||||
generate_ld_script()
|
||||
generate_ptable()
|
||||
|
||||
#
|
||||
# Target: Build Core Library
|
||||
@@ -112,12 +140,15 @@ generate_ld_script()
|
||||
|
||||
libs = []
|
||||
|
||||
ignore_dirs = (
|
||||
"bootloader", "esptool_py", "idf_test", "newlib", "partition_table")
|
||||
|
||||
for d in listdir(join(FRAMEWORK_DIR, "components")):
|
||||
if d == "bootloader":
|
||||
if d in ignore_dirs:
|
||||
continue
|
||||
if isdir(join(FRAMEWORK_DIR, "components", d)):
|
||||
libs.append(env.BuildLibrary(
|
||||
join("$BUILD_DIR", "IDFComponents_%s" % d),
|
||||
join("$BUILD_DIR", "%s" % d),
|
||||
join(FRAMEWORK_DIR, "components", d),
|
||||
src_filter="+<*> -<test>"
|
||||
))
|
||||
|
||||
+10
-23
@@ -88,7 +88,8 @@ env.Replace(
|
||||
CFLAGS=["-std=gnu99"],
|
||||
|
||||
CCFLAGS=[
|
||||
"-Os", # optimize for size
|
||||
"-Og",
|
||||
"-g3",
|
||||
"-nostdlib",
|
||||
"-Wpointer-arith",
|
||||
"-Wno-error=unused-function",
|
||||
@@ -102,7 +103,8 @@ env.Replace(
|
||||
CXXFLAGS=[
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions",
|
||||
"-std=gnu++11"
|
||||
"-std=gnu++11",
|
||||
"-fstrict-volatile-bitfields"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
@@ -114,11 +116,9 @@ env.Replace(
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-nostdlib",
|
||||
"-Wl,-static",
|
||||
"-u", "call_user_start_cpu0",
|
||||
"-Wl,-static",
|
||||
"-Wl,--undefined=uxTopUsedPriority",
|
||||
"-Wl,--gc-sections"
|
||||
],
|
||||
@@ -167,21 +167,9 @@ if env.subst("$PIOFRAMEWORK") == "espidf":
|
||||
env.Append(
|
||||
UPLOADERFLAGS=[
|
||||
"0x1000", join("$BUILD_DIR", "bootloader.bin"),
|
||||
"0x4000", join("$BUILD_DIR", "partitions_singleapp.bin"),
|
||||
"0x4000", join("$BUILD_DIR", "partitions_table.bin"),
|
||||
"0x10000"
|
||||
],
|
||||
|
||||
PTABLE_SCRIPT=join("$ESPIDF_DIR", "components",
|
||||
"partition_table", "gen_esp32part.py"),
|
||||
|
||||
PTABLE_FLAGS=[
|
||||
"-q", join("$ESPIDF_DIR", "components",
|
||||
"partition_table", "partitions_singleapp.csv"),
|
||||
join(env.subst("$BUILD_DIR"), "partitions_singleapp.bin")
|
||||
|
||||
],
|
||||
|
||||
PTABLE_CMD='"$PYTHONEXE" "$PTABLE_SCRIPT" $PTABLE_FLAGS'
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -227,12 +215,11 @@ if "PIOFRAMEWORK" in env:
|
||||
target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
if "espidf" in env.subst("$PIOFRAMEWORK"):
|
||||
target_buildboot = env.ElfToBin(
|
||||
target_boot = env.ElfToBin(
|
||||
join("$BUILD_DIR", "bootloader"), build_espidf_bootloader())
|
||||
target_buildprog = env.Alias(
|
||||
"buildprog", [target_firm, target_buildboot], "$PTABLE_CMD")
|
||||
else:
|
||||
target_buildprog = env.Alias("buildprog", target_firm, target_firm)
|
||||
env.Depends(target_firm, target_boot)
|
||||
|
||||
target_buildprog = env.Alias("buildprog", target_firm, target_firm)
|
||||
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user