arduino-esp32/tools/platformio-build.py

240 lines
10 KiB
Python
Raw Normal View History

# 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
"""
# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py
from os.path import abspath, isdir, isfile, join
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
platform = env.PioPlatform()
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
assert isdir(FRAMEWORK_DIR)
env.Append(
ASFLAGS=["-x", "assembler-with-cpp", "-mlongcalls"],
CFLAGS=[
"-std=gnu99",
"-Wno-old-style-declaration"
],
CCFLAGS=[
"-Os",
"-g3",
"-Wall",
"-nostdlib",
"-Wpointer-arith",
"-Wno-error=unused-but-set-variable",
"-Wno-error=unused-variable",
"-mlongcalls",
"-ffunction-sections",
"-fdata-sections",
"-fstrict-volatile-bitfields",
"-Wno-error=deprecated-declarations",
"-Wno-error=unused-function",
"-Wno-unused-parameter",
"-Wno-sign-compare",
"-fstack-protector",
"-fexceptions",
"-Werror=reorder"
],
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",
"-T", "esp32.project.ld",
"-T", "esp32.rom.ld",
"-T", "esp32.peripherals.ld",
"-T", "esp32.rom.libgcc.ld",
"-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('"', ""))
],
CPPPATH=[
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"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "asio"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "bootloader_support"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "bt"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "coap"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "console"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "driver"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "efuse"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp-tls"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32"),
2017-09-12 08:40:52 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_adc_cal"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_event"),
Update IDF to aaf1239 (#1539) * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * Initial add of @stickbreaker i2c * Add log_n * fix warnings when log is off * i2c code clean up and reorganization * add flags to interrupt allocator * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * fix errors with latest IDF * fix debug optimization (#1365) incorrect optimization for debugging tick markers. * Fix some missing BT header * Change BTSerial log calls * Update BLE lib * Arduino-ESP32 release management scripted (#1515) * Calculate an absolute path for a custom partitions table (#1452) * * Arduino-ESP32 release management scripted (ready-to-merge) * * secure env for espressif/arduino-esp32 * * build tests enabled * gitter webhook enabled * * gitter room link fixed * better comment * * filepaths fixed * BT Serial adjustments * * don't run sketch builds & tests for tagged builds * Return false from WiFi.hostByName() if hostname is not resolved * Free BT Memory when BT is not used * WIFI_MODE_NULL is not supported anymore * Select some key examples to build with PlatformIO to save some time * Update BLE lib * Fixed BLE lib * Major WiFi overhaul - auto reconnect on connection loss now works - moved to event groups - some code clean up and procedure optimizations - new methods to get a more elaborate system ststus * Add cmake tests to travis * Add initial AsyncUDP * Add NetBIOS lib and fix CMake includes * Add Initial WebServer * Fix WebServer and examples * travis not quiting on build fail * Try different travis build * Update IDF to aaf1239 * Fix WPS Example * fix script permission and add some fail tests to sketch builder * Add missing space in WiFiClient::write(Stream &stream)
2018-06-27 09:01:06 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_http_client"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_http_server"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_https_ota"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_https_server"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_ringbuf"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_websocket_client"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "espcoredump"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "ethernet"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "expat"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "fatfs"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "freemodbus"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "freertos"),
2017-08-01 07:51:04 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "heap"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "idf_test"),
2017-04-04 00:26:23 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "jsmn"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "json"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "libsodium"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "log"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "lwip"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mbedtls"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mdns"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "micro-ecc"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mqtt"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nghttp"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nimble"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nvs_flash"),
2017-04-04 00:26:23 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "openssl"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "protobuf-c"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "protocomm"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "pthread"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "sdmmc"),
Update IDF to aaf1239 (#1539) * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * Initial add of @stickbreaker i2c * Add log_n * fix warnings when log is off * i2c code clean up and reorganization * add flags to interrupt allocator * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * fix errors with latest IDF * fix debug optimization (#1365) incorrect optimization for debugging tick markers. * Fix some missing BT header * Change BTSerial log calls * Update BLE lib * Arduino-ESP32 release management scripted (#1515) * Calculate an absolute path for a custom partitions table (#1452) * * Arduino-ESP32 release management scripted (ready-to-merge) * * secure env for espressif/arduino-esp32 * * build tests enabled * gitter webhook enabled * * gitter room link fixed * better comment * * filepaths fixed * BT Serial adjustments * * don't run sketch builds & tests for tagged builds * Return false from WiFi.hostByName() if hostname is not resolved * Free BT Memory when BT is not used * WIFI_MODE_NULL is not supported anymore * Select some key examples to build with PlatformIO to save some time * Update BLE lib * Fixed BLE lib * Major WiFi overhaul - auto reconnect on connection loss now works - moved to event groups - some code clean up and procedure optimizations - new methods to get a more elaborate system ststus * Add cmake tests to travis * Add initial AsyncUDP * Add NetBIOS lib and fix CMake includes * Add Initial WebServer * Fix WebServer and examples * travis not quiting on build fail * Try different travis build * Update IDF to aaf1239 * Fix WPS Example * fix script permission and add some fail tests to sketch builder * Add missing space in WiFiClient::write(Stream &stream)
2018-06-27 09:01:06 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "smartconfig_ack"),
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"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "tcp_transport"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "tcpip_adapter"),
2017-04-04 00:26:23 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "ulp"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "unity"),
2017-04-04 00:26:23 +02:00
join(FRAMEWORK_DIR, "tools", "sdk", "include", "vfs"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wear_levelling"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wifi_provisioning"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"),
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"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32-camera"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp-face"),
join(FRAMEWORK_DIR, "tools", "sdk", "include", "fb_gfx"),
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
],
LIBPATH=[
join(FRAMEWORK_DIR, "tools", "sdk", "lib"),
join(FRAMEWORK_DIR, "tools", "sdk", "ld")
],
LIBS=[
"-lgcc", "-lespcoredump", "-lesp_event", "-lheap", "-lpe", "-lmesh", "-lm", "-lesp_http_client", "-lfb_gfx", "-lface_detection", "-lesp_adc_cal", "-ldetection_cat_face", "-lmbedtls", "-lunity", "-lspiffs", "-lod", "-lapp_trace", "-llog", "-lesp_websocket_client", "-lexpat", "-lwpa2", "-lxtensa-debug-module", "-lnet80211", "-lhal", "-lvfs", "-lwps", "-lmqtt", "-lasio", "-lbt", "-lwpa_supplicant", "-lpp", "-lmdns", "-llwip", "-lnvs_flash", "-lc", "-lbootloader_support", "-lnewlib", "-lsdmmc", "-lapp_update", "-lethernet", "-lefuse", "-lprotobuf-c", "-ldetection", "-lfreemodbus", "-lcore", "-lface_recognition", "-lfd", "-lcoap", "-ljsmn", "-lesp_https_ota", "-ltcp_transport", "-lbtdm_app", "-lesp_ringbuf", "-ldriver", "-lwifi_provisioning", "-llibsodium", "-lopenssl", "-lfatfs", "-lnghttp", "-lespnow", "-lprotocomm", "-lspi_flash", "-lc_nano", "-lulp", "-lesp_http_server", "-lesp32-camera", "-lsmartconfig", "-lsmartconfig_ack", "-lesp-tls", "-lcoexist", "-lmicro-ecc", "-lesp_https_server", "-lwpa", "-ltcpip_adapter", "-lwear_levelling", "-lfreertos", "-lsoc", "-ljson", "-lesp32", "-lpthread", "-lcxx", "-lfr", "-ldl", "-lphy", "-limage_util", "-lrtc", "-lconsole", "-lstdc++"
],
LIBSOURCE_DIRS=[
join(FRAMEWORK_DIR, "libraries")
],
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"))
]
)
if not env.BoardConfig().get("build.ldscript", ""):
env.Replace(LDSCRIPT_PATH=env.BoardConfig().get("build.arduino.ldscript", ""))
#
# Target: Build Core Library
#
libs = []
2020-11-15 16:20:02 +01:00
variants_dir = join(FRAMEWORK_DIR, "variants")
if "build.variants_dir" in env.BoardConfig():
variants_dir = join("$PROJECT_DIR", env.BoardConfig().get("build.variants_dir"))
if "build.variant" in env.BoardConfig():
env.Append(
CPPPATH=[
2020-11-15 16:20:02 +01:00
join(variants_dir, env.BoardConfig().get("build.variant"))
]
)
libs.append(env.BuildLibrary(
join("$BUILD_DIR", "FrameworkArduinoVariant"),
2020-11-15 16:20:02 +01:00
join(variants_dir, 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"))
))
env.Prepend(LIBS=libs)
#
# Generate partition table
#
2018-05-07 22:47:22 +02:00
fwpartitions_dir = join(FRAMEWORK_DIR, "tools", "partitions")
partitions_csv = env.BoardConfig().get("build.partitions", "default.csv")
2018-05-07 22:47:22 +02:00
env.Replace(
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
partition_table = env.Command(
join("$BUILD_DIR", "partitions.bin"),
"$PARTITIONS_TABLE_CSV",
env.VerboseAction('"$PYTHONEXE" "%s" -q $SOURCE $TARGET' % join(
FRAMEWORK_DIR, "tools", "gen_esp32part.py"),
"Generating partitions $TARGET"))
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)