From 95125e2627e13e5625e5cb68fe69830a01f1c723 Mon Sep 17 00:00:00 2001 From: valeros Date: Tue, 1 Aug 2023 19:38:55 +0300 Subject: [PATCH] Update Arduino core to v2.0.11 - Added several new boards (including Nano ESP32) // Resolves #1162 - Added DFU upload method via dfu-util for the new Arduino Nano ESP32 - Updated IDF version to v4.4.5 for mixed Arduino/IDF projects --- boards/adafruit_matrixportal_esp32s3.json | 65 +++++++++++++++++++++++ boards/arduino_nano_esp32.json | 53 ++++++++++++++++++ boards/dfrobot_romeo_esp32s3.json | 47 ++++++++++++++++ boards/m5stamp-pico.json | 34 ++++++++++++ boards/nebulas3.json | 47 ++++++++++++++++ builder/main.py | 22 ++++++++ platform.json | 10 +++- platform.py | 12 ++++- 8 files changed, 287 insertions(+), 3 deletions(-) create mode 100644 boards/adafruit_matrixportal_esp32s3.json create mode 100644 boards/arduino_nano_esp32.json create mode 100644 boards/dfrobot_romeo_esp32s3.json create mode 100644 boards/m5stamp-pico.json create mode 100644 boards/nebulas3.json diff --git a/boards/adafruit_matrixportal_esp32s3.json b/boards/adafruit_matrixportal_esp32s3.json new file mode 100644 index 0000000..3446cd2 --- /dev/null +++ b/boards/adafruit_matrixportal_esp32s3.json @@ -0,0 +1,65 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "partitions": "partitions-8MB-tinyuf2.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x239A", + "0x8125" + ], + [ + "0x239A", + "0x0125" + ], + [ + "0x239A", + "0x8126" + ] + ], + "mcu": "esp32s3", + "variant": "adafruit_matrixportal_esp32s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Adafruit MatrixPortal ESP32-S3", + "upload": { + "arduino": { + "flash_extra_images": [ + [ + "0x410000", + "variants/adafruit_matrixportal_esp32s3/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/5778", + "vendor": "Adafruit" +} diff --git a/boards/arduino_nano_esp32.json b/boards/arduino_nano_esp32.json new file mode 100644 index 0000000..c6da4e2 --- /dev/null +++ b/boards/arduino_nano_esp32.json @@ -0,0 +1,53 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "partitions": "app3M_fat9M_fact512k_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_NANO_ESP32", + "-DBOARD_HAS_PIN_REMAP", + "-DBOARD_HAS_PSRAM", + "-DUSB_MANUFACTURER=\\\"Arduino\\\"", + "-DUSB_PRODUCT=\\\"NanoESP32\\\"", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_DFU_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x2341", + "0x0070" + ] + ], + "mcu": "esp32s3", + "variant": "arduino_nano_nora" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Arduino Nano ESP32", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800, + "protocol": "dfu" + }, + "url": "https://docs.arduino.cc/hardware/nano-esp32", + "vendor": "Arduino" +} diff --git a/boards/dfrobot_romeo_esp32s3.json b/boards/dfrobot_romeo_esp32s3.json new file mode 100644 index 0000000..63a7cb4 --- /dev/null +++ b/boards/dfrobot_romeo_esp32s3.json @@ -0,0 +1,47 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "app3M_fat9M_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_DFROBOT_ROMEO_ESP32S3", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "dfrobot_romeo_esp32s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "DFRobot Romeo ESP32-S3", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://wiki.dfrobot.com/", + "vendor": "DFRobot" +} diff --git a/boards/m5stamp-pico.json b/boards/m5stamp-pico.json new file mode 100644 index 0000000..8f39fe5 --- /dev/null +++ b/boards/m5stamp-pico.json @@ -0,0 +1,34 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": "-DARDUINO_M5Stamp_Pico", + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "m5stack_stamp_pico" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stamp-Pico", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 1500000 + }, + "url": "https://shop.m5stack.com/products/m5stamp-pico-mate-with-pin-headers", + "vendor": "M5Stack" +} diff --git a/boards/nebulas3.json b/boards/nebulas3.json new file mode 100644 index 0000000..dc62364 --- /dev/null +++ b/boards/nebulas3.json @@ -0,0 +1,47 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_NEBULAS3", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "Nebula_S3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Kinetic Dynamics Nebula S3", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://kineticdynamics.in/product/nebula-s3/", + "vendor": "Kinetic Dynamics" +} diff --git a/builder/main.py b/builder/main.py index 261b568..dd0055f 100644 --- a/builder/main.py +++ b/builder/main.py @@ -460,6 +460,28 @@ elif upload_protocol == "mbctool": env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") ] +elif upload_protocol == "dfu": + # C:\Users\ROOT\AppData\Local\Arduino15\packages\arduino\tools\dfu-util\0.11.0-arduino5/dfu-util --device 0x2341:0x0070 -D C:\Users\ROOT\AppData\Local\Temp\arduino_build_789426/sketch_jul31a.ino.bin -Q + + hwids = board.get("build.hwids", [["0x2341", "0x0070"]]) + vid = hwids[0][0] + pid = hwids[0][1] + + upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] + + env.Replace( + UPLOADER=join( + platform.get_package_dir("tool-dfuutil-arduino") or "", "dfu-util" + ), + UPLOADERFLAGS=[ + "-d", + ",".join(["%s:%s" % (hwid[0], hwid[1]) for hwid in hwids]), + "-Q", + "-D" + ], + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS "$SOURCE"', + ) + elif upload_protocol in debug_tools: openocd_args = ["-d%d" % (2 if int(ARGUMENTS.get("PIOVERBOSE", 0)) else 1)] diff --git a/platform.json b/platform.json index 818fffa..be4cd44 100644 --- a/platform.json +++ b/platform.json @@ -67,7 +67,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~3.20009.0" + "version": "~3.20011.0" }, "framework-arduino-mbcwb": { "type": "framework", @@ -80,7 +80,7 @@ "optional": true, "owner": "platformio", "version": "~3.50002.0", - "optionalVersions": ["~3.40404.0"] + "optionalVersions": ["~3.40405.0"] }, "tool-esptoolpy": { "type": "uploader", @@ -92,6 +92,12 @@ "owner": "meteca", "version": ">=2.0.0" }, + "tool-dfuutil-arduino": { + "type": "uploader", + "optional": true, + "owner": "platformio", + "version": "~1.11.0" + }, "tool-openocd-esp32": { "type": "debugger", "optional": true, diff --git a/platform.py b/platform.py index 50ce912..0e4de86 100644 --- a/platform.py +++ b/platform.py @@ -46,6 +46,12 @@ class Espressif32Platform(PlatformBase): if os.path.isdir("ulp"): self.packages["toolchain-esp32ulp"]["optional"] = False + # Currently only Arduino Nano ESP32 uses the dfuutil tool as uploader + if variables.get("board") == "arduino_nano_esp32": + self.packages["tool-dfuutil-arduino"]["optional"] = False + else: + del self.packages["tool-dfuutil-arduino"] + build_core = variables.get( "board_build.core", board_config.get("build.core", "arduino") ).lower() @@ -96,7 +102,7 @@ class Espressif32Platform(PlatformBase): if "arduino" in frameworks: # Downgrade the IDF version for mixed Arduino+IDF projects - self.packages["framework-espidf"]["version"] = "~3.40404.0" + self.packages["framework-espidf"]["version"] = "~3.40405.0" else: # Use the latest toolchains available for IDF v5.0 for target in ( @@ -247,6 +253,10 @@ class Espressif32Platform(PlatformBase): "default": link == debug.get("default_tool"), } + # Avoid erasing Arduino Nano bootloader by preloading app binary + if board.id == "arduino_nano_esp32": + debug["tools"][link]["load_cmds"] = "preload" + board.manifest["debug"] = debug return board