diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..6a58391 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,20 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 30 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - bug + - known issue + - feature + - enhancement + - board request +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. Please provide more details or it will be closed if no + further activity occurs. Thank you for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/boards/adafruit_feather_esp32s2_tft.json b/boards/adafruit_feather_esp32s2_tft.json index 6f141b0..aee4431 100644 --- a/boards/adafruit_feather_esp32s2_tft.json +++ b/boards/adafruit_feather_esp32s2_tft.json @@ -1,7 +1,8 @@ { "build": { "arduino": { - "ldscript": "esp32s2_out.ld" + "ldscript": "esp32s2_out.ld", + "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", "extra_flags": [ @@ -41,14 +42,6 @@ ], "name": "Adafruit Feather ESP32-S2 TFT", "upload": { - "arduino": { - "flash_extra_images": [ - [ - "0x2d0000", - "variants/adafruit_feather_esp32s2_tft/tinyuf2.bin" - ] - ] - }, "flash_size": "4MB", "maximum_ram_size": 327680, "maximum_size": 4194304, diff --git a/boards/adafruit_feather_esp32s3.json b/boards/adafruit_feather_esp32s3.json index d6e5e97..9c14bd3 100644 --- a/boards/adafruit_feather_esp32s3.json +++ b/boards/adafruit_feather_esp32s3.json @@ -1,11 +1,12 @@ { "build": { "arduino":{ - "ldscript": "esp32s3_out.ld" + "ldscript": "esp32s3_out.ld", + "partitions": "partitions.csv" }, "core": "esp32", "extra_flags": [ - "-DARDUINO_ADAFRUIT_FEATHER_ESP32S3_NOPSRAM", + "-DARDUINO_ADAFRUIT_FEATHER_ESP32S3", "-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1" @@ -16,19 +17,19 @@ "hwids": [ [ "0x239A", - "0x8113" + "0x811B" ], [ "0x239A", - "0x0113" + "0x011B" ], [ "0x239A", - "0x8114" + "0x811C" ] ], "mcu": "esp32s3", - "variant": "adafruit_feather_esp32s3_nopsram" + "variant": "adafruit_feather_esp32s3" }, "connectivity": [ "wifi" @@ -40,16 +41,8 @@ "arduino", "espidf" ], - "name": "Adafruit Feather ESP32-S3 No PSRAM", + "name": "Adafruit Feather ESP32-S3 2MB PSRAM", "upload": { - "arduino": { - "flash_extra_images": [ - [ - "0x410000", - "variants/adafruit_feather_esp32s3_nopsram/tinyuf2.bin" - ] - ] - }, "flash_size": "4MB", "maximum_ram_size": 327680, "maximum_size": 4194304, @@ -58,6 +51,6 @@ "require_upload_port": true, "speed": 460800 }, - "url": "https://www.adafruit.com/product/5323", + "url": "https://www.adafruit.com/product/5477", "vendor": "Adafruit" } diff --git a/boards/adafruit_feather_esp32s3_nopsram.json b/boards/adafruit_feather_esp32s3_nopsram.json new file mode 100644 index 0000000..29541e5 --- /dev/null +++ b/boards/adafruit_feather_esp32s3_nopsram.json @@ -0,0 +1,63 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ADAFRUIT_FEATHER_ESP32S3_NOPSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x239A", + "0x811B" + ], + [ + "0x239A", + "0x011B" + ], + [ + "0x239A", + "0x811C" + ] + ], + "mcu": "esp32s3", + "variant": "adafruit_feather_esp32s3_nopsram" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Adafruit Feather ESP32-S3 No PSRAM", + "upload": { + "arduino": { + "flash_extra_images": [ + [ + "0x2d0000", + "variants/adafruit_feather_esp32s3_nopsram/tinyuf2.bin" + ] + ] + }, + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.adafruit.com/product/5323", + "vendor": "Adafruit" +} diff --git a/boards/adafruit_feather_esp32s3_tft.json b/boards/adafruit_feather_esp32s3_tft.json new file mode 100644 index 0000000..4e38ae0 --- /dev/null +++ b/boards/adafruit_feather_esp32s3_tft.json @@ -0,0 +1,64 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "partitions.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ADAFRUIT_FEATHER_ESP32S3_TFT", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x239A", + "0x811D" + ], + [ + "0x239A", + "0x011D" + ], + [ + "0x239A", + "0x811E" + ] + ], + "mcu": "esp32s3", + "variant": "adafruit_feather_esp32s3_tft" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Adafruit Feather ESP32-S3 TFT", + "upload": { + "arduino": { + "flash_extra_images": [ + [ + "0x2d0000", + "variants/adafruit_feather_esp32s3_tft/tinyuf2.bin" + ] + ] + }, + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.adafruit.com/product/5483", + "vendor": "Adafruit" +} diff --git a/boards/adafruit_funhouse_esp32s2.json b/boards/adafruit_funhouse_esp32s2.json index 9747612..eb5ee1d 100644 --- a/boards/adafruit_funhouse_esp32s2.json +++ b/boards/adafruit_funhouse_esp32s2.json @@ -1,7 +1,8 @@ { "build": { "arduino":{ - "ldscript": "esp32s2_out.ld" + "ldscript": "esp32s2_out.ld", + "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", "extra_flags": [ @@ -41,14 +42,6 @@ ], "name": "Adafruit FunHouse", "upload": { - "arduino": { - "flash_extra_images": [ - [ - "0x2d0000", - "variants/adafruit_funhouse_esp32s2/tinyuf2.bin" - ] - ] - }, "flash_size": "4MB", "maximum_ram_size": 327680, "maximum_size": 4194304, diff --git a/boards/adafruit_magtag29_esp32s2.json b/boards/adafruit_magtag29_esp32s2.json index 5e2dd71..fc51f61 100644 --- a/boards/adafruit_magtag29_esp32s2.json +++ b/boards/adafruit_magtag29_esp32s2.json @@ -1,7 +1,8 @@ { "build": { "arduino":{ - "ldscript": "esp32s2_out.ld" + "ldscript": "esp32s2_out.ld", + "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", "extra_flags": [ @@ -41,14 +42,6 @@ ], "name": "Adafruit MagTag 2.9", "upload": { - "arduino": { - "flash_extra_images": [ - [ - "0x2d0000", - "variants/adafruit_magtag29_esp32s2/tinyuf2.bin" - ] - ] - }, "flash_size": "4MB", "maximum_ram_size": 327680, "maximum_size": 4194304, diff --git a/boards/adafruit_metro_esp32s2.json b/boards/adafruit_metro_esp32s2.json index af8df22..7f75dfb 100644 --- a/boards/adafruit_metro_esp32s2.json +++ b/boards/adafruit_metro_esp32s2.json @@ -1,7 +1,8 @@ { "build": { "arduino":{ - "ldscript": "esp32s2_out.ld" + "ldscript": "esp32s2_out.ld", + "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", "extra_flags": [ @@ -41,14 +42,6 @@ ], "name": "Adafruit Metro ESP32-S2", "upload": { - "arduino": { - "flash_extra_images": [ - [ - "0x2d0000", - "variants/adafruit_metro_esp32s2/tinyuf2.bin" - ] - ] - }, "flash_size": "4MB", "maximum_ram_size": 327680, "maximum_size": 4194304, diff --git a/boards/adafruit_qtpy_esp32s2.json b/boards/adafruit_qtpy_esp32s2.json index 30f51dc..51beac6 100644 --- a/boards/adafruit_qtpy_esp32s2.json +++ b/boards/adafruit_qtpy_esp32s2.json @@ -1,7 +1,8 @@ { "build": { "arduino": { - "ldscript": "esp32s2_out.ld" + "ldscript": "esp32s2_out.ld", + "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", "extra_flags": [ @@ -41,14 +42,6 @@ ], "name": "Adafruit QT Py ESP32-S2", "upload": { - "arduino": { - "flash_extra_images": [ - [ - "0x2d0000", - "variants/adafruit_qtpy_esp32s2/tinyuf2.bin" - ] - ] - }, "flash_size": "4MB", "maximum_ram_size": 327680, "maximum_size": 4194304, diff --git a/boards/adafruit_qtpy_esp32s3.json b/boards/adafruit_qtpy_esp32s3_nopsram.json similarity index 98% rename from boards/adafruit_qtpy_esp32s3.json rename to boards/adafruit_qtpy_esp32s3_nopsram.json index 067d8a6..4412a31 100644 --- a/boards/adafruit_qtpy_esp32s3.json +++ b/boards/adafruit_qtpy_esp32s3_nopsram.json @@ -1,6 +1,6 @@ { "build": { - "arduino":{ + "arduino": { "ldscript": "esp32s3_out.ld" }, "core": "esp32", diff --git a/boards/atmegazero_esp32s2.json b/boards/atmegazero_esp32s2.json index bfc4069..a23a6ce 100644 --- a/boards/atmegazero_esp32s2.json +++ b/boards/atmegazero_esp32s2.json @@ -1,7 +1,8 @@ { "build": { "arduino":{ - "ldscript": "esp32s2_out.ld" + "ldscript": "esp32s2_out.ld", + "partitions": "partitions-16MB-tinyuf2.csv" }, "core": "esp32", "extra_flags": [ @@ -32,14 +33,6 @@ ], "name": "EspinalLab ATMegaZero ESP32-S2", "upload": { - "arduino": { - "flash_extra_images": [ - [ - "0x2d0000", - "variants/atmegazero_esp32s2/tinyuf2.bin" - ] - ] - }, "flash_size": "16MB", "maximum_ram_size": 327680, "maximum_size": 16777216, diff --git a/boards/cnrs_aw2eth.json b/boards/cnrs_aw2eth.json new file mode 100644 index 0000000..3669347 --- /dev/null +++ b/boards/cnrs_aw2eth.json @@ -0,0 +1,36 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32_PICO" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "cnrs_aw2eth" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "CNRS AW2ETH", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://en.wikipedia.org/wiki/ESP32", + "vendor": "CNRS" +} diff --git a/boards/connaxio_espoir.json b/boards/connaxio_espoir.json new file mode 100644 index 0000000..e9e7265 --- /dev/null +++ b/boards/connaxio_espoir.json @@ -0,0 +1,47 @@ + +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_CONNAXIO_ESPOIR", + "-DCONFIG_FREERTOS_UNICORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "connaxio_espoir", + "hwids": [ + [ + "0x10C4", + "0x8D9A" + ] + ] + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp32-solo-1.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Connaxio's Espoir", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://www.connaxio.com/electronics/espoir/", + "vendor": "Connaxio" +} diff --git a/boards/dfrobot_beetle_esp32c3.json b/boards/dfrobot_beetle_esp32c3.json new file mode 100644 index 0000000..a5b884f --- /dev/null +++ b/boards/dfrobot_beetle_esp32c3.json @@ -0,0 +1,47 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32c3_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32C3_DEV", + "-DARDUINO_USB_MODE=1" + ], + "f_cpu": "160000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x3343", + "0x8364" + ], + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32c3", + "variant": "dfrobot_beetle_esp32c3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32c3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "DFRobot Beetle ESP32-C3", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.dfrobot.com/product-2566.html", + "vendor": "DFRobot" +} diff --git a/boards/dfrobot_firebeetle2_esp32s3.json b/boards/dfrobot_firebeetle2_esp32s3.json new file mode 100644 index 0000000..0f87150 --- /dev/null +++ b/boards/dfrobot_firebeetle2_esp32s3.json @@ -0,0 +1,49 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x83CF" + ], + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "dfrobot_firebeetle2_esp32s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "DFRobot Firebeetle 2 ESP32-S3", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.dfrobot.com/product-1590.html", + "vendor": "DFRobot" +} diff --git a/boards/featheresp32-s2.json b/boards/featheresp32-s2.json index bf6f0cb..f645bf6 100644 --- a/boards/featheresp32-s2.json +++ b/boards/featheresp32-s2.json @@ -1,7 +1,8 @@ { "build": { "arduino":{ - "ldscript": "esp32s2_out.ld" + "ldscript": "esp32s2_out.ld", + "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", "extra_flags": [ diff --git a/boards/firebeetle32.json b/boards/firebeetle32.json index d580c39..3463fa1 100644 --- a/boards/firebeetle32.json +++ b/boards/firebeetle32.json @@ -13,9 +13,7 @@ }, "connectivity": [ "wifi", - "bluetooth", - "ethernet", - "can" + "bluetooth" ], "debug": { "openocd_board": "esp-wroom-32.cfg" @@ -26,12 +24,12 @@ ], "name": "FireBeetle-ESP32", "upload": { - "flash_size": "4MB", - "maximum_ram_size": 327680, - "maximum_size": 4194304, + "flash_size": "16MB", + "maximum_ram_size": 532480, + "maximum_size": 16777216, "require_upload_port": true, "speed": 460800 }, - "url": "https://dfrobotblog.wordpress.com", + "url": "https://wiki.dfrobot.com/FireBeetle_ESP32_IOT_Microcontroller(V3.0)__Supports_Wi-Fi_&_Bluetooth__SKU__DFR0478", "vendor": "DFRobot" } diff --git a/boards/m5stack-coreink.json b/boards/m5stack-coreink.json index f5aee0d..e7b3cbb 100644 --- a/boards/m5stack-coreink.json +++ b/boards/m5stack-coreink.json @@ -21,7 +21,7 @@ "arduino", "espidf" ], - "name": "M5Stick-Core Ink", + "name": "M5Stack-Core Ink", "upload": { "flash_size": "4MB", "maximum_ram_size": 327680, diff --git a/boards/seeed_xiao_esp32c3.json b/boards/seeed_xiao_esp32c3.json new file mode 100644 index 0000000..4d8ded0 --- /dev/null +++ b/boards/seeed_xiao_esp32c3.json @@ -0,0 +1,44 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32c3_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_XIAO_ESP32C3", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "f_cpu": "160000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x2886", + "0x0047" + ] + ], + "mcu": "esp32c3", + "variant": "XIAO_ESP32C3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32c3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Seeed Studio XIAO ESP32C3", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/", + "vendor": "Seeed Studio" +} diff --git a/boards/wemos_d1_mini32.json b/boards/wemos_d1_mini32.json index 4770623..90b1d6b 100644 --- a/boards/wemos_d1_mini32.json +++ b/boards/wemos_d1_mini32.json @@ -24,7 +24,7 @@ "arduino", "espidf" ], - "name": "WeMos D1 MINI ESP32", + "name": "WEMOS D1 MINI ESP32", "upload": { "flash_size": "4MB", "maximum_ram_size": 327680, diff --git a/boards/wemos_d1_uno32.json b/boards/wemos_d1_uno32.json new file mode 100644 index 0000000..2a38aa4 --- /dev/null +++ b/boards/wemos_d1_uno32.json @@ -0,0 +1,37 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": "-DARDUINO_D1_UNO32", + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "d1_uno32" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp-wroom-32.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "WEMOS D1 R32", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.wemos.cc", + "vendor": "WEMOS" +} diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index c6fc754..eea32aa 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -41,4 +41,4 @@ elif "espidf" not in env.subst("$PIOFRAMEWORK"): SConscript( join(DefaultEnvironment().PioPlatform().get_package_dir( "framework-arduinoespressif32"), "tools", "platformio-build.py")) - env["IDE_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")}) + env["INTEGRATION_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")}) diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index 21cad67..a80a616 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -815,6 +815,8 @@ def get_targets_by_type(target_configs, target_types, ignore_targets=None): def get_components_map(target_configs, target_types, ignore_components=None): result = {} for config in get_targets_by_type(target_configs, target_types, ignore_components): + if "nameOnDisk" not in config: + config["nameOnDisk"] = "lib%s.a" % config["name"] result[config["id"]] = {"config": config} return result @@ -1246,7 +1248,6 @@ project_defines = get_app_defines(project_config) project_flags = get_app_flags(project_config, default_config) link_args = extract_link_args(elf_config) app_includes = get_app_includes(elf_config) -project_lib_includes = get_project_lib_includes(env) # # Compile bootloader @@ -1301,32 +1302,6 @@ def _skip_prj_source_files(node): env.AddBuildMiddleware(_skip_prj_source_files) -# Project files should be compiled only when a special -# option is enabled when running 'test' command -if "__test" not in COMMAND_LINE_TARGETS or env.GetProjectOption( - "test_build_project_src" -): - project_env = env.Clone() - if project_target_name != "__idf_main": - # Manually add dependencies to CPPPATH since ESP-IDF build system doesn't generate - # this info if the folder with sources is not named 'main' - # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#rename-main - project_env.AppendUnique(CPPPATH=app_includes["plain_includes"]) - - # Add include dirs from PlatformIO build system to project CPPPATH so - # they're visible to PIOBUILDFILES - project_env.Append( - CPPPATH=["$PROJECT_INCLUDE_DIR", "$PROJECT_SRC_DIR"] + project_lib_includes - ) - - env.Append( - PIOBUILDFILES=compile_source_files( - target_configs.get(project_target_name), - project_env, - project_env.subst("$PROJECT_DIR"), - ) - ) - # # Generate partition table # @@ -1387,6 +1362,52 @@ env.Prepend( ], ) +# +# Propagate Arduino defines to the main build environment +# + +if "arduino" in env.subst("$PIOFRAMEWORK"): + arduino_config_name = list( + filter( + lambda config_name: config_name.startswith( + "__idf_framework-arduinoespressif32" + ), + target_configs, + ) + )[0] + env.AppendUnique( + CPPDEFINES=extract_defines( + target_configs.get(arduino_config_name, {}).get("compileGroups", [])[0] + ) + ) + +# Project files should be compiled only when a special +# option is enabled when running 'test' command +if "__test" not in COMMAND_LINE_TARGETS or env.GetProjectOption( + "test_build_project_src" +): + project_env = env.Clone() + if project_target_name != "__idf_main": + # Manually add dependencies to CPPPATH since ESP-IDF build system doesn't generate + # this info if the folder with sources is not named 'main' + # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#rename-main + project_env.AppendUnique(CPPPATH=app_includes["plain_includes"]) + + # Add include dirs from PlatformIO build system to project CPPPATH so + # they're visible to PIOBUILDFILES + project_env.AppendUnique( + CPPPATH=["$PROJECT_INCLUDE_DIR", "$PROJECT_SRC_DIR"] + + get_project_lib_includes(env) + ) + + env.Append( + PIOBUILDFILES=compile_source_files( + target_configs.get(project_target_name), + project_env, + project_env.subst("$PROJECT_DIR"), + ) + ) + # # Generate mbedtls bundle # @@ -1449,4 +1470,4 @@ env.Replace( ) # Propagate application offset to debug configurations -env["IDE_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")}) +env["INTEGRATION_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")}) diff --git a/builder/main.py b/builder/main.py index 19d88b3..7926766 100644 --- a/builder/main.py +++ b/builder/main.py @@ -160,6 +160,18 @@ def __fetch_fs_size(target, source, env): return (target, source) +def merge_binaries(source, target, env, for_signature): + return " ".join([ + '"$PYTHONEXE"', + join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"), + "--chip", mcu, "merge_bin", + "-o", "$TARGET", + "--flash_mode", "$BOARD_FLASH_MODE", + "--flash_size", board.get("upload.flash_size", "4MB"), + "$ESP32_APP_OFFSET", "$SOURCES" + ] + ['"%s"' % itm for img in env.get("FLASH_EXTRA_IMAGES", []) for itm in img]) + + env = DefaultEnvironment() platform = env.PioPlatform() board = env.BoardConfig() @@ -169,6 +181,24 @@ filesystem = board.get("build.filesystem", "spiffs") if mcu == "esp32c3": toolchain_arch = "riscv32-esp" +# Arduino core v2.0.4 contains updated bootloader images that have innacurate default +# headers. This results in bootloops if firmware is flashed via OpenOCD (e.g. debugging +# or uploading via debug tools). For this reason, before uploading or debugging we need +# to merge binaries via esptoolpy so that the image headers will be adjusted according to +# --flash-size and --flash-mode arguments. +# Note: This behavior doesn't occur if uploading is done via esptoolpy, as esptoolpy +# overrides the binary image headers before flashing. +firmware_merge_required = bool( + env.get("PIOFRAMEWORK", []) == ["arduino"] + and ( + "debug" in env.GetBuildType() + or env.subst("$UPLOAD_PROTOCOL") in board.get("debug.tools", {}) + ) +) + +if "INTEGRATION_EXTRA_DATA" not in env: + env["INTEGRATION_EXTRA_DATA"] = {} + env.Replace( __get_board_boot_mode=_get_board_boot_mode, __get_board_f_flash=_get_board_f_flash, @@ -261,6 +291,10 @@ env.Append( source_factory=env.Dir, suffix=".bin", ), + MergeBin=Builder( + generator=merge_binaries, + suffix=".bin", + ), ) ) @@ -272,6 +306,7 @@ if not env.get("PIOFRAMEWORK"): # target_elf = None +target_firm_merged = None if "nobuild" in COMMAND_LINE_TARGETS: target_elf = join("$BUILD_DIR", "${PROGNAME}.elf") if set(["uploadfs", "uploadfsota"]) & set(COMMAND_LINE_TARGETS): @@ -290,6 +325,14 @@ else: else: target_firm = env.ElfToBin( join("$BUILD_DIR", "${PROGNAME}"), target_elf) + if firmware_merge_required: + # Note: Default offset address must be set to 0x0 because debugging + # relies on OpenOCD that requires merged firmware + env["INTEGRATION_EXTRA_DATA"].update( + {"application_offset": "0x0", "merged_firmware": True} + ) + target_firm_merged = env.MergeBin(join( + "$BUILD_DIR", "${PROGNAME}_merged"), target_firm) env.Depends(target_firm, "checkprogsize") env.AddPlatformTarget("buildfs", target_firm, target_firm, "Build Filesystem Image") @@ -427,6 +470,10 @@ elif upload_protocol == "mbctool": elif upload_protocol in debug_tools: + if firmware_merge_required: + # Only merged firmware with proper headers will work when uploading is done via + # debug probes. The firmware offset address must be adjusted to 0x0 accordingly. + target_firm = target_firm_merged openocd_args = ["-d%d" % (2 if int(ARGUMENTS.get("PIOVERBOSE", 0)) else 1)] openocd_args.extend( debug_tools.get(upload_protocol).get("server").get("arguments", [])) @@ -439,11 +486,14 @@ elif upload_protocol in debug_tools: % ( "$FS_START" if "uploadfs" in COMMAND_LINE_TARGETS - else "$ESP32_APP_OFFSET" + else board.get( + "upload.offset_address", + "0x0" if firmware_merge_required else "$ESP32_APP_OFFSET" + ) ), ] ) - if "uploadfs" not in COMMAND_LINE_TARGETS: + if "uploadfs" not in COMMAND_LINE_TARGETS and not firmware_merge_required: for image in env.get("FLASH_EXTRA_IMAGES", []): openocd_args.extend( [ @@ -501,6 +551,13 @@ if any("-Wl,-T" in f for f in env.get("LINKFLAGS", [])): print("Warning! '-Wl,-T' option for specifying linker scripts is deprecated. " "Please use 'board_build.ldscript' option in your 'platformio.ini' file.") +# +# A temporary workaround to propagate additional data to the debug configuration routine +# + +Import("projenv") +projenv["INTEGRATION_EXTRA_DATA"] = env.get("INTEGRATION_EXTRA_DATA") + # # Default targets # diff --git a/platform.json b/platform.json index cdff993..3c55e32 100644 --- a/platform.json +++ b/platform.json @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/platformio/platform-espressif32.git" }, - "version": "5.0.0", + "version": "5.1.0", "frameworks": { "arduino": { "package": "framework-arduinoespressif32", @@ -72,7 +72,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~3.20003.0" + "version": "~3.20004.0" }, "framework-arduino-mbcwb": { "type": "framework", diff --git a/platform.py b/platform.py index 07b0a4c..9a6801a 100644 --- a/platform.py +++ b/platform.py @@ -88,7 +88,9 @@ class Espressif32Platform(PlatformBase): sys.exit(1) if "espidf" in frameworks: - # Common package for IDF and mixed Arduino+IDF projects + if "arduino" in frameworks: + self.packages["framework-arduinoespressif32"]["version"] = "~3.20003.0" + # Common packages for IDF and mixed Arduino+IDF projects for p in self.packages: if p in ("tool-cmake", "tool-ninja", "toolchain-%sulp" % mcu): self.packages[p]["optional"] = False @@ -259,16 +261,23 @@ class Espressif32Platform(PlatformBase): if any(ignore_conds): return - load_cmds = [ - 'monitor program_esp "{{{path}}}" {offset} verify'.format( - path=to_unix_path(item["path"]), offset=item["offset"] - ) - for item in flash_images - ] + merged_firmware = build_extra_data.get("merged_firmware", False) + load_cmds = [] + if not merged_firmware: + load_cmds.extend([ + 'monitor program_esp "{{{path}}}" {offset} verify'.format( + path=to_unix_path(item["path"]), offset=item["offset"] + ) + for item in flash_images + ]) + load_cmds.append( 'monitor program_esp "{%s.bin}" %s verify' % ( - to_unix_path(debug_config.build_data["prog_path"][:-4]), + to_unix_path( + debug_config.build_data["prog_path"][:-4] + + ("_merged" if merged_firmware else "") + ), build_extra_data.get("application_offset", "0x10000"), ) )