2017-01-28 13:19:56 +01:00
|
|
|
# Copyright 2014-present PlatformIO <contact@platformio.org>
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Arduino
|
|
|
|
|
|
|
|
Arduino Wiring-based Framework allows writing cross-platform software to
|
|
|
|
control devices attached to a wide range of Arduino boards to create all
|
|
|
|
kinds of creative coding, interactive objects, spaces or physical experiences.
|
|
|
|
|
|
|
|
http://arduino.cc/en/Reference/HomePage
|
|
|
|
"""
|
|
|
|
|
2017-01-28 17:15:46 +01:00
|
|
|
# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py
|
|
|
|
|
2018-05-31 19:19:10 +02:00
|
|
|
from os.path import abspath, isdir, isfile, join
|
2017-01-28 13:19:56 +01:00
|
|
|
|
|
|
|
from SCons.Script import DefaultEnvironment
|
|
|
|
|
|
|
|
env = DefaultEnvironment()
|
|
|
|
platform = env.PioPlatform()
|
|
|
|
|
|
|
|
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
|
|
|
|
assert isdir(FRAMEWORK_DIR)
|
|
|
|
|
2018-08-14 12:01:07 +02:00
|
|
|
env.Append(
|
2020-10-16 20:58:05 +02:00
|
|
|
ASFLAGS=["-x", "assembler-with-cpp", "-mlongcalls"],
|
2017-01-28 13:19:56 +01:00
|
|
|
|
2018-08-14 12:01:07 +02:00
|
|
|
CFLAGS=[
|
|
|
|
"-std=gnu99",
|
|
|
|
"-Wno-old-style-declaration"
|
|
|
|
],
|
2017-01-28 13:19:56 +01:00
|
|
|
|
|
|
|
CCFLAGS=[
|
2018-08-14 12:01:07 +02:00
|
|
|
"-Os",
|
2019-03-03 15:51:59 +01:00
|
|
|
"-g3",
|
2018-08-14 12:01:07 +02:00
|
|
|
"-Wall",
|
|
|
|
"-nostdlib",
|
|
|
|
"-Wpointer-arith",
|
|
|
|
"-Wno-error=unused-but-set-variable",
|
|
|
|
"-Wno-error=unused-variable",
|
|
|
|
"-mlongcalls",
|
|
|
|
"-ffunction-sections",
|
|
|
|
"-fdata-sections",
|
|
|
|
"-fstrict-volatile-bitfields",
|
2017-01-28 13:19:56 +01:00
|
|
|
"-Wno-error=deprecated-declarations",
|
2017-11-26 01:22:42 +01:00
|
|
|
"-Wno-error=unused-function",
|
2017-01-28 13:19:56 +01:00
|
|
|
"-Wno-unused-parameter",
|
2017-11-26 01:22:42 +01:00
|
|
|
"-Wno-sign-compare",
|
2018-04-07 08:45:18 +02:00
|
|
|
"-fstack-protector",
|
2019-04-25 11:02:21 +02:00
|
|
|
"-fexceptions",
|
|
|
|
"-Werror=reorder"
|
2017-01-28 13:19:56 +01:00
|
|
|
],
|
|
|
|
|
2018-08-14 12:01:07 +02:00
|
|
|
CXXFLAGS=[
|
|
|
|
"-fno-rtti",
|
|
|
|
"-fno-exceptions",
|
|
|
|
"-std=gnu++11"
|
|
|
|
],
|
|
|
|
|
|
|
|
LINKFLAGS=[
|
|
|
|
"-nostdlib",
|
|
|
|
"-Wl,-static",
|
|
|
|
"-u", "call_user_start_cpu0",
|
|
|
|
"-Wl,--undefined=uxTopUsedPriority",
|
|
|
|
"-Wl,--gc-sections",
|
|
|
|
"-Wl,-EL",
|
2020-01-20 21:07:04 +01:00
|
|
|
"-T", "esp32.project.ld",
|
2018-08-14 12:01:07 +02:00
|
|
|
"-T", "esp32.rom.ld",
|
|
|
|
"-T", "esp32.peripherals.ld",
|
2019-05-09 12:07:49 +02:00
|
|
|
"-T", "esp32.rom.libgcc.ld",
|
2018-08-14 12:01:07 +02:00
|
|
|
"-T", "esp32.rom.spiram_incompatible_fns.ld",
|
|
|
|
"-u", "ld_include_panic_highint_hdl",
|
|
|
|
"-u", "__cxa_guard_dummy",
|
|
|
|
"-u", "__cxx_fatal_exception"
|
|
|
|
],
|
|
|
|
|
|
|
|
CPPDEFINES=[
|
|
|
|
"ESP32",
|
|
|
|
"ESP_PLATFORM",
|
|
|
|
("F_CPU", "$BOARD_F_CPU"),
|
|
|
|
"HAVE_CONFIG_H",
|
|
|
|
("MBEDTLS_CONFIG_FILE", '\\"mbedtls/esp_config.h\\"'),
|
|
|
|
("ARDUINO", 10805),
|
|
|
|
"ARDUINO_ARCH_ESP32",
|
|
|
|
("ARDUINO_VARIANT", '\\"%s\\"' % env.BoardConfig().get("build.variant").replace('"', "")),
|
|
|
|
("ARDUINO_BOARD", '\\"%s\\"' % env.BoardConfig().get("name").replace('"', ""))
|
|
|
|
],
|
|
|
|
|
2017-01-28 13:19:56 +01:00
|
|
|
CPPPATH=[
|
2019-05-12 17:52:23 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "config"),
|
2017-08-01 07:51:04 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "app_trace"),
|
2017-04-04 00:26:23 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "app_update"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "asio"),
|
2017-03-11 07:15:44 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "bootloader_support"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "bt"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "coap"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "console"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "driver"),
|
2020-01-20 21:07:04 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "efuse"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp-tls"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32"),
|
2017-09-12 08:40:52 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_adc_cal"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_event"),
|
2018-06-27 09:01:06 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_http_client"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_http_server"),
|
2018-09-21 08:39:36 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_https_ota"),
|
2020-01-20 21:07:04 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_https_server"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_ringbuf"),
|
2020-01-20 21:07:04 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "espcoredump"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "ethernet"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "expat"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "fatfs"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "freemodbus"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "freertos"),
|
2017-08-01 07:51:04 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "heap"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "idf_test"),
|
2017-04-04 00:26:23 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "jsmn"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "json"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "libsodium"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "log"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "lwip"),
|
2017-02-06 14:17:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mbedtls"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mdns"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "micro-ecc"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mqtt"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nghttp"),
|
2020-01-20 21:07:04 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nimble"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nvs_flash"),
|
2017-04-04 00:26:23 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "openssl"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "protobuf-c"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "protocomm"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "pthread"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "sdmmc"),
|
2018-06-27 09:01:06 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "smartconfig_ack"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "soc"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "spi_flash"),
|
2017-09-12 08:40:52 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "spiffs"),
|
2018-09-21 08:39:36 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "tcp_transport"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "tcpip_adapter"),
|
2017-04-04 00:26:23 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "ulp"),
|
2020-01-20 21:07:04 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "unity"),
|
2017-04-04 00:26:23 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "vfs"),
|
2017-05-06 19:29:12 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wear_levelling"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wifi_provisioning"),
|
2018-01-17 23:56:58 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"),
|
2018-11-26 23:22:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "xtensa-debug-module"),
|
2019-07-17 09:09:43 +02:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp-face"),
|
2018-12-15 17:38:34 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32-camera"),
|
2019-01-09 19:31:46 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp-face"),
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "include", "fb_gfx"),
|
2017-01-28 13:19:56 +01:00
|
|
|
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
|
|
|
|
],
|
2018-08-14 12:01:07 +02:00
|
|
|
|
2017-01-28 13:19:56 +01:00
|
|
|
LIBPATH=[
|
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "lib"),
|
2017-02-06 14:17:11 +01:00
|
|
|
join(FRAMEWORK_DIR, "tools", "sdk", "ld")
|
2017-01-28 13:19:56 +01:00
|
|
|
],
|
2018-08-14 12:01:07 +02:00
|
|
|
|
2017-01-28 13:19:56 +01:00
|
|
|
LIBS=[
|
2020-01-20 21:07:04 +01:00
|
|
|
"-lgcc", "-lfreertos", "-lmesh", "-lod", "-lwear_levelling", "-lfb_gfx", "-lesp_adc_cal", "-lc_nano", "-lesp32", "-ldriver", "-lhal", "-ljsmn", "-lsmartconfig", "-lesp_http_server", "-lprotocomm", "-lface_recognition", "-lespnow", "-ltcpip_adapter", "-lface_detection", "-lunity", "-lc", "-llibsodium", "-lesp_http_client", "-lapp_update", "-lnewlib", "-lcxx", "-ltcp_transport", "-lm", "-lefuse", "-lopenssl", "-lwifi_provisioning", "-lespcoredump", "-llog", "-lmbedtls", "-lesp_ringbuf", "-lwps", "-lnet80211", "-lmqtt", "-lesp_https_server", "-lapp_trace", "-lesp_event", "-lesp32-camera", "-lsoc", "-lheap", "-llwip", "-lwpa", "-lrtc", "-lxtensa-debug-module", "-lspi_flash", "-lphy", "-lfr", "-lconsole", "-lcoap", "-lbtdm_app", "-lsdmmc", "-lfd", "-lmicro-ecc", "-ljson", "-lcore", "-lprotobuf-c", "-lethernet", "-lspiffs", "-lnvs_flash", "-lwpa_supplicant", "-lvfs", "-lasio", "-lwpa2", "-lpp", "-lbootloader_support", "-limage_util", "-ldl_lib", "-lulp", "-lnghttp", "-lpthread", "-lfreemodbus", "-lexpat", "-lfatfs", "-lsmartconfig_ack", "-lmdns", "-lcoexist", "-lesp-tls", "-lesp_https_ota", "-lbt", "-lstdc++"
|
2018-08-14 12:01:07 +02:00
|
|
|
],
|
2017-11-25 01:49:24 +01:00
|
|
|
|
2017-01-28 13:19:56 +01:00
|
|
|
LIBSOURCE_DIRS=[
|
|
|
|
join(FRAMEWORK_DIR, "libraries")
|
|
|
|
],
|
|
|
|
|
2018-05-11 01:30:00 +02:00
|
|
|
FLASH_EXTRA_IMAGES=[
|
|
|
|
("0x1000", join(FRAMEWORK_DIR, "tools", "sdk", "bin", "bootloader_${BOARD_FLASH_MODE}_${__get_board_f_flash(__env__)}.bin")),
|
|
|
|
("0x8000", join(env.subst("$BUILD_DIR"), "partitions.bin")),
|
|
|
|
("0xe000", join(FRAMEWORK_DIR, "tools", "partitions", "boot_app0.bin"))
|
2017-01-28 13:19:56 +01:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2020-05-04 15:47:14 +02:00
|
|
|
if not env.BoardConfig().get("build.ldscript", ""):
|
|
|
|
env.Replace(LDSCRIPT_PATH=env.BoardConfig().get("build.arduino.ldscript", ""))
|
|
|
|
|
2017-01-28 13:19:56 +01:00
|
|
|
#
|
|
|
|
# Target: Build Core Library
|
|
|
|
#
|
|
|
|
|
|
|
|
libs = []
|
|
|
|
|
|
|
|
if "build.variant" in env.BoardConfig():
|
|
|
|
env.Append(
|
|
|
|
CPPPATH=[
|
|
|
|
join(FRAMEWORK_DIR, "variants",
|
|
|
|
env.BoardConfig().get("build.variant"))
|
|
|
|
]
|
|
|
|
)
|
|
|
|
libs.append(env.BuildLibrary(
|
|
|
|
join("$BUILD_DIR", "FrameworkArduinoVariant"),
|
|
|
|
join(FRAMEWORK_DIR, "variants", env.BoardConfig().get("build.variant"))
|
|
|
|
))
|
|
|
|
|
|
|
|
envsafe = env.Clone()
|
|
|
|
|
|
|
|
libs.append(envsafe.BuildLibrary(
|
|
|
|
join("$BUILD_DIR", "FrameworkArduino"),
|
|
|
|
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
|
|
|
|
))
|
|
|
|
|
2018-02-08 14:56:13 +01:00
|
|
|
env.Prepend(LIBS=libs)
|
2017-02-10 18:33:55 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Generate partition table
|
|
|
|
#
|
2018-05-07 22:47:22 +02:00
|
|
|
|
2018-05-26 07:49:22 +02:00
|
|
|
fwpartitions_dir = join(FRAMEWORK_DIR, "tools", "partitions")
|
2019-01-10 15:53:51 +01:00
|
|
|
partitions_csv = env.BoardConfig().get("build.partitions", "default.csv")
|
2018-05-07 22:47:22 +02:00
|
|
|
env.Replace(
|
2018-05-31 19:19:10 +02:00
|
|
|
PARTITIONS_TABLE_CSV=abspath(
|
|
|
|
join(fwpartitions_dir, partitions_csv) if isfile(
|
|
|
|
join(fwpartitions_dir, partitions_csv)) else partitions_csv))
|
2018-05-07 22:47:22 +02:00
|
|
|
|
2017-02-10 18:33:55 +01:00
|
|
|
partition_table = env.Command(
|
|
|
|
join("$BUILD_DIR", "partitions.bin"),
|
2018-05-26 07:49:22 +02:00
|
|
|
"$PARTITIONS_TABLE_CSV",
|
2017-11-26 01:22:42 +01:00
|
|
|
env.VerboseAction('"$PYTHONEXE" "%s" -q $SOURCE $TARGET' % join(
|
|
|
|
FRAMEWORK_DIR, "tools", "gen_esp32part.py"),
|
2017-02-10 23:14:09 +01:00
|
|
|
"Generating partitions $TARGET"))
|
2017-02-10 18:33:55 +01:00
|
|
|
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)
|