From 0afa11add6f1eb5870adecbff7ec13d825ad2ff9 Mon Sep 17 00:00:00 2001 From: Jason2866 Date: Wed, 5 Nov 2025 18:33:57 +0100 Subject: [PATCH] Arduino core 3.3.3 --- .github/workflows/examples.yml | 2 +- README.md | 6 +- boards/adafruit_camera_esp32s3.json | 3 +- boards/adafruit_feather_esp32_v2.json | 3 - boards/adafruit_itsybitsy_esp32.json | 1 - boards/adafruit_qtpy_esp32.json | 3 - boards/adafruit_qtpy_esp32c3.json | 3 - boards/airm2m_core_esp32c3.json | 3 - boards/alksesp32.json | 3 - boards/atd147_s3.json | 1 - boards/atmegazero_esp32s2.json | 3 +- boards/aventen_s3_sync.json | 1 - boards/az-delivery-devkit-v4.json | 3 - boards/bee_data_logger.json | 3 - boards/bee_motion.json | 3 - boards/bee_motion_mini.json | 3 - boards/bee_motion_s3.json | 3 - boards/bee_s3.json | 3 - boards/bpi-bit.json | 3 - boards/bpi_leaf_s3.json | 1 - boards/cnrs_aw2eth.json | 3 - boards/connaxio_espoir.json | 4 - boards/cytron_maker_feather_aiot_s3.json | 1 - boards/d-duino-32.json | 3 - boards/deneyapkart.json | 3 - boards/deneyapkart1A.json | 3 - boards/deneyapkart1Av2.json | 1 - boards/deneyapkartg.json | 3 - boards/deneyapmini.json | 3 - boards/deneyapminiv2.json | 3 - boards/denky32.json | 3 - boards/denky_d4.json | 3 - boards/dfrobot_beetle_esp32c3.json | 3 - boards/dfrobot_firebeetle2_esp32e.json | 3 - boards/dfrobot_firebeetle2_esp32s3.json | 3 - boards/dpu_esp32.json | 1 - boards/edgebox-esp-100.json | 1 - boards/esp-wrover-kit.json | 3 - boards/esp32-c3-devkitc-02.json | 3 - boards/esp32-c3-devkitm-1.json | 3 - boards/esp32-c3-m1i-kit.json | 3 - boards/esp32-devkitlipo.json | 10 +- boards/esp32-evb.json | 10 +- boards/esp32-gateway.json | 10 +- boards/esp32-p4-evboard.json | 1 + boards/esp32-p4.json | 1 + boards/esp32-pico-devkitm-2.json | 3 - boards/esp32-poe-iso.json | 10 +- boards/esp32-poe.json | 10 +- boards/esp32-pro.json | 3 - boards/esp32-s2-kaluga-1.json | 3 - boards/esp32-s2-saola-1.json | 3 - boards/esp32-s3-devkitc-1.json | 3 +- boards/esp32-s3-devkitm-1.json | 3 +- boards/esp320.json | 3 - boards/esp32cam.json | 3 +- boards/esp32dev.json | 3 - boards/esp32doit-devkit-v1.json | 3 - boards/esp32doit-espduino.json | 3 - boards/esp32s3box.json | 3 +- boards/esp32s3camlcd.json | 3 +- boards/esp32s3usbotg.json | 3 +- boards/esp32thing.json | 3 - boards/esp32thing_plus.json | 3 +- boards/esp32vn-iot-uno.json | 3 - boards/espea32.json | 3 - boards/espectro32.json | 3 - boards/espino32.json | 3 - boards/etboard.json | 3 - boards/featheresp32-s2.json | 3 +- boards/featheresp32.json | 3 - boards/firebeetle32.json | 3 - boards/fm-devkit.json | 3 - boards/franzininho_wifi_esp32s2.json | 3 - boards/franzininho_wifi_msc_esp32s2.json | 3 - boards/frogboard.json | 3 - boards/healthypi4.json | 3 - boards/heltec_wifi_kit_32.json | 3 - boards/heltec_wifi_kit_32_v2.json | 3 +- boards/heltec_wifi_lora_32.json | 3 - boards/heltec_wifi_lora_32_V2.json | 3 +- boards/heltec_wifi_lora_32_V3.json | 1 - boards/heltec_wireless_stick.json | 3 +- boards/honeylemon.json | 3 - boards/hornbill32dev.json | 3 - boards/hornbill32minima.json | 3 - boards/imbrios-logsens-v1p1.json | 3 - boards/inex_openkb.json | 3 - boards/intorobot.json | 3 - boards/iotaap_magnolia.json | 3 - boards/iotbusio.json | 3 - boards/iotbusproteus.json | 3 - boards/ioxesp32.json | 3 - boards/ioxesp32ps.json | 3 - boards/kb32-ft.json | 3 - boards/kits-edu.json | 3 - boards/labplus_mpython.json | 3 +- boards/lilka_v2.json | 4 +- boards/lilygo-t-display-s3.json | 3 +- boards/lilygo-t-display.json | 5 +- boards/lionbit.json | 7 +- boards/lionbits3.json | 3 - boards/lolin32.json | 3 - boards/lolin32_lite.json | 3 - boards/lolin_c3_mini.json | 3 - boards/lolin_d32.json | 3 - boards/lolin_d32_pro.json | 3 - boards/lolin_s2_mini.json | 3 - boards/lolin_s2_pico.json | 3 - boards/lolin_s3.json | 1 - boards/lolin_s3_pro.json | 1 - boards/lopy.json | 3 - boards/lopy4.json | 3 - boards/m5stack-atom.json | 3 - boards/m5stack-atoms3.json | 1 - boards/m5stack-core2.json | 3 +- boards/m5stack-coreink.json | 3 - boards/m5stack-cores3.json | 1 - boards/m5stack-fire.json | 3 +- boards/m5stack-stamps3.json | 1 - boards/m5stack-station.json | 3 - boards/m5stack-tab5-p4.json | 1 + boards/m5stack-timer-cam.json | 3 - boards/m5stamp-pico.json | 3 - boards/m5stick-c.json | 3 - boards/magicbit.json | 3 - boards/mgbot-iotik32a.json | 3 - boards/mgbot-iotik32b.json | 3 - boards/mhetesp32devkit.json | 3 - boards/mhetesp32minikit.json | 3 - boards/microduino-core-esp32.json | 3 - boards/micros2.json | 3 +- boards/minimain_esp32s2.json | 1 - boards/namino_arancio.json | 1 - boards/namino_rosso.json | 1 - boards/nano32.json | 3 - boards/nebulas3.json | 1 - boards/nina_w10.json | 3 +- boards/node32s.json | 3 - boards/nodemcu-32s.json | 3 - boards/nodemcu-32s2.json | 3 - boards/nscreen-32.json | 77 +-- boards/odroid_esp32.json | 3 - boards/onehorse32dev.json | 3 - boards/oroca_edubot.json | 3 +- boards/pico32.json | 3 - boards/piranha_esp32.json | 3 - boards/pocket_32.json | 3 - boards/pycom_gpy.json | 3 - boards/qchip.json | 63 +- boards/quantum.json | 3 - boards/redpill_esp32s3.json | 1 - boards/roboheart_hercules.json | 3 - boards/s_odi_ultra.json | 3 - boards/seeed_xiao_esp32c3.json | 5 +- boards/seeed_xiao_esp32s3.json | 107 ++- boards/sensebox_mcu_esp32s2.json | 1 - boards/sensesiot_weizen.json | 3 - boards/sg-o_airMon.json | 5 +- boards/sparkfun_esp32_iot_redboard.json | 5 +- boards/sparkfun_esp32micromod.json | 3 - boards/sparkfun_esp32s2_thing_plus.json | 3 - boards/sparkfun_esp32s2_thing_plus_c.json | 1 - boards/sparkfun_lora_gateway_1-channel.json | 3 - boards/tamc_termod_s3.json | 1 - boards/tinypico.json | 3 - boards/trueverit-iot-driver-mk2.json | 3 - boards/trueverit-iot-driver-mk3.json | 4 - boards/trueverit-iot-driver.json | 3 - boards/ttgo-lora32-v1.json | 3 - boards/ttgo-lora32-v2.json | 3 - boards/ttgo-lora32-v21.json | 3 - boards/ttgo-t-beam.json | 3 - boards/ttgo-t-oi-plus.json | 3 - boards/ttgo-t-watch.json | 3 +- boards/ttgo-t1.json | 3 - boards/ttgo-t7-v13-mini32.json | 3 - boards/ttgo-t7-v14-mini32.json | 3 - boards/turta_iot_node.json | 3 - boards/um_feathers2.json | 3 - boards/um_feathers2_neo.json | 3 - boards/um_rmp.json | 3 - boards/unphone7.json | 3 - boards/unphone8.json | 3 +- boards/unphone9.json | 3 +- boards/upesy_wroom.json | 3 - boards/upesy_wrover.json | 3 - boards/valtrack_v4_mfw_esp32_c3.json | 3 - boards/valtrack_v4_vts_esp32_c3.json | 3 - boards/vintlabs-devkit-v1.json | 3 - boards/watchy.json | 3 +- boards/wemos_d1_mini32.json | 3 - boards/wemos_d1_uno32.json | 3 - boards/wemosbat.json | 3 - boards/wesp32.json | 3 - boards/widora-air.json | 3 - boards/wifiduino32.json | 3 - boards/wifiduino32c3.json | 3 - boards/wifiduino32s3.json | 3 - boards/wipy3.json | 3 - boards/wt32-eth01.json | 3 - boards/xinabox_cw02.json | 3 - builder/build_lib/idf_component.yml | 2 - builder/frameworks/arduino.py | 5 +- builder/frameworks/espidf.py | 427 +++++++++++- builder/main.py | 151 ++++- builder/penv_setup.py | 110 +-- .../README.md | 0 .../include/README | 0 .../lib/README | 0 .../platformio.ini | 5 +- .../src/SampleScan.ino | 0 examples/arduino-usb-keyboard/platformio.ini | 1 + .../components/esp_tinyusb/CHANGELOG.md | 53 -- .../components/esp_tinyusb/CMakeLists.txt | 53 -- .../components/esp_tinyusb/Kconfig | 272 -------- .../components/esp_tinyusb/LICENSE | 202 ------ .../components/esp_tinyusb/README.md | 32 - .../components/esp_tinyusb/cdc.c | 109 --- .../esp_tinyusb/descriptors_control.c | 294 -------- .../components/esp_tinyusb/idf_component.yml | 14 - .../components/esp_tinyusb/include/tinyusb.h | 75 -- .../esp_tinyusb/include/tinyusb_net.h | 99 --- .../esp_tinyusb/include/tinyusb_types.h | 21 - .../esp_tinyusb/include/tusb_cdc_acm.h | 206 ------ .../esp_tinyusb/include/tusb_config.h | 155 ----- .../esp_tinyusb/include/tusb_console.h | 33 - .../esp_tinyusb/include/tusb_msc_storage.h | 188 ----- .../esp_tinyusb/include/tusb_tasks.h | 39 -- .../esp_tinyusb/include/vfs_tinyusb.h | 69 -- .../esp_tinyusb/include_private/cdc.h | 82 --- .../include_private/descriptors_control.h | 47 -- .../include_private/usb_descriptors.h | 62 -- .../components/esp_tinyusb/sbom.yml | 2 - .../esp_tinyusb/test/local/CMakeLists.txt | 8 - .../esp_tinyusb/test/local/libusb_test.c | 121 ---- .../esp_tinyusb/test_app/CMakeLists.txt | 11 - .../components/esp_tinyusb/test_app/README.md | 4 - .../esp_tinyusb/test_app/main/CMakeLists.txt | 6 - .../test_app/main/idf_component.yml | 7 - .../esp_tinyusb/test_app/main/test_app_main.c | 57 -- .../test_app/main/test_bvalid_sig.c | 103 --- .../test_app/main/test_bvalid_sig.h | 18 - .../test_app/main/test_descriptors_config.c | 235 ------- .../test_app/main/test_descriptors_config.h | 18 - .../test_app/main/test_esp_tinyusb.c | 132 ---- .../esp_tinyusb/test_app/main/test_tud_cb.c | 28 - .../test_app/pytest_usb_device_cdc.py | 73 -- .../test_app/pytest_usb_device_esp_tinyusb.py | 12 - .../esp_tinyusb/test_app/sdkconfig.defaults | 19 - .../components/esp_tinyusb/tinyusb.c | 73 -- .../components/esp_tinyusb/tinyusb_net.c | 174 ----- .../components/esp_tinyusb/tusb_cdc_acm.c | 346 ---------- .../components/esp_tinyusb/tusb_console.c | 115 ---- .../components/esp_tinyusb/tusb_msc_storage.c | 640 ------------------ .../components/esp_tinyusb/tusb_tasks.c | 77 --- .../components/esp_tinyusb/usb_descriptors.c | 251 ------- .../components/esp_tinyusb/vfs_tinyusb.c | 301 -------- .../src/idf_component.yml | 4 + .../src/tusb_serial_device_main.c | 79 ++- monitor/filter_exception_decoder.py | 391 ++++++++++- platform.json | 8 +- platform.py | 58 +- 263 files changed, 1305 insertions(+), 5718 deletions(-) rename examples/{arduino-NimBLE-ext_client => arduino-NimBLE-SampleScan}/README.md (100%) rename examples/{arduino-NimBLE-ext_client => arduino-NimBLE-SampleScan}/include/README (100%) rename examples/{arduino-NimBLE-ext_client => arduino-NimBLE-SampleScan}/lib/README (100%) rename examples/{arduino-NimBLE-ext_client => arduino-NimBLE-SampleScan}/platformio.ini (94%) rename examples/{arduino-NimBLE-ext_client => arduino-NimBLE-SampleScan}/src/SampleScan.ino (100%) delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/CHANGELOG.md delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/CMakeLists.txt delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/Kconfig delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/LICENSE delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/README.md delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/cdc.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/descriptors_control.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/idf_component.yml delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_net.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_types.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_cdc_acm.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_config.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_console.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_msc_storage.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_tasks.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include/vfs_tinyusb.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/cdc.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/descriptors_control.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/usb_descriptors.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/sbom.yml delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/CMakeLists.txt delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/libusb_test.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/CMakeLists.txt delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/README.md delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/CMakeLists.txt delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/idf_component.yml delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_app_main.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.h delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_esp_tinyusb.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_tud_cb.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_cdc.py delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_esp_tinyusb.py delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/sdkconfig.defaults delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb_net.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_cdc_acm.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_console.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_msc_storage.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_tasks.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/usb_descriptors.c delete mode 100644 examples/espidf-peripherals-usb/components/esp_tinyusb/vfs_tinyusb.c create mode 100644 examples/espidf-peripherals-usb/src/idf_component.yml diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 86b4a8a..a8cde98 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -20,7 +20,7 @@ jobs: - "examples/arduino-wifiscan" - "examples/arduino-zigbee-light" - "examples/arduino-zigbee-switch" - - "examples/arduino-NimBLE-ext_client" + - "examples/arduino-NimBLE-SampleScan" - "examples/arduino-matter-light" - "examples/tasmota" - "examples/espidf-arduino-matter-light" diff --git a/README.md b/README.md index 58da7ae..0c6ebae 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Espressif Systems is a privately held, fabless semiconductor company renowned fo * No support for the Arduino Nora Nano board, issues needs to be solved by the community ## IDE Preparation Prerequisites: -- Python >= 3.10 and git is required for pioarduino to function properly. +- Python (3.10, 3.11, 3.12, 3.13) and git is required for pioarduino to function properly. ## Installation - [Download and install Microsoft Visual Studio Code](https://code.visualstudio.com/). pioarduino IDE is on top of it. @@ -23,14 +23,14 @@ Prerequisites: ## Usage 1. Setup new VSCode pioarduino project. -1. Configure a platform option in platformio.ini file: +1. Check the `platform` setting in platformio.ini file: ## Documentation [pioarduino Wiki](https://deepwiki.com/pioarduino/platform-espressif32) The Wiki is AI generated and insane detailed and accurate. ### Stable Arduino -currently espressif Arduino 3.3.2 and IDF 5.5.1.250929 +currently espressif Arduino 3.3.3 and IDF 5.5.1.251017 ```ini [env:stable] diff --git a/boards/adafruit_camera_esp32s3.json b/boards/adafruit_camera_esp32s3.json index 2693d86..919fe93 100644 --- a/boards/adafruit_camera_esp32s3.json +++ b/boards/adafruit_camera_esp32s3.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "partitions": "partitions-4MB-1ota.csv" }, "core": "esp32", diff --git a/boards/adafruit_feather_esp32_v2.json b/boards/adafruit_feather_esp32_v2.json index 9414b99..40e15c8 100644 --- a/boards/adafruit_feather_esp32_v2.json +++ b/boards/adafruit_feather_esp32_v2.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ADAFRUIT_FEATHER_ESP32_V2", diff --git a/boards/adafruit_itsybitsy_esp32.json b/boards/adafruit_itsybitsy_esp32.json index dd87bfc..477660f 100644 --- a/boards/adafruit_itsybitsy_esp32.json +++ b/boards/adafruit_itsybitsy_esp32.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32_out.ld", "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/adafruit_qtpy_esp32.json b/boards/adafruit_qtpy_esp32.json index d2371f7..563ffcd 100644 --- a/boards/adafruit_qtpy_esp32.json +++ b/boards/adafruit_qtpy_esp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ADAFRUIT_QTPY_ESP32_PICO", diff --git a/boards/adafruit_qtpy_esp32c3.json b/boards/adafruit_qtpy_esp32c3.json index 7c870e0..e2e3e91 100644 --- a/boards/adafruit_qtpy_esp32c3.json +++ b/boards/adafruit_qtpy_esp32c3.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ADAFRUIT_QTPY_ESP32C3", diff --git a/boards/airm2m_core_esp32c3.json b/boards/airm2m_core_esp32c3.json index e227fad..b80ea54 100644 --- a/boards/airm2m_core_esp32c3.json +++ b/boards/airm2m_core_esp32c3.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "f_cpu": "160000000L", "f_flash": "80000000L", diff --git a/boards/alksesp32.json b/boards/alksesp32.json index d94ec71..fe71ae2 100644 --- a/boards/alksesp32.json +++ b/boards/alksesp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ALKS", "f_cpu": "240000000L", diff --git a/boards/atd147_s3.json b/boards/atd147_s3.json index 8fb9d0e..abaf855 100644 --- a/boards/atd147_s3.json +++ b/boards/atd147_s3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_opi", "partitions": "default_8MB.csv" }, diff --git a/boards/atmegazero_esp32s2.json b/boards/atmegazero_esp32s2.json index a23a6ce..00be047 100644 --- a/boards/atmegazero_esp32s2.json +++ b/boards/atmegazero_esp32s2.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld", + "arduino": { "partitions": "partitions-16MB-tinyuf2.csv" }, "core": "esp32", diff --git a/boards/aventen_s3_sync.json b/boards/aventen_s3_sync.json index 83cda02..7cb8119 100644 --- a/boards/aventen_s3_sync.json +++ b/boards/aventen_s3_sync.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_qspi" }, "core": "esp32", diff --git a/boards/az-delivery-devkit-v4.json b/boards/az-delivery-devkit-v4.json index 93237d7..07ef463 100644 --- a/boards/az-delivery-devkit-v4.json +++ b/boards/az-delivery-devkit-v4.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/bee_data_logger.json b/boards/bee_data_logger.json index eb9e79d..469a58b 100644 --- a/boards/bee_data_logger.json +++ b/boards/bee_data_logger.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_BeeDataLogger", diff --git a/boards/bee_motion.json b/boards/bee_motion.json index c857790..e6ad3a3 100644 --- a/boards/bee_motion.json +++ b/boards/bee_motion.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_Bee_Motion", diff --git a/boards/bee_motion_mini.json b/boards/bee_motion_mini.json index d24163e..51df340 100644 --- a/boards/bee_motion_mini.json +++ b/boards/bee_motion_mini.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "f_cpu": "160000000L", "f_flash": "80000000L", diff --git a/boards/bee_motion_s3.json b/boards/bee_motion_s3.json index 5059861..aaa9983 100644 --- a/boards/bee_motion_s3.json +++ b/boards/bee_motion_s3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_BeeMotionS3", diff --git a/boards/bee_s3.json b/boards/bee_s3.json index 98e9663..8ed0d95 100644 --- a/boards/bee_s3.json +++ b/boards/bee_s3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_Bee_S3", diff --git a/boards/bpi-bit.json b/boards/bpi-bit.json index ec5c0dc..2a67a12 100644 --- a/boards/bpi-bit.json +++ b/boards/bpi-bit.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_BPI_BIT", "f_cpu": "160000000L", diff --git a/boards/bpi_leaf_s3.json b/boards/bpi_leaf_s3.json index 62cc90e..fe24abf 100644 --- a/boards/bpi_leaf_s3.json +++ b/boards/bpi_leaf_s3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_8MB.csv", "memory_type": "qio_qspi" }, diff --git a/boards/cnrs_aw2eth.json b/boards/cnrs_aw2eth.json index 3669347..232f695 100644 --- a/boards/cnrs_aw2eth.json +++ b/boards/cnrs_aw2eth.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ESP32_PICO" diff --git a/boards/connaxio_espoir.json b/boards/connaxio_espoir.json index e9e7265..215617f 100644 --- a/boards/connaxio_espoir.json +++ b/boards/connaxio_espoir.json @@ -1,9 +1,5 @@ - { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_CONNAXIO_ESPOIR", diff --git a/boards/cytron_maker_feather_aiot_s3.json b/boards/cytron_maker_feather_aiot_s3.json index 839a54b..ec31a2e 100644 --- a/boards/cytron_maker_feather_aiot_s3.json +++ b/boards/cytron_maker_feather_aiot_s3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_opi", "partitions": "partitions-8MB-tinyuf2.csv" }, diff --git a/boards/d-duino-32.json b/boards/d-duino-32.json index e4d92e3..0ceb569 100644 --- a/boards/d-duino-32.json +++ b/boards/d-duino-32.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_D_DUINO_32", "f_cpu": "240000000L", diff --git a/boards/deneyapkart.json b/boards/deneyapkart.json index 7d499bd..0944cba 100644 --- a/boards/deneyapkart.json +++ b/boards/deneyapkart.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DYDK", diff --git a/boards/deneyapkart1A.json b/boards/deneyapkart1A.json index 46f513f..c0ea331 100644 --- a/boards/deneyapkart1A.json +++ b/boards/deneyapkart1A.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DYDK1A", diff --git a/boards/deneyapkart1Av2.json b/boards/deneyapkart1Av2.json index e57a008..3889891 100644 --- a/boards/deneyapkart1Av2.json +++ b/boards/deneyapkart1Av2.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_opi" }, "core": "esp32", diff --git a/boards/deneyapkartg.json b/boards/deneyapkartg.json index 19f1b04..d9c38a9 100644 --- a/boards/deneyapkartg.json +++ b/boards/deneyapkartg.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DYG", diff --git a/boards/deneyapmini.json b/boards/deneyapmini.json index 5a358cd..5ca30ee 100644 --- a/boards/deneyapmini.json +++ b/boards/deneyapmini.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DYM", diff --git a/boards/deneyapminiv2.json b/boards/deneyapminiv2.json index 42058a8..358defc 100644 --- a/boards/deneyapminiv2.json +++ b/boards/deneyapminiv2.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DYMv2", diff --git a/boards/denky32.json b/boards/denky32.json index 3b2c407..8b95c31 100644 --- a/boards/denky32.json +++ b/boards/denky32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DENKY_WROOM32", diff --git a/boards/denky_d4.json b/boards/denky_d4.json index 7846bf1..7d9f724 100644 --- a/boards/denky_d4.json +++ b/boards/denky_d4.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DENKY_PICOV3", diff --git a/boards/dfrobot_beetle_esp32c3.json b/boards/dfrobot_beetle_esp32c3.json index ab0b4c9..0f2367b 100644 --- a/boards/dfrobot_beetle_esp32c3.json +++ b/boards/dfrobot_beetle_esp32c3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ESP32C3_DEV", diff --git a/boards/dfrobot_firebeetle2_esp32e.json b/boards/dfrobot_firebeetle2_esp32e.json index 0d3790c..06f6630 100644 --- a/boards/dfrobot_firebeetle2_esp32e.json +++ b/boards/dfrobot_firebeetle2_esp32e.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_DFROBOT_FIREBEETLE_2_ESP32E", diff --git a/boards/dfrobot_firebeetle2_esp32s3.json b/boards/dfrobot_firebeetle2_esp32s3.json index c1997db..a779d13 100644 --- a/boards/dfrobot_firebeetle2_esp32s3.json +++ b/boards/dfrobot_firebeetle2_esp32s3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ESP32S3_DEV", diff --git a/boards/dpu_esp32.json b/boards/dpu_esp32.json index 1f5b89a..f56a8ba 100644 --- a/boards/dpu_esp32.json +++ b/boards/dpu_esp32.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32_out.ld", "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/edgebox-esp-100.json b/boards/edgebox-esp-100.json index d00074d..63e0961 100644 --- a/boards/edgebox-esp-100.json +++ b/boards/edgebox-esp-100.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_qspi" }, "core": "esp32", diff --git a/boards/esp-wrover-kit.json b/boards/esp-wrover-kit.json index 50d66a7..f0bd387 100644 --- a/boards/esp-wrover-kit.json +++ b/boards/esp-wrover-kit.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/esp32-c3-devkitc-02.json b/boards/esp32-c3-devkitc-02.json index 320b763..6e163b6 100644 --- a/boards/esp32-c3-devkitc-02.json +++ b/boards/esp32-c3-devkitc-02.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "f_cpu": "160000000L", "f_flash": "80000000L", diff --git a/boards/esp32-c3-devkitm-1.json b/boards/esp32-c3-devkitm-1.json index cf1a573..fdce4f6 100644 --- a/boards/esp32-c3-devkitm-1.json +++ b/boards/esp32-c3-devkitm-1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "f_cpu": "160000000L", "f_flash": "80000000L", diff --git a/boards/esp32-c3-m1i-kit.json b/boards/esp32-c3-m1i-kit.json index 8e7d7cb..5a11064 100644 --- a/boards/esp32-c3-m1i-kit.json +++ b/boards/esp32-c3-m1i-kit.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "f_cpu": "160000000L", "f_flash": "80000000L", diff --git a/boards/esp32-devkitlipo.json b/boards/esp32-devkitlipo.json index 419edfd..760f069 100644 --- a/boards/esp32-devkitlipo.json +++ b/boards/esp32-devkitlipo.json @@ -1,14 +1,16 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEVKIT_LIPO", "f_cpu": "240000000L", "f_flash": "80000000L", "flash_mode": "qio", - "hwids": [["0x1A86", "0x7523"]], + "hwids": [ + [ + "0x1A86", + "0x7523" + ] + ], "mcu": "esp32", "variant": "esp32-devkit-lipo" }, diff --git a/boards/esp32-evb.json b/boards/esp32-evb.json index c821386..3250e5c 100644 --- a/boards/esp32-evb.json +++ b/boards/esp32-evb.json @@ -1,14 +1,16 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_EVB", "f_cpu": "240000000L", "f_flash": "40000000L", "flash_mode": "dio", - "hwids": [["0x1A86", "0x7523"]], + "hwids": [ + [ + "0x1A86", + "0x7523" + ] + ], "mcu": "esp32", "variant": "esp32-evb" }, diff --git a/boards/esp32-gateway.json b/boards/esp32-gateway.json index 33f0f2f..4151795 100644 --- a/boards/esp32-gateway.json +++ b/boards/esp32-gateway.json @@ -1,14 +1,16 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_GATEWAY", "f_cpu": "240000000L", "f_flash": "40000000L", "flash_mode": "dio", - "hwids": [["0x1A86", "0x7523"]], + "hwids": [ + [ + "0x1A86", + "0x7523" + ] + ], "mcu": "esp32", "variant": "esp32-gateway" }, diff --git a/boards/esp32-p4-evboard.json b/boards/esp32-p4-evboard.json index 1ea9283..f879cf6 100644 --- a/boards/esp32-p4-evboard.json +++ b/boards/esp32-p4-evboard.json @@ -6,6 +6,7 @@ ], "f_cpu": "360000000L", "f_flash": "80000000L", + "f_psram": "200000000L", "flash_mode": "qio", "mcu": "esp32p4", "variant": "esp32p4" diff --git a/boards/esp32-p4.json b/boards/esp32-p4.json index 0a05148..ec721a8 100644 --- a/boards/esp32-p4.json +++ b/boards/esp32-p4.json @@ -6,6 +6,7 @@ ], "f_cpu": "360000000L", "f_flash": "80000000L", + "f_psram": "200000000L", "flash_mode": "qio", "mcu": "esp32p4", "variant": "esp32p4" diff --git a/boards/esp32-pico-devkitm-2.json b/boards/esp32-pico-devkitm-2.json index 821128b..b792612 100644 --- a/boards/esp32-pico-devkitm-2.json +++ b/boards/esp32-pico-devkitm-2.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ESP32_PICO_DEVKITM_2", diff --git a/boards/esp32-poe-iso.json b/boards/esp32-poe-iso.json index 4412f94..680179b 100644 --- a/boards/esp32-poe-iso.json +++ b/boards/esp32-poe-iso.json @@ -1,14 +1,16 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_POE_ISO", "f_cpu": "240000000L", "f_flash": "40000000L", "flash_mode": "dio", - "hwids": [["0x1A86", "0x7523"]], + "hwids": [ + [ + "0x1A86", + "0x7523" + ] + ], "mcu": "esp32", "variant": "esp32-poe-iso" }, diff --git a/boards/esp32-poe.json b/boards/esp32-poe.json index 0cf9bd4..f55a52d 100644 --- a/boards/esp32-poe.json +++ b/boards/esp32-poe.json @@ -1,14 +1,16 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_POE", "f_cpu": "240000000L", "f_flash": "40000000L", "flash_mode": "dio", - "hwids": [["0x1A86", "0x7523"]], + "hwids": [ + [ + "0x1A86", + "0x7523" + ] + ], "mcu": "esp32", "variant": "esp32-poe" }, diff --git a/boards/esp32-pro.json b/boards/esp32-pro.json index ab19572..1306da9 100644 --- a/boards/esp32-pro.json +++ b/boards/esp32-pro.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_PRO", "f_cpu": "240000000L", diff --git a/boards/esp32-s2-kaluga-1.json b/boards/esp32-s2-kaluga-1.json index 1f16533..656feb4 100644 --- a/boards/esp32-s2-kaluga-1.json +++ b/boards/esp32-s2-kaluga-1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "f_cpu": "240000000L", "f_flash": "80000000L", diff --git a/boards/esp32-s2-saola-1.json b/boards/esp32-s2-saola-1.json index f264131..492db86 100644 --- a/boards/esp32-s2-saola-1.json +++ b/boards/esp32-s2-saola-1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32S2_DEV", "f_cpu": "240000000L", diff --git a/boards/esp32-s3-devkitc-1.json b/boards/esp32-s3-devkitc-1.json index b9c184c..883d085 100644 --- a/boards/esp32-s3-devkitc-1.json +++ b/boards/esp32-s3-devkitc-1.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/esp32-s3-devkitm-1.json b/boards/esp32-s3-devkitm-1.json index b4bcf5c..91950e5 100644 --- a/boards/esp32-s3-devkitm-1.json +++ b/boards/esp32-s3-devkitm-1.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/esp320.json b/boards/esp320.json index dfa8720..a4960ea 100644 --- a/boards/esp320.json +++ b/boards/esp320.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP320", "f_cpu": "240000000L", diff --git a/boards/esp32cam.json b/boards/esp32cam.json index f712939..f7deed4 100644 --- a/boards/esp32cam.json +++ b/boards/esp32cam.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "huge_app.csv" }, "core": "esp32", diff --git a/boards/esp32dev.json b/boards/esp32dev.json index 53c81b6..cf2839b 100644 --- a/boards/esp32dev.json +++ b/boards/esp32dev.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/esp32doit-devkit-v1.json b/boards/esp32doit-devkit-v1.json index 5aff5de..fc33c35 100644 --- a/boards/esp32doit-devkit-v1.json +++ b/boards/esp32doit-devkit-v1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/esp32doit-espduino.json b/boards/esp32doit-espduino.json index 1cadd7e..b5dea83 100644 --- a/boards/esp32doit-espduino.json +++ b/boards/esp32doit-espduino.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/esp32s3box.json b/boards/esp32s3box.json index 8a7bfa9..4bd6a1d 100644 --- a/boards/esp32s3box.json +++ b/boards/esp32s3box.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "memory_type": "qio_opi" }, "core": "esp32", diff --git a/boards/esp32s3camlcd.json b/boards/esp32s3camlcd.json index 1d7e0c4..96da223 100644 --- a/boards/esp32s3camlcd.json +++ b/boards/esp32s3camlcd.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "memory_type": "opi_opi" }, "boot": "opi", diff --git a/boards/esp32s3usbotg.json b/boards/esp32s3usbotg.json index eaa427a..b9da99e 100644 --- a/boards/esp32s3usbotg.json +++ b/boards/esp32s3usbotg.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/esp32thing.json b/boards/esp32thing.json index 4c168e3..b8ac940 100644 --- a/boards/esp32thing.json +++ b/boards/esp32thing.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_THING", "f_cpu": "240000000L", diff --git a/boards/esp32thing_plus.json b/boards/esp32thing_plus.json index cf1a74d..862d824 100644 --- a/boards/esp32thing_plus.json +++ b/boards/esp32thing_plus.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "default_16MB.csv" }, "core": "esp32", diff --git a/boards/esp32vn-iot-uno.json b/boards/esp32vn-iot-uno.json index 83e794e..89154f4 100644 --- a/boards/esp32vn-iot-uno.json +++ b/boards/esp32vn-iot-uno.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_esp32vn_iot_uno", "f_cpu": "240000000L", diff --git a/boards/espea32.json b/boards/espea32.json index d995b8b..ea6fb83 100644 --- a/boards/espea32.json +++ b/boards/espea32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESPea32", "f_cpu": "240000000L", diff --git a/boards/espectro32.json b/boards/espectro32.json index 973c608..165663d 100644 --- a/boards/espectro32.json +++ b/boards/espectro32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESPECTRO32", "f_cpu": "240000000L", diff --git a/boards/espino32.json b/boards/espino32.json index 162d979..d466ed3 100644 --- a/boards/espino32.json +++ b/boards/espino32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESPino32", "f_cpu": "240000000L", diff --git a/boards/etboard.json b/boards/etboard.json index 8ae9775..0b2146e 100644 --- a/boards/etboard.json +++ b/boards/etboard.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ETBoard", "f_cpu": "240000000L", diff --git a/boards/featheresp32-s2.json b/boards/featheresp32-s2.json index 6933ccb..9105b3f 100644 --- a/boards/featheresp32-s2.json +++ b/boards/featheresp32-s2.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld", + "arduino": { "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", diff --git a/boards/featheresp32.json b/boards/featheresp32.json index ac922db..982d2db 100644 --- a/boards/featheresp32.json +++ b/boards/featheresp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_FEATHER_ESP32", "f_cpu": "240000000L", diff --git a/boards/firebeetle32.json b/boards/firebeetle32.json index 3463fa1..a699f50 100644 --- a/boards/firebeetle32.json +++ b/boards/firebeetle32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/fm-devkit.json b/boards/fm-devkit.json index 322975a..9df93d5 100644 --- a/boards/fm-devkit.json +++ b/boards/fm-devkit.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_fm_devkit", "f_cpu": "240000000L", diff --git a/boards/franzininho_wifi_esp32s2.json b/boards/franzininho_wifi_esp32s2.json index df3a565..9697937 100644 --- a/boards/franzininho_wifi_esp32s2.json +++ b/boards/franzininho_wifi_esp32s2.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_FRANZININHO_WIFI", diff --git a/boards/franzininho_wifi_msc_esp32s2.json b/boards/franzininho_wifi_msc_esp32s2.json index 163587b..715eada 100644 --- a/boards/franzininho_wifi_msc_esp32s2.json +++ b/boards/franzininho_wifi_msc_esp32s2.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_FRANZININHO_WIFI_MSC", diff --git a/boards/frogboard.json b/boards/frogboard.json index 93a7729..1c27679 100644 --- a/boards/frogboard.json +++ b/boards/frogboard.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_FROG_ESP32", "f_cpu": "240000000L", diff --git a/boards/healthypi4.json b/boards/healthypi4.json index bfebc98..2624758 100644 --- a/boards/healthypi4.json +++ b/boards/healthypi4.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_HEALTHYPI_4", "f_cpu": "240000000L", diff --git a/boards/heltec_wifi_kit_32.json b/boards/heltec_wifi_kit_32.json index 0960dd4..1940753 100644 --- a/boards/heltec_wifi_kit_32.json +++ b/boards/heltec_wifi_kit_32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_HELTEC_WIFI_KIT_32", "f_cpu": "240000000L", diff --git a/boards/heltec_wifi_kit_32_v2.json b/boards/heltec_wifi_kit_32_v2.json index eb80db6..4ce1fac 100644 --- a/boards/heltec_wifi_kit_32_v2.json +++ b/boards/heltec_wifi_kit_32_v2.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/heltec_wifi_lora_32.json b/boards/heltec_wifi_lora_32.json index 3937118..59896b0 100644 --- a/boards/heltec_wifi_lora_32.json +++ b/boards/heltec_wifi_lora_32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_HELTEC_WIFI_LORA_32", "f_cpu": "240000000L", diff --git a/boards/heltec_wifi_lora_32_V2.json b/boards/heltec_wifi_lora_32_V2.json index c2a0f95..3bb3872 100644 --- a/boards/heltec_wifi_lora_32_V2.json +++ b/boards/heltec_wifi_lora_32_V2.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/heltec_wifi_lora_32_V3.json b/boards/heltec_wifi_lora_32_V3.json index 09a8e1c..24fc15c 100644 --- a/boards/heltec_wifi_lora_32_V3.json +++ b/boards/heltec_wifi_lora_32_V3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/heltec_wireless_stick.json b/boards/heltec_wireless_stick.json index 1f09ca4..611592f 100644 --- a/boards/heltec_wireless_stick.json +++ b/boards/heltec_wireless_stick.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/honeylemon.json b/boards/honeylemon.json index c3796df..67ebb37 100644 --- a/boards/honeylemon.json +++ b/boards/honeylemon.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_HONEYLEMON", "f_cpu": "240000000L", diff --git a/boards/hornbill32dev.json b/boards/hornbill32dev.json index 6d96e58..97e149c 100644 --- a/boards/hornbill32dev.json +++ b/boards/hornbill32dev.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_HORNBILL_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/hornbill32minima.json b/boards/hornbill32minima.json index fce2579..e91d6bc 100644 --- a/boards/hornbill32minima.json +++ b/boards/hornbill32minima.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_HORNBILL_ESP32_MINIMA", "f_cpu": "240000000L", diff --git a/boards/imbrios-logsens-v1p1.json b/boards/imbrios-logsens-v1p1.json index a65362f..f4e3bf7 100644 --- a/boards/imbrios-logsens-v1p1.json +++ b/boards/imbrios-logsens-v1p1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_IMBRIOS_LOGSENS_V1P1", "f_cpu": "240000000L", diff --git a/boards/inex_openkb.json b/boards/inex_openkb.json index 8f326d5..de8efa9 100644 --- a/boards/inex_openkb.json +++ b/boards/inex_openkb.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_openkb", "f_cpu": "240000000L", diff --git a/boards/intorobot.json b/boards/intorobot.json index 6149bce..0b7b8b1 100644 --- a/boards/intorobot.json +++ b/boards/intorobot.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_INTOROBOT_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/iotaap_magnolia.json b/boards/iotaap_magnolia.json index 47c1eba..6f2345f 100644 --- a/boards/iotaap_magnolia.json +++ b/boards/iotaap_magnolia.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/iotbusio.json b/boards/iotbusio.json index 11c4264..e7297f3 100644 --- a/boards/iotbusio.json +++ b/boards/iotbusio.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/iotbusproteus.json b/boards/iotbusproteus.json index 3859504..03f5507 100644 --- a/boards/iotbusproteus.json +++ b/boards/iotbusproteus.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/ioxesp32.json b/boards/ioxesp32.json index e157542..d4d5d2c 100644 --- a/boards/ioxesp32.json +++ b/boards/ioxesp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_IOXESP32", "f_cpu": "240000000L", diff --git a/boards/ioxesp32ps.json b/boards/ioxesp32ps.json index ad66d9b..e12efb9 100644 --- a/boards/ioxesp32ps.json +++ b/boards/ioxesp32ps.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-mfix-esp32-psram-cache-issue", diff --git a/boards/kb32-ft.json b/boards/kb32-ft.json index 4bfab5e..86bc071 100644 --- a/boards/kb32-ft.json +++ b/boards/kb32-ft.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ESP32_DEV", diff --git a/boards/kits-edu.json b/boards/kits-edu.json index 6ec72ae..c47b3fe 100644 --- a/boards/kits-edu.json +++ b/boards/kits-edu.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_PICO", "f_cpu": "240000000L", diff --git a/boards/labplus_mpython.json b/boards/labplus_mpython.json index 3d3a4ff..94b71ae 100644 --- a/boards/labplus_mpython.json +++ b/boards/labplus_mpython.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "huge_app.csv" }, "core": "esp32", diff --git a/boards/lilka_v2.json b/boards/lilka_v2.json index c21432e..dcd2d04 100644 --- a/boards/lilka_v2.json +++ b/boards/lilka_v2.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "memory_type": "qio_opi", "partitions": "default_16MB.csv" }, @@ -57,4 +56,3 @@ "url": "https://github.com/and3rson/lilka", "vendor": "Anderson & friends" } - diff --git a/boards/lilygo-t-display-s3.json b/boards/lilygo-t-display-s3.json index f764727..34dcb34 100644 --- a/boards/lilygo-t-display-s3.json +++ b/boards/lilygo-t-display-s3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_opi", "partitions": "default_16MB.csv" }, @@ -44,6 +43,6 @@ "require_upload_port": true, "speed": 460800 }, - "url": "https://www.lilygo.cc/products/t-display-s3", + "url": "https://lilygo.cc/products/t-display-s3", "vendor": "LilyGo" } diff --git a/boards/lilygo-t-display.json b/boards/lilygo-t-display.json index c55bdb1..2700fa9 100644 --- a/boards/lilygo-t-display.json +++ b/boards/lilygo-t-display.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_LILYGO_T_DISPLAY", @@ -39,6 +36,6 @@ "require_upload_port": true, "speed": 460800 }, - "url": "hhttps://www.lilygo.cc/products/lilygo%C2%AE-ttgo-t-display-1-14-inch-lcd-esp32-control-board", + "url": "https://lilygo.cc/products/t-display", "vendor": "LilyGo" } diff --git a/boards/lionbit.json b/boards/lionbit.json index c8186d0..b53d0a2 100644 --- a/boards/lionbit.json +++ b/boards/lionbit.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_LIONBIT", @@ -12,7 +9,7 @@ "f_cpu": "240000000L", "f_flash": "40000000L", "flash_mode": "dio", - "flags" : "-DCORE_DEBUG_LEVEL=5", + "flags": "-DCORE_DEBUG_LEVEL=5", "mcu": "esp32", "variant": "lionbit" }, @@ -38,7 +35,7 @@ "speed": 115200 }, "monitor": { - "speed" : 115200 + "speed": 115200 }, "url": "http://lionbit.lk/", "vendor": "Lion:Bit" diff --git a/boards/lionbits3.json b/boards/lionbits3.json index 56bc5cd..f99f6cb 100644 --- a/boards/lionbits3.json +++ b/boards/lionbits3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_LIONBITS3_DEV", diff --git a/boards/lolin32.json b/boards/lolin32.json index 446b2cd..b24dbc3 100644 --- a/boards/lolin32.json +++ b/boards/lolin32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_LOLIN32", "f_cpu": "240000000L", diff --git a/boards/lolin32_lite.json b/boards/lolin32_lite.json index 4563269..deb82ee 100644 --- a/boards/lolin32_lite.json +++ b/boards/lolin32_lite.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_LOLIN32_LITE", "f_cpu": "240000000L", diff --git a/boards/lolin_c3_mini.json b/boards/lolin_c3_mini.json index 63afade..dffb7ab 100644 --- a/boards/lolin_c3_mini.json +++ b/boards/lolin_c3_mini.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_LOLIN_C3_MINI", diff --git a/boards/lolin_d32.json b/boards/lolin_d32.json index bde02b3..5758349 100644 --- a/boards/lolin_d32.json +++ b/boards/lolin_d32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_LOLIN_D32", "f_cpu": "240000000L", diff --git a/boards/lolin_d32_pro.json b/boards/lolin_d32_pro.json index 732b073..0029f33 100644 --- a/boards/lolin_d32_pro.json +++ b/boards/lolin_d32_pro.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_LOLIN_D32_PRO -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue", "f_cpu": "240000000L", diff --git a/boards/lolin_s2_mini.json b/boards/lolin_s2_mini.json index 1282c1f..6a149bd 100644 --- a/boards/lolin_s2_mini.json +++ b/boards/lolin_s2_mini.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_LOLIN_S2_MINI", diff --git a/boards/lolin_s2_pico.json b/boards/lolin_s2_pico.json index 0214a0e..08c7329 100644 --- a/boards/lolin_s2_pico.json +++ b/boards/lolin_s2_pico.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_LOLIN_S2_PICO", diff --git a/boards/lolin_s3.json b/boards/lolin_s3.json index 8124b93..9ba721f 100644 --- a/boards/lolin_s3.json +++ b/boards/lolin_s3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_16MB.csv", "memory_type": "qio_opi" }, diff --git a/boards/lolin_s3_pro.json b/boards/lolin_s3_pro.json index 4340aac..09a984c 100644 --- a/boards/lolin_s3_pro.json +++ b/boards/lolin_s3_pro.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_16MB.csv", "memory_type": "qio_opi" }, diff --git a/boards/lopy.json b/boards/lopy.json index 307d06a..8f7c936 100644 --- a/boards/lopy.json +++ b/boards/lopy.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_LoPy", "f_cpu": "240000000L", diff --git a/boards/lopy4.json b/boards/lopy4.json index 29062f0..42b07ed 100644 --- a/boards/lopy4.json +++ b/boards/lopy4.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_LoPy4", "f_cpu": "240000000L", diff --git a/boards/m5stack-atom.json b/boards/m5stack-atom.json index fd704b0..e42a8cb 100644 --- a/boards/m5stack-atom.json +++ b/boards/m5stack-atom.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_M5Stack_ATOM", "f_cpu": "240000000L", diff --git a/boards/m5stack-atoms3.json b/boards/m5stack-atoms3.json index c80ded0..ec923d9 100644 --- a/boards/m5stack-atoms3.json +++ b/boards/m5stack-atoms3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/m5stack-core2.json b/boards/m5stack-core2.json index 2c3b951..18432be 100644 --- a/boards/m5stack-core2.json +++ b/boards/m5stack-core2.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "default_16MB.csv" }, "core": "esp32", diff --git a/boards/m5stack-coreink.json b/boards/m5stack-coreink.json index e7b3cbb..2246783 100644 --- a/boards/m5stack-coreink.json +++ b/boards/m5stack-coreink.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_M5Stack_CoreInk", "f_cpu": "240000000L", diff --git a/boards/m5stack-cores3.json b/boards/m5stack-cores3.json index 96bc686..372c3cc 100644 --- a/boards/m5stack-cores3.json +++ b/boards/m5stack-cores3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_16MB.csv" }, "core": "esp32", diff --git a/boards/m5stack-fire.json b/boards/m5stack-fire.json index 1a500ab..2ae6cd2 100644 --- a/boards/m5stack-fire.json +++ b/boards/m5stack-fire.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "default_16MB.csv" }, "core": "esp32", diff --git a/boards/m5stack-stamps3.json b/boards/m5stack-stamps3.json index 31c7f25..e90b30d 100644 --- a/boards/m5stack-stamps3.json +++ b/boards/m5stack-stamps3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/m5stack-station.json b/boards/m5stack-station.json index 31693d5..bf93dd6 100644 --- a/boards/m5stack-station.json +++ b/boards/m5stack-station.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_M5Stack_Station", "f_cpu": "240000000L", diff --git a/boards/m5stack-tab5-p4.json b/boards/m5stack-tab5-p4.json index a8fea2b..7c561ca 100644 --- a/boards/m5stack-tab5-p4.json +++ b/boards/m5stack-tab5-p4.json @@ -8,6 +8,7 @@ ], "f_cpu": "360000000L", "f_flash": "80000000L", + "f_psram": "200000000L", "flash_mode": "qio", "mcu": "esp32p4", "variant": "m5stack_tab5" diff --git a/boards/m5stack-timer-cam.json b/boards/m5stack-timer-cam.json index 5f76a86..19090aa 100644 --- a/boards/m5stack-timer-cam.json +++ b/boards/m5stack-timer-cam.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_M5Stack_Timer_CAM", diff --git a/boards/m5stamp-pico.json b/boards/m5stamp-pico.json index 8f39fe5..46220c8 100644 --- a/boards/m5stamp-pico.json +++ b/boards/m5stamp-pico.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_M5Stamp_Pico", "f_cpu": "240000000L", diff --git a/boards/m5stick-c.json b/boards/m5stick-c.json index 5c96d7e..6fd3b77 100644 --- a/boards/m5stick-c.json +++ b/boards/m5stick-c.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_M5Stick_C", "f_cpu": "240000000L", diff --git a/boards/magicbit.json b/boards/magicbit.json index 53b939e..4395d48 100644 --- a/boards/magicbit.json +++ b/boards/magicbit.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/mgbot-iotik32a.json b/boards/mgbot-iotik32a.json index b4dc416..f9fc0f6 100644 --- a/boards/mgbot-iotik32a.json +++ b/boards/mgbot-iotik32a.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_MGBOT_IOTIK32A", "f_cpu": "240000000L", diff --git a/boards/mgbot-iotik32b.json b/boards/mgbot-iotik32b.json index 15f3d85..220d550 100644 --- a/boards/mgbot-iotik32b.json +++ b/boards/mgbot-iotik32b.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_MGBOT_IOTIK32B", "f_cpu": "240000000L", diff --git a/boards/mhetesp32devkit.json b/boards/mhetesp32devkit.json index 7b677c9..6aa0a6b 100644 --- a/boards/mhetesp32devkit.json +++ b/boards/mhetesp32devkit.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_MH_ET_LIVE_ESP32DEVKIT", "f_cpu": "240000000L", diff --git a/boards/mhetesp32minikit.json b/boards/mhetesp32minikit.json index 67f451e..d456622 100644 --- a/boards/mhetesp32minikit.json +++ b/boards/mhetesp32minikit.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_MH_ET_LIVE_ESP32MINIKIT", "f_cpu": "240000000L", diff --git a/boards/microduino-core-esp32.json b/boards/microduino-core-esp32.json index f1dddb7..f4fed41 100644 --- a/boards/microduino-core-esp32.json +++ b/boards/microduino-core-esp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_CoreESP32", "f_cpu": "240000000L", diff --git a/boards/micros2.json b/boards/micros2.json index 93243bd..97d596b 100644 --- a/boards/micros2.json +++ b/boards/micros2.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld", + "arduino": { "partitions": "ffat.csv" }, "core": "esp32", diff --git a/boards/minimain_esp32s2.json b/boards/minimain_esp32s2.json index 5502a6a..843a3ea 100644 --- a/boards/minimain_esp32s2.json +++ b/boards/minimain_esp32s2.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s2_out.ld", "partitions": "partitions-4MB-tinyuf2.csv" }, "core": "esp32", diff --git a/boards/namino_arancio.json b/boards/namino_arancio.json index e0fcd34..2afc620 100644 --- a/boards/namino_arancio.json +++ b/boards/namino_arancio.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_qspi" }, "core": "esp32", diff --git a/boards/namino_rosso.json b/boards/namino_rosso.json index 0154584..212b2ba 100644 --- a/boards/namino_rosso.json +++ b/boards/namino_rosso.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_qspi" }, "core": "esp32", diff --git a/boards/nano32.json b/boards/nano32.json index 2e1f556..3e33aae 100644 --- a/boards/nano32.json +++ b/boards/nano32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_NANO32", "f_cpu": "240000000L", diff --git a/boards/nebulas3.json b/boards/nebulas3.json index 5dd922b..7ec1aac 100644 --- a/boards/nebulas3.json +++ b/boards/nebulas3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_opi" }, "core": "esp32", diff --git a/boards/nina_w10.json b/boards/nina_w10.json index a0041df..1310524 100644 --- a/boards/nina_w10.json +++ b/boards/nina_w10.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "minimal.csv" }, "core": "esp32", diff --git a/boards/node32s.json b/boards/node32s.json index 192bda3..a20fb1e 100644 --- a/boards/node32s.json +++ b/boards/node32s.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Node32s", "f_cpu": "240000000L", diff --git a/boards/nodemcu-32s.json b/boards/nodemcu-32s.json index 5d30f2c..fd67363 100644 --- a/boards/nodemcu-32s.json +++ b/boards/nodemcu-32s.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_NodeMCU_32S", "f_cpu": "240000000L", diff --git a/boards/nodemcu-32s2.json b/boards/nodemcu-32s2.json index 984b90d..9a81882 100644 --- a/boards/nodemcu-32s2.json +++ b/boards/nodemcu-32s2.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32S2_DEV", "f_cpu": "240000000L", diff --git a/boards/nscreen-32.json b/boards/nscreen-32.json index d9b3a40..ab4cabd 100644 --- a/boards/nscreen-32.json +++ b/boards/nscreen-32.json @@ -1,40 +1,37 @@ -{ - "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, - "core": "esp32", - "extra_flags": "-DARDUINO_ESP32_DEV", - "f_cpu": "240000000L", - "f_flash": "80000000L", - "flash_mode": "qio", - "hwids": [ - [ - "0x0403", - "0x6010" - ] - ], - "mcu": "esp32", - "variant": "esp32" - }, - "connectivity": [ - "wifi", - "bluetooth", - "ethernet", - "can" - ], - "frameworks": [ - "arduino", - "espidf" - ], - "name": "YeaCreate NSCREEN-32", - "upload": { - "flash_size": "16MB", - "maximum_ram_size": 327680, - "maximum_size": 16777216, - "require_upload_port": true, - "speed": 460800 - }, - "url": "https://yeacreate.com", - "vendor": "YeaCreate" -} +{ + "build": { + "core": "esp32", + "extra_flags": "-DARDUINO_ESP32_DEV", + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x0403", + "0x6010" + ] + ], + "mcu": "esp32", + "variant": "esp32" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "YeaCreate NSCREEN-32", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://yeacreate.com", + "vendor": "YeaCreate" +} diff --git a/boards/odroid_esp32.json b/boards/odroid_esp32.json index 0634df3..4e840ce 100644 --- a/boards/odroid_esp32.json +++ b/boards/odroid_esp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ODROID_ESP32 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue", "f_cpu": "240000000L", diff --git a/boards/onehorse32dev.json b/boards/onehorse32dev.json index 4b23641..183f74d 100644 --- a/boards/onehorse32dev.json +++ b/boards/onehorse32dev.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ONEHORSE_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/oroca_edubot.json b/boards/oroca_edubot.json index 2a99c8c..2e14204 100644 --- a/boards/oroca_edubot.json +++ b/boards/oroca_edubot.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "huge_app.csv" }, "core": "esp32", diff --git a/boards/pico32.json b/boards/pico32.json index 5580b07..933ac5a 100644 --- a/boards/pico32.json +++ b/boards/pico32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_PICO", "f_cpu": "240000000L", diff --git a/boards/piranha_esp32.json b/boards/piranha_esp32.json index acd8a23..b07919e 100644 --- a/boards/piranha_esp32.json +++ b/boards/piranha_esp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Piranha", "f_cpu": "240000000L", diff --git a/boards/pocket_32.json b/boards/pocket_32.json index 153ac23..be78a3e 100644 --- a/boards/pocket_32.json +++ b/boards/pocket_32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Pocket32", "f_cpu": "240000000L", diff --git a/boards/pycom_gpy.json b/boards/pycom_gpy.json index 37cc507..036f60d 100644 --- a/boards/pycom_gpy.json +++ b/boards/pycom_gpy.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_PYCOM_GPY", "f_cpu": "240000000L", diff --git a/boards/qchip.json b/boards/qchip.json index 11f4c92..0fb9218 100644 --- a/boards/qchip.json +++ b/boards/qchip.json @@ -1,34 +1,31 @@ { - "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, - "core": "esp32", - "extra_flags": "-DARDUINO_HELTEC_WIFI_KIT_32", - "f_cpu": "240000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "mcu": "esp32", - "variant": "heltec_wifi_kit_32" - }, - "connectivity": [ - "wifi", - "bluetooth", - "ethernet", - "can" - ], - "frameworks": [ - "arduino", - "espidf" - ], - "name": "Qchip", - "upload": { - "flash_size": "4MB", - "maximum_ram_size": 327680, - "maximum_size": 4194304, - "require_upload_port": true, - "speed": 460800 - }, - "url": "http://qmobot.com/", - "vendor": "Qmobot LLP" - } \ No newline at end of file + "build": { + "core": "esp32", + "extra_flags": "-DARDUINO_HELTEC_WIFI_KIT_32", + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "heltec_wifi_kit_32" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Qchip", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "http://qmobot.com/", + "vendor": "Qmobot LLP" +} diff --git a/boards/quantum.json b/boards/quantum.json index ea5ae27..f458313 100644 --- a/boards/quantum.json +++ b/boards/quantum.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_QUANTUM", "f_cpu": "240000000L", diff --git a/boards/redpill_esp32s3.json b/boards/redpill_esp32s3.json index c9991e7..c281d7f 100644 --- a/boards/redpill_esp32s3.json +++ b/boards/redpill_esp32s3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_qspi" }, "core": "esp32", diff --git a/boards/roboheart_hercules.json b/boards/roboheart_hercules.json index 46740d2..14a9678 100644 --- a/boards/roboheart_hercules.json +++ b/boards/roboheart_hercules.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_roboheart_hercules", diff --git a/boards/s_odi_ultra.json b/boards/s_odi_ultra.json index 3a03078..d758105 100644 --- a/boards/s_odi_ultra.json +++ b/boards/s_odi_ultra.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/seeed_xiao_esp32c3.json b/boards/seeed_xiao_esp32c3.json index 24b1671..92f1ac7 100644 --- a/boards/seeed_xiao_esp32c3.json +++ b/boards/seeed_xiao_esp32c3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_XIAO_ESP32C3", @@ -20,7 +17,7 @@ [ "0x303a", "0x1001" - ] + ] ], "mcu": "esp32c3", "variant": "XIAO_ESP32C3" diff --git a/boards/seeed_xiao_esp32s3.json b/boards/seeed_xiao_esp32s3.json index 5c7171c..09b6a44 100644 --- a/boards/seeed_xiao_esp32s3.json +++ b/boards/seeed_xiao_esp32s3.json @@ -1,54 +1,53 @@ -{ - "build": { - "arduino": { - "ldscript": "esp32s3_out.ld", - "partitions": "default_8MB.csv", - "memory_type": "qio_opi" - }, - "core": "esp32", - "extra_flags": [ - "-DARDUINO_XIAO_ESP32S3", - "-DBOARD_HAS_PSRAM", - "-DARDUINO_USB_MODE=1", - "-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": [ - [ - "0x2886", - "0x0056" - ], - [ - "0x2886", - "0x8056" - ] - ], - "mcu": "esp32s3", - "variant": "XIAO_ESP32S3" - }, - "connectivity": [ - "bluetooth", - "wifi" - ], - "debug": { - "openocd_target": "esp32s3.cfg" - }, - "frameworks": [ - "arduino", - "espidf" - ], - "name": "Seeed Studio XIAO ESP32S3", - "upload": { - "flash_size": "8MB", - "maximum_ram_size": 327680, - "maximum_size": 8388608, - "require_upload_port": true, - "speed": 460800 - }, - "url": "https://www.seeedstudio.com/XIAO-ESP32S3-p-5627.html", - "vendor": "Seeed Studio" -} +{ + "build": { + "arduino": { + "partitions": "default_8MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_XIAO_ESP32S3", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_MODE=1", + "-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": [ + [ + "0x2886", + "0x0056" + ], + [ + "0x2886", + "0x8056" + ] + ], + "mcu": "esp32s3", + "variant": "XIAO_ESP32S3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Seeed Studio XIAO ESP32S3", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.seeedstudio.com/XIAO-ESP32S3-p-5627.html", + "vendor": "Seeed Studio" +} diff --git a/boards/sensebox_mcu_esp32s2.json b/boards/sensebox_mcu_esp32s2.json index dc9e6db..2430b5c 100644 --- a/boards/sensebox_mcu_esp32s2.json +++ b/boards/sensebox_mcu_esp32s2.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s2_out.ld", "partitions": "partitions-4MB-tinyuf2.csv", "memory_type": "qio_qspi" }, diff --git a/boards/sensesiot_weizen.json b/boards/sensesiot_weizen.json index 4492655..032f381 100644 --- a/boards/sensesiot_weizen.json +++ b/boards/sensesiot_weizen.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_sensesiot_weizen", "f_cpu": "240000000L", diff --git a/boards/sg-o_airMon.json b/boards/sg-o_airMon.json index 53e2544..98b58ec 100644 --- a/boards/sg-o_airMon.json +++ b/boards/sg-o_airMon.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_SG_O_AIRMON_ESP32", "f_cpu": "240000000L", @@ -25,7 +22,7 @@ "espidf" ], "platforms": [ - "espressif32" + "espressif32" ], "name": "SG-O AirMon", "upload": { diff --git a/boards/sparkfun_esp32_iot_redboard.json b/boards/sparkfun_esp32_iot_redboard.json index e97c2d8..77a2586 100644 --- a/boards/sparkfun_esp32_iot_redboard.json +++ b/boards/sparkfun_esp32_iot_redboard.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_ESP32_IOT_REDBOARD", @@ -29,7 +26,7 @@ "espidf" ], "name": "SparkFun ESP32 IoT RedBoard", - "upload": { + "upload": { "flash_size": "4MB", "maximum_ram_size": 327680, "maximum_size": 4194304, diff --git a/boards/sparkfun_esp32micromod.json b/boards/sparkfun_esp32micromod.json index 16fb0f1..7642009 100644 --- a/boards/sparkfun_esp32micromod.json +++ b/boards/sparkfun_esp32micromod.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_MICROMOD", "f_cpu": "240000000L", diff --git a/boards/sparkfun_esp32s2_thing_plus.json b/boards/sparkfun_esp32s2_thing_plus.json index f8697e7..ccbb258 100644 --- a/boards/sparkfun_esp32s2_thing_plus.json +++ b/boards/sparkfun_esp32s2_thing_plus.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32S2_THING_PLUS", "f_cpu": "240000000L", diff --git a/boards/sparkfun_esp32s2_thing_plus_c.json b/boards/sparkfun_esp32s2_thing_plus_c.json index 01aaed7..9620bea 100644 --- a/boards/sparkfun_esp32s2_thing_plus_c.json +++ b/boards/sparkfun_esp32s2_thing_plus_c.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32_out.ld", "partitions": "default_16MB.csv" }, "core": "esp32", diff --git a/boards/sparkfun_lora_gateway_1-channel.json b/boards/sparkfun_lora_gateway_1-channel.json index 16eb843..9f354f7 100644 --- a/boards/sparkfun_lora_gateway_1-channel.json +++ b/boards/sparkfun_lora_gateway_1-channel.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/tamc_termod_s3.json b/boards/tamc_termod_s3.json index 0ddc527..5942c24 100644 --- a/boards/tamc_termod_s3.json +++ b/boards/tamc_termod_s3.json @@ -1,7 +1,6 @@ { "build": { "arduino": { - "ldscript": "esp32s3_out.ld", "memory_type": "qio_qspi" }, "core": "esp32", diff --git a/boards/tinypico.json b/boards/tinypico.json index 0b1302e..548c567 100644 --- a/boards/tinypico.json +++ b/boards/tinypico.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_TINYPICO", diff --git a/boards/trueverit-iot-driver-mk2.json b/boards/trueverit-iot-driver-mk2.json index 22e3eca..9bc76c8 100644 --- a/boards/trueverit-iot-driver-mk2.json +++ b/boards/trueverit-iot-driver-mk2.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Trueverit_ESP32_Universal_IoT_Driver_MK_II", "f_cpu": "240000000L", diff --git a/boards/trueverit-iot-driver-mk3.json b/boards/trueverit-iot-driver-mk3.json index 0b394a7..b132363 100644 --- a/boards/trueverit-iot-driver-mk3.json +++ b/boards/trueverit-iot-driver-mk3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Trueverit_ESP32_Universal_IoT_Driver_MK_III", "f_cpu": "240000000L", @@ -35,4 +32,3 @@ "url": "https://trueverit.com/", "vendor": "Trueverit" } - diff --git a/boards/trueverit-iot-driver.json b/boards/trueverit-iot-driver.json index 7f808ec..3bf2430 100644 --- a/boards/trueverit-iot-driver.json +++ b/boards/trueverit-iot-driver.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Trueverit_ESP32_Universal_IoT_Driver", "f_cpu": "240000000L", diff --git a/boards/ttgo-lora32-v1.json b/boards/ttgo-lora32-v1.json index 339a8b6..5d2e6ef 100644 --- a/boards/ttgo-lora32-v1.json +++ b/boards/ttgo-lora32-v1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_TTGO_LoRa32_V1", "f_cpu": "240000000L", diff --git a/boards/ttgo-lora32-v2.json b/boards/ttgo-lora32-v2.json index 502c357..9abafe0 100644 --- a/boards/ttgo-lora32-v2.json +++ b/boards/ttgo-lora32-v2.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_TTGO_LoRa32_V2", "f_cpu": "240000000L", diff --git a/boards/ttgo-lora32-v21.json b/boards/ttgo-lora32-v21.json index c2fb118..0f910cb 100644 --- a/boards/ttgo-lora32-v21.json +++ b/boards/ttgo-lora32-v21.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_TTGO_LoRa32_v21new", "f_cpu": "240000000L", diff --git a/boards/ttgo-t-beam.json b/boards/ttgo-t-beam.json index f2d144a..54c5908 100644 --- a/boards/ttgo-t-beam.json +++ b/boards/ttgo-t-beam.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_T_Beam -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue", "f_cpu": "240000000L", diff --git a/boards/ttgo-t-oi-plus.json b/boards/ttgo-t-oi-plus.json index 3b05918..f7d8b6a 100644 --- a/boards/ttgo-t-oi-plus.json +++ b/boards/ttgo-t-oi-plus.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "f_cpu": "160000000L", "f_flash": "80000000L", diff --git a/boards/ttgo-t-watch.json b/boards/ttgo-t-watch.json index 354f54f..0e759d7 100644 --- a/boards/ttgo-t-watch.json +++ b/boards/ttgo-t-watch.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "default_16MB.csv" }, "core": "esp32", diff --git a/boards/ttgo-t1.json b/boards/ttgo-t1.json index 4f428cd..ae006ce 100644 --- a/boards/ttgo-t1.json +++ b/boards/ttgo-t1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_TTGO_T1", "f_cpu": "240000000L", diff --git a/boards/ttgo-t7-v13-mini32.json b/boards/ttgo-t7-v13-mini32.json index 21552df..9d3d560 100644 --- a/boards/ttgo-t7-v13-mini32.json +++ b/boards/ttgo-t7-v13-mini32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_TTGO_T7_V13_Mini32", "f_cpu": "240000000L", diff --git a/boards/ttgo-t7-v14-mini32.json b/boards/ttgo-t7-v14-mini32.json index 23d3271..c32dc5b 100644 --- a/boards/ttgo-t7-v14-mini32.json +++ b/boards/ttgo-t7-v14-mini32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_TTGO_T7_V14_Mini32", "f_cpu": "240000000L", diff --git a/boards/turta_iot_node.json b/boards/turta_iot_node.json index 3f34825..84961c4 100644 --- a/boards/turta_iot_node.json +++ b/boards/turta_iot_node.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_PICO", "f_cpu": "240000000L", diff --git a/boards/um_feathers2.json b/boards/um_feathers2.json index 1fa6aab..f5a2eab 100644 --- a/boards/um_feathers2.json +++ b/boards/um_feathers2.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_FEATHERS2", diff --git a/boards/um_feathers2_neo.json b/boards/um_feathers2_neo.json index 410e4b7..cea0e41 100644 --- a/boards/um_feathers2_neo.json +++ b/boards/um_feathers2_neo.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_FEATHERS2NEO", diff --git a/boards/um_rmp.json b/boards/um_rmp.json index 50cdecd..59f94aa 100644 --- a/boards/um_rmp.json +++ b/boards/um_rmp.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s2_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_RMP", diff --git a/boards/unphone7.json b/boards/unphone7.json index 4204c79..d32335d 100644 --- a/boards/unphone7.json +++ b/boards/unphone7.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DUNPHONE_SPIN=7", diff --git a/boards/unphone8.json b/boards/unphone8.json index 8dd371a..d1d10a7 100644 --- a/boards/unphone8.json +++ b/boards/unphone8.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/unphone9.json b/boards/unphone9.json index 1b4e8ee..10e8ce0 100644 --- a/boards/unphone9.json +++ b/boards/unphone9.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32s3_out.ld", + "arduino": { "partitions": "default_8MB.csv" }, "core": "esp32", diff --git a/boards/upesy_wroom.json b/boards/upesy_wroom.json index 5d25532..176de7e 100644 --- a/boards/upesy_wroom.json +++ b/boards/upesy_wroom.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_uPesy_WROOM", "f_cpu": "240000000L", diff --git a/boards/upesy_wrover.json b/boards/upesy_wrover.json index 5eb0e0f..0a7db43 100644 --- a/boards/upesy_wrover.json +++ b/boards/upesy_wrover.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_uPesy_WROVER", diff --git a/boards/valtrack_v4_mfw_esp32_c3.json b/boards/valtrack_v4_mfw_esp32_c3.json index c910f15..e0ecdfa 100644 --- a/boards/valtrack_v4_mfw_esp32_c3.json +++ b/boards/valtrack_v4_mfw_esp32_c3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_VALTRACK_V4_MFW_ESP32_C3", diff --git a/boards/valtrack_v4_vts_esp32_c3.json b/boards/valtrack_v4_vts_esp32_c3.json index 8197b0b..7176f6e 100644 --- a/boards/valtrack_v4_vts_esp32_c3.json +++ b/boards/valtrack_v4_vts_esp32_c3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_VALTRACK_V4_VTS_ESP32_C3", diff --git a/boards/vintlabs-devkit-v1.json b/boards/vintlabs-devkit-v1.json index 4ba1fa1..3b99857 100644 --- a/boards/vintlabs-devkit-v1.json +++ b/boards/vintlabs-devkit-v1.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/boards/watchy.json b/boards/watchy.json index f91eed0..385bfa1 100644 --- a/boards/watchy.json +++ b/boards/watchy.json @@ -1,7 +1,6 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld", + "arduino": { "partitions": "huge_app.csv" }, "core": "esp32", diff --git a/boards/wemos_d1_mini32.json b/boards/wemos_d1_mini32.json index 90b1d6b..706b819 100644 --- a/boards/wemos_d1_mini32.json +++ b/boards/wemos_d1_mini32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_D1_MINI32", "f_cpu": "240000000L", diff --git a/boards/wemos_d1_uno32.json b/boards/wemos_d1_uno32.json index 2a38aa4..a05207c 100644 --- a/boards/wemos_d1_uno32.json +++ b/boards/wemos_d1_uno32.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_D1_UNO32", "f_cpu": "240000000L", diff --git a/boards/wemosbat.json b/boards/wemosbat.json index 1312abb..19e5153 100644 --- a/boards/wemosbat.json +++ b/boards/wemosbat.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Pocket32", "f_cpu": "240000000L", diff --git a/boards/wesp32.json b/boards/wesp32.json index 9f924ba..77d5bce 100644 --- a/boards/wesp32.json +++ b/boards/wesp32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_WESP32", "f_cpu": "240000000L", diff --git a/boards/widora-air.json b/boards/widora-air.json index 4dfda27..d62f1d0 100644 --- a/boards/widora-air.json +++ b/boards/widora-air.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_WIDORA_AIR", "f_cpu": "240000000L", diff --git a/boards/wifiduino32.json b/boards/wifiduino32.json index 53ca009..e3ce848 100644 --- a/boards/wifiduino32.json +++ b/boards/wifiduino32.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_Wifiduino32", "f_cpu": "240000000L", diff --git a/boards/wifiduino32c3.json b/boards/wifiduino32c3.json index 5b5b616..38ef3b6 100644 --- a/boards/wifiduino32c3.json +++ b/boards/wifiduino32c3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32c3_out.ld" - }, "core": "esp32", "f_cpu": "160000000L", "f_flash": "80000000L", diff --git a/boards/wifiduino32s3.json b/boards/wifiduino32s3.json index 6bef2bd..cf29e1a 100644 --- a/boards/wifiduino32s3.json +++ b/boards/wifiduino32s3.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32s3_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_WiFiduino32S3", diff --git a/boards/wipy3.json b/boards/wipy3.json index b9e5419..c54da9a 100644 --- a/boards/wipy3.json +++ b/boards/wipy3.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_WIPY3", "f_cpu": "240000000L", diff --git a/boards/wt32-eth01.json b/boards/wt32-eth01.json index 3fddb34..ded746b 100644 --- a/boards/wt32-eth01.json +++ b/boards/wt32-eth01.json @@ -1,8 +1,5 @@ { "build": { - "arduino": { - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": [ "-DARDUINO_WT32_ETH01" diff --git a/boards/xinabox_cw02.json b/boards/xinabox_cw02.json index 527956b..6da3843 100644 --- a/boards/xinabox_cw02.json +++ b/boards/xinabox_cw02.json @@ -1,8 +1,5 @@ { "build": { - "arduino":{ - "ldscript": "esp32_out.ld" - }, "core": "esp32", "extra_flags": "-DARDUINO_ESP32_DEV", "f_cpu": "240000000L", diff --git a/builder/build_lib/idf_component.yml b/builder/build_lib/idf_component.yml index 9402459..02959d9 100644 --- a/builder/build_lib/idf_component.yml +++ b/builder/build_lib/idf_component.yml @@ -1,8 +1,6 @@ dependencies: # Required IDF version idf: ">=5.1" - espressif/cmake_utilities: - version: "0.*" espressif/fb_gfx: version: "master" path: components/fb_gfx diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index b720dd3..f86642f 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -565,7 +565,8 @@ FRAMEWORK_LIB_DIR = path_cache.framework_lib_dir SConscript("_embed_files.py", exports="env") -flag_any_custom_sdkconfig = exists(str(Path(FRAMEWORK_LIB_DIR) / "sdkconfig")) +flag_any_custom_sdkconfig = (FRAMEWORK_LIB_DIR is not None and + exists(str(Path(FRAMEWORK_LIB_DIR) / "sdkconfig"))) def has_unicore_flags(): @@ -644,6 +645,8 @@ IS_INTEGRATION_DUMP = env.IsIntegrationDump() def is_framework_subfolder(potential_subfolder): """Check if a path is a subfolder of the framework SDK directory""" # carefully check before change this function + if FRAMEWORK_SDK_DIR is None: + return False if not isabs(potential_subfolder): return False if (splitdrive(FRAMEWORK_SDK_DIR)[0] != diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index 56acff9..9219839 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -78,7 +78,7 @@ config = env.GetProjectConfig() board = env.BoardConfig() mcu = board.get("build.mcu", "esp32") flash_speed = board.get("build.f_flash", "40000000L") -flash_frequency = str(flash_speed.replace("000000L", "m")) +flash_frequency = str(flash_speed.replace("000000L", "")) flash_mode = board.get("build.flash_mode", "dio") idf_variant = mcu.lower() flag_custom_sdkonfig = False @@ -218,6 +218,26 @@ if config.has_option("env:"+env["PIOENV"], "custom_sdkconfig"): if "espidf.custom_sdkconfig" in board: flag_custom_sdkonfig = True + +# Check for board-specific configurations that require sdkconfig generation +def has_board_specific_config(): + """Check if board has configuration that needs to be applied to sdkconfig.""" + # Check for PSRAM support + extra_flags = board.get("build.extra_flags", []) + has_psram = any("-DBOARD_HAS_PSRAM" in flag for flag in extra_flags) + + # Check for special memory types + memory_type = None + build_section = board.get("build", {}) + arduino_section = build_section.get("arduino", {}) + if "memory_type" in arduino_section: + memory_type = arduino_section["memory_type"] + elif "memory_type" in build_section: + memory_type = build_section["memory_type"] + has_special_memory = memory_type and ("opi" in memory_type.lower()) + + return has_psram or has_special_memory + def HandleArduinoIDFsettings(env): """ Handles Arduino IDF settings configuration with custom sdkconfig support. @@ -284,48 +304,366 @@ def HandleArduinoIDFsettings(env): return line.split("=")[0] return None + def generate_board_specific_config(): + """Generate board-specific sdkconfig settings from board.json manifest.""" + board_config_flags = [] + + # Handle memory type configuration with platformio.ini override support + # Priority: platformio.ini > board.json manifest + memory_type = None + + # Check for memory_type override in platformio.ini + if hasattr(env, 'GetProjectOption'): + try: + memory_type = env.GetProjectOption("board_build.memory_type", None) + except: + pass + + # Fallback to board.json manifest + if not memory_type: + build_section = board.get("build", {}) + arduino_section = build_section.get("arduino", {}) + if "memory_type" in arduino_section: + memory_type = arduino_section["memory_type"] + elif "memory_type" in build_section: + memory_type = build_section["memory_type"] + + flash_memory_type = None + psram_memory_type = None + if memory_type: + parts = memory_type.split("_") + if len(parts) == 2: + flash_memory_type, psram_memory_type = parts + else: + flash_memory_type = memory_type + + # Check for additional flash configuration indicators + boot_mode = board.get("build", {}).get("boot", None) + flash_mode = board.get("build", {}).get("flash_mode", None) + + # Override flash_memory_type if boot mode indicates OPI + if boot_mode == "opi" or flash_mode in ["dout", "opi"]: + if not flash_memory_type or flash_memory_type.lower() != "opi": + flash_memory_type = "opi" + print(f"Info: Detected OPI Flash via boot_mode='{boot_mode}' or flash_mode='{flash_mode}'") + + # Set CPU frequency with platformio.ini override support + # Priority: platformio.ini > board.json manifest + f_cpu = None + if hasattr(env, 'GetProjectOption'): + # Check for board_build.f_cpu override in platformio.ini + try: + f_cpu = env.GetProjectOption("board_build.f_cpu", None) + except: + pass + + # Fallback to board.json manifest + if not f_cpu: + f_cpu = board.get("build.f_cpu", None) + + if f_cpu: + cpu_freq = str(f_cpu).replace("000000L", "") + board_config_flags.append(f"CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ={cpu_freq}") + + # MCU name mapping for config flags (uppercase MCU name) + mcu_upper = mcu.upper().replace("-", "") + + # Disable other CPU frequency options and enable the specific one + common_cpu_freqs = ["80", "160", "240"] + for freq in common_cpu_freqs: + if freq != cpu_freq: + board_config_flags.append(f"# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_{freq} is not set") + board_config_flags.append(f"# CONFIG_{mcu_upper}_DEFAULT_CPU_FREQ_{freq} is not set") + + # Enable the specific CPU frequency (both generic and MCU-specific) + board_config_flags.append(f"CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_{cpu_freq}=y") + board_config_flags.append(f"CONFIG_{mcu_upper}_DEFAULT_CPU_FREQ_{cpu_freq}=y") + + # Set flash size with platformio.ini override support + # Priority: platformio.ini > board.json manifest + flash_size = None + if hasattr(env, 'GetProjectOption'): + # Check for board_upload.flash_size override in platformio.ini + try: + flash_size = env.GetProjectOption("board_upload.flash_size", None) + except: + pass + + # Fallback to board.json manifest + if not flash_size: + flash_size = board.get("upload", {}).get("flash_size", None) + + if flash_size: + # Configure both string and boolean flash size formats + # Disable other flash size options first + flash_sizes = ["4MB", "8MB", "16MB", "32MB", "64MB", "128MB"] + for size in flash_sizes: + if size != flash_size: + board_config_flags.append(f"# CONFIG_ESPTOOLPY_FLASHSIZE_{size} is not set") + + # Set the specific flash size configs + board_config_flags.append(f"CONFIG_ESPTOOLPY_FLASHSIZE=\"{flash_size}\"") + board_config_flags.append(f"CONFIG_ESPTOOLPY_FLASHSIZE_{flash_size}=y") + + # Handle Flash and PSRAM frequency configuration with platformio.ini override support + # Priority: platformio.ini > board.json manifest + # From 80MHz onwards, Flash and PSRAM frequencies must be identical + + # Get f_flash with override support + f_flash = None + if hasattr(env, 'GetProjectOption'): + try: + f_flash = env.GetProjectOption("board_build.f_flash", None) + except: + pass + if not f_flash: + f_flash = board.get("build.f_flash", None) + + # Get f_boot with override support + f_boot = None + if hasattr(env, 'GetProjectOption'): + try: + f_boot = env.GetProjectOption("board_build.f_boot", None) + except: + pass + if not f_boot: + f_boot = board.get("build.f_boot", None) + + # Get f_psram with override support (ESP32-P4 specific) + f_psram = None + if hasattr(env, 'GetProjectOption'): + try: + f_psram = env.GetProjectOption("board_build.f_psram", None) + except: + pass + if not f_psram: + f_psram = board.get("build.f_psram", None) + + # Determine the frequencies to use + # ESP32-P4: f_flash for Flash, f_psram for PSRAM (doesn't affect bootloader name) + + if mcu == "esp32p4": + # ESP32-P4: f_flash is always used for Flash frequency + # f_psram is used for PSRAM frequency (if set), otherwise use f_flash + # Note: f_boot is NOT used for P4 as it affects bootloader filename + flash_compile_freq = f_flash + psram_compile_freq = f_psram if f_psram else f_flash + else: + # Other chips: f_boot overrides f_flash for compile-time (both Flash and PSRAM) + compile_freq = f_boot if f_boot else f_flash + flash_compile_freq = compile_freq + psram_compile_freq = compile_freq + + if f_flash and flash_compile_freq and psram_compile_freq: + # Validate and parse frequency values + try: + flash_freq_val = int(str(flash_compile_freq).replace("000000L", "")) + psram_freq_val = int(str(psram_compile_freq).replace("000000L", "")) + except (ValueError, AttributeError): + print("Warning: Invalid frequency values, skipping frequency configuration") + flash_freq_val = None + psram_freq_val = None + + if flash_freq_val and psram_freq_val: + # Determine frequency strings + flash_freq_str = f"{flash_freq_val}m" + psram_freq_str = str(psram_freq_val) + + # Info message + if mcu == "esp32p4": + print(f"Info: ESP32-P4 frequency mode: Flash={flash_freq_val}MHz, PSRAM={psram_freq_val}MHz") + elif flash_freq_val >= 80: + print(f"Info: Unified frequency mode (>= 80MHz): {flash_freq_val}MHz for both Flash and PSRAM") + else: + print(f"Info: Independent frequency mode (< 80MHz): Flash={flash_freq_str}, PSRAM={psram_freq_str}") + + # Configure Flash frequency + # Disable other flash frequency options first + flash_freqs = ["20m", "26m", "40m", "80m", "120m"] + for freq in flash_freqs: + if freq != flash_freq_str: + board_config_flags.append(f"# CONFIG_ESPTOOLPY_FLASHFREQ_{freq.upper()} is not set") + # Then set the specific frequency configs + board_config_flags.append(f"CONFIG_ESPTOOLPY_FLASHFREQ=\"{flash_freq_str}\"") + board_config_flags.append(f"CONFIG_ESPTOOLPY_FLASHFREQ_{flash_freq_str.upper()}=y") + + # ESP32-P4 requires additional FLASHFREQ_VAL setting + if mcu == "esp32p4": + board_config_flags.append(f"CONFIG_ESPTOOLPY_FLASHFREQ_VAL={flash_freq_val}") + + # Configure PSRAM frequency + # Disable other SPIRAM speed options first + psram_freqs = ["20", "40", "80", "120", "200"] + for freq in psram_freqs: + if freq != psram_freq_str: + board_config_flags.append(f"# CONFIG_SPIRAM_SPEED_{freq}M is not set") + # Then set the specific SPIRAM configs + board_config_flags.append(f"CONFIG_SPIRAM_SPEED={psram_freq_str}") + board_config_flags.append(f"CONFIG_SPIRAM_SPEED_{psram_freq_str}M=y") + + # Enable experimental features for Flash frequencies > 80MHz + if flash_freq_val > 80: + board_config_flags.append("CONFIG_IDF_EXPERIMENTAL_FEATURES=y") + board_config_flags.append("CONFIG_SPI_FLASH_HPM_ENABLE=y") + board_config_flags.append("CONFIG_SPI_FLASH_HPM_AUTO=y") + + # Check for PSRAM support based on board flags + extra_flags = board.get("build.extra_flags", "") + # Handle both string and list formats + if isinstance(extra_flags, str): + has_psram = "-DBOARD_HAS_PSRAM" in extra_flags + else: + has_psram = any("-DBOARD_HAS_PSRAM" in flag for flag in extra_flags) + + # Additional PSRAM detection methods + if not has_psram: + # Check if memory_type contains psram indicators + if memory_type and ("opi" in memory_type.lower() or "psram" in memory_type.lower()): + has_psram = True + # Check build.psram_type + elif "psram_type" in board.get("build", {}): + has_psram = True + # Check for SPIRAM mentions in extra_flags + elif isinstance(extra_flags, str) and "PSRAM" in extra_flags: + has_psram = True + elif not isinstance(extra_flags, str) and any("PSRAM" in str(flag) for flag in extra_flags): + has_psram = True + + if has_psram: + # Enable basic SPIRAM support + board_config_flags.append("CONFIG_SPIRAM=y") + + # Determine PSRAM type with platformio.ini override support + # Priority: platformio.ini > memory_type > build.psram_type > default + psram_type = None + + # Priority 1: Check for platformio.ini override + if hasattr(env, 'GetProjectOption'): + try: + psram_type = env.GetProjectOption("board_build.psram_type", None) + if psram_type: + psram_type = psram_type.lower() + except: + pass + + # Priority 2: Check psram_memory_type from memory_type field (e.g., "qio_opi") + if not psram_type and psram_memory_type: + psram_type = psram_memory_type.lower() + # Priority 3: Check build.psram_type field as fallback + elif not psram_type and "psram_type" in board.get("build", {}): + psram_type = board.get("build.psram_type", "qio").lower() + # Priority 4: Default based on MCU + elif not psram_type: + # ESP32-P4 defaults to HEX (only type available) + if mcu == "esp32p4": + psram_type = "hex" + else: + psram_type = "qio" + + # Configure PSRAM mode based on detected type + if psram_type == "hex": + # HEX PSRAM configuration (ESP32-P4 only) + board_config_flags.append("CONFIG_SPIRAM_MODE_HEX=y") + + elif psram_type == "opi": + # Octal PSRAM configuration (for ESP32-S3) + if mcu == "esp32s3": + board_config_flags.extend([ + "CONFIG_IDF_EXPERIMENTAL_FEATURES=y", + "# CONFIG_SPIRAM_MODE_QUAD is not set", + "CONFIG_SPIRAM_MODE_OCT=y", + "CONFIG_SPIRAM_TYPE_AUTO=y" + ]) + else: + # Fallback to QUAD for other chips + board_config_flags.extend([ + "# CONFIG_SPIRAM_MODE_OCT is not set", + "CONFIG_SPIRAM_MODE_QUAD=y" + ]) + + elif psram_type in ["qio", "qspi"]: + # Quad PSRAM configuration + if mcu in ["esp32s2", "esp32s3"]: + board_config_flags.extend([ + "# CONFIG_SPIRAM_MODE_OCT is not set", + "CONFIG_SPIRAM_MODE_QUAD=y" + ]) + elif mcu == "esp32": + board_config_flags.extend([ + "# CONFIG_SPIRAM_MODE_OCT is not set", + "# CONFIG_SPIRAM_MODE_QUAD is not set" + ]) + else: + # Explicitly disable PSRAM if not present + board_config_flags.extend([ + "# CONFIG_SPIRAM is not set" + ]) + + # Use flash_memory_type for flash config + if flash_memory_type and "opi" in flash_memory_type.lower(): + # OPI Flash configurations require specific settings + # According to ESP-IDF documentation, OPI flash must use DOUT mode for bootloader + # The bootloader starts in DOUT mode and switches to OPI at runtime + # Reference: ESP-IDF Programming Guide - SPI Flash Configuration + board_config_flags.extend([ + "# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set", + "# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set", + "# CONFIG_ESPTOOLPY_FLASHMODE_DIO is not set", + "CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y", + "CONFIG_ESPTOOLPY_OCT_FLASH=y", + "# CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR is not set", + "CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_DTR=y" + ]) + + return board_config_flags + def build_idf_config_flags(): """Build complete IDF configuration flags from all sources.""" flags = [] - # Add board-specific flags first - if "espidf.custom_sdkconfig" in board: - board_flags = board.get("espidf.custom_sdkconfig", []) - if board_flags: - flags.extend(board_flags) + # FIRST: Add board-specific flags derived from board.json manifest + board_flags = generate_board_specific_config() + if board_flags: + flags.extend(board_flags) - # Add custom sdkconfig file content + # SECOND: Add board-specific flags from board manifest (espidf.custom_sdkconfig) + if "espidf.custom_sdkconfig" in board: + board_manifest_flags = board.get("espidf.custom_sdkconfig", []) + if board_manifest_flags: + flags.extend(board_manifest_flags) + + # THIRD: Add custom sdkconfig file content custom_file_content = load_custom_sdkconfig_file() if custom_file_content: flags.append(custom_file_content) - # Add project-level custom sdkconfig + # FOURTH: Add project-level custom sdkconfig (highest precedence for user overrides) if config.has_option("env:" + env["PIOENV"], "custom_sdkconfig"): custom_flags = env.GetProjectOption("custom_sdkconfig").rstrip("\n") if custom_flags: flags.append(custom_flags) + # FIFTH: Apply ESP32-specific compatibility fixes + all_flags_str = "\n".join(flags) + "\n" if flags else "" + esp32_compatibility_flags = apply_esp32_compatibility_fixes(all_flags_str) + if esp32_compatibility_flags: + flags.extend(esp32_compatibility_flags) + return "\n".join(flags) + "\n" if flags else "" - def add_flash_configuration(config_flags): - """Add flash frequency and mode configuration.""" - if flash_frequency != "80m": - config_flags += "# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set\n" - config_flags += f"CONFIG_ESPTOOLPY_FLASHFREQ_{flash_frequency.upper()}=y\n" - config_flags += f"CONFIG_ESPTOOLPY_FLASHFREQ=\"{flash_frequency}\"\n" - - if flash_mode != "qio": - config_flags += "# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set\n" - - flash_mode_flag = f"CONFIG_ESPTOOLPY_FLASHMODE_{flash_mode.upper()}=y\n" - if flash_mode_flag not in config_flags: - config_flags += flash_mode_flag + def apply_esp32_compatibility_fixes(config_flags_str): + """Apply ESP32-specific compatibility fixes based on final configuration.""" + compatibility_flags = [] # ESP32 specific SPIRAM configuration - if mcu == "esp32" and "CONFIG_FREERTOS_UNICORE=y" in config_flags: - config_flags += "# CONFIG_SPIRAM is not set\n" + # On ESP32, SPIRAM is not used with UNICORE mode + if mcu == "esp32" and "CONFIG_FREERTOS_UNICORE=y" in config_flags_str: + if "CONFIG_SPIRAM=y" in config_flags_str: + compatibility_flags.append("# CONFIG_SPIRAM is not set") + print("Info: ESP32 SPIRAM disabled since solo1 core mode is enabled") - return config_flags + return compatibility_flags + def write_sdkconfig_file(idf_config_flags, checksum_source): if "arduino" not in env.subst("$PIOFRAMEWORK"): @@ -346,7 +684,9 @@ def HandleArduinoIDFsettings(env): dst.write(f"# TASMOTA__{checksum}\n") # Process each line from source sdkconfig - for line in src: + src_lines = src.readlines() + + for line in src_lines: flag_name = extract_flag_name(line) if flag_name is None: @@ -375,20 +715,25 @@ def HandleArduinoIDFsettings(env): print(f"Add: {cleaned_flag}") dst.write(cleaned_flag + "\n") + # Main execution logic has_custom_config = ( config.has_option("env:" + env["PIOENV"], "custom_sdkconfig") or "espidf.custom_sdkconfig" in board ) - if not has_custom_config: + has_board_config = has_board_specific_config() + + if not has_custom_config and not has_board_config: return - print("*** Add \"custom_sdkconfig\" settings to IDF sdkconfig.defaults ***") + if has_board_config and not has_custom_config: + print("*** Apply board-specific settings to IDF sdkconfig.defaults ***") + else: + print("*** Add \"custom_sdkconfig\" settings to IDF sdkconfig.defaults ***") # Build complete configuration idf_config_flags = build_idf_config_flags() - idf_config_flags = add_flash_configuration(idf_config_flags) # Convert to list for processing idf_config_list = [line for line in idf_config_flags.splitlines() if line.strip()] @@ -1678,8 +2023,7 @@ def install_python_deps(): # https://github.com/platformio/platform-espressif32/issues/635 "cryptography": "~=44.0.0", "pyparsing": ">=3.1.0,<4", - "pydantic": "~=2.11.10", - "idf-component-manager": "~=2.2", + "idf-component-manager": "~=2.4", "esp-idf-kconfig": "~=2.5.0" } @@ -2222,7 +2566,9 @@ env["BUILDERS"]["ElfToBin"].action = action # ulp_dir = str(Path(PROJECT_DIR) / "ulp") -if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32h2"): +# ULP support: ESP32, ESP32-S2, ESP32-S3, ESP32-C6, ESP32-P4 +# No ULP: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-H2 +if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32c5", "esp32h2"): env.SConscript("ulp.py", exports="env sdk_config project_config app_includes idf_variant") # @@ -2320,12 +2666,19 @@ if "espidf" in env.subst("$PIOFRAMEWORK") and (flag_custom_component_add == True try: shutil.copy(str(Path(PROJECT_SRC_DIR) / "idf_component.yml.orig"), str(Path(PROJECT_SRC_DIR) / "idf_component.yml")) print("*** Original \"idf_component.yml\" restored ***") - except (FileNotFoundError, PermissionError, OSError): # no "idf_component.yml" in source folder - try: - os.remove(str(Path(PROJECT_SRC_DIR) / "idf_component.yml")) - print("*** pioarduino generated \"idf_component.yml\" removed ***") - except (FileNotFoundError, PermissionError, OSError): - print("*** no custom \"idf_component.yml\" found for removing ***") + except (FileNotFoundError, PermissionError, OSError): + # Only remove idf_component.yml if a .orig backup exists + # This indicates the file was created/modified by pioarduino + orig_file = Path(PROJECT_SRC_DIR) / "idf_component.yml.orig" + yml_file = Path(PROJECT_SRC_DIR) / "idf_component.yml" + if orig_file.exists() and yml_file.exists(): + try: + os.remove(str(yml_file)) + print("*** pioarduino generated \"idf_component.yml\" removed ***") + except (FileNotFoundError, PermissionError, OSError): + print("*** Failed to remove pioarduino generated \"idf_component.yml\" ***") + elif yml_file.exists(): + print("*** User-created \"idf_component.yml\" preserved (no .orig backup found) ***") if "arduino" in env.subst("$PIOFRAMEWORK"): # Restore original pioarduino-build.py, only used with Arduino from component_manager import ComponentManager diff --git a/builder/main.py b/builder/main.py index cc4fc5f..69122b3 100644 --- a/builder/main.py +++ b/builder/main.py @@ -596,8 +596,8 @@ def firmware_metrics(target, source, env): source: SCons source env: SCons environment object """ - if terminal_cp != "utf-8": - print("Firmware metrics can not be shown. Set the terminal codepage to \"utf-8\"") + if terminal_cp not in ["utf-8", "cp65001"]: + print("Firmware metrics can not be shown. Set the terminal codepage to \"utf-8\" or \"cp65001\" on Windows.") return map_file = str(Path(env.subst("$BUILD_DIR")) / (env.subst("$PROGNAME") + ".map")) @@ -650,6 +650,132 @@ def firmware_metrics(target, source, env): print(f'Make sure esp-idf-size is installed: uv pip install --python "{PYTHON_EXE}" esp-idf-size') +def coredump_analysis(target, source, env): + """ + Custom target to run esp-coredump with support for command line parameters. + Usage: pio run -t coredump -- [esp-coredump arguments] + + Args: + target: SCons target + source: SCons source + env: SCons environment object + """ + if terminal_cp != "utf-8": + print("Coredump analysis can not be shown. Set the terminal codepage to \"utf-8\"") + return + + elf_file = str(Path(env.subst("$BUILD_DIR")) / (env.subst("$PROGNAME") + ".elf")) + if not Path(elf_file).is_file(): + # elf file can be in project dir + elf_file = str(Path(get_project_dir()) / (env.subst("$PROGNAME") + ".elf")) + + if not Path(elf_file).is_file(): + print(f"Error: ELF file not found: {elf_file}") + print("Make sure the project is built first with 'pio run'") + return + + try: + cmd = [PYTHON_EXE, "-m", "esp_coredump"] + + # Command Line Parameter, after -- + cli_args = [] + if "--" in sys.argv: + dash_index = sys.argv.index("--") + if dash_index + 1 < len(sys.argv): + cli_args = sys.argv[dash_index + 1:] + + # Add CLI arguments or use defaults + if cli_args: + cmd.extend(cli_args) + # ELF file should be at the end as positional argument + if not any(arg.endswith('.elf') for arg in cli_args): + cmd.append(elf_file) + else: + # Default arguments if none provided + # Parameters from platformio.ini + extra_args = env.GetProjectOption("custom_esp_coredump_args", "") + if extra_args: + args = shlex.split(extra_args) + cmd.extend(args) + # Ensure ELF is last positional if not present + if not any(a.endswith(".elf") for a in args): + cmd.append(elf_file) + else: + # Prefer an explicit core file if configured or present; else read from flash + core_file = env.GetProjectOption("custom_esp_coredump_corefile", "") + if not core_file: + for name in ("coredump.bin", "coredump.b64"): + cand = Path(get_project_dir()) / name + if cand.is_file(): + core_file = str(cand) + break + + # Global options + cmd.extend(["--chip", mcu]) + upload_port = env.subst("$UPLOAD_PORT") + if upload_port: + cmd.extend(["--port", upload_port]) + + # Subcommand and arguments + cmd.append("info_corefile") + if core_file: + cmd.extend(["--core", core_file]) + if core_file.lower().endswith(".b64"): + cmd.extend(["--core-format", "b64"]) + # ELF is the required positional + cmd.append(elf_file) + + # Set up ESP-IDF environment variables and ensure required packages are installed + coredump_env = os.environ.copy() + + # Check if ESP-IDF packages are available, install if missing + _framework_pkg_dir = platform.get_package_dir("framework-espidf") + _rom_elfs_dir = platform.get_package_dir("tool-esp-rom-elfs") + + # Install framework-espidf if not available + if not _framework_pkg_dir or not os.path.isdir(_framework_pkg_dir): + print("ESP-IDF framework not found, installing...") + try: + platform.install_package("framework-espidf") + _framework_pkg_dir = platform.get_package_dir("framework-espidf") + except Exception as e: + print(f"Warning: Failed to install framework-espidf: {e}") + + # Install tool-esp-rom-elfs if not available + if not _rom_elfs_dir or not os.path.isdir(_rom_elfs_dir): + print("ESP ROM ELFs tool not found, installing...") + try: + platform.install_package("tool-esp-rom-elfs") + _rom_elfs_dir = platform.get_package_dir("tool-esp-rom-elfs") + except Exception as e: + print(f"Warning: Failed to install tool-esp-rom-elfs: {e}") + + # Set environment variables if packages are available + if _framework_pkg_dir and os.path.isdir(_framework_pkg_dir): + coredump_env['IDF_PATH'] = str(Path(_framework_pkg_dir).resolve()) + if _rom_elfs_dir and os.path.isdir(_rom_elfs_dir): + coredump_env['ESP_ROM_ELF_DIR'] = str(Path(_rom_elfs_dir).resolve()) + + # Debug-Info if wanted + if env.GetProjectOption("custom_esp_coredump_verbose", False): + print(f"Running command: {' '.join(cmd)}") + if 'IDF_PATH' in coredump_env: + print(f"IDF_PATH: {coredump_env['IDF_PATH']}") + print(f"ESP_ROM_ELF_DIR: {coredump_env.get('ESP_ROM_ELF_DIR', 'Not set')}") + + # Execute esp-coredump with ESP-IDF environment + result = subprocess.run(cmd, check=False, capture_output=False, env=coredump_env) + + if result.returncode != 0: + print(f"Warning: esp-coredump exited with code {result.returncode}") + + except FileNotFoundError: + print("Error: Python executable not found.") + print("Check your Python installation.") + except Exception as e: + print(f"Error: Failed to run coredump analysis: {e}") + print(f'Make sure esp-coredump is installed: uv pip install --python "{PYTHON_EXE}" esp-coredump') + # # Target: Build executable and linkable firmware or FS image # @@ -931,6 +1057,27 @@ env.AddCustomTarget( always_build=True, ) +# Register Custom Target for coredump analysis +env.AddCustomTarget( + name="coredump", + dependencies="$BUILD_DIR/${PROGNAME}.elf", + actions=coredump_analysis, + title="Coredump Analysis", + description="Analyze coredumps using esp-coredump " + "(supports CLI args after --)", + always_build=True, +) + +# Additional Target without Build-Dependency when already compiled +env.AddCustomTarget( + name="coredump-only", + dependencies=None, + actions=coredump_analysis, + title="Coredump Analysis (No Build)", + description="Analyze coredumps without building first", + always_build=True, +) + # Override memory inspection behavior env.SConscript("sizedata.py", exports="env") diff --git a/builder/penv_setup.py b/builder/penv_setup.py index 5236402..197e7c7 100644 --- a/builder/penv_setup.py +++ b/builder/penv_setup.py @@ -21,6 +21,7 @@ import socket import subprocess import sys from pathlib import Path +from urllib.parse import urlparse from platformio.package.version import pepver_to_semver from platformio.compat import IS_WINDOWS @@ -55,20 +56,49 @@ python_deps = { "ecdsa": ">=0.19.1", "bitstring": ">=4.3.1", "reedsolo": ">=1.5.3,<1.8", - "esp-idf-size": ">=2.0.0" + "esp-idf-size": ">=2.0.0", + "esp-coredump": ">=1.14.0" } -def has_internet_connection(host="1.1.1.1", port=53, timeout=2): +def has_internet_connection(timeout=5): """ - Checks if an internet connection is available (default: Cloudflare DNS server). - Returns True if a connection is possible, otherwise False. + Checks practical internet reachability for dependency installation. + 1) If HTTPS/HTTP proxy environment variable is set, test TCP connectivity to the proxy endpoint. + 2) Otherwise, test direct TCP connectivity to common HTTPS endpoints (port 443). + + Args: + timeout (int): Timeout duration in seconds for the connection test. + + Returns: + True if at least one path appears reachable; otherwise False. """ - try: - with socket.create_connection((host, port), timeout=timeout): + # 1) Test TCP connectivity to the proxy endpoint. + proxy = os.getenv("HTTPS_PROXY") or os.getenv("https_proxy") or os.getenv("HTTP_PROXY") or os.getenv("http_proxy") + if proxy: + try: + u = urlparse(proxy if "://" in proxy else f"http://{proxy}") + host = u.hostname + port = u.port or (443 if u.scheme == "https" else 80) + if host and port: + socket.create_connection((host, port), timeout=timeout).close() + return True + except Exception: + # If proxy connection fails, fall back to direct connection test + pass + + # 2) Test direct TCP connectivity to common HTTPS endpoints (port 443). + https_hosts = ("pypi.org", "files.pythonhosted.org", "github.com") + for host in https_hosts: + try: + socket.create_connection((host, 443), timeout=timeout).close() return True - except OSError: - return False + except Exception: + continue + + # Direct DNS:53 connection is abolished due to many false positives on enterprise networks + # (add it at the end if necessary) + return False def get_executable_path(penv_dir, executable_name): @@ -286,18 +316,18 @@ def install_python_deps(python_exe, external_uv_executable): for p in packages: result[p["name"].lower()] = pepver_to_semver(p["version"]) else: - print(f"Error: uv pip list failed with exit code {result_obj.returncode}") + print(f"Warning: uv pip list failed with exit code {result_obj.returncode}") if result_obj.stderr: print(f"Error output: {result_obj.stderr.strip()}") except subprocess.TimeoutExpired: - print("Error: uv pip list command timed out") + print("Warning: uv pip list command timed out") except (json.JSONDecodeError, KeyError) as e: - print(f"Error: Could not parse package list: {e}") + print(f"Warning: Could not parse package list: {e}") except FileNotFoundError: - print("Error: uv command not found") + print("Warning: uv command not found") except Exception as e: - print(f"Error! Couldn't extract the list of installed Python packages: {e}") + print(f"Warning! Couldn't extract the list of installed Python packages: {e}") return result @@ -306,39 +336,39 @@ def install_python_deps(python_exe, external_uv_executable): if packages_to_install: packages_list = [] - package_map = {} for p in packages_to_install: spec = python_deps[p] if spec.startswith(('http://', 'https://', 'git+', 'file://')): packages_list.append(spec) - package_map[spec] = p else: - full_spec = f"{p}{spec}" - packages_list.append(full_spec) - package_map[full_spec] = p + packages_list.append(f"{p}{spec}") - for package_spec in packages_list: - cmd = [ - penv_uv_executable, "pip", "install", - f"--python={python_exe}", - "--quiet", "--upgrade", - package_spec - ] - try: - subprocess.check_call( - cmd, - stdout=subprocess.DEVNULL, - stderr=subprocess.STDOUT, - timeout=300 - ) - except subprocess.CalledProcessError as e: - print(f"Error: Installing package '{package_map.get(package_spec, package_spec)}' failed (exit code {e.returncode}).") - except subprocess.TimeoutExpired: - print(f"Error: Installing package '{package_map.get(package_spec, package_spec)}' timed out.") - except FileNotFoundError: - print("Error: uv command not found") - except Exception as e: - print(f"Error: Installing package '{package_map.get(package_spec, package_spec)}': {e}.") + cmd = [ + penv_uv_executable, "pip", "install", + f"--python={python_exe}", + "--quiet", "--upgrade" + ] + packages_list + + try: + subprocess.check_call( + cmd, + stdout=subprocess.DEVNULL, + stderr=subprocess.STDOUT, + timeout=300 + ) + + except subprocess.CalledProcessError as e: + print(f"Error: Failed to install Python dependencies (exit code: {e.returncode})") + return False + except subprocess.TimeoutExpired: + print("Error: Python dependencies installation timed out") + return False + except FileNotFoundError: + print("Error: uv command not found") + return False + except Exception as e: + print(f"Error installing Python dependencies: {e}") + return False return True diff --git a/examples/arduino-NimBLE-ext_client/README.md b/examples/arduino-NimBLE-SampleScan/README.md similarity index 100% rename from examples/arduino-NimBLE-ext_client/README.md rename to examples/arduino-NimBLE-SampleScan/README.md diff --git a/examples/arduino-NimBLE-ext_client/include/README b/examples/arduino-NimBLE-SampleScan/include/README similarity index 100% rename from examples/arduino-NimBLE-ext_client/include/README rename to examples/arduino-NimBLE-SampleScan/include/README diff --git a/examples/arduino-NimBLE-ext_client/lib/README b/examples/arduino-NimBLE-SampleScan/lib/README similarity index 100% rename from examples/arduino-NimBLE-ext_client/lib/README rename to examples/arduino-NimBLE-SampleScan/lib/README diff --git a/examples/arduino-NimBLE-ext_client/platformio.ini b/examples/arduino-NimBLE-SampleScan/platformio.ini similarity index 94% rename from examples/arduino-NimBLE-ext_client/platformio.ini rename to examples/arduino-NimBLE-SampleScan/platformio.ini index 75f8004..5436b1a 100644 --- a/examples/arduino-NimBLE-ext_client/platformio.ini +++ b/examples/arduino-NimBLE-SampleScan/platformio.ini @@ -13,8 +13,6 @@ platform = espressif32 framework = arduino monitor_speed = 115200 custom_component_remove = - espressif/esp_hosted - espressif/esp_wifi_remote espressif/esp-dsp espressif/network_provisioning espressif/esp_rainmaker @@ -40,5 +38,8 @@ board = esp32-c3-devkitm-1 [env:esp32c6] board = esp32-c6-devkitm-1 +[env:esp32p4] +board = esp32-p4-evboard + [env:esp32h2] board = esp32-h2-devkitm-1 diff --git a/examples/arduino-NimBLE-ext_client/src/SampleScan.ino b/examples/arduino-NimBLE-SampleScan/src/SampleScan.ino similarity index 100% rename from examples/arduino-NimBLE-ext_client/src/SampleScan.ino rename to examples/arduino-NimBLE-SampleScan/src/SampleScan.ino diff --git a/examples/arduino-usb-keyboard/platformio.ini b/examples/arduino-usb-keyboard/platformio.ini index 434e1a6..24f73cf 100644 --- a/examples/arduino-usb-keyboard/platformio.ini +++ b/examples/arduino-usb-keyboard/platformio.ini @@ -11,6 +11,7 @@ platform = espressif32 framework = arduino monitor_speed = 115200 +monitor_filters = esp32_exception_decoder [env:esp32-s2-saola-1] board = esp32-s2-saola-1 diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/CHANGELOG.md b/examples/espidf-peripherals-usb/components/esp_tinyusb/CHANGELOG.md deleted file mode 100644 index 78608a7..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/CHANGELOG.md +++ /dev/null @@ -1,53 +0,0 @@ -## 1.4.4 - -- esp_tinyusb: Added HighSpeed and Qualifier device descriptors in tinyusb configuration -- CDC-ACM: Removed MIN() definition if already defined -- MSC: Fixed EP size selecting in default configuration descriptor - -## 1.4.3 - -- esp_tinyusb: Added ESP32P4 support (HS only) - -## 1.4.2 - -- MSC: Fixed maximum files open -- Added uninstall function - -## 1.4.0 - -- MSC: Fixed integer overflows -- CDC-ACM: Removed intermediate RX ringbuffer -- CDC-ACM: Increased default FIFO size to 512 bytes -- CDC-ACM: Fixed Virtual File System binding - -## 1.3.0 - -- Added NCM extension - -## 1.2.1 - 1.2.2 - -- Minor bugfixes - -## 1.2.0 - -- Added MSC extension for accessing SPI Flash on memory card https://github.com/espressif/idf-extra-components/commit/a8c00d7707ba4ceeb0970c023d702c7768dba3dc - -## 1.1.0 - -- Added support for NCM, ECM/RNDIS, DFU and Bluetooth TinyUSB drivers https://github.com/espressif/idf-extra-components/commit/79f35c9b047b583080f93a63310e2ee7d82ef17b - -## 1.0.4 - -- Cleaned up string descriptors handling https://github.com/espressif/idf-extra-components/commit/046cc4b02f524d5c7e3e56480a473cfe844dc3d6 - -## 1.0.2 - 1.0.3 - -- Minor bugfixes - -## 1.0.1 - -- CDC-ACM: Return ESP_OK if there is nothing to flush https://github.com/espressif/idf-extra-components/commit/388ff32eb09aa572d98c54cb355f1912ce42707c - -## 1.0.0 - -- Initial version based on [esp-idf v4.4.3](https://github.com/espressif/esp-idf/tree/v4.4.3/components/tinyusb) diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/CMakeLists.txt b/examples/espidf-peripherals-usb/components/esp_tinyusb/CMakeLists.txt deleted file mode 100644 index 98fc960..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -set(srcs - "descriptors_control.c" - "tinyusb.c" - "usb_descriptors.c" - ) - -if(NOT CONFIG_TINYUSB_NO_DEFAULT_TASK) - list(APPEND srcs "tusb_tasks.c") -endif() # CONFIG_TINYUSB_NO_DEFAULT_TASK - -if(CONFIG_TINYUSB_CDC_ENABLED) - list(APPEND srcs - "cdc.c" - "tusb_cdc_acm.c" - ) - if(CONFIG_VFS_SUPPORT_IO) - list(APPEND srcs - "tusb_console.c" - "vfs_tinyusb.c" - ) - endif() # CONFIG_VFS_SUPPORT_IO -endif() # CONFIG_TINYUSB_CDC_ENABLED - -if(CONFIG_TINYUSB_MSC_ENABLED) - list(APPEND srcs - tusb_msc_storage.c - ) -endif() # CONFIG_TINYUSB_MSC_ENABLED - -if(CONFIG_TINYUSB_NET_MODE_NCM) - list(APPEND srcs - tinyusb_net.c - ) -endif() # CONFIG_TINYUSB_NET_MODE_NCM - -idf_component_register(SRCS ${srcs} - INCLUDE_DIRS "include" - PRIV_INCLUDE_DIRS "include_private" - PRIV_REQUIRES usb - REQUIRES fatfs vfs - ) - -# Determine whether tinyusb is fetched from component registry or from local path -idf_build_get_property(build_components BUILD_COMPONENTS) -if(tinyusb IN_LIST build_components) - set(tinyusb_name tinyusb) # Local component -else() - set(tinyusb_name espressif__tinyusb) # Managed component -endif() - -# Pass tusb_config.h from this component to TinyUSB -idf_component_get_property(tusb_lib ${tinyusb_name} COMPONENT_LIB) -target_include_directories(${tusb_lib} PRIVATE "include") diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/Kconfig b/examples/espidf-peripherals-usb/components/esp_tinyusb/Kconfig deleted file mode 100644 index 7b01f4c..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/Kconfig +++ /dev/null @@ -1,272 +0,0 @@ -menu "TinyUSB Stack" - config TINYUSB_DEBUG_LEVEL - int "TinyUSB log level (0-3)" - default 1 - range 0 3 - help - Specify verbosity of TinyUSB log output. - - choice TINYUSB_RHPORT - depends on IDF_TARGET_ESP32P4 - prompt "TinyUSB PHY" - default TINYUSB_RHPORT_HS - help - Allows set the USB PHY Controller for TinyUSB: HS (USB OTG2.0 PHY for HighSpeed) - - config TINYUSB_RHPORT_HS - bool "HS" - endchoice - - menu "TinyUSB task configuration" - config TINYUSB_NO_DEFAULT_TASK - bool "Do not create a TinyUSB task" - default n - help - This option allows to not create the FreeRTOS task during the driver initialization. - User will have to handle TinyUSB events manually. - - config TINYUSB_TASK_PRIORITY - int "TinyUSB task priority" - default 5 - depends on !TINYUSB_NO_DEFAULT_TASK - help - Set the priority of the default TinyUSB main task. - - config TINYUSB_TASK_STACK_SIZE - int "TinyUSB task stack size (bytes)" - default 4096 - depends on !TINYUSB_NO_DEFAULT_TASK - help - Set the stack size of the default TinyUSB main task. - - choice TINYUSB_TASK_AFFINITY - prompt "TinyUSB task affinity" - default TINYUSB_TASK_AFFINITY_NO_AFFINITY - depends on !TINYUSB_NO_DEFAULT_TASK - help - Allows setting TinyUSB tasks affinity, i.e. whether the task is pinned to - CPU0, pinned to CPU1, or allowed to run on any CPU. - - config TINYUSB_TASK_AFFINITY_NO_AFFINITY - bool "No affinity" - config TINYUSB_TASK_AFFINITY_CPU0 - bool "CPU0" - config TINYUSB_TASK_AFFINITY_CPU1 - bool "CPU1" - depends on !FREERTOS_UNICORE - endchoice - - config TINYUSB_TASK_AFFINITY - hex - default FREERTOS_NO_AFFINITY if TINYUSB_TASK_AFFINITY_NO_AFFINITY - default 0x0 if TINYUSB_TASK_AFFINITY_CPU0 - default 0x1 if TINYUSB_TASK_AFFINITY_CPU1 - - config TINYUSB_INIT_IN_DEFAULT_TASK - bool "Initialize TinyUSB stack within the default TinyUSB task" - default n - depends on !TINYUSB_NO_DEFAULT_TASK - help - Run TinyUSB stack initialization just after starting the default TinyUSB task. - This is especially useful in multicore scenarios, when we need to pin the task - to a specific core and, at the same time initialize TinyUSB stack - (i.e. install interrupts) on the same core. - endmenu - - menu "Descriptor configuration" - comment "You can provide your custom descriptors via tinyusb_driver_install()" - config TINYUSB_DESC_USE_ESPRESSIF_VID - bool "VID: Use Espressif's vendor ID" - default y - help - Enable this option, USB device will use Espressif's vendor ID as its VID. - This is helpful at product develop stage. - - config TINYUSB_DESC_CUSTOM_VID - hex "VID: Custom vendor ID" - default 0x1234 - depends on !TINYUSB_DESC_USE_ESPRESSIF_VID - help - Custom Vendor ID. - - config TINYUSB_DESC_USE_DEFAULT_PID - bool "PID: Use a default PID assigned to TinyUSB" - default y - help - Default TinyUSB PID assigning uses values 0x4000...0x4007. - - config TINYUSB_DESC_CUSTOM_PID - hex "PID: Custom product ID" - default 0x5678 - depends on !TINYUSB_DESC_USE_DEFAULT_PID - help - Custom Product ID. - - config TINYUSB_DESC_BCD_DEVICE - hex "bcdDevice" - default 0x0100 - help - Version of the firmware of the USB device. - - config TINYUSB_DESC_MANUFACTURER_STRING - string "Manufacturer name" - default "Espressif Systems" - help - Name of the manufacturer of the USB device. - - config TINYUSB_DESC_PRODUCT_STRING - string "Product name" - default "Espressif Device" - help - Name of the USB device. - - config TINYUSB_DESC_SERIAL_STRING - string "Serial string" - default "123456" - help - Serial number of the USB device. - - config TINYUSB_DESC_CDC_STRING - depends on TINYUSB_CDC_ENABLED - string "CDC Device String" - default "Espressif CDC Device" - help - Name of the CDC device. - - config TINYUSB_DESC_MSC_STRING - depends on TINYUSB_MSC_ENABLED - string "MSC Device String" - default "Espressif MSC Device" - help - Name of the MSC device. - endmenu # "Descriptor configuration" - - menu "Massive Storage Class (MSC)" - config TINYUSB_MSC_ENABLED - bool "Enable TinyUSB MSC feature" - default n - help - Enable TinyUSB MSC feature. - - config TINYUSB_MSC_BUFSIZE - depends on TINYUSB_MSC_ENABLED - int "MSC FIFO size" - default 512 - range 64 10000 - help - MSC FIFO size, in bytes. - - config TINYUSB_MSC_MOUNT_PATH - depends on TINYUSB_MSC_ENABLED - string "Mount Path" - default "/data" - help - MSC Mount Path of storage. - endmenu # "Massive Storage Class" - - menu "Communication Device Class (CDC)" - config TINYUSB_CDC_ENABLED - bool "Enable TinyUSB CDC feature" - default n - help - Enable TinyUSB CDC feature. - - config TINYUSB_CDC_COUNT - int "CDC Channel Count" - default 1 - range 1 2 - depends on TINYUSB_CDC_ENABLED - help - Number of independent serial ports. - - config TINYUSB_CDC_RX_BUFSIZE - depends on TINYUSB_CDC_ENABLED - int "CDC FIFO size of RX channel" - default 512 - range 64 10000 - help - CDC FIFO size of RX channel. - - config TINYUSB_CDC_TX_BUFSIZE - depends on TINYUSB_CDC_ENABLED - int "CDC FIFO size of TX channel" - default 512 - help - CDC FIFO size of TX channel. - endmenu # "Communication Device Class" - - menu "Musical Instrument Digital Interface (MIDI)" - config TINYUSB_MIDI_COUNT - int "TinyUSB MIDI interfaces count" - default 0 - range 0 2 - help - Setting value greater than 0 will enable TinyUSB MIDI feature. - endmenu # "Musical Instrument Digital Interface (MIDI)" - - menu "Human Interface Device Class (HID)" - config TINYUSB_HID_COUNT - int "TinyUSB HID interfaces count" - default 0 - range 0 4 - help - Setting value greater than 0 will enable TinyUSB HID feature. - endmenu # "HID Device Class (HID)" - - menu "Device Firmware Upgrade (DFU)" - choice TINYUSB_DFU_MODE - prompt "DFU mode" - default TINYUSB_DFU_MODE_NONE - help - Select which DFU driver you want to use. - - config TINYUSB_DFU_MODE_DFU - bool "DFU" - - config TINYUSB_DFU_MODE_DFU_RUNTIME - bool "DFU Runtime" - - config TINYUSB_DFU_MODE_NONE - bool "None" - endchoice - config TINYUSB_DFU_BUFSIZE - depends on TINYUSB_DFU_MODE_DFU - int "DFU XFER BUFFSIZE" - default 512 - help - DFU XFER BUFFSIZE. - endmenu # Device Firmware Upgrade (DFU) - - menu "Bluetooth Host Class (BTH)" - config TINYUSB_BTH_ENABLED - bool "Enable TinyUSB BTH feature" - default n - help - Enable TinyUSB BTH feature. - - config TINYUSB_BTH_ISO_ALT_COUNT - depends on TINYUSB_BTH_ENABLED - int "BTH ISO ALT COUNT" - default 0 - help - BTH ISO ALT COUNT. - endmenu # "Bluetooth Host Device Class" - - menu "Network driver (ECM/NCM/RNDIS)" - choice TINYUSB_NET_MODE - prompt "Network mode" - default TINYUSB_NET_MODE_NONE - help - Select network driver you want to use. - - config TINYUSB_NET_MODE_ECM_RNDIS - bool "ECM/RNDIS" - - config TINYUSB_NET_MODE_NCM - bool "NCM" - - config TINYUSB_NET_MODE_NONE - bool "None" - endchoice - endmenu # "Network driver (ECM/NCM/RNDIS)" -endmenu # "TinyUSB Stack" diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/LICENSE b/examples/espidf-peripherals-usb/components/esp_tinyusb/LICENSE deleted file mode 100644 index d645695..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/README.md b/examples/espidf-peripherals-usb/components/esp_tinyusb/README.md deleted file mode 100644 index 478f206..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Espressif's additions to TinyUSB - -[![Component Registry](https://components.espressif.com/components/espressif/esp_tinyusb/badge.svg)](https://components.espressif.com/components/espressif/esp_tinyusb) - -This component adds features to TinyUSB that help users with integrating TinyUSB with their ESP-IDF application. - -It contains: -* Configuration of USB device and string descriptors -* USB Serial Device (CDC-ACM) with optional Virtual File System support -* Input and output streams through USB Serial Device. This feature is available only when Virtual File System support is enabled. -* Other USB classes (MIDI, MSC, HID…) support directly via TinyUSB -* VBUS monitoring for self-powered devices -* SPI Flash or sd-card access via MSC USB device Class. - -## Documentation and examples -You can find documentation in [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/usb_device.html). - -You can find examples in [ESP-IDF on GitHub](https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/device). -## How to use? - -This component is distributed via [IDF component manager](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html). Just add `idf_component.yml` file to your main component with the following content: - -``` yaml -## IDF Component Manager Manifest File -dependencies: - esp_tinyusb: "~1.0.0" -``` - -Or simply run: -``` -idf.py add-dependency esp_tinyusb~1.0.0 -``` diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/cdc.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/cdc.c deleted file mode 100644 index 9e46c7c..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/cdc.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "esp_check.h" -#include "esp_err.h" -#include "esp_log.h" -#include "tusb.h" -#include "cdc.h" - -#define CDC_INTF_NUM CFG_TUD_CDC // number of cdc blocks -static esp_tusb_cdc_t *cdc_obj[CDC_INTF_NUM] = {}; -static const char *TAG = "tusb_cdc"; - -esp_tusb_cdc_t *tinyusb_cdc_get_intf(int itf_num) -{ - if (itf_num >= CDC_INTF_NUM || itf_num < 0) { - return NULL; - } - return cdc_obj[itf_num]; -} - -static esp_err_t cdc_obj_check(int itf, bool expected_inited, tusb_class_code_t expected_type) -{ - esp_tusb_cdc_t *this_itf = tinyusb_cdc_get_intf(itf); - - bool inited = (this_itf != NULL); - ESP_RETURN_ON_FALSE(expected_inited == inited, ESP_ERR_INVALID_STATE, TAG, "Wrong state of the interface. Expected state: %s", expected_inited ? "initialized" : "not initialized"); - ESP_RETURN_ON_FALSE(!(inited && (expected_type != -1) && !(this_itf->type == expected_type)), ESP_ERR_INVALID_STATE, TAG, "Wrong type of the interface. Should be : 0x%x (tusb_class_code_t)", expected_type); - return ESP_OK; -} - -static esp_err_t tusb_cdc_comm_init(int itf) -{ - ESP_RETURN_ON_ERROR(cdc_obj_check(itf, false, -1), TAG, "cdc_obj_check failed"); - cdc_obj[itf] = calloc(1, sizeof(esp_tusb_cdc_t)); - if (cdc_obj[itf] != NULL) { - cdc_obj[itf]->type = TUSB_CLASS_CDC; - ESP_LOGD(TAG, "CDC Comm class initialized"); - return ESP_OK; - } else { - ESP_LOGE(TAG, "CDC Comm initialization error"); - return ESP_FAIL; - } -} - -static esp_err_t tusb_cdc_deinit_comm(int itf) -{ - ESP_RETURN_ON_ERROR(cdc_obj_check(itf, true, TUSB_CLASS_CDC), TAG, "cdc_obj_check failed"); - free(cdc_obj[itf]); - cdc_obj[itf] = NULL; - return ESP_OK; -} - -static esp_err_t tusb_cdc_data_init(int itf) -{ - ESP_RETURN_ON_ERROR(cdc_obj_check(itf, false, TUSB_CLASS_CDC_DATA), TAG, "cdc_obj_check failed"); - cdc_obj[itf] = calloc(1, sizeof(esp_tusb_cdc_t)); - if (cdc_obj[itf] != NULL) { - cdc_obj[itf]->type = TUSB_CLASS_CDC_DATA; - ESP_LOGD(TAG, "CDC Data class initialized"); - return ESP_OK; - } else { - ESP_LOGE(TAG, "CDC Data initialization error"); - return ESP_FAIL; - } -} - -static esp_err_t tusb_cdc_deinit_data(int itf) -{ - ESP_RETURN_ON_ERROR(cdc_obj_check(itf, true, TUSB_CLASS_CDC_DATA), TAG, "cdc_obj_check failed"); - free(cdc_obj[itf]); - cdc_obj[itf] = NULL; - return ESP_OK; -} - -esp_err_t tinyusb_cdc_init(int itf, const tinyusb_config_cdc_t *cfg) -{ - ESP_RETURN_ON_ERROR(cdc_obj_check(itf, false, -1), TAG, "cdc_obj_check failed"); - - ESP_LOGD(TAG, "Init CDC %d", itf); - if (cfg->cdc_class == TUSB_CLASS_CDC) { - ESP_RETURN_ON_ERROR(tusb_cdc_comm_init(itf), TAG, "tusb_cdc_comm_init failed"); - cdc_obj[itf]->cdc_subclass.comm_subclass = cfg->cdc_subclass.comm_subclass; - } else { - ESP_RETURN_ON_ERROR(tusb_cdc_data_init(itf), TAG, "tusb_cdc_data_init failed"); - cdc_obj[itf]->cdc_subclass.data_subclass = cfg->cdc_subclass.data_subclass; - } - cdc_obj[itf]->usb_dev = cfg->usb_dev; - return ESP_OK; -} - -esp_err_t tinyusb_cdc_deinit(int itf) -{ - ESP_RETURN_ON_ERROR(cdc_obj_check(itf, true, -1), TAG, "cdc_obj_check failed"); - - ESP_LOGD(TAG, "Deinit CDC %d", itf); - if (cdc_obj[itf]->type == TUSB_CLASS_CDC) { - ESP_RETURN_ON_ERROR(tusb_cdc_deinit_comm(itf), TAG, "tusb_cdc_deinit_comm failed"); - } else if (cdc_obj[itf]->type == TUSB_CLASS_CDC_DATA) { - ESP_RETURN_ON_ERROR(tusb_cdc_deinit_data(itf), TAG, "tusb_cdc_deinit_data failed"); - } else { - return ESP_ERR_INVALID_ARG; - } - return ESP_OK; -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/descriptors_control.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/descriptors_control.c deleted file mode 100644 index 67b6cb3..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/descriptors_control.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "esp_log.h" -#include "esp_check.h" -#include "esp_err.h" -#include "descriptors_control.h" -#include "usb_descriptors.h" - -#define MAX_DESC_BUF_SIZE 32 // Max length of string descriptor (can be extended, USB supports lengths up to 255 bytes) - -static const char *TAG = "tusb_desc"; - -// ============================================================================= -// STRUCTS -// ============================================================================= - -/** - * @brief Descriptor pointers for tinyusb descriptor requests callbacks - * - */ -typedef struct { - const tusb_desc_device_t *dev; /*!< Pointer to device descriptor */ - union { - const uint8_t *cfg; /*!< Pointer to FullSpeed configuration descriptor when device one-speed only */ - const uint8_t *fs_cfg; /*!< Pointer to FullSpeed configuration descriptor when device support HighSpeed */ - }; -#if (TUD_OPT_HIGH_SPEED) - const uint8_t *hs_cfg; /*!< Pointer to HighSpeed configuration descriptor */ - const tusb_desc_device_qualifier_t *qualifier; /*!< Pointer to Qualifier descriptor */ - uint8_t *other_speed; /*!< Pointer for other speed configuration descriptor */ -#endif // TUD_OPT_HIGH_SPEED - const char *str[USB_STRING_DESCRIPTOR_ARRAY_SIZE]; /*!< Pointer to array of UTF-8 strings */ - int str_count; /*!< Number of descriptors in str */ -} tinyusb_descriptor_config_t; - -static tinyusb_descriptor_config_t s_desc_cfg; - -// ============================================================================= -// CALLBACKS -// ============================================================================= - -/** - * @brief Invoked when received GET DEVICE DESCRIPTOR. - * Descriptor contents must exist long enough for transfer to complete - * - * @return Pointer to device descriptor - */ -uint8_t const *tud_descriptor_device_cb(void) -{ - assert(s_desc_cfg.dev); - return (uint8_t const *)s_desc_cfg.dev; -} - -/** - * @brief Invoked when received GET CONFIGURATION DESCRIPTOR. - * Descriptor contents must exist long enough for transfer to complete - * - * @param[in] index Index of required configuration - * @return Pointer to configuration descriptor - */ -uint8_t const *tud_descriptor_configuration_cb(uint8_t index) -{ - (void)index; // Unused, this driver supports only 1 configuration - assert(s_desc_cfg.cfg); - -#if (TUD_OPT_HIGH_SPEED) - // HINT: cfg and fs_cfg are union, no need to assert(fs_cfg) - assert(s_desc_cfg.hs_cfg); - // Return configuration descriptor based on Host speed - return (TUSB_SPEED_HIGH == tud_speed_get()) - ? s_desc_cfg.hs_cfg - : s_desc_cfg.fs_cfg; -#else - return s_desc_cfg.cfg; -#endif // TUD_OPT_HIGH_SPEED -} - -#if (TUD_OPT_HIGH_SPEED) -/** - * @brief Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request - * Descriptor contents must exist long enough for transfer to complete - * If not highspeed capable stall this request - */ -uint8_t const *tud_descriptor_device_qualifier_cb(void) -{ - assert(s_desc_cfg.qualifier); - return (uint8_t const *)s_desc_cfg.qualifier; -} - -/** - * @brief Invoked when received GET OTHER SPEED CONFIGURATION DESCRIPTOR request - * Descriptor contents must exist long enough for transfer to complete - * Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa - */ -uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) -{ - assert(s_desc_cfg.other_speed); - - const uint8_t *other_speed = (TUSB_SPEED_HIGH == tud_speed_get()) - ? s_desc_cfg.fs_cfg - : s_desc_cfg.hs_cfg; - - memcpy(s_desc_cfg.other_speed, - other_speed, - ((tusb_desc_configuration_t *)other_speed)->wTotalLength); - - ((tusb_desc_configuration_t *)s_desc_cfg.other_speed)->bDescriptorType = TUSB_DESC_OTHER_SPEED_CONFIG; - return s_desc_cfg.other_speed; -} -#endif // TUD_OPT_HIGH_SPEED - -/** - * @brief Invoked when received GET STRING DESCRIPTOR request - * - * @param[in] index Index of required descriptor - * @param[in] langid Language of the descriptor - * @return Pointer to UTF-16 string descriptor - */ -uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) -{ - (void) langid; // Unused, this driver supports only one language in string descriptors - assert(s_desc_cfg.str); - uint8_t chr_count; - static uint16_t _desc_str[MAX_DESC_BUF_SIZE]; - - if (index == 0) { - memcpy(&_desc_str[1], s_desc_cfg.str[0], 2); - chr_count = 1; - } else { - if (index >= USB_STRING_DESCRIPTOR_ARRAY_SIZE) { - ESP_LOGW(TAG, "String index (%u) is out of bounds, check your string descriptor", index); - return NULL; - } - - if (s_desc_cfg.str[index] == NULL) { - ESP_LOGW(TAG, "String index (%u) points to NULL, check your string descriptor", index); - return NULL; - } - - const char *str = s_desc_cfg.str[index]; - chr_count = strnlen(str, MAX_DESC_BUF_SIZE - 1); // Buffer len - header - - // Convert ASCII string into UTF-16 - for (uint8_t i = 0; i < chr_count; i++) { - _desc_str[1 + i] = str[i]; - } - } - - // First byte is length in bytes (including header), second byte is descriptor type (TUSB_DESC_STRING) - _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2 * chr_count + 2); - - return _desc_str; -} - -// ============================================================================= -// Driver functions -// ============================================================================= -esp_err_t tinyusb_set_descriptors(const tinyusb_config_t *config) -{ - esp_err_t ret = ESP_FAIL; - assert(config); - const char **pstr_desc; - // Flush descriptors control struct - memset(&s_desc_cfg, 0x00, sizeof(tinyusb_descriptor_config_t)); - // Parse configuration and save descriptors's pointer - // Select Device Descriptor - if (config->device_descriptor == NULL) { - ESP_LOGW(TAG, "No Device descriptor provided, using default."); - s_desc_cfg.dev = &descriptor_dev_default; - } else { - s_desc_cfg.dev = config->device_descriptor; - } - - // Select FullSpeed configuration descriptor - if (config->configuration_descriptor == NULL) { - // Default configuration descriptor is provided only for CDC, MSC and NCM classes -#if (CFG_TUD_HID > 0 || CFG_TUD_MIDI > 0 || CFG_TUD_CUSTOM_CLASS > 0 || CFG_TUD_ECM_RNDIS > 0 || CFG_TUD_DFU > 0 || CFG_TUD_DFU_RUNTIME > 0 || CFG_TUD_BTH > 0) - ESP_GOTO_ON_FALSE(config->configuration_descriptor, ESP_ERR_INVALID_ARG, fail, TAG, "Configuration descriptor must be provided for this device"); -#else - ESP_LOGW(TAG, "No FullSpeed configuration descriptor provided, using default."); - s_desc_cfg.cfg = descriptor_fs_cfg_default; -#endif - } else { - s_desc_cfg.cfg = config->configuration_descriptor; - } - -#if (TUD_OPT_HIGH_SPEED) - // High Speed - if (config->hs_configuration_descriptor == NULL) { - // Default configuration descriptor is provided only for CDC, MSC and NCM classes -#if (CFG_TUD_HID > 0 || CFG_TUD_MIDI > 0 || CFG_TUD_CUSTOM_CLASS > 0 || CFG_TUD_ECM_RNDIS > 0 || CFG_TUD_DFU > 0 || CFG_TUD_DFU_RUNTIME > 0 || CFG_TUD_BTH > 0) - ESP_GOTO_ON_FALSE(config->hs_configuration_descriptor, ESP_ERR_INVALID_ARG, fail, TAG, "HighSpeed configuration descriptor must be provided for this device"); -#else - ESP_LOGW(TAG, "No HighSpeed configuration descriptor provided, using default."); - s_desc_cfg.hs_cfg = descriptor_hs_cfg_default; -#endif - } else { - s_desc_cfg.hs_cfg = config->hs_configuration_descriptor; - } - - // HS and FS cfg desc should be equal length - ESP_GOTO_ON_FALSE(((tusb_desc_configuration_t *)s_desc_cfg.hs_cfg)->wTotalLength == - ((tusb_desc_configuration_t *)s_desc_cfg.fs_cfg)->wTotalLength, - ESP_ERR_INVALID_ARG, fail, TAG, "HighSpeed and FullSpeed configuration descriptors must be same length"); - - // Qualifier Descriptor - if (config->qualifier_descriptor == NULL) { - ESP_GOTO_ON_FALSE((s_desc_cfg.dev == &descriptor_dev_default), ESP_ERR_INVALID_ARG, fail, TAG, "Qualifier descriptor must be present (Device Descriptor not default)."); - // Get default qualifier if device descriptor is default - ESP_LOGW(TAG, "No Qulifier descriptor provided, using default."); - s_desc_cfg.qualifier = &descriptor_qualifier_default; - } else { - s_desc_cfg.qualifier = config->qualifier_descriptor; - } - - // Other Speed buffer allocate - s_desc_cfg.other_speed = calloc(1, ((tusb_desc_configuration_t *)s_desc_cfg.hs_cfg)->wTotalLength); - ESP_GOTO_ON_FALSE(s_desc_cfg.other_speed, ESP_ERR_NO_MEM, fail, TAG, "Other speed memory allocation error"); -#endif // TUD_OPT_HIGH_SPEED - - // Select String Descriptors and count them - if (config->string_descriptor == NULL) { - ESP_LOGW(TAG, "No String descriptors provided, using default."); - pstr_desc = descriptor_str_default; - while (descriptor_str_default[++s_desc_cfg.str_count] != NULL); - } else { - pstr_desc = config->string_descriptor; - s_desc_cfg.str_count = (config->string_descriptor_count != 0) - ? config->string_descriptor_count - : 8; // '8' is for backward compatibility with esp_tinyusb v1.0.0. Do NOT remove! - } - - ESP_GOTO_ON_FALSE(s_desc_cfg.str_count <= USB_STRING_DESCRIPTOR_ARRAY_SIZE, ESP_ERR_NOT_SUPPORTED, fail, TAG, "String descriptors exceed limit"); - memcpy(s_desc_cfg.str, pstr_desc, s_desc_cfg.str_count * sizeof(pstr_desc[0])); - - ESP_LOGI(TAG, "\n" - "┌─────────────────────────────────┐\n" - "│ USB Device Descriptor Summary │\n" - "├───────────────────┬─────────────┤\n" - "│bDeviceClass │ %-4u │\n" - "├───────────────────┼─────────────┤\n" - "│bDeviceSubClass │ %-4u │\n" - "├───────────────────┼─────────────┤\n" - "│bDeviceProtocol │ %-4u │\n" - "├───────────────────┼─────────────┤\n" - "│bMaxPacketSize0 │ %-4u │\n" - "├───────────────────┼─────────────┤\n" - "│idVendor │ %-#10x │\n" - "├───────────────────┼─────────────┤\n" - "│idProduct │ %-#10x │\n" - "├───────────────────┼─────────────┤\n" - "│bcdDevice │ %-#10x │\n" - "├───────────────────┼─────────────┤\n" - "│iManufacturer │ %-#10x │\n" - "├───────────────────┼─────────────┤\n" - "│iProduct │ %-#10x │\n" - "├───────────────────┼─────────────┤\n" - "│iSerialNumber │ %-#10x │\n" - "├───────────────────┼─────────────┤\n" - "│bNumConfigurations │ %-#10x │\n" - "└───────────────────┴─────────────┘", - s_desc_cfg.dev->bDeviceClass, s_desc_cfg.dev->bDeviceSubClass, - s_desc_cfg.dev->bDeviceProtocol, s_desc_cfg.dev->bMaxPacketSize0, - s_desc_cfg.dev->idVendor, s_desc_cfg.dev->idProduct, s_desc_cfg.dev->bcdDevice, - s_desc_cfg.dev->iManufacturer, s_desc_cfg.dev->iProduct, s_desc_cfg.dev->iSerialNumber, - s_desc_cfg.dev->bNumConfigurations); - - return ESP_OK; - -fail: -#if (TUD_OPT_HIGH_SPEED) - free(s_desc_cfg.other_speed); -#endif // TUD_OPT_HIGH_SPEED - return ret; -} - -void tinyusb_set_str_descriptor(const char *str, int str_idx) -{ - assert(str_idx < USB_STRING_DESCRIPTOR_ARRAY_SIZE); - s_desc_cfg.str[str_idx] = str; -} - -void tinyusb_free_descriptors(void) -{ -#if (TUD_OPT_HIGH_SPEED) - assert(s_desc_cfg.other_speed); - free(s_desc_cfg.other_speed); -#endif // TUD_OPT_HIGH_SPEED -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/idf_component.yml b/examples/espidf-peripherals-usb/components/esp_tinyusb/idf_component.yml deleted file mode 100644 index 45421d9..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/idf_component.yml +++ /dev/null @@ -1,14 +0,0 @@ -dependencies: - idf: - version: '>=5.0' - tinyusb: - public: true - version: '>=0.14.2' -description: Espressif's additions to TinyUSB -documentation: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/usb_device.html -repository: git://github.com/espressif/esp-usb.git -repository_info: - commit_sha: 4b6a798d0bed444fff48147c8dcdbbd038e92892 - path: device/esp_tinyusb -url: https://github.com/espressif/esp-usb/tree/master/device/esp_tinyusb -version: 1.4.4 diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb.h deleted file mode 100644 index 484c86e..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include "esp_err.h" -#include "tusb.h" -#include "tinyusb_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Configuration structure of the TinyUSB core - * - * USB specification mandates self-powered devices to monitor USB VBUS to detect connection/disconnection events. - * If you want to use this feature, connected VBUS to any free GPIO through a voltage divider or voltage comparator. - * The voltage divider output should be (0.75 * Vdd) if VBUS is 4.4V (lowest valid voltage at device port). - * The comparator thresholds should be set with hysteresis: 4.35V (falling edge) and 4.75V (raising edge). - */ -typedef struct { - union { - const tusb_desc_device_t *device_descriptor; /*!< Pointer to a device descriptor. If set to NULL, the TinyUSB device will use a default device descriptor whose values are set in Kconfig */ - const tusb_desc_device_t *descriptor __attribute__((deprecated)); /*!< Alias to `device_descriptor` for backward compatibility */ - }; - const char **string_descriptor; /*!< Pointer to array of string descriptors. If set to NULL, TinyUSB device will use a default string descriptors whose values are set in Kconfig */ - int string_descriptor_count; /*!< Number of descriptors in above array */ - bool external_phy; /*!< Should USB use an external PHY */ - union { - struct { - const uint8_t *configuration_descriptor; /*!< Pointer to a configuration descriptor. If set to NULL, TinyUSB device will use a default configuration descriptor whose values are set in Kconfig */ - }; -#if (TUD_OPT_HIGH_SPEED) - struct { - const uint8_t *fs_configuration_descriptor; /*!< Pointer to a FullSpeed configuration descriptor. If set to NULL, TinyUSB device will use a default configuration descriptor whose values are set in Kconfig */ - }; - }; - const uint8_t *hs_configuration_descriptor; /*!< Pointer to a HighSpeed configuration descriptor. If set to NULL, TinyUSB device will use a default configuration descriptor whose values are set in Kconfig */ - const tusb_desc_device_qualifier_t *qualifier_descriptor; /*!< Pointer to a qualifier descriptor */ -#else - }; -#endif // TUD_OPT_HIGH_SPEED - bool self_powered; /*!< This is a self-powered USB device. USB VBUS must be monitored. */ - int vbus_monitor_io; /*!< GPIO for VBUS monitoring. Ignored if not self_powered. */ -} tinyusb_config_t; - -/** - * @brief This is an all-in-one helper function, including: - * 1. USB device driver initialization - * 2. Descriptors preparation - * 3. TinyUSB stack initialization - * 4. Creates and start a task to handle usb events - * - * @note Don't change Custom descriptor, but if it has to be done, - * Suggest to define as follows in order to match the Interface Association Descriptor (IAD): - * bDeviceClass = TUSB_CLASS_MISC, - * bDeviceSubClass = MISC_SUBCLASS_COMMON, - * - * @param config tinyusb stack specific configuration - * @retval ESP_ERR_INVALID_ARG Install driver and tinyusb stack failed because of invalid argument - * @retval ESP_FAIL Install driver and tinyusb stack failed because of internal error - * @retval ESP_OK Install driver and tinyusb stack successfully - */ -esp_err_t tinyusb_driver_install(const tinyusb_config_t *config); - -esp_err_t tinyusb_driver_uninstall(void); - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_net.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_net.h deleted file mode 100644 index 19e53c4..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_net.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include "tinyusb_types.h" -#include "esp_err.h" -#include "sdkconfig.h" - -#if (CONFIG_TINYUSB_NET_MODE_NONE != 1) - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief On receive callback type - */ -typedef esp_err_t (*tusb_net_rx_cb_t)(void *buffer, uint16_t len, void *ctx); - -/** - * @brief Free Tx buffer callback type - */ -typedef void (*tusb_net_free_tx_cb_t)(void *buffer, void *ctx); - -/** - * @brief On init callback type - */ -typedef void (*tusb_net_init_cb_t)(void *ctx); - -/** - * @brief ESP TinyUSB NCM driver configuration structure - */ -typedef struct { - uint8_t mac_addr[6]; /*!< MAC address. Must be 6 bytes long. */ - tusb_net_rx_cb_t on_recv_callback; /*!< TinyUSB receive data callbeck */ - tusb_net_free_tx_cb_t free_tx_buffer; /*!< User function for freeing the Tx buffer. - * - could be NULL, if user app is responsible for freeing the buffer - * - must be used in asynchronous send mode - * - is only called if the used tinyusb_net_send...() function returns ESP_OK - * - in sync mode means that the packet was accepted by TinyUSB - * - in async mode means that the packet was queued to be processed in TinyUSB task - */ - tusb_net_init_cb_t on_init_callback; /*!< TinyUSB init network callback */ - void *user_context; /*!< User context to be passed to any of the callback */ -} tinyusb_net_config_t; - -/** - * @brief Initialize TinyUSB NET driver - * - * @param[in] usb_dev USB device to use - * @param[in] cfg Configuration of the driver - * @return esp_err_t - */ -esp_err_t tinyusb_net_init(tinyusb_usbdev_t usb_dev, const tinyusb_net_config_t *cfg); - -/** - * @brief TinyUSB NET driver send data synchronously - * - * @note It is possible to use sync and async send interchangeably. - * This function needs some synchronization primitives, so using sync mode (even once) uses more heap - * - * @param[in] buffer USB send data - * @param[in] len Send data len - * @param[in] buff_free_arg Pointer to be passed to the free_tx_buffer() callback - * @param[in] timeout Send data len - * @return ESP_OK on success == packet has been consumed by tusb and would be eventually freed - * by free_tx_buffer() callback (if non null) - * ESP_ERR_TIMEOUT on timeout - * ESP_ERR_INVALID_STATE if tusb not initialized, ESP_ERR_NO_MEM on alloc failure - */ -esp_err_t tinyusb_net_send_sync(void *buffer, uint16_t len, void *buff_free_arg, TickType_t timeout); - -/** - * @brief TinyUSB NET driver send data asynchronously - * - * @note If using asynchronous sends, you must free the buffer using free_tx_buffer() callback. - * @note It is possible to use sync and async send interchangeably. - * @note Async flavor of the send is useful when the USB stack runs faster than the caller, - * since we have no control over the transmitted packets, if they get accepted or discarded. - * - * @param[in] buffer USB send data - * @param[in] len Send data len - * @param[in] buff_free_arg Pointer to be passed to the free_tx_buffer() callback - * @return ESP_OK on success == packet has been consumed by tusb and will be freed - * by free_tx_buffer() callback (if non null) - * ESP_ERR_INVALID_STATE if tusb not initialized - */ -esp_err_t tinyusb_net_send_async(void *buffer, uint16_t len, void *buff_free_arg); - -#endif // (CONFIG_TINYUSB_NET_MODE_NONE != 1) - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_types.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_types.h deleted file mode 100644 index 106aaaf..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tinyusb_types.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#define USB_ESPRESSIF_VID 0x303A - -typedef enum { - TINYUSB_USBDEV_0, -} tinyusb_usbdev_t; - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_cdc_acm.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_cdc_acm.h deleted file mode 100644 index 8f64ba4..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_cdc_acm.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "sdkconfig.h" -#include "esp_err.h" - -#include "tinyusb_types.h" -#include "class/cdc/cdc.h" - -#if (CONFIG_TINYUSB_CDC_ENABLED != 1) -#error "TinyUSB CDC driver must be enabled in menuconfig" -#endif - - -/** - * @brief CDC ports available to setup - */ -typedef enum { - TINYUSB_CDC_ACM_0 = 0x0, - TINYUSB_CDC_ACM_1, - TINYUSB_CDC_ACM_MAX -} tinyusb_cdcacm_itf_t; - -/* Callbacks and events - ********************************************************************* */ - -/** - * @brief Data provided to the input of the `callback_rx_wanted_char` callback - */ -typedef struct { - char wanted_char; /*!< Wanted character */ -} cdcacm_event_rx_wanted_char_data_t; - -/** - * @brief Data provided to the input of the `callback_line_state_changed` callback - */ -typedef struct { - bool dtr; /*!< Data Terminal Ready (DTR) line state */ - bool rts; /*!< Request To Send (RTS) line state */ -} cdcacm_event_line_state_changed_data_t; - -/** - * @brief Data provided to the input of the `line_coding_changed` callback - */ -typedef struct { - cdc_line_coding_t const *p_line_coding; /*!< New line coding value */ -} cdcacm_event_line_coding_changed_data_t; - -/** - * @brief Types of CDC ACM events - */ -typedef enum { - CDC_EVENT_RX, - CDC_EVENT_RX_WANTED_CHAR, - CDC_EVENT_LINE_STATE_CHANGED, - CDC_EVENT_LINE_CODING_CHANGED -} cdcacm_event_type_t; - -/** - * @brief Describes an event passing to the input of a callbacks - */ -typedef struct { - cdcacm_event_type_t type; /*!< Event type */ - union { - cdcacm_event_rx_wanted_char_data_t rx_wanted_char_data; /*!< Data input of the `callback_rx_wanted_char` callback */ - cdcacm_event_line_state_changed_data_t line_state_changed_data; /*!< Data input of the `callback_line_state_changed` callback */ - cdcacm_event_line_coding_changed_data_t line_coding_changed_data; /*!< Data input of the `line_coding_changed` callback */ - }; -} cdcacm_event_t; - -/** - * @brief CDC-ACM callback type - */ -typedef void(*tusb_cdcacm_callback_t)(int itf, cdcacm_event_t *event); - -/*********************************************************************** Callbacks and events*/ -/* Other structs - ********************************************************************* */ - -/** - * @brief Configuration structure for CDC-ACM - */ -typedef struct { - tinyusb_usbdev_t usb_dev; /*!< Usb device to set up */ - tinyusb_cdcacm_itf_t cdc_port; /*!< CDC port */ - size_t rx_unread_buf_sz __attribute__((deprecated("This parameter is not used any more. Configure RX buffer in menuconfig."))); - tusb_cdcacm_callback_t callback_rx; /*!< Pointer to the function with the `tusb_cdcacm_callback_t` type that will be handled as a callback */ - tusb_cdcacm_callback_t callback_rx_wanted_char; /*!< Pointer to the function with the `tusb_cdcacm_callback_t` type that will be handled as a callback */ - tusb_cdcacm_callback_t callback_line_state_changed; /*!< Pointer to the function with the `tusb_cdcacm_callback_t` type that will be handled as a callback */ - tusb_cdcacm_callback_t callback_line_coding_changed; /*!< Pointer to the function with the `tusb_cdcacm_callback_t` type that will be handled as a callback */ -} tinyusb_config_cdcacm_t; - -/*********************************************************************** Other structs*/ -/* Public functions - ********************************************************************* */ -/** - * @brief Initialize CDC ACM. Initialization will be finished with - * the `tud_cdc_line_state_cb` callback - * - * @param[in] cfg Configuration structure - * @return esp_err_t - */ -esp_err_t tusb_cdc_acm_init(const tinyusb_config_cdcacm_t *cfg); - -/** - * @brief De-initialize CDC ACM. - * - * @param[in] itf Index of CDC interface - * @return esp_err_t - */ -esp_err_t tusb_cdc_acm_deinit(int itf); - -/** - * @brief Register a callback invoking on CDC event. If the callback had been - * already registered, it will be overwritten - * - * @param[in] itf Index of CDC interface - * @param[in] event_type Type of registered event for a callback - * @param[in] callback Callback function - * @return esp_err_t - ESP_OK or ESP_ERR_INVALID_ARG - */ -esp_err_t tinyusb_cdcacm_register_callback(tinyusb_cdcacm_itf_t itf, - cdcacm_event_type_t event_type, - tusb_cdcacm_callback_t callback); - -/** - * @brief Unregister a callback invoking on CDC event - * - * @param[in] itf Index of CDC interface - * @param[in] event_type Type of registered event for a callback - * @return esp_err_t - ESP_OK or ESP_ERR_INVALID_ARG - */ -esp_err_t tinyusb_cdcacm_unregister_callback(tinyusb_cdcacm_itf_t itf, cdcacm_event_type_t event_type); - -/** - * @brief Sent one character to a write buffer - * - * @param[in] itf Index of CDC interface - * @param[in] ch Character to send - * @return size_t - amount of queued bytes - */ -size_t tinyusb_cdcacm_write_queue_char(tinyusb_cdcacm_itf_t itf, char ch); - -/** - * @brief Write data to write buffer - * - * @param[in] itf Index of CDC interface - * @param[in] in_buf Data - * @param[in] in_size Data size in bytes - * @return size_t - amount of queued bytes - */ -size_t tinyusb_cdcacm_write_queue(tinyusb_cdcacm_itf_t itf, const uint8_t *in_buf, size_t in_size); - -/** - * @brief Flush data in write buffer of CDC interface - * - * Use `tinyusb_cdcacm_write_queue` to add data to the buffer - * - * WARNING! TinyUSB can block output Endpoint for several RX callbacks, after will do additional flush - * after the each transfer. That can leads to the situation when you requested a flush, but it will fail until - * one of the next callbacks ends. - * SO USING OF THE FLUSH WITH TIMEOUTS IN CALLBACKS IS NOT RECOMMENDED - YOU CAN GET A LOCK FOR THE TIMEOUT - * - * @param[in] itf Index of CDC interface - * @param[in] timeout_ticks Transfer timeout. Set to zero for non-blocking mode - * @return - ESP_OK All data flushed - * - ESP_ERR_TIMEOUT Time out occurred in blocking mode - * - ESP_NOT_FINISHED The transfer is still in progress in non-blocking mode - */ -esp_err_t tinyusb_cdcacm_write_flush(tinyusb_cdcacm_itf_t itf, uint32_t timeout_ticks); - -/** - * @brief Receive data from CDC interface - * - * @param[in] itf Index of CDC interface - * @param[out] out_buf Data buffer - * @param[in] out_buf_sz Data buffer size in bytes - * @param[out] rx_data_size Number of bytes written to out_buf - * @return esp_err_t ESP_OK, ESP_FAIL or ESP_ERR_INVALID_STATE - */ -esp_err_t tinyusb_cdcacm_read(tinyusb_cdcacm_itf_t itf, uint8_t *out_buf, size_t out_buf_sz, size_t *rx_data_size); - -/** - * @brief Check if the CDC interface is initialized - * - * @param[in] itf Index of CDC interface - * @return - true Initialized - * - false Not Initialized - */ -bool tusb_cdc_acm_initialized(tinyusb_cdcacm_itf_t itf); - -/*********************************************************************** Public functions*/ - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_config.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_config.h deleted file mode 100644 index adcea7c..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_config.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019 Ha Thach (tinyusb.org), - * SPDX-FileContributor: 2020 Espressif Systems (Shanghai) CO LTD - * SPDX-License-Identifier: MIT - * - * Copyright (c) 2019 Ha Thach (tinyusb.org), - * Additions Copyright (c) 2020, Espressif Systems (Shanghai) PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#pragma once - -#include "tusb_option.h" -#include "sdkconfig.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef CONFIG_TINYUSB_CDC_ENABLED -# define CONFIG_TINYUSB_CDC_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_CDC_COUNT -# define CONFIG_TINYUSB_CDC_COUNT 0 -#endif - -#ifndef CONFIG_TINYUSB_MSC_ENABLED -# define CONFIG_TINYUSB_MSC_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_HID_COUNT -# define CONFIG_TINYUSB_HID_COUNT 0 -#endif - -#ifndef CONFIG_TINYUSB_MIDI_COUNT -# define CONFIG_TINYUSB_MIDI_COUNT 0 -#endif - -#ifndef CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED -# define CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_NET_MODE_ECM_RNDIS -# define CONFIG_TINYUSB_NET_MODE_ECM_RNDIS 0 -#endif - -#ifndef CONFIG_TINYUSB_NET_MODE_NCM -# define CONFIG_TINYUSB_NET_MODE_NCM 0 -#endif - -#ifndef CONFIG_TINYUSB_DFU_MODE_DFU -# define CONFIG_TINYUSB_DFU_MODE_DFU 0 -#endif - -#ifndef CONFIG_TINYUSB_DFU_MODE_DFU_RUNTIME -# define CONFIG_TINYUSB_DFU_MODE_DFU_RUNTIME 0 -#endif - -#ifndef CONFIG_TINYUSB_BTH_ENABLED -# define CONFIG_TINYUSB_BTH_ENABLED 0 -# define CONFIG_TINYUSB_BTH_ISO_ALT_COUNT 0 -#endif - -#ifndef CONFIG_TINYUSB_DEBUG_LEVEL -# define CONFIG_TINYUSB_DEBUG_LEVEL 0 -#endif - -#ifdef CONFIG_TINYUSB_RHPORT_HS -# define CFG_TUSB_RHPORT1_MODE OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED -#else -# define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED -#endif - -#define CFG_TUSB_OS OPT_OS_FREERTOS - -/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. - * Tinyusb use follows macros to declare transferring memory so that they can be put - * into those specific section. - * e.g - * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) - * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) - */ -#ifndef CFG_TUSB_MEM_SECTION -# define CFG_TUSB_MEM_SECTION -#endif - -#ifndef CFG_TUSB_MEM_ALIGN -# define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) -#endif - -#ifndef CFG_TUD_ENDPOINT0_SIZE -#define CFG_TUD_ENDPOINT0_SIZE 64 -#endif - -// Debug Level -#define CFG_TUSB_DEBUG CONFIG_TINYUSB_DEBUG_LEVEL - -// CDC FIFO size of TX and RX -#define CFG_TUD_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE -#define CFG_TUD_CDC_TX_BUFSIZE CONFIG_TINYUSB_CDC_TX_BUFSIZE - -// MSC Buffer size of Device Mass storage -#define CFG_TUD_MSC_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE - -// MIDI macros -#define CFG_TUD_MIDI_EP_BUFSIZE 64 -#define CFG_TUD_MIDI_EPSIZE CFG_TUD_MIDI_EP_BUFSIZE -#define CFG_TUD_MIDI_RX_BUFSIZE 64 -#define CFG_TUD_MIDI_TX_BUFSIZE 64 - -// Vendor FIFO size of TX and RX -// If not configured vendor endpoints will not be buffered -#define CFG_TUD_VENDOR_RX_BUFSIZE 64 -#define CFG_TUD_VENDOR_TX_BUFSIZE 64 - -// DFU macros -#define CFG_TUD_DFU_XFER_BUFSIZE CONFIG_TINYUSB_DFU_BUFSIZE - -// Number of BTH ISO alternatives -#define CFG_TUD_BTH_ISO_ALT_COUNT CONFIG_TINYUSB_BTH_ISO_ALT_COUNT - -// Enabled device class driver -#define CFG_TUD_CDC CONFIG_TINYUSB_CDC_COUNT -#define CFG_TUD_MSC CONFIG_TINYUSB_MSC_ENABLED -#define CFG_TUD_HID CONFIG_TINYUSB_HID_COUNT -#define CFG_TUD_MIDI CONFIG_TINYUSB_MIDI_COUNT -#define CFG_TUD_CUSTOM_CLASS CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED -#define CFG_TUD_ECM_RNDIS CONFIG_TINYUSB_NET_MODE_ECM_RNDIS -#define CFG_TUD_NCM CONFIG_TINYUSB_NET_MODE_NCM -#define CFG_TUD_DFU CONFIG_TINYUSB_DFU_MODE_DFU -#define CFG_TUD_DFU_RUNTIME CONFIG_TINYUSB_DFU_MODE_DFU_RUNTIME -#define CFG_TUD_BTH CONFIG_TINYUSB_BTH_ENABLED - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_console.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_console.h deleted file mode 100644 index 568fee0..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_console.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "esp_err.h" - -/** - * @brief Redirect output to the USB serial - * @param cdc_intf - interface number of TinyUSB's CDC - * - * @return esp_err_t - ESP_OK, ESP_FAIL or an error code - */ -esp_err_t esp_tusb_init_console(int cdc_intf); - -/** - * @brief Switch log to the default output - * @param cdc_intf - interface number of TinyUSB's CDC - * - * @return esp_err_t - */ -esp_err_t esp_tusb_deinit_console(int cdc_intf); - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_msc_storage.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_msc_storage.h deleted file mode 100644 index 35e3fb3..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_msc_storage.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "esp_err.h" -#include "wear_levelling.h" -#include "esp_vfs_fat.h" -#if SOC_SDMMC_HOST_SUPPORTED -#include "driver/sdmmc_host.h" -#endif - -/** - * @brief Data provided to the input of the `callback_mount_changed` and `callback_premount_changed` callback - */ -typedef struct { - bool is_mounted; /*!< Flag if storage is mounted or not */ -} tinyusb_msc_event_mount_changed_data_t; - -/** - * @brief Types of MSC events - */ -typedef enum { - TINYUSB_MSC_EVENT_MOUNT_CHANGED, /*!< Event type AFTER mount/unmount operation is successfully finished */ - TINYUSB_MSC_EVENT_PREMOUNT_CHANGED /*!< Event type BEFORE mount/unmount operation is started */ -} tinyusb_msc_event_type_t; - -/** - * @brief Describes an event passing to the input of a callbacks - */ -typedef struct { - tinyusb_msc_event_type_t type; /*!< Event type */ - union { - tinyusb_msc_event_mount_changed_data_t mount_changed_data; /*!< Data input of the callback */ - }; -} tinyusb_msc_event_t; - -/** - * @brief MSC callback that is delivered whenever a specific event occurs. - */ -typedef void(*tusb_msc_callback_t)(tinyusb_msc_event_t *event); - -#if SOC_SDMMC_HOST_SUPPORTED -/** - * @brief Configuration structure for sdmmc initialization - * - * User configurable parameters that are used while - * initializing the sdmmc media. - */ -typedef struct { - sdmmc_card_t *card; /*!< Pointer to sdmmc card configuration structure */ - tusb_msc_callback_t callback_mount_changed; /*!< Pointer to the function callback that will be delivered AFTER mount/unmount operation is successfully finished */ - tusb_msc_callback_t callback_premount_changed; /*!< Pointer to the function callback that will be delivered BEFORE mount/unmount operation is started */ - const esp_vfs_fat_mount_config_t mount_config; /*!< FATFS mount config */ -} tinyusb_msc_sdmmc_config_t; -#endif - -/** - * @brief Configuration structure for spiflash initialization - * - * User configurable parameters that are used while - * initializing the SPI Flash media. - */ -typedef struct { - wl_handle_t wl_handle; /*!< Pointer to spiflash wera-levelling handle */ - tusb_msc_callback_t callback_mount_changed; /*!< Pointer to the function callback that will be delivered AFTER mount/unmount operation is successfully finished */ - tusb_msc_callback_t callback_premount_changed; /*!< Pointer to the function callback that will be delivered BEFORE mount/unmount operation is started */ - const esp_vfs_fat_mount_config_t mount_config; /*!< FATFS mount config */ -} tinyusb_msc_spiflash_config_t; - -/** - * @brief Register storage type spiflash with tinyusb driver - * - * @param config pointer to the spiflash configuration - * @return esp_err_t - * - ESP_OK, if success; - * - ESP_ERR_NO_MEM, if there was no memory to allocate storage components; - */ -esp_err_t tinyusb_msc_storage_init_spiflash(const tinyusb_msc_spiflash_config_t *config); - -#if SOC_SDMMC_HOST_SUPPORTED -/** - * @brief Register storage type sd-card with tinyusb driver - * - * @param config pointer to the sd card configuration - * @return esp_err_t - * - ESP_OK, if success; - * - ESP_ERR_NO_MEM, if there was no memory to allocate storage components; - */ -esp_err_t tinyusb_msc_storage_init_sdmmc(const tinyusb_msc_sdmmc_config_t *config); -#endif -/** - * @brief Deregister storage with tinyusb driver and frees the memory - * - */ -void tinyusb_msc_storage_deinit(void); - -/** - * @brief Register a callback invoking on MSC event. If the callback had been - * already registered, it will be overwritten - * - * @param event_type - type of registered event for a callback - * @param callback - callback function - * @return esp_err_t - ESP_OK or ESP_ERR_INVALID_ARG - */ -esp_err_t tinyusb_msc_register_callback(tinyusb_msc_event_type_t event_type, - tusb_msc_callback_t callback); - - -/** - * @brief Unregister a callback invoking on MSC event. - * - * @param event_type - type of registered event for a callback - * @return esp_err_t - ESP_OK or ESP_ERR_INVALID_ARG - */ -esp_err_t tinyusb_msc_unregister_callback(tinyusb_msc_event_type_t event_type); - -/** - * @brief Mount the storage partition locally on the firmware application. - * - * Get the available drive number. Register spi flash partition. - * Connect POSIX and C standard library IO function with FATFS. - * Mounts the partition. - * This API is used by the firmware application. If the storage partition is - * mounted by this API, host (PC) can't access the storage via MSC. - * When this function is called from the tinyusb callback functions, care must be taken - * so as to make sure that user callbacks must be completed within a - * specific time. Otherwise, MSC device may re-appear again on Host. - * - * @param base_path path prefix where FATFS should be registered - * @return esp_err_t - * - ESP_OK, if success; - * - ESP_ERR_NOT_FOUND if the maximum count of volumes is already mounted - * - ESP_ERR_NO_MEM if not enough memory or too many VFSes already registered; - */ -esp_err_t tinyusb_msc_storage_mount(const char *base_path); - -/** - * @brief Unmount the storage partition from the firmware application. - * - * Unmount the partition. Unregister diskio driver. - * Unregister the SPI flash partition. - * Finally, Un-register FATFS from VFS. - * After this function is called, storage device can be seen (recognized) by host (PC). - * When this function is called from the tinyusb callback functions, care must be taken - * so as to make sure that user callbacks must be completed within a specific time. - * Otherwise, MSC device may not appear on Host. - * - * @return esp_err_t - * - ESP_OK on success - * - ESP_ERR_INVALID_STATE if FATFS is not registered in VFS - */ -esp_err_t tinyusb_msc_storage_unmount(void); - -/** - * @brief Get number of sectors in storage media - * - * @return usable size, in bytes - */ -uint32_t tinyusb_msc_storage_get_sector_count(void); - -/** - * @brief Get sector size of storage media - * - * @return sector count - */ -uint32_t tinyusb_msc_storage_get_sector_size(void); - -/** - * @brief Get status if storage media is exposed over USB to Host - * - * @return bool - * - true, if the storage media is exposed to Host - * - false, if the stoarge media is mounted on application (not exposed to Host) - */ -bool tinyusb_msc_storage_in_use_by_usb_host(void); - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_tasks.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_tasks.h deleted file mode 100644 index 38bd7de..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/tusb_tasks.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "esp_err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief This helper function creates and starts a task which wraps `tud_task()`. - * - * The wrapper function basically wraps tud_task and some log. - * Default parameters: stack size and priority as configured, argument = NULL, not pinned to any core. - * If you have more requirements for this task, you can create your own task which calls tud_task as the last step. - * - * @retval ESP_OK run tinyusb main task successfully - * @retval ESP_FAIL run tinyusb main task failed of internal error or initialization within the task failed when TINYUSB_INIT_IN_DEFAULT_TASK=y - * @retval ESP_FAIL initialization within the task failed if CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK is enabled - * @retval ESP_ERR_INVALID_STATE tinyusb main task has been created before - */ -esp_err_t tusb_run_task(void); - -/** - * @brief This helper function stops and destroys the task created by `tusb_run_task()` - * - * @retval ESP_OK stop and destroy tinyusb main task successfully - * @retval ESP_ERR_INVALID_STATE tinyusb main task hasn't been created yet - */ -esp_err_t tusb_stop_task(void); - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/vfs_tinyusb.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include/vfs_tinyusb.h deleted file mode 100644 index 9c9ba91..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include/vfs_tinyusb.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "esp_err.h" -#include "esp_vfs_common.h" // For esp_line_endings_t definitions - -#ifdef __cplusplus -extern "C" { -#endif - -#define VFS_TUSB_MAX_PATH 16 -#define VFS_TUSB_PATH_DEFAULT "/dev/tusb_cdc" - -/** - * @brief Register TinyUSB CDC at VFS with path - * - * Know limitation: - * In case there are multiple CDC interfaces in the system, only one of them can be registered to VFS. - * - * @param[in] cdc_intf Interface number of TinyUSB's CDC - * @param[in] path Path where the CDC will be registered, `/dev/tusb_cdc` will be used if left NULL. - * @return esp_err_t ESP_OK or ESP_FAIL - */ -esp_err_t esp_vfs_tusb_cdc_register(int cdc_intf, char const *path); - -/** - * @brief Unregister TinyUSB CDC from VFS - * - * @param[in] path Path where the CDC will be unregistered if NULL will be used `/dev/tusb_cdc` - * @return esp_err_t ESP_OK or ESP_FAIL - */ -esp_err_t esp_vfs_tusb_cdc_unregister(char const *path); - -/** - * @brief Set the line endings to sent - * - * This specifies the conversion between newlines ('\n', LF) on stdout and line - * endings sent: - * - * - ESP_LINE_ENDINGS_CRLF: convert LF to CRLF - * - ESP_LINE_ENDINGS_CR: convert LF to CR - * - ESP_LINE_ENDINGS_LF: no modification - * - * @param[in] mode line endings to send - */ -void esp_vfs_tusb_cdc_set_tx_line_endings(esp_line_endings_t mode); - -/** - * @brief Set the line endings expected to be received - * - * This specifies the conversion between line endings received and - * newlines ('\n', LF) passed into stdin: - * - * - ESP_LINE_ENDINGS_CRLF: convert CRLF to LF - * - ESP_LINE_ENDINGS_CR: convert CR to LF - * - ESP_LINE_ENDINGS_LF: no modification - * - * @param[in] mode line endings expected - */ -void esp_vfs_tusb_cdc_set_rx_line_endings(esp_line_endings_t mode); - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/cdc.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/cdc.h deleted file mode 100644 index c6eb923..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/cdc.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "freertos/FreeRTOS.h" -#include "freertos/semphr.h" -#include "freertos/timers.h" -#include "tusb.h" -#include "tinyusb_types.h" - -/* CDC classification - ********************************************************************* */ -typedef enum { - TINYUSB_CDC_DATA = 0x00, -} cdc_data_sublcass_type_t; // CDC120 specification - -/* Note:other classification is represented in the file components\tinyusb\tinyusb\src\class\cdc\cdc.h */ - -/*********************************************************************** CDC classification*/ -/* Structs - ********************************************************************* */ -typedef struct { - tinyusb_usbdev_t usb_dev; /*!< USB device to set up */ - tusb_class_code_t cdc_class; /*!< CDC device class : Communications or Data device */ - union { - cdc_comm_sublcass_type_t comm_subclass; /*!< Communications device subclasses: ACM, ECM, etc. */ - cdc_data_sublcass_type_t data_subclass; /*!< Data device has only one subclass.*/ - } cdc_subclass; /*!< CDC device subclass according to Class Definitions for Communications Devices the CDC v.1.20 */ -} tinyusb_config_cdc_t; /*!< Main configuration structure of a CDC device */ - -typedef struct { - tinyusb_usbdev_t usb_dev; /*!< USB device used for the instance */ - tusb_class_code_t type; - union { - cdc_comm_sublcass_type_t comm_subclass; /*!< Communications device subclasses: ACM, ECM, etc. */ - cdc_data_sublcass_type_t data_subclass; /*!< Data device has only one subclass.*/ - } cdc_subclass; /*!< CDC device subclass according to Class Definitions for Communications Devices the CDC v.1.20 */ - void *subclass_obj; /*!< Dynamically allocated subclass specific object */ -} esp_tusb_cdc_t; -/*********************************************************************** Structs*/ -/* Functions - ********************************************************************* */ -/** - * @brief Initializing CDC basic object - * @param itf - number of a CDC object - * @param cfg - CDC configuration structure - * - * @return esp_err_t ESP_OK or ESP_FAIL - */ -esp_err_t tinyusb_cdc_init(int itf, const tinyusb_config_cdc_t *cfg); - - -/** - * @brief De-initializing CDC. Clean its objects - * @param itf - number of a CDC object - * @return esp_err_t ESP_OK, ESP_ERR_INVALID_ARG, ESP_ERR_INVALID_STATE - * - */ -esp_err_t tinyusb_cdc_deinit(int itf); - - -/** - * @brief Return interface of a CDC device - * - * @param itf_num - * @return esp_tusb_cdc_t* pointer to the interface or (NULL) on error - */ -esp_tusb_cdc_t *tinyusb_cdc_get_intf(int itf_num); -/*********************************************************************** Functions*/ - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/descriptors_control.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/descriptors_control.h deleted file mode 100644 index fcf3522..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/descriptors_control.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "tinyusb.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define USB_STRING_DESCRIPTOR_ARRAY_SIZE 8 // Max 8 string descriptors for a device. LANGID, Manufacturer, Product, Serial number + 4 user defined - -/** - * @brief Parse tinyusb configuration and prepare the device configuration pointer list to configure tinyusb driver - * - * @attention All descriptors passed to this function must exist for the duration of USB device lifetime - * - * @param[in] config tinyusb stack specific configuration - * @retval ESP_ERR_INVALID_ARG Default configuration descriptor is provided only for CDC, MSC and NCM classes - * @retval ESP_ERR_NO_MEM Memory allocation error - * @retval ESP_OK Descriptors configured without error - */ -esp_err_t tinyusb_set_descriptors(const tinyusb_config_t *config); - -/** - * @brief Set specific string descriptor - * - * @attention The descriptor passed to this function must exist for the duration of USB device lifetime - * - * @param[in] str UTF-8 string - * @param[in] str_idx String descriptor index - */ -void tinyusb_set_str_descriptor(const char *str, int str_idx); - -/** - * @brief Free memory allocated during tinyusb_set_descriptors - * - */ -void tinyusb_free_descriptors(void); - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/usb_descriptors.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/usb_descriptors.h deleted file mode 100644 index be1979a..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/include_private/usb_descriptors.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "tusb.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Device descriptor generated from Kconfig - * - * This descriptor is used by default. - * The user can provide their own device descriptor via tinyusb_driver_install() call - */ -extern const tusb_desc_device_t descriptor_dev_default; - -#if (TUD_OPT_HIGH_SPEED) -/** - * @brief Qualifier Device descriptor generated from Kconfig - * - * This descriptor is used by default. - * The user can provide their own descriptor via tinyusb_driver_install() call - */ -extern const tusb_desc_device_qualifier_t descriptor_qualifier_default; -#endif // TUD_OPT_HIGH_SPEED - -/** - * @brief Array of string descriptors generated from Kconfig - * - * This descriptor is used by default. - * The user can provide their own descriptor via tinyusb_driver_install() call - */ -extern const char *descriptor_str_default[]; - -/** - * @brief FullSpeed configuration descriptor generated from Kconfig - * This descriptor is used by default. - * The user can provide their own FullSpeed configuration descriptor via tinyusb_driver_install() call - */ -extern const uint8_t descriptor_fs_cfg_default[]; - -#if (TUD_OPT_HIGH_SPEED) -/** - * @brief HighSpeed Configuration descriptor generated from Kconfig - * - * This descriptor is used by default. - * The user can provide their own HighSpeed configuration descriptor via tinyusb_driver_install() call - */ -extern const uint8_t descriptor_hs_cfg_default[]; -#endif // TUD_OPT_HIGH_SPEED - -uint8_t tusb_get_mac_string_id(void); - -#ifdef __cplusplus -} -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/sbom.yml b/examples/espidf-peripherals-usb/components/esp_tinyusb/sbom.yml deleted file mode 100644 index f1e805b..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/sbom.yml +++ /dev/null @@ -1,2 +0,0 @@ -supplier: 'Organization: Espressif Systems (Shanghai) CO LTD' -originator: 'Organization: Espressif Systems (Shanghai) CO LTD' diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/CMakeLists.txt b/examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/CMakeLists.txt deleted file mode 100644 index 637991e..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.22) -project(libusb_test - LANGUAGES C -) - -add_executable(libusb_test libusb_test.c) -target_link_libraries(libusb_test -lusb-1.0) - diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/libusb_test.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/libusb_test.c deleted file mode 100644 index 3c86f44..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test/local/libusb_test.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -#define TINYUSB_VENDOR 0x303A -#define TINYUSB_PRODUCT 0x4002 - -#define DESC_TYPE_DEVICE_QUALIFIER 0x06 -#define DESC_TYOE_OTHER_SPEED_CONFIG 0x07 - -// Buffer for descriptor data -unsigned char buffer[512] = { 0 }; - -// USB Other Speed Configuration Descriptor -typedef struct __attribute__ ((packed)) -{ - uint8_t bLength ; ///< Size of descriptor - uint8_t bDescriptorType ; ///< Other_speed_Configuration Type - uint16_t wTotalLength ; ///< Total length of data returned - - uint8_t bNumInterfaces ; ///< Number of interfaces supported by this speed configuration - uint8_t bConfigurationValue ; ///< Value to use to select configuration - uint8_t iConfiguration ; ///< Index of string descriptor - uint8_t bmAttributes ; ///< Same as Configuration descriptor - uint8_t bMaxPower ; ///< Same as Configuration descriptor -} desc_other_speed_t; - -// USB Device Qualifier Descriptor -typedef struct __attribute__ ((packed)) -{ - uint8_t bLength ; ///< Size of descriptor - uint8_t bDescriptorType ; ///< Device Qualifier Type - uint16_t bcdUSB ; ///< USB specification version number (e.g., 0200H for V2.00) - - uint8_t bDeviceClass ; ///< Class Code - uint8_t bDeviceSubClass ; ///< SubClass Code - uint8_t bDeviceProtocol ; ///< Protocol Code - - uint8_t bMaxPacketSize0 ; ///< Maximum packet size for other speed - uint8_t bNumConfigurations ; ///< Number of Other-speed Configurations - uint8_t bReserved ; ///< Reserved for future use, must be zero -} desc_device_qualifier_t; - -// printf helpers -static void _print_device_qulifier_desc(unsigned char *buffer, int length); -static void _print_other_speed_desc(unsigned char *buffer, int length); - -// -// MAIN -// -int main() -{ - libusb_context *context = NULL; - int rc = 0; - - rc = libusb_init(&context); - assert(rc == 0); - libusb_device_handle *dev_handle = libusb_open_device_with_vid_pid(context, - TINYUSB_VENDOR, - TINYUSB_PRODUCT); - - if (dev_handle != NULL) { - printf("TinyUSB Device has been found\n"); - - // Test Qualifier Descriprtor - // 1. Get Qualifier Descriptor - // 2. print descriptor data - rc = libusb_get_descriptor(dev_handle, DESC_TYPE_DEVICE_QUALIFIER, 0, buffer, 512); - _print_device_qulifier_desc(buffer, rc); - - // Test Other Speed Descriptor - // 1. Get Other Speed Descriptor - // 2. print descriptor data - rc = libusb_get_descriptor(dev_handle, DESC_TYOE_OTHER_SPEED_CONFIG, 0, buffer, 512); - _print_other_speed_desc(buffer, rc); - - libusb_close(dev_handle); - } else { - printf("TinyUSB Device has NOT been found\n"); - } - - libusb_exit(context); -} - - -// ============================================================================= -static void _print_device_qulifier_desc(unsigned char *buffer, int length) -{ - assert(buffer); - desc_device_qualifier_t *qualifier_desc = (desc_device_qualifier_t *) buffer; - printf("========= Device Qualifier ========== \n"); - printf("\t bLength: %d \n", qualifier_desc->bLength); - printf("\t bDescriptorType: %d (%#x)\n", qualifier_desc->bDescriptorType, qualifier_desc->bDescriptorType); - printf("\t bcdUSB: %d (%#x) \n", qualifier_desc->bcdUSB, qualifier_desc->bcdUSB); - printf("\t bDeviceClass: %d (%#x) \n", qualifier_desc->bDeviceClass, qualifier_desc->bDeviceClass); - printf("\t bDeviceSubClass: %d \n", qualifier_desc->bDeviceSubClass); - printf("\t bDeviceProtocol: %d \n", qualifier_desc->bDeviceProtocol); - printf("\t bMaxPacketSize0: %d \n", qualifier_desc->bMaxPacketSize0); - printf("\t bNumConfigurations: %d \n", qualifier_desc->bNumConfigurations); -} - -static void _print_other_speed_desc(unsigned char *buffer, int length) -{ - assert(buffer); - desc_other_speed_t *other_speed = (desc_other_speed_t *) buffer; - printf("============ Other Speed ============ \n"); - printf("\t bLength: %d \n", other_speed->bLength); - printf("\t bDescriptorType: %d (%#x) \n", other_speed->bDescriptorType, other_speed->bDescriptorType); - printf("\t wTotalLength: %d \n", other_speed->wTotalLength); - printf("\t bNumInterfaces: %d \n", other_speed->bNumInterfaces); - printf("\t bConfigurationValue: %d \n", other_speed->bConfigurationValue); - printf("\t iConfiguration: %d \n", other_speed->iConfiguration); - printf("\t bmAttributes: %d (%#x) \n", other_speed->bmAttributes, other_speed->bmAttributes); - printf("\t bMaxPower: %d (%#x) \n", other_speed->bMaxPower, other_speed->bMaxPower); -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/CMakeLists.txt b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/CMakeLists.txt deleted file mode 100644 index 9298e90..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# The following lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.16) -include($ENV{IDF_PATH}/tools/cmake/project.cmake) - -# Set the components to include the tests for. -set(EXTRA_COMPONENT_DIRS - ../ - ) - -project(test_app_usb_device_esp_tinyusb) diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/README.md b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/README.md deleted file mode 100644 index c3b5e9e..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/README.md +++ /dev/null @@ -1,4 +0,0 @@ -| Supported Targets | ESP32-S2 | ESP32-S3 | -| ----------------- | -------- | -------- | - -# USB: esp_tinyusb test application \ No newline at end of file diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/CMakeLists.txt b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/CMakeLists.txt deleted file mode 100644 index 3cb6ad5..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -include($ENV{IDF_PATH}/tools/cmake/version.cmake) - -idf_component_register(SRC_DIRS . - INCLUDE_DIRS . - REQUIRES unity esp_tinyusb - WHOLE_ARCHIVE) diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/idf_component.yml b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/idf_component.yml deleted file mode 100644 index 43ab341..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/idf_component.yml +++ /dev/null @@ -1,7 +0,0 @@ -## IDF Component Manager Manifest File -dependencies: - espressif/esp_tinyusb: - version: "*" - override_path: "../../" - rules: - - if: "idf_version >= 5.0" \ No newline at end of file diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_app_main.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_app_main.c deleted file mode 100644 index b25c8df..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_app_main.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "unity.h" -#include "esp_heap_caps.h" - -static size_t before_free_8bit; -static size_t before_free_32bit; - -#define TEST_MEMORY_LEAK_THRESHOLD (-530) -static void check_leak(size_t before_free, size_t after_free, const char *type) -{ - ssize_t delta = after_free - before_free; - printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta); - TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak"); -} - -void app_main(void) -{ - // ____ ___ ___________________ __ __ - // | | \/ _____/\______ \ _/ |_ ____ _______/ |_ - // | | /\_____ \ | | _/ \ __\/ __ \ / ___/\ __\. - // | | / / \ | | \ | | \ ___/ \___ \ | | - // |______/ /_______ / |______ / |__| \___ >____ > |__| - // \/ \/ \/ \/ - printf(" ____ ___ ___________________ __ __ \r\n"); - printf("| | \\/ _____/\\______ \\ _/ |_ ____ _______/ |_ \r\n"); - printf("| | /\\_____ \\ | | _/ \\ __\\/ __ \\ / ___/\\ __\\\r\n"); - printf("| | / / \\ | | \\ | | \\ ___/ \\___ \\ | | \r\n"); - printf("|______/ /_______ / |______ / |__| \\___ >____ > |__| \r\n"); - printf(" \\/ \\/ \\/ \\/ \r\n"); - - UNITY_BEGIN(); - unity_run_menu(); - UNITY_END(); -} - -/* setUp runs before every test */ -void setUp(void) -{ - before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); - before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); -} - -/* tearDown runs after every test */ -void tearDown(void) -{ - size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); - size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); - check_leak(before_free_8bit, after_free_8bit, "8BIT"); - check_leak(before_free_32bit, after_free_32bit, "32BIT"); -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.c deleted file mode 100644 index b596564..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "soc/soc_caps.h" - -#if SOC_USB_OTG_SUPPORTED - -#include -#include -#include "esp_system.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_log.h" -#include "esp_err.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "soc/gpio_sig_map.h" -#include "unity.h" -#include "tinyusb.h" -#include "tusb_tasks.h" - -#define DEVICE_DETACH_TEST_ROUNDS 10 -#define DEVICE_DETACH_ROUND_DELAY_MS 1000 - -#if (CONFIG_IDF_TARGET_ESP32P4) -#define USB_SRP_BVALID_IN_IDX USB_SRP_BVALID_PAD_IN_IDX -#endif // CONFIG_IDF_TARGET_ESP32P4 - -/* TinyUSB descriptors - ********************************************************************* */ -#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN) - -static unsigned int dev_mounted = 0; -static unsigned int dev_umounted = 0; - -static uint8_t const test_configuration_descriptor[] = { - // Config number, interface count, string index, total length, attribute, power in mA - TUD_CONFIG_DESCRIPTOR(1, 0, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_SELF_POWERED | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), -}; - -static const tusb_desc_device_t test_device_descriptor = { - .bLength = sizeof(test_device_descriptor), - .bDescriptorType = TUSB_DESC_DEVICE, - .bcdUSB = 0x0200, - .bDeviceClass = TUSB_CLASS_MISC, - .bDeviceSubClass = MISC_SUBCLASS_COMMON, - .bDeviceProtocol = MISC_PROTOCOL_IAD, - .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, - .idVendor = 0x303A, // This is Espressif VID. This needs to be changed according to Users / Customers - .idProduct = 0x4002, - .bcdDevice = 0x100, - .iManufacturer = 0x01, - .iProduct = 0x02, - .iSerialNumber = 0x03, - .bNumConfigurations = 0x01 -}; - -void test_bvalid_sig_mount_cb(void) -{ - dev_mounted++; -} - -void test_bvalid_sig_umount_cb(void) -{ - dev_umounted++; -} - -TEST_CASE("bvalid_signal", "[esp_tinyusb][usb_device]") -{ - unsigned int rounds = DEVICE_DETACH_TEST_ROUNDS; - - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = &test_device_descriptor, - .configuration_descriptor = test_configuration_descriptor, - }; - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - - dev_mounted = 0; - dev_umounted = 0; - - while (rounds--) { - // LOW to emulate disconnect USB device - esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ZERO_INPUT, USB_SRP_BVALID_IN_IDX, false); - vTaskDelay(pdMS_TO_TICKS(DEVICE_DETACH_ROUND_DELAY_MS)); - // HIGH to emulate connect USB device - esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ONE_INPUT, USB_SRP_BVALID_IN_IDX, false); - vTaskDelay(pdMS_TO_TICKS(DEVICE_DETACH_ROUND_DELAY_MS)); - } - - // Verify - TEST_ASSERT_EQUAL(dev_umounted, dev_mounted); - TEST_ASSERT_EQUAL(DEVICE_DETACH_TEST_ROUNDS, dev_mounted); - - // Cleanup - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_uninstall()); - TEST_ASSERT_EQUAL(ESP_OK, tusb_stop_task()); -} -#endif // SOC_USB_OTG_SUPPORTED diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.h deleted file mode 100644 index 82dd31b..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_bvalid_sig.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void test_bvalid_sig_mount_cb(void); -void test_bvalid_sig_umount_cb(void); - -#ifdef __cplusplus -} -#endif //__cplusplus diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.c deleted file mode 100644 index 2b92b51..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "soc/soc_caps.h" - -#if SOC_USB_OTG_SUPPORTED - -#include -#include -#include "esp_system.h" -#include "esp_err.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/semphr.h" -#include "esp_log.h" -#include "esp_err.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "soc/gpio_sig_map.h" -#include "unity.h" -#include "tinyusb.h" -#include "tusb_tasks.h" - -#define DEVICE_MOUNT_TIMEOUT_MS 5000 - -// ========================= TinyUSB descriptors =============================== -#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN) - -static uint8_t const test_fs_configuration_descriptor[] = { - // Config number, interface count, string index, total length, attribute, power in mA - TUD_CONFIG_DESCRIPTOR(1, 0, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_SELF_POWERED | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), -}; - -#if (TUD_OPT_HIGH_SPEED) -static uint8_t const test_hs_configuration_descriptor[] = { - // Config number, interface count, string index, total length, attribute, power in mA - TUD_CONFIG_DESCRIPTOR(1, 0, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_SELF_POWERED | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), -}; -#endif // TUD_OPT_HIGH_SPEED - -static const tusb_desc_device_t test_device_descriptor = { - .bLength = sizeof(test_device_descriptor), - .bDescriptorType = TUSB_DESC_DEVICE, - .bcdUSB = 0x0200, - .bDeviceClass = TUSB_CLASS_MISC, - .bDeviceSubClass = MISC_SUBCLASS_COMMON, - .bDeviceProtocol = MISC_PROTOCOL_IAD, - .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, - .idVendor = 0x303A, // This is Espressif VID. This needs to be changed according to Users / Customers - .idProduct = 0x4002, - .bcdDevice = 0x100, - .iManufacturer = 0x01, - .iProduct = 0x02, - .iSerialNumber = 0x03, - .bNumConfigurations = 0x01 -}; - -// ========================== Private logic ==================================== -SemaphoreHandle_t desc_config_device_mounted = NULL; - -static bool __test_prep(void) -{ - desc_config_device_mounted = xSemaphoreCreateBinary(); - return (desc_config_device_mounted != NULL); -} - -static esp_err_t __test_wait_conn(void) -{ - if (!desc_config_device_mounted) { - return ESP_ERR_INVALID_STATE; - } - - return ( xSemaphoreTake(desc_config_device_mounted, pdMS_TO_TICKS(DEVICE_MOUNT_TIMEOUT_MS)) - ? ESP_OK - : ESP_ERR_TIMEOUT ); -} - -static void __test_conn(void) -{ - if (desc_config_device_mounted) { - xSemaphoreGive(desc_config_device_mounted); - } -} - -static void __test_free(void) -{ - if (desc_config_device_mounted) { - vSemaphoreDelete(desc_config_device_mounted); - } -} - -// ========================== Callbacks ======================================== -// Invoked when device is mounted -void test_descriptors_config_mount_cb(void) -{ - __test_conn(); -} - -void test_descriptors_config_umount_cb(void) -{ - -} - -TEST_CASE("descriptors_config_all_default", "[esp_tinyusb][usb_device]") -{ - TEST_ASSERT_EQUAL(true, __test_prep()); - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = NULL, - .configuration_descriptor = NULL, -#if (TUD_OPT_HIGH_SPEED) - .hs_configuration_descriptor = NULL, -#endif // TUD_OPT_HIGH_SPEED - }; - // Install - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - // Wait for mounted callback - TEST_ASSERT_EQUAL(ESP_OK, __test_wait_conn()); - // Cleanup - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_uninstall()); - TEST_ASSERT_EQUAL(ESP_OK, tusb_stop_task()); - __test_free(); -} - -TEST_CASE("descriptors_config_device", "[esp_tinyusb][usb_device]") -{ - TEST_ASSERT_EQUAL(true, __test_prep()); - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = &test_device_descriptor, - .configuration_descriptor = NULL, -#if (TUD_OPT_HIGH_SPEED) - .hs_configuration_descriptor = NULL, -#endif // TUD_OPT_HIGH_SPEED - }; - // Install - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - // Wait for mounted callback - TEST_ASSERT_EQUAL(ESP_OK, __test_wait_conn()); - // Cleanup - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_uninstall()); - TEST_ASSERT_EQUAL(ESP_OK, tusb_stop_task()); - __test_free(); -} - -TEST_CASE("descriptors_config_device_and_config", "[esp_tinyusb][usb_device]") -{ - TEST_ASSERT_EQUAL(true, __test_prep()); - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = &test_device_descriptor, - .configuration_descriptor = test_fs_configuration_descriptor, -#if (TUD_OPT_HIGH_SPEED) - .hs_configuration_descriptor = NULL, -#endif // TUD_OPT_HIGH_SPEED - }; - // Install - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - // Wait for mounted callback - TEST_ASSERT_EQUAL(ESP_OK, __test_wait_conn()); - // Cleanup - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_uninstall()); - TEST_ASSERT_EQUAL(ESP_OK, tusb_stop_task()); - __test_free(); -} - -#if (TUD_OPT_HIGH_SPEED) -TEST_CASE("descriptors_config_device_and_fs_config_only", "[esp_tinyusb][usb_device]") -{ - TEST_ASSERT_EQUAL(true, __test_prep()); - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = &test_device_descriptor, - .configuration_descriptor = test_fs_configuration_descriptor, - .hs_configuration_descriptor = NULL, - }; - // Install - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - // Wait for mounted callback - TEST_ASSERT_EQUAL(ESP_OK, __test_wait_conn()); - // Cleanup - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_uninstall()); - TEST_ASSERT_EQUAL(ESP_OK, tusb_stop_task()); - __test_free(); -} - -TEST_CASE("descriptors_config_device_and_hs_config_only", "[esp_tinyusb][usb_device]") -{ - TEST_ASSERT_EQUAL(true, __test_prep()); - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = &test_device_descriptor, - .configuration_descriptor = NULL, - .hs_configuration_descriptor = test_hs_configuration_descriptor, - }; - // Install - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - // Wait for mounted callback - TEST_ASSERT_EQUAL(ESP_OK, __test_wait_conn()); - // Cleanup - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_uninstall()); - TEST_ASSERT_EQUAL(ESP_OK, tusb_stop_task()); - __test_free(); -} - -TEST_CASE("descriptors_config_all_configured", "[esp_tinyusb][usb_device]") -{ - TEST_ASSERT_EQUAL(true, __test_prep()); - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = &test_device_descriptor, - .fs_configuration_descriptor = test_fs_configuration_descriptor, - .hs_configuration_descriptor = test_hs_configuration_descriptor, - }; - // Install - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - // Wait for mounted callback - TEST_ASSERT_EQUAL(ESP_OK, __test_wait_conn()); - // Cleanup - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_uninstall()); - TEST_ASSERT_EQUAL(ESP_OK, tusb_stop_task()); - __test_free(); -} -#endif // TUD_OPT_HIGH_SPEED - -#endif // SOC_USB_OTG_SUPPORTED diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.h b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.h deleted file mode 100644 index 6bdd77b..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_descriptors_config.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void test_descriptors_config_mount_cb(void); -void test_descriptors_config_umount_cb(void); - -#ifdef __cplusplus -} -#endif //__cplusplus diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_esp_tinyusb.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_esp_tinyusb.c deleted file mode 100644 index b71d487..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_esp_tinyusb.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "soc/soc_caps.h" -#if SOC_USB_OTG_SUPPORTED - -#include -#include -#include "esp_system.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_log.h" -#include "esp_err.h" - -#include "unity.h" -#include "tinyusb.h" -#include "tusb_cdc_acm.h" -#include "vfs_tinyusb.h" - -#define VFS_PATH "/dev/usb-cdc1" - -// idf_component_register(WHOLE_ARCHIVE) backward compatibility to IDF_v4.4 -void linker_hook(void) {}; - -static const tusb_desc_device_t cdc_device_descriptor = { - .bLength = sizeof(cdc_device_descriptor), - .bDescriptorType = TUSB_DESC_DEVICE, - .bcdUSB = 0x0200, - .bDeviceClass = TUSB_CLASS_MISC, - .bDeviceSubClass = MISC_SUBCLASS_COMMON, - .bDeviceProtocol = MISC_PROTOCOL_IAD, - .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, - .idVendor = USB_ESPRESSIF_VID, - .idProduct = 0x4002, - .bcdDevice = 0x0100, - .iManufacturer = 0x01, - .iProduct = 0x02, - .iSerialNumber = 0x03, - .bNumConfigurations = 0x01 -}; - -static const uint16_t cdc_desc_config_len = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN; -static const uint8_t cdc_desc_configuration[] = { - TUD_CONFIG_DESCRIPTOR(1, 4, 0, cdc_desc_config_len, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), - TUD_CDC_DESCRIPTOR(0, 4, 0x81, 8, 0x02, 0x82, 64), - TUD_CDC_DESCRIPTOR(2, 4, 0x83, 8, 0x04, 0x84, 64), -}; - -static void tinyusb_cdc_rx_callback(int itf, cdcacm_event_t *event) -{ -} - -/** - * @brief TinyUSB CDC testcase - * - * This is not a 'standard' testcase, as it never exits. The testcase runs in a loop where it echoes back all the data received. - * - * - Init TinyUSB with standard CDC device and configuration descriptors - * - Init 2 CDC-ACM interfaces - * - Map CDC1 to Virtual File System - * - In a loop: Read data from CDC0 and CDC1. Echo received data back - * - * Note: CDC0 appends 'novfs' to echoed data, so the host (test runner) can easily determine which port is which. - */ -TEST_CASE("tinyusb_cdc", "[esp_tinyusb]") -{ - // Install TinyUSB driver - const tinyusb_config_t tusb_cfg = { - .external_phy = false, - .device_descriptor = &cdc_device_descriptor, - .configuration_descriptor = cdc_desc_configuration - }; - TEST_ASSERT_EQUAL(ESP_OK, tinyusb_driver_install(&tusb_cfg)); - - tinyusb_config_cdcacm_t acm_cfg = { - .usb_dev = TINYUSB_USBDEV_0, - .cdc_port = TINYUSB_CDC_ACM_0, - .rx_unread_buf_sz = 64, - .callback_rx = &tinyusb_cdc_rx_callback, - .callback_rx_wanted_char = NULL, - .callback_line_state_changed = NULL, - .callback_line_coding_changed = NULL - }; - - // Init CDC 0 - TEST_ASSERT_FALSE(tusb_cdc_acm_initialized(TINYUSB_CDC_ACM_0)); - TEST_ASSERT_EQUAL(ESP_OK, tusb_cdc_acm_init(&acm_cfg)); - TEST_ASSERT_TRUE(tusb_cdc_acm_initialized(TINYUSB_CDC_ACM_0)); - - // Init CDC 1 - acm_cfg.cdc_port = TINYUSB_CDC_ACM_1; - acm_cfg.callback_rx = NULL; - TEST_ASSERT_FALSE(tusb_cdc_acm_initialized(TINYUSB_CDC_ACM_1)); - TEST_ASSERT_EQUAL(ESP_OK, tusb_cdc_acm_init(&acm_cfg)); - TEST_ASSERT_TRUE(tusb_cdc_acm_initialized(TINYUSB_CDC_ACM_1)); - - // Install VFS to CDC 1 - TEST_ASSERT_EQUAL(ESP_OK, esp_vfs_tusb_cdc_register(TINYUSB_CDC_ACM_1, VFS_PATH)); - esp_vfs_tusb_cdc_set_rx_line_endings(ESP_LINE_ENDINGS_CRLF); - esp_vfs_tusb_cdc_set_tx_line_endings(ESP_LINE_ENDINGS_LF); - FILE *cdc = fopen(VFS_PATH, "r+"); - TEST_ASSERT_NOT_NULL(cdc); - - uint8_t buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE + 1]; - while (true) { - size_t b = fread(buf, 1, sizeof(buf), cdc); - if (b > 0) { - printf("Intf VFS, RX %d bytes\n", b); - //ESP_LOG_BUFFER_HEXDUMP("test", buf, b, ESP_LOG_INFO); - fwrite(buf, 1, b, cdc); - } - vTaskDelay(1); - - size_t rx_size = 0; - int itf = 0; - ESP_ERROR_CHECK(tinyusb_cdcacm_read(itf, buf, CONFIG_TINYUSB_CDC_RX_BUFSIZE, &rx_size)); - if (rx_size > 0) { - printf("Intf %d, RX %d bytes\n", itf, rx_size); - - // Add 'novfs' to reply so the host can identify the port - strcpy((char *)&buf[rx_size - 2], "novfs\r\n"); - tinyusb_cdcacm_write_queue(itf, buf, rx_size + sizeof("novfs") - 1); - - tinyusb_cdcacm_write_flush(itf, 0); - } - } -} - -#endif diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_tud_cb.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_tud_cb.c deleted file mode 100644 index 37d0a33..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/main/test_tud_cb.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "tinyusb.h" -#include "tusb_tasks.h" -#include "test_bvalid_sig.h" -#include "test_descriptors_config.h" - -// Invoked when device is mounted -void tud_mount_cb(void) -{ - printf("%s\n", __FUNCTION__); - test_bvalid_sig_mount_cb(); - test_descriptors_config_mount_cb(); -} - -// Invoked when device is unmounted -void tud_umount_cb(void) -{ - printf("%s\n", __FUNCTION__); - test_bvalid_sig_umount_cb(); - test_descriptors_config_umount_cb(); -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_cdc.py b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_cdc.py deleted file mode 100644 index 1b48438..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_cdc.py +++ /dev/null @@ -1,73 +0,0 @@ -# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: Apache-2.0 - -import pytest -from pytest_embedded_idf.dut import IdfDut -from time import sleep -from serial import Serial -from serial.tools.list_ports import comports - - -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.usb_device -def test_usb_device_cdc(dut) -> None: - ''' - Running the test locally: - 1. Build the testa app for your DUT (ESP32-S2 or S3) - 2. Connect you DUT to your test runner (local machine) with USB port and flashing port - 3. Run `pytest --target esp32s3` - - Test procedure: - 1. Run the test on the DUT - 2. Expect 2 Virtual COM Ports in the system - 3. Open both comports and send some data. Expect echoed data - ''' - dut.expect_exact('Press ENTER to see the list of tests.') - dut.write('[esp_tinyusb]') - dut.expect_exact('TinyUSB: TinyUSB Driver installed') - sleep(2) # Some time for the OS to enumerate our USB device - - # Find devices with Espressif TinyUSB VID/PID - s = [] - ports = comports() - for port, _, hwid in ports: - if '303A:4002' in hwid: - s.append(port) - - if len(s) != 2: - raise Exception('TinyUSB COM port not found') - - with Serial(s[0]) as cdc0: - with Serial(s[1]) as cdc1: - # Write dummy string and check for echo - cdc0.write('text\r\n'.encode()) - res = cdc0.readline() - assert b'text' in res - if b'novfs' in res: - novfs_cdc = cdc0 - vfs_cdc = cdc1 - - cdc1.write('text\r\n'.encode()) - res = cdc1.readline() - assert b'text' in res - if b'novfs' in res: - novfs_cdc = cdc1 - vfs_cdc = cdc0 - - # Write more than MPS, check that the transfer is not divided - novfs_cdc.write(bytes(100)) - dut.expect_exact("Intf 0, RX 100 bytes") - - # Write more than RX buffer, check correct reception - novfs_cdc.write(bytes(600)) - transfer_len1 = int(dut.expect(r'Intf 0, RX (\d+) bytes')[1].decode()) - transfer_len2 = int(dut.expect(r'Intf 0, RX (\d+) bytes')[1].decode()) - assert transfer_len1 + transfer_len2 == 600 - - # The VFS is setup for CRLF RX and LF TX - vfs_cdc.write('text\r\n'.encode()) - res = vfs_cdc.readline() - assert b'text\n' in res - - return diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_esp_tinyusb.py b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_esp_tinyusb.py deleted file mode 100644 index 78765bc..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/pytest_usb_device_esp_tinyusb.py +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: Apache-2.0 - -import pytest -from pytest_embedded_idf.dut import IdfDut - - -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.usb_device -def test_usb_device_esp_tinyusb(dut: IdfDut) -> None: - dut.run_all_single_board_cases(group='usb_device') diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/sdkconfig.defaults b/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/sdkconfig.defaults deleted file mode 100644 index e68b6cd..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/test_app/sdkconfig.defaults +++ /dev/null @@ -1,19 +0,0 @@ -# Configure TinyUSB, it will be used to mock USB devices -CONFIG_TINYUSB=y -CONFIG_TINYUSB_MSC_ENABLED=n -CONFIG_TINYUSB_CDC_ENABLED=y -CONFIG_TINYUSB_CDC_COUNT=2 -CONFIG_TINYUSB_HID_COUNT=0 - -# Disable watchdogs, they'd get triggered during unity interactive menu -CONFIG_ESP_INT_WDT=n -CONFIG_ESP_TASK_WDT=n - -# Run-time checks of Heap and Stack -CONFIG_HEAP_POISONING_COMPREHENSIVE=y -CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y -CONFIG_COMPILER_STACK_CHECK=y - -CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL=y - -CONFIG_COMPILER_CXX_EXCEPTIONS=y diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb.c deleted file mode 100644 index 52bc2ae..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "sdkconfig.h" -#include "esp_log.h" -#include "esp_check.h" -#include "esp_err.h" -#include "esp_private/periph_ctrl.h" -#include "esp_private/usb_phy.h" -#include "soc/usb_pins.h" -#include "tinyusb.h" -#include "descriptors_control.h" -#include "tusb.h" -#include "tusb_tasks.h" - -const static char *TAG = "TinyUSB"; -static usb_phy_handle_t phy_hdl; - -esp_err_t tinyusb_driver_install(const tinyusb_config_t *config) -{ - ESP_RETURN_ON_FALSE(config, ESP_ERR_INVALID_ARG, TAG, "Config can't be NULL"); - - // Configure USB PHY - usb_phy_config_t phy_conf = { - .controller = USB_PHY_CTRL_OTG, - .otg_mode = USB_OTG_MODE_DEVICE, - }; - - // External PHY IOs config - usb_phy_ext_io_conf_t ext_io_conf = { - .vp_io_num = USBPHY_VP_NUM, - .vm_io_num = USBPHY_VM_NUM, - .rcv_io_num = USBPHY_RCV_NUM, - .oen_io_num = USBPHY_OEN_NUM, - .vpo_io_num = USBPHY_VPO_NUM, - .vmo_io_num = USBPHY_VMO_NUM, - }; - if (config->external_phy) { - phy_conf.target = USB_PHY_TARGET_EXT; - phy_conf.ext_io_conf = &ext_io_conf; - } else { - phy_conf.target = USB_PHY_TARGET_INT; - } - - // OTG IOs config - const usb_phy_otg_io_conf_t otg_io_conf = USB_PHY_SELF_POWERED_DEVICE(config->vbus_monitor_io); - if (config->self_powered) { - phy_conf.otg_io_conf = &otg_io_conf; - } - ESP_RETURN_ON_ERROR(usb_new_phy(&phy_conf, &phy_hdl), TAG, "Install USB PHY failed"); - - // Descriptors config - ESP_RETURN_ON_ERROR(tinyusb_set_descriptors(config), TAG, "Descriptors config failed"); - - // Init -#if !CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK - ESP_RETURN_ON_FALSE(tusb_init(), ESP_FAIL, TAG, "Init TinyUSB stack failed"); -#endif -#if !CONFIG_TINYUSB_NO_DEFAULT_TASK - ESP_RETURN_ON_ERROR(tusb_run_task(), TAG, "Run TinyUSB task failed"); -#endif - ESP_LOGI(TAG, "TinyUSB Driver installed"); - return ESP_OK; -} - -esp_err_t tinyusb_driver_uninstall() -{ - tinyusb_free_descriptors(); - return usb_del_phy(phy_hdl); -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb_net.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb_net.c deleted file mode 100644 index f7390d7..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/tinyusb_net.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include "freertos/FreeRTOS.h" -#include "freertos/event_groups.h" -#include "tinyusb_net.h" -#include "descriptors_control.h" -#include "usb_descriptors.h" -#include "device/usbd_pvt.h" -#include "esp_check.h" - -#define MAC_ADDR_LEN 6 - -typedef struct packet { - void *buffer; - void *buff_free_arg; - uint16_t len; - esp_err_t result; -} packet_t; - -struct tinyusb_net_handle { - bool initialized; - SemaphoreHandle_t buffer_sema; - EventGroupHandle_t tx_flags; - tusb_net_rx_cb_t rx_cb; - tusb_net_free_tx_cb_t tx_buff_free_cb; - tusb_net_init_cb_t init_cb; - char mac_str[2 * MAC_ADDR_LEN + 1]; - void *ctx; - packet_t *packet_to_send; -}; - -const static int TX_FINISHED_BIT = BIT0; -static struct tinyusb_net_handle s_net_obj = { }; -static const char *TAG = "tusb_net"; - -static void do_send_sync(void *ctx) -{ - (void) ctx; - if (xSemaphoreTake(s_net_obj.buffer_sema, 0) != pdTRUE || s_net_obj.packet_to_send == NULL) { - return; - } - - packet_t *packet = s_net_obj.packet_to_send; - if (tud_network_can_xmit(packet->len)) { - tud_network_xmit(packet, packet->len); - packet->result = ESP_OK; - } else { - packet->result = ESP_FAIL; - } - xSemaphoreGive(s_net_obj.buffer_sema); - xEventGroupSetBits(s_net_obj.tx_flags, TX_FINISHED_BIT); -} - -static void do_send_async(void *ctx) -{ - packet_t *packet = ctx; - if (tud_network_can_xmit(packet->len)) { - tud_network_xmit(packet, packet->len); - } else if (s_net_obj.tx_buff_free_cb) { - ESP_LOGW(TAG, "Packet cannot be accepted on USB interface, dropping"); - s_net_obj.tx_buff_free_cb(packet->buff_free_arg, s_net_obj.ctx); - } - free(packet); -} - -esp_err_t tinyusb_net_send_async(void *buffer, uint16_t len, void *buff_free_arg) -{ - if (!tud_ready()) { - return ESP_ERR_INVALID_STATE; - } - - packet_t *packet = calloc(1, sizeof(packet_t)); - packet->len = len; - packet->buffer = buffer; - packet->buff_free_arg = buff_free_arg; - ESP_RETURN_ON_FALSE(packet, ESP_ERR_NO_MEM, TAG, "Failed to allocate packet to send"); - usbd_defer_func(do_send_async, packet, false); - return ESP_OK; -} - -esp_err_t tinyusb_net_send_sync(void *buffer, uint16_t len, void *buff_free_arg, TickType_t timeout) -{ - if (!tud_ready()) { - return ESP_ERR_INVALID_STATE; - } - - // Lazy init the flags and semaphores, as they might not be needed (if async approach is used) - if (!s_net_obj.tx_flags) { - s_net_obj.tx_flags = xEventGroupCreate(); - ESP_RETURN_ON_FALSE(s_net_obj.tx_flags, ESP_ERR_NO_MEM, TAG, "Failed to allocate event flags"); - } - if (!s_net_obj.buffer_sema) { - s_net_obj.buffer_sema = xSemaphoreCreateBinary(); - ESP_RETURN_ON_FALSE(s_net_obj.buffer_sema, ESP_ERR_NO_MEM, TAG, "Failed to allocate buffer semaphore"); - } - - packet_t packet = { - .buffer = buffer, - .len = len, - .buff_free_arg = buff_free_arg - }; - s_net_obj.packet_to_send = &packet; - xSemaphoreGive(s_net_obj.buffer_sema); // now the packet is ready, let's mark it available to tusb send - - // to execute the send function in tinyUSB task context - usbd_defer_func(do_send_sync, NULL, false); // arg=NULL -> sync send, we keep the packet inside the object - - // wait wor completion with defined timeout - EventBits_t bits = xEventGroupWaitBits(s_net_obj.tx_flags, TX_FINISHED_BIT, pdTRUE, pdTRUE, timeout); - xSemaphoreTake(s_net_obj.buffer_sema, portMAX_DELAY); // if tusb sending already started, we have wait before ditching the packet - s_net_obj.packet_to_send = NULL; // invalidate the argument - if (bits & TX_FINISHED_BIT) { // If transaction finished, return error code - return packet.result; - } - return ESP_ERR_TIMEOUT; -} - -esp_err_t tinyusb_net_init(tinyusb_usbdev_t usb_dev, const tinyusb_net_config_t *cfg) -{ - (void) usb_dev; - - ESP_RETURN_ON_FALSE(s_net_obj.initialized == false, ESP_ERR_INVALID_STATE, TAG, "TinyUSB Net class is already initialized"); - - // the semaphore and event flags are initialized only if needed - s_net_obj.rx_cb = cfg->on_recv_callback; - s_net_obj.init_cb = cfg->on_init_callback; - s_net_obj.tx_buff_free_cb = cfg->free_tx_buffer; - s_net_obj.ctx = cfg->user_context; - - const uint8_t *mac = &cfg->mac_addr[0]; - snprintf(s_net_obj.mac_str, sizeof(s_net_obj.mac_str), "%02X%02X%02X%02X%02X%02X", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - uint8_t mac_id = tusb_get_mac_string_id(); - // Pass it to Descriptor control module - tinyusb_set_str_descriptor(s_net_obj.mac_str, mac_id); - - s_net_obj.initialized = true; - - return ESP_OK; -} - -//--------------------------------------------------------------------+ -// tinyusb callbacks -//--------------------------------------------------------------------+ -bool tud_network_recv_cb(const uint8_t *src, uint16_t size) -{ - if (s_net_obj.rx_cb) { - s_net_obj.rx_cb((void *)src, size, s_net_obj.ctx); - } - tud_network_recv_renew(); - return true; -} - -uint16_t tud_network_xmit_cb(uint8_t *dst, void *ref, uint16_t arg) -{ - packet_t *packet = ref; - uint16_t len = arg; - - memcpy(dst, packet->buffer, packet->len); - if (s_net_obj.tx_buff_free_cb) { - s_net_obj.tx_buff_free_cb(packet->buff_free_arg, s_net_obj.ctx); - } - return len; -} - -void tud_network_init_cb(void) -{ - if (s_net_obj.init_cb) { - s_net_obj.init_cb(s_net_obj.ctx); - } -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_cdc_acm.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_cdc_acm.c deleted file mode 100644 index a69ba6e..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_cdc_acm.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "esp_check.h" -#include "esp_err.h" -#include "esp_log.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "tusb.h" -#include "tusb_cdc_acm.h" -#include "cdc.h" -#include "sdkconfig.h" - -#ifndef MIN -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -// CDC-ACM spinlock -static portMUX_TYPE cdc_acm_lock = portMUX_INITIALIZER_UNLOCKED; -#define CDC_ACM_ENTER_CRITICAL() portENTER_CRITICAL(&cdc_acm_lock) -#define CDC_ACM_EXIT_CRITICAL() portEXIT_CRITICAL(&cdc_acm_lock) - -typedef struct { - tusb_cdcacm_callback_t callback_rx; - tusb_cdcacm_callback_t callback_rx_wanted_char; - tusb_cdcacm_callback_t callback_line_state_changed; - tusb_cdcacm_callback_t callback_line_coding_changed; -} esp_tusb_cdcacm_t; /*!< CDC_ACM object */ - -static const char *TAG = "tusb_cdc_acm"; - -static inline esp_tusb_cdcacm_t *get_acm(tinyusb_cdcacm_itf_t itf) -{ - esp_tusb_cdc_t *cdc_inst = tinyusb_cdc_get_intf(itf); - if (cdc_inst == NULL) { - return (esp_tusb_cdcacm_t *)NULL; - } - return (esp_tusb_cdcacm_t *)(cdc_inst->subclass_obj); -} - - -/* TinyUSB callbacks - ********************************************************************* */ - -/* Invoked by cdc interface when line state changed e.g connected/disconnected */ -void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - if (dtr && rts) { // connected - if (acm != NULL) { - ESP_LOGV(TAG, "Host connected to CDC no.%d.", itf); - } else { - ESP_LOGW(TAG, "Host is connected to CDC no.%d, but it is not initialized. Initialize it using `tinyusb_cdc_init`.", itf); - return; - } - } else { // disconnected - if (acm != NULL) { - ESP_LOGV(TAG, "Serial device is ready to connect to CDC no.%d", itf); - } else { - return; - } - } - if (acm) { - CDC_ACM_ENTER_CRITICAL(); - tusb_cdcacm_callback_t cb = acm->callback_line_state_changed; - CDC_ACM_EXIT_CRITICAL(); - if (cb) { - cdcacm_event_t event = { - .type = CDC_EVENT_LINE_STATE_CHANGED, - .line_state_changed_data = { - .dtr = dtr, - .rts = rts - } - }; - cb(itf, &event); - } - } -} - -/* Invoked when CDC interface received data from host */ -void tud_cdc_rx_cb(uint8_t itf) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - if (acm) { - CDC_ACM_ENTER_CRITICAL(); - tusb_cdcacm_callback_t cb = acm->callback_rx; - CDC_ACM_EXIT_CRITICAL(); - if (cb) { - cdcacm_event_t event = { - .type = CDC_EVENT_RX - }; - cb(itf, &event); - } - } -} - -// Invoked when line coding is change via SET_LINE_CODING -void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const *p_line_coding) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - if (acm) { - CDC_ACM_ENTER_CRITICAL(); - tusb_cdcacm_callback_t cb = acm->callback_line_coding_changed; - CDC_ACM_EXIT_CRITICAL(); - if (cb) { - cdcacm_event_t event = { - .type = CDC_EVENT_LINE_CODING_CHANGED, - .line_coding_changed_data = { - .p_line_coding = p_line_coding, - } - }; - cb(itf, &event); - } - } -} - -// Invoked when received `wanted_char` -void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - if (acm) { - CDC_ACM_ENTER_CRITICAL(); - tusb_cdcacm_callback_t cb = acm->callback_rx_wanted_char; - CDC_ACM_EXIT_CRITICAL(); - if (cb) { - cdcacm_event_t event = { - .type = CDC_EVENT_RX_WANTED_CHAR, - .rx_wanted_char_data = { - .wanted_char = wanted_char, - } - }; - cb(itf, &event); - } - } -} - -esp_err_t tinyusb_cdcacm_register_callback(tinyusb_cdcacm_itf_t itf, - cdcacm_event_type_t event_type, - tusb_cdcacm_callback_t callback) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - if (acm) { - switch (event_type) { - case CDC_EVENT_RX: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_rx = callback; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - case CDC_EVENT_RX_WANTED_CHAR: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_rx_wanted_char = callback; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - case CDC_EVENT_LINE_STATE_CHANGED: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_line_state_changed = callback; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - case CDC_EVENT_LINE_CODING_CHANGED: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_line_coding_changed = callback; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - default: - ESP_LOGE(TAG, "Wrong event type"); - return ESP_ERR_INVALID_ARG; - } - } else { - ESP_LOGE(TAG, "CDC-ACM is not initialized"); - return ESP_ERR_INVALID_STATE; - } -} - -esp_err_t tinyusb_cdcacm_unregister_callback(tinyusb_cdcacm_itf_t itf, - cdcacm_event_type_t event_type) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - if (!acm) { - ESP_LOGE(TAG, "Interface is not initialized. Use `tinyusb_cdc_init` for initialization"); - return ESP_ERR_INVALID_STATE; - } - switch (event_type) { - case CDC_EVENT_RX: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_rx = NULL; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - case CDC_EVENT_RX_WANTED_CHAR: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_rx_wanted_char = NULL; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - case CDC_EVENT_LINE_STATE_CHANGED: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_line_state_changed = NULL; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - case CDC_EVENT_LINE_CODING_CHANGED: - CDC_ACM_ENTER_CRITICAL(); - acm->callback_line_coding_changed = NULL; - CDC_ACM_EXIT_CRITICAL(); - return ESP_OK; - default: - ESP_LOGE(TAG, "Wrong event type"); - return ESP_ERR_INVALID_ARG; - } -} - -/*********************************************************************** TinyUSB callbacks*/ -/* CDC-ACM - ********************************************************************* */ - -esp_err_t tinyusb_cdcacm_read(tinyusb_cdcacm_itf_t itf, uint8_t *out_buf, size_t out_buf_sz, size_t *rx_data_size) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - ESP_RETURN_ON_FALSE(acm, ESP_ERR_INVALID_STATE, TAG, "Interface is not initialized. Use `tinyusb_cdc_init` for initialization"); - - if (tud_cdc_n_available(itf) == 0) { - *rx_data_size = 0; - } else { - *rx_data_size = tud_cdc_n_read(itf, out_buf, out_buf_sz); - } - return ESP_OK; -} - -size_t tinyusb_cdcacm_write_queue_char(tinyusb_cdcacm_itf_t itf, char ch) -{ - if (!get_acm(itf)) { // non-initialized - return 0; - } - return tud_cdc_n_write_char(itf, ch); -} - -size_t tinyusb_cdcacm_write_queue(tinyusb_cdcacm_itf_t itf, const uint8_t *in_buf, size_t in_size) -{ - if (!get_acm(itf)) { // non-initialized - return 0; - } - const uint32_t size_available = tud_cdc_n_write_available(itf); - return tud_cdc_n_write(itf, in_buf, MIN(in_size, size_available)); -} - -static uint32_t tud_cdc_n_write_occupied(tinyusb_cdcacm_itf_t itf) -{ - return CFG_TUD_CDC_TX_BUFSIZE - tud_cdc_n_write_available(itf); -} - -esp_err_t tinyusb_cdcacm_write_flush(tinyusb_cdcacm_itf_t itf, uint32_t timeout_ticks) -{ - if (!get_acm(itf)) { // non-initialized - return ESP_FAIL; - } - - if (!timeout_ticks) { // if no timeout - nonblocking mode - // It might take some time until TinyUSB flushes the endpoint - // Since this call is non-blocking, we don't wait for flush finished, - // We only inform the user by returning ESP_ERR_NOT_FINISHED - tud_cdc_n_write_flush(itf); - if (tud_cdc_n_write_occupied(itf)) { - return ESP_ERR_NOT_FINISHED; - } - } else { // trying during the timeout - uint32_t ticks_start = xTaskGetTickCount(); - uint32_t ticks_now = ticks_start; - while (1) { // loop until success or until the time runs out - ticks_now = xTaskGetTickCount(); - tud_cdc_n_write_flush(itf); - if (tud_cdc_n_write_occupied(itf) == 0) { - break; // All data flushed - } - if ( (ticks_now - ticks_start) > timeout_ticks ) { // Time is up - ESP_LOGW(TAG, "Flush failed"); - return ESP_ERR_TIMEOUT; - } - vTaskDelay(1); - } - } - return ESP_OK; -} - -static esp_err_t alloc_obj(tinyusb_cdcacm_itf_t itf) -{ - esp_tusb_cdc_t *cdc_inst = tinyusb_cdc_get_intf(itf); - if (cdc_inst == NULL) { - return ESP_FAIL; - } - cdc_inst->subclass_obj = calloc(1, sizeof(esp_tusb_cdcacm_t)); - if (cdc_inst->subclass_obj == NULL) { - return ESP_FAIL; - } - return ESP_OK; -} - -esp_err_t tusb_cdc_acm_init(const tinyusb_config_cdcacm_t *cfg) -{ - esp_err_t ret = ESP_OK; - int itf = (int)cfg->cdc_port; - /* Creating a CDC object */ - const tinyusb_config_cdc_t cdc_cfg = { - .usb_dev = cfg->usb_dev, - .cdc_class = TUSB_CLASS_CDC, - .cdc_subclass.comm_subclass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL - }; - - ESP_RETURN_ON_ERROR(tinyusb_cdc_init(itf, &cdc_cfg), TAG, "tinyusb_cdc_init failed"); - ESP_GOTO_ON_ERROR(alloc_obj(itf), fail, TAG, "alloc_obj failed"); - - /* Callbacks setting up*/ - if (cfg->callback_rx) { - tinyusb_cdcacm_register_callback(itf, CDC_EVENT_RX, cfg->callback_rx); - } - if (cfg->callback_rx_wanted_char) { - tinyusb_cdcacm_register_callback(itf, CDC_EVENT_RX_WANTED_CHAR, cfg->callback_rx_wanted_char); - } - if (cfg->callback_line_state_changed) { - tinyusb_cdcacm_register_callback(itf, CDC_EVENT_LINE_STATE_CHANGED, cfg->callback_line_state_changed); - } - if (cfg->callback_line_coding_changed) { - tinyusb_cdcacm_register_callback( itf, CDC_EVENT_LINE_CODING_CHANGED, cfg->callback_line_coding_changed); - } - - return ESP_OK; -fail: - tinyusb_cdc_deinit(itf); - return ret; -} - -esp_err_t tusb_cdc_acm_deinit(int itf) -{ - return tinyusb_cdc_deinit(itf); -} - -bool tusb_cdc_acm_initialized(tinyusb_cdcacm_itf_t itf) -{ - esp_tusb_cdcacm_t *acm = get_acm(itf); - if (acm) { - return true; - } else { - return false; - } -} -/*********************************************************************** CDC-ACM*/ diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_console.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_console.c deleted file mode 100644 index 692f64f..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_console.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - - -#include -#include -#include "esp_log.h" -#include "cdc.h" -#include "tusb_console.h" -#include "tinyusb.h" -#include "vfs_tinyusb.h" -#include "esp_check.h" - -#define STRINGIFY(s) STRINGIFY2(s) -#define STRINGIFY2(s) #s - -static const char *TAG = "tusb_console"; - -typedef struct { - FILE *in; - FILE *out; - FILE *err; -} console_handle_t; - -static console_handle_t con; - - -/** - * @brief Reopen standard streams using a new path - * - * @param f_in - pointer to a pointer holding a file for in or NULL to don't change stdin - * @param f_out - pointer to a pointer holding a file for out or NULL to don't change stdout - * @param f_err - pointer to a pointer holding a file for err or NULL to don't change stderr - * @param path - mount point - * @return esp_err_t ESP_FAIL or ESP_OK - */ -static esp_err_t redirect_std_streams_to(FILE **f_in, FILE **f_out, FILE **f_err, const char *path) -{ - if (f_in) { - *f_in = freopen(path, "r", stdin); - if (*f_in == NULL) { - ESP_LOGE(TAG, "Failed to reopen in!"); - return ESP_FAIL; - } - } - if (f_out) { - *f_out = freopen(path, "w", stdout); - if (*f_out == NULL) { - ESP_LOGE(TAG, "Failed to reopen out!"); - return ESP_FAIL; - } - } - if (f_err) { - *f_err = freopen(path, "w", stderr); - if (*f_err == NULL) { - ESP_LOGE(TAG, "Failed to reopen err!"); - return ESP_FAIL; - } - } - - return ESP_OK; -} - -/** - * @brief Restore output to default - * - * @param f_in - pointer to a pointer of an in file updated with `redirect_std_streams_to` or NULL to don't change stdin - * @param f_out - pointer to a pointer of an out file updated with `redirect_std_streams_to` or NULL to don't change stdout - * @param f_err - pointer to a pointer of an err file updated with `redirect_std_streams_to` or NULL to don't change stderr - * @return esp_err_t ESP_FAIL or ESP_OK - */ -static esp_err_t restore_std_streams(FILE **f_in, FILE **f_out, FILE **f_err) -{ - const char *default_uart_dev = "/dev/uart/" STRINGIFY(CONFIG_ESP_CONSOLE_UART_NUM); - if (f_in) { - stdin = freopen(default_uart_dev, "r", *f_in); - if (stdin == NULL) { - ESP_LOGE(TAG, "Failed to reopen stdin!"); - return ESP_FAIL; - } - } - if (f_out) { - stdout = freopen(default_uart_dev, "w", *f_out); - if (stdout == NULL) { - ESP_LOGE(TAG, "Failed to reopen stdout!"); - return ESP_FAIL; - } - } - if (f_err) { - stderr = freopen(default_uart_dev, "w", *f_err); - if (stderr == NULL) { - ESP_LOGE(TAG, "Failed to reopen stderr!"); - return ESP_FAIL; - } - } - return ESP_OK; -} - -esp_err_t esp_tusb_init_console(int cdc_intf) -{ - /* Registering TUSB at VFS */ - ESP_RETURN_ON_ERROR(esp_vfs_tusb_cdc_register(cdc_intf, NULL), TAG, ""); - ESP_RETURN_ON_ERROR(redirect_std_streams_to(&con.in, &con.out, &con.err, VFS_TUSB_PATH_DEFAULT), TAG, "Failed to redirect STD streams"); - return ESP_OK; -} - -esp_err_t esp_tusb_deinit_console(int cdc_intf) -{ - ESP_RETURN_ON_ERROR(restore_std_streams(&con.in, &con.out, &con.err), TAG, "Failed to restore STD streams"); - esp_vfs_tusb_cdc_unregister(NULL); - return ESP_OK; -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_msc_storage.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_msc_storage.c deleted file mode 100644 index 356ad2c..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_msc_storage.c +++ /dev/null @@ -1,640 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "esp_log.h" -#include "esp_err.h" -#include "esp_check.h" -#include "esp_vfs_fat.h" -#include "diskio_impl.h" -#include "diskio_wl.h" -#include "wear_levelling.h" -#include "esp_partition.h" -#include "vfs_fat_internal.h" -#include "tinyusb.h" -#include "class/msc/msc_device.h" -#include "tusb_msc_storage.h" -#include "esp_vfs_fat.h" -#if SOC_SDMMC_HOST_SUPPORTED -#include "diskio_sdmmc.h" -#endif - -static const char *TAG = "tinyusb_msc_storage"; - -typedef struct { - bool is_fat_mounted; - const char *base_path; - union { - wl_handle_t wl_handle; -#if SOC_SDMMC_HOST_SUPPORTED - sdmmc_card_t *card; -#endif - }; - esp_err_t (*mount)(BYTE pdrv); - esp_err_t (*unmount)(void); - uint32_t (*sector_count)(void); - uint32_t (*sector_size)(void); - esp_err_t (*read)(size_t sector_size, uint32_t lba, uint32_t offset, size_t size, void *dest); - esp_err_t (*write)(size_t sector_size, size_t addr, uint32_t lba, uint32_t offset, size_t size, const void *src); - tusb_msc_callback_t callback_mount_changed; - tusb_msc_callback_t callback_premount_changed; - int max_files; -} tinyusb_msc_storage_handle_s; /*!< MSC object */ - -/* handle of tinyusb driver connected to application */ -static tinyusb_msc_storage_handle_s *s_storage_handle; - -static esp_err_t _mount_spiflash(BYTE pdrv) -{ - return ff_diskio_register_wl_partition(pdrv, s_storage_handle->wl_handle); -} - -static esp_err_t _unmount_spiflash(void) -{ - BYTE pdrv; - pdrv = ff_diskio_get_pdrv_wl(s_storage_handle->wl_handle); - if (pdrv == 0xff) { - ESP_LOGE(TAG, "Invalid state"); - return ESP_ERR_INVALID_STATE; - } - ff_diskio_clear_pdrv_wl(s_storage_handle->wl_handle); - - char drv[3] = {(char)('0' + pdrv), ':', 0}; - f_mount(0, drv, 0); - ff_diskio_unregister(pdrv); - - return ESP_OK; -} - -static uint32_t _get_sector_count_spiflash(void) -{ - uint32_t result = 0; - assert(s_storage_handle->wl_handle != WL_INVALID_HANDLE); - size_t size = wl_sector_size(s_storage_handle->wl_handle); - if (size == 0) { - ESP_LOGW(TAG, "WL Sector size is zero !!!"); - result = 0; - } else { - result = (uint32_t)(wl_size(s_storage_handle->wl_handle) / size); - } - return result; -} - -static uint32_t _get_sector_size_spiflash(void) -{ - assert(s_storage_handle->wl_handle != WL_INVALID_HANDLE); - return (uint32_t)wl_sector_size(s_storage_handle->wl_handle); -} - -static esp_err_t _read_sector_spiflash(size_t sector_size, - uint32_t lba, - uint32_t offset, - size_t size, - void *dest) -{ - size_t temp = 0; - size_t addr = 0; // Address of the data to be read, relative to the beginning of the partition. - ESP_RETURN_ON_FALSE(!__builtin_umul_overflow(lba, sector_size, &temp), ESP_ERR_INVALID_SIZE, TAG, "overflow lba %lu sector_size %u", lba, sector_size); - ESP_RETURN_ON_FALSE(!__builtin_uadd_overflow(temp, offset, &addr), ESP_ERR_INVALID_SIZE, TAG, "overflow addr %u offset %lu", temp, offset); - return wl_read(s_storage_handle->wl_handle, addr, dest, size); -} - -static esp_err_t _write_sector_spiflash(size_t sector_size, - size_t addr, - uint32_t lba, - uint32_t offset, - size_t size, - const void *src) -{ - ESP_RETURN_ON_ERROR(wl_erase_range(s_storage_handle->wl_handle, addr, size), - TAG, "Failed to erase"); - return wl_write(s_storage_handle->wl_handle, addr, src, size); -} - -#if SOC_SDMMC_HOST_SUPPORTED -static esp_err_t _mount_sdmmc(BYTE pdrv) -{ - ff_diskio_register_sdmmc(pdrv, s_storage_handle->card); - ff_sdmmc_set_disk_status_check(pdrv, false); - return ESP_OK; -} - -static esp_err_t _unmount_sdmmc(void) -{ - BYTE pdrv; - pdrv = ff_diskio_get_pdrv_card(s_storage_handle->card); - if (pdrv == 0xff) { - ESP_LOGE(TAG, "Invalid state"); - return ESP_ERR_INVALID_STATE; - } - - char drv[3] = {(char)('0' + pdrv), ':', 0}; - f_mount(0, drv, 0); - ff_diskio_unregister(pdrv); - - return ESP_OK; -} - -static uint32_t _get_sector_count_sdmmc(void) -{ - assert(s_storage_handle->card); - return (uint32_t)s_storage_handle->card->csd.capacity; -} - -static uint32_t _get_sector_size_sdmmc(void) -{ - assert(s_storage_handle->card); - return (uint32_t)s_storage_handle->card->csd.sector_size; -} - -static esp_err_t _read_sector_sdmmc(size_t sector_size, - uint32_t lba, - uint32_t offset, - size_t size, - void *dest) -{ - return sdmmc_read_sectors(s_storage_handle->card, dest, lba, size / sector_size); -} - -static esp_err_t _write_sector_sdmmc(size_t sector_size, - size_t addr, - uint32_t lba, - uint32_t offset, - size_t size, - const void *src) -{ - return sdmmc_write_sectors(s_storage_handle->card, src, lba, size / sector_size); -} -#endif - -static esp_err_t msc_storage_read_sector(uint32_t lba, - uint32_t offset, - size_t size, - void *dest) -{ - assert(s_storage_handle); - size_t sector_size = tinyusb_msc_storage_get_sector_size(); - return (s_storage_handle->read)(sector_size, lba, offset, size, dest); -} - -static esp_err_t msc_storage_write_sector(uint32_t lba, - uint32_t offset, - size_t size, - const void *src) -{ - assert(s_storage_handle); - if (s_storage_handle->is_fat_mounted) { - ESP_LOGE(TAG, "can't write, FAT mounted"); - return ESP_ERR_INVALID_STATE; - } - size_t sector_size = tinyusb_msc_storage_get_sector_size(); - size_t temp = 0; - size_t addr = 0; // Address of the data to be read, relative to the beginning of the partition. - ESP_RETURN_ON_FALSE(!__builtin_umul_overflow(lba, sector_size, &temp), ESP_ERR_INVALID_SIZE, TAG, "overflow lba %lu sector_size %u", lba, sector_size); - ESP_RETURN_ON_FALSE(!__builtin_uadd_overflow(temp, offset, &addr), ESP_ERR_INVALID_SIZE, TAG, "overflow addr %u offset %lu", temp, offset); - - if (addr % sector_size != 0 || size % sector_size != 0) { - ESP_LOGE(TAG, "Invalid Argument lba(%lu) offset(%lu) size(%u) sector_size(%u)", lba, offset, size, sector_size); - return ESP_ERR_INVALID_ARG; - } - return (s_storage_handle->write)(sector_size, addr, lba, offset, size, src); -} - -static esp_err_t _mount(char *drv, FATFS *fs) -{ - void *workbuf = NULL; - const size_t workbuf_size = 4096; - esp_err_t ret; - // Try to mount partition - FRESULT fresult = f_mount(fs, drv, 1); - if (fresult != FR_OK) { - ESP_LOGW(TAG, "f_mount failed (%d)", fresult); - if (!((fresult == FR_NO_FILESYSTEM || fresult == FR_INT_ERR))) { - ret = ESP_FAIL; - goto fail; - } - workbuf = ff_memalloc(workbuf_size); - if (workbuf == NULL) { - ret = ESP_ERR_NO_MEM; - goto fail; - } - size_t alloc_unit_size = esp_vfs_fat_get_allocation_unit_size( - CONFIG_WL_SECTOR_SIZE, - 4096); - ESP_LOGW(TAG, "formatting card, allocation unit size=%d", alloc_unit_size); - const MKFS_PARM opt = {(BYTE)FM_FAT, 0, 0, 0, alloc_unit_size}; - fresult = f_mkfs("", &opt, workbuf, workbuf_size); // Use default volume - if (fresult != FR_OK) { - ret = ESP_FAIL; - ESP_LOGE(TAG, "f_mkfs failed (%d)", fresult); - goto fail; - } - free(workbuf); - workbuf = NULL; - fresult = f_mount(fs, drv, 0); - if (fresult != FR_OK) { - ret = ESP_FAIL; - ESP_LOGE(TAG, "f_mount failed after formatting (%d)", fresult); - goto fail; - } - } - return ESP_OK; -fail: - if (workbuf) { - free(workbuf); - } - return ret; -} - -esp_err_t tinyusb_msc_storage_mount(const char *base_path) -{ - esp_err_t ret = ESP_OK; - assert(s_storage_handle); - - if (s_storage_handle->is_fat_mounted) { - return ESP_OK; - } - - tusb_msc_callback_t cb = s_storage_handle->callback_premount_changed; - if (cb) { - tinyusb_msc_event_t event = { - .type = TINYUSB_MSC_EVENT_PREMOUNT_CHANGED, - .mount_changed_data = { - .is_mounted = s_storage_handle->is_fat_mounted - } - }; - cb(&event); - } - - if (!base_path) { - base_path = CONFIG_TINYUSB_MSC_MOUNT_PATH; - } - - // connect driver to FATFS - BYTE pdrv = 0xFF; - ESP_RETURN_ON_ERROR(ff_diskio_get_drive(&pdrv), TAG, - "The maximum count of volumes is already mounted"); - char drv[3] = {(char)('0' + pdrv), ':', 0}; - - ESP_GOTO_ON_ERROR((s_storage_handle->mount)(pdrv), fail, TAG, "Failed pdrv=%d", pdrv); - - FATFS *fs = NULL; - ret = esp_vfs_fat_register(base_path, drv, s_storage_handle->max_files, &fs); - if (ret == ESP_ERR_INVALID_STATE) { - ESP_LOGD(TAG, "it's okay, already registered with VFS"); - } else if (ret != ESP_OK) { - ESP_LOGE(TAG, "esp_vfs_fat_register failed (0x%x)", ret); - goto fail; - } - - ESP_GOTO_ON_ERROR(_mount(drv, fs), fail, TAG, "Failed _mount"); - - s_storage_handle->is_fat_mounted = true; - s_storage_handle->base_path = base_path; - - cb = s_storage_handle->callback_mount_changed; - if (cb) { - tinyusb_msc_event_t event = { - .type = TINYUSB_MSC_EVENT_MOUNT_CHANGED, - .mount_changed_data = { - .is_mounted = s_storage_handle->is_fat_mounted - } - }; - cb(&event); - } - - return ret; - -fail: - if (fs) { - esp_vfs_fat_unregister_path(base_path); - } - ff_diskio_unregister(pdrv); - s_storage_handle->is_fat_mounted = false; - ESP_LOGW(TAG, "Failed to mount storage (0x%x)", ret); - return ret; -} - -esp_err_t tinyusb_msc_storage_unmount(void) -{ - if (!s_storage_handle) { - return ESP_FAIL; - } - - if (!s_storage_handle->is_fat_mounted) { - return ESP_OK; - } - - tusb_msc_callback_t cb = s_storage_handle->callback_premount_changed; - if (cb) { - tinyusb_msc_event_t event = { - .type = TINYUSB_MSC_EVENT_PREMOUNT_CHANGED, - .mount_changed_data = { - .is_mounted = s_storage_handle->is_fat_mounted - } - }; - cb(&event); - } - - esp_err_t err = (s_storage_handle->unmount)(); - if (err) { - return err; - } - err = esp_vfs_fat_unregister_path(s_storage_handle->base_path); - s_storage_handle->base_path = NULL; - s_storage_handle->is_fat_mounted = false; - - cb = s_storage_handle->callback_mount_changed; - if (cb) { - tinyusb_msc_event_t event = { - .type = TINYUSB_MSC_EVENT_MOUNT_CHANGED, - .mount_changed_data = { - .is_mounted = s_storage_handle->is_fat_mounted - } - }; - cb(&event); - } - - return err; -} - -uint32_t tinyusb_msc_storage_get_sector_count(void) -{ - assert(s_storage_handle); - return (s_storage_handle->sector_count)(); -} - -uint32_t tinyusb_msc_storage_get_sector_size(void) -{ - assert(s_storage_handle); - return (s_storage_handle->sector_size)(); -} - -esp_err_t tinyusb_msc_storage_init_spiflash(const tinyusb_msc_spiflash_config_t *config) -{ - assert(!s_storage_handle); - s_storage_handle = (tinyusb_msc_storage_handle_s *)malloc(sizeof(tinyusb_msc_storage_handle_s)); - ESP_RETURN_ON_FALSE(s_storage_handle, ESP_ERR_NO_MEM, TAG, "could not allocate new handle for storage"); - s_storage_handle->mount = &_mount_spiflash; - s_storage_handle->unmount = &_unmount_spiflash; - s_storage_handle->sector_count = &_get_sector_count_spiflash; - s_storage_handle->sector_size = &_get_sector_size_spiflash; - s_storage_handle->read = &_read_sector_spiflash; - s_storage_handle->write = &_write_sector_spiflash; - s_storage_handle->is_fat_mounted = false; - s_storage_handle->base_path = NULL; - s_storage_handle->wl_handle = config->wl_handle; - // In case the user does not set mount_config.max_files - // and for backward compatibility with versions <1.4.2 - // max_files is set to 2 - const int max_files = config->mount_config.max_files; - s_storage_handle->max_files = max_files > 0 ? max_files : 2; - - /* Callbacks setting up*/ - if (config->callback_mount_changed) { - tinyusb_msc_register_callback(TINYUSB_MSC_EVENT_MOUNT_CHANGED, config->callback_mount_changed); - } else { - tinyusb_msc_unregister_callback(TINYUSB_MSC_EVENT_MOUNT_CHANGED); - } - if (config->callback_premount_changed) { - tinyusb_msc_register_callback(TINYUSB_MSC_EVENT_PREMOUNT_CHANGED, config->callback_premount_changed); - } else { - tinyusb_msc_unregister_callback(TINYUSB_MSC_EVENT_PREMOUNT_CHANGED); - } - - return ESP_OK; -} - -#if SOC_SDMMC_HOST_SUPPORTED -esp_err_t tinyusb_msc_storage_init_sdmmc(const tinyusb_msc_sdmmc_config_t *config) -{ - assert(!s_storage_handle); - s_storage_handle = (tinyusb_msc_storage_handle_s *)malloc(sizeof(tinyusb_msc_storage_handle_s)); - ESP_RETURN_ON_FALSE(s_storage_handle, ESP_ERR_NO_MEM, TAG, "could not allocate new handle for storage"); - s_storage_handle->mount = &_mount_sdmmc; - s_storage_handle->unmount = &_unmount_sdmmc; - s_storage_handle->sector_count = &_get_sector_count_sdmmc; - s_storage_handle->sector_size = &_get_sector_size_sdmmc; - s_storage_handle->read = &_read_sector_sdmmc; - s_storage_handle->write = &_write_sector_sdmmc; - s_storage_handle->is_fat_mounted = false; - s_storage_handle->base_path = NULL; - s_storage_handle->card = config->card; - // In case the user does not set mount_config.max_files - // and for backward compatibility with versions <1.4.2 - // max_files is set to 2 - const int max_files = config->mount_config.max_files; - s_storage_handle->max_files = max_files > 0 ? max_files : 2; - - /* Callbacks setting up*/ - if (config->callback_mount_changed) { - tinyusb_msc_register_callback(TINYUSB_MSC_EVENT_MOUNT_CHANGED, config->callback_mount_changed); - } else { - tinyusb_msc_unregister_callback(TINYUSB_MSC_EVENT_MOUNT_CHANGED); - } - if (config->callback_premount_changed) { - tinyusb_msc_register_callback(TINYUSB_MSC_EVENT_PREMOUNT_CHANGED, config->callback_premount_changed); - } else { - tinyusb_msc_unregister_callback(TINYUSB_MSC_EVENT_PREMOUNT_CHANGED); - } - - return ESP_OK; -} -#endif - -void tinyusb_msc_storage_deinit(void) -{ - assert(s_storage_handle); - free(s_storage_handle); - s_storage_handle = NULL; -} - -esp_err_t tinyusb_msc_register_callback(tinyusb_msc_event_type_t event_type, - tusb_msc_callback_t callback) -{ - assert(s_storage_handle); - switch (event_type) { - case TINYUSB_MSC_EVENT_MOUNT_CHANGED: - s_storage_handle->callback_mount_changed = callback; - return ESP_OK; - case TINYUSB_MSC_EVENT_PREMOUNT_CHANGED: - s_storage_handle->callback_premount_changed = callback; - return ESP_OK; - default: - ESP_LOGE(TAG, "Wrong event type"); - return ESP_ERR_INVALID_ARG; - } -} - -esp_err_t tinyusb_msc_unregister_callback(tinyusb_msc_event_type_t event_type) -{ - assert(s_storage_handle); - switch (event_type) { - case TINYUSB_MSC_EVENT_MOUNT_CHANGED: - s_storage_handle->callback_mount_changed = NULL; - return ESP_OK; - case TINYUSB_MSC_EVENT_PREMOUNT_CHANGED: - s_storage_handle->callback_premount_changed = NULL; - return ESP_OK; - default: - ESP_LOGE(TAG, "Wrong event type"); - return ESP_ERR_INVALID_ARG; - } -} - -bool tinyusb_msc_storage_in_use_by_usb_host(void) -{ - assert(s_storage_handle); - return !s_storage_handle->is_fat_mounted; -} - - -/* TinyUSB MSC callbacks - ********************************************************************* */ - -/** SCSI ASC/ASCQ codes. **/ -/** User can add and use more codes as per the need of the application **/ -#define SCSI_CODE_ASC_MEDIUM_NOT_PRESENT 0x3A /** SCSI ASC code for 'MEDIUM NOT PRESENT' **/ -#define SCSI_CODE_ASC_INVALID_COMMAND_OPERATION_CODE 0x20 /** SCSI ASC code for 'INVALID COMMAND OPERATION CODE' **/ -#define SCSI_CODE_ASCQ 0x00 - -// Invoked when received SCSI_CMD_INQUIRY -// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively -void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) -{ - (void) lun; - const char vid[] = "TinyUSB"; - const char pid[] = "Flash Storage"; - const char rev[] = "0.1"; - - memcpy(vendor_id, vid, strlen(vid)); - memcpy(product_id, pid, strlen(pid)); - memcpy(product_rev, rev, strlen(rev)); -} - -// Invoked when received Test Unit Ready command. -// return true allowing host to read/write this LUN e.g SD card inserted -bool tud_msc_test_unit_ready_cb(uint8_t lun) -{ - (void) lun; - bool result = false; - - if (s_storage_handle->is_fat_mounted) { - tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, SCSI_CODE_ASC_MEDIUM_NOT_PRESENT, SCSI_CODE_ASCQ); - result = false; - } else { - if (tinyusb_msc_storage_unmount() != ESP_OK) { - ESP_LOGW(TAG, "tud_msc_test_unit_ready_cb() unmount Fails"); - } - result = true; - } - return result; -} - -// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size -// Application update block count and block size -void tud_msc_capacity_cb(uint8_t lun, uint32_t *block_count, uint16_t *block_size) -{ - (void) lun; - - uint32_t sec_count = tinyusb_msc_storage_get_sector_count(); - uint32_t sec_size = tinyusb_msc_storage_get_sector_size(); - *block_count = sec_count; - *block_size = (uint16_t)sec_size; -} - -// Invoked when received Start Stop Unit command -// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage -// - Start = 1 : active mode, if load_eject = 1 : load disk storage -bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) -{ - (void) lun; - (void) power_condition; - - if (load_eject && !start) { - if (tinyusb_msc_storage_mount(s_storage_handle->base_path) != ESP_OK) { - ESP_LOGW(TAG, "tud_msc_start_stop_cb() mount Fails"); - } - } - return true; -} - -// Invoked when received SCSI READ10 command -// - Address = lba * BLOCK_SIZE + offset -// - Application fill the buffer (up to bufsize) with address contents and return number of read byte. -int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buffer, uint32_t bufsize) -{ - esp_err_t err = msc_storage_read_sector(lba, offset, bufsize, buffer); - if (err != ESP_OK) { - ESP_LOGE(TAG, "msc_storage_read_sector failed: 0x%x", err); - return 0; - } - return bufsize; -} - -// Invoked when received SCSI WRITE10 command -// - Address = lba * BLOCK_SIZE + offset -// - Application write data from buffer to address contents (up to bufsize) and return number of written byte. -int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *buffer, uint32_t bufsize) -{ - esp_err_t err = msc_storage_write_sector(lba, offset, bufsize, buffer); - if (err != ESP_OK) { - ESP_LOGE(TAG, "msc_storage_write_sector failed: 0x%x", err); - return 0; - } - return bufsize; -} - -/** - * Invoked when received an SCSI command not in built-in list below. - * - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, TEST_UNIT_READY, START_STOP_UNIT, MODE_SENSE6, REQUEST_SENSE - * - READ10 and WRITE10 has their own callbacks - * - * \param[in] lun Logical unit number - * \param[in] scsi_cmd SCSI command contents which application must examine to response accordingly - * \param[out] buffer Buffer for SCSI Data Stage. - * - For INPUT: application must fill this with response. - * - For OUTPUT it holds the Data from host - * \param[in] bufsize Buffer's length. - * - * \return Actual bytes processed, can be zero for no-data command. - * \retval negative Indicate error e.g unsupported command, tinyusb will \b STALL the corresponding - * endpoint and return failed status in command status wrapper phase. - */ -int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void *buffer, uint16_t bufsize) -{ - int32_t ret; - - switch (scsi_cmd[0]) { - case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL: - /* SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL is the Prevent/Allow Medium Removal - command (1Eh) that requests the library to enable or disable user access to - the storage media/partition. */ - ret = 0; - break; - default: - ESP_LOGW(TAG, "tud_msc_scsi_cb() invoked: %d", scsi_cmd[0]); - tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_CODE_ASC_INVALID_COMMAND_OPERATION_CODE, SCSI_CODE_ASCQ); - ret = -1; - break; - } - return ret; -} - -// Invoked when device is unmounted -void tud_umount_cb(void) -{ - if (tinyusb_msc_storage_mount(s_storage_handle->base_path) != ESP_OK) { - ESP_LOGW(TAG, "tud_umount_cb() mount Fails"); - } -} - -// Invoked when device is mounted (configured) -void tud_mount_cb(void) -{ - tinyusb_msc_storage_unmount(); -} -/*********************************************************************** TinyUSB MSC callbacks*/ diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_tasks.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_tasks.c deleted file mode 100644 index cd4add4..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/tusb_tasks.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "sdkconfig.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/event_groups.h" -#include "esp_log.h" -#include "esp_check.h" -#include "tinyusb.h" -#include "tusb_tasks.h" - -const static char *TAG = "tusb_tsk"; -static TaskHandle_t s_tusb_tskh; - -#if CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK -const static int INIT_OK = BIT0; -const static int INIT_FAILED = BIT1; -#endif - -/** - * @brief This top level thread processes all usb events and invokes callbacks - */ -static void tusb_device_task(void *arg) -{ - ESP_LOGD(TAG, "tinyusb task started"); -#if CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK - EventGroupHandle_t *init_flags = arg; - if (!tusb_init()) { - ESP_LOGI(TAG, "Init TinyUSB stack failed"); - xEventGroupSetBits(*init_flags, INIT_FAILED); - vTaskDelete(NULL); - } - ESP_LOGD(TAG, "tinyusb task has been initialized"); - xEventGroupSetBits(*init_flags, INIT_OK); -#endif // CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK - while (1) { // RTOS forever loop - tud_task(); - } -} - -esp_err_t tusb_run_task(void) -{ - // This function is not guaranteed to be thread safe, if invoked multiple times without calling `tusb_stop_task`, will cause memory leak - // doing a sanity check anyway - ESP_RETURN_ON_FALSE(!s_tusb_tskh, ESP_ERR_INVALID_STATE, TAG, "TinyUSB main task already started"); - - void *task_arg = NULL; -#if CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK - // need to synchronize to potentially report issue if init failed - EventGroupHandle_t init_flags = xEventGroupCreate(); - ESP_RETURN_ON_FALSE(init_flags, ESP_ERR_NO_MEM, TAG, "Failed to allocate task sync flags"); - task_arg = &init_flags; -#endif - // Create a task for tinyusb device stack: - xTaskCreatePinnedToCore(tusb_device_task, "TinyUSB", CONFIG_TINYUSB_TASK_STACK_SIZE, task_arg, CONFIG_TINYUSB_TASK_PRIORITY, &s_tusb_tskh, CONFIG_TINYUSB_TASK_AFFINITY); - ESP_RETURN_ON_FALSE(s_tusb_tskh, ESP_FAIL, TAG, "create TinyUSB main task failed"); -#if CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK - // wait until tusb initialization has completed - EventBits_t bits = xEventGroupWaitBits(init_flags, INIT_OK | INIT_FAILED, pdFALSE, pdFALSE, portMAX_DELAY); - vEventGroupDelete(init_flags); - ESP_RETURN_ON_FALSE(bits & INIT_OK, ESP_FAIL, TAG, "Init TinyUSB stack failed"); -#endif - - return ESP_OK; -} - -esp_err_t tusb_stop_task(void) -{ - ESP_RETURN_ON_FALSE(s_tusb_tskh, ESP_ERR_INVALID_STATE, TAG, "TinyUSB main task not started yet"); - vTaskDelete(s_tusb_tskh); - s_tusb_tskh = NULL; - return ESP_OK; -} diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/usb_descriptors.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/usb_descriptors.c deleted file mode 100644 index 8910913..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/usb_descriptors.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "usb_descriptors.h" -#include "sdkconfig.h" -#include "tinyusb_types.h" - -/* - * A combination of interfaces must have a unique product id, since PC will save device driver after the first plug. - * Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC. - * - * Auto ProductID layout's Bitmap: - * [MSB] HID | MSC | CDC [LSB] - */ -#define _PID_MAP(itf, n) ((CFG_TUD_##itf) << (n)) -#define USB_TUSB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ - _PID_MAP(MIDI, 3) ) //| _PID_MAP(AUDIO, 4) | _PID_MAP(VENDOR, 5) ) - -/**** Kconfig driven Descriptor ****/ - -//------------- Device Descriptor -------------// -const tusb_desc_device_t descriptor_dev_default = { - .bLength = sizeof(descriptor_dev_default), - .bDescriptorType = TUSB_DESC_DEVICE, - .bcdUSB = 0x0200, - -#if CFG_TUD_CDC - // Use Interface Association Descriptor (IAD) for CDC - // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1) - .bDeviceClass = TUSB_CLASS_MISC, - .bDeviceSubClass = MISC_SUBCLASS_COMMON, - .bDeviceProtocol = MISC_PROTOCOL_IAD, -#else - .bDeviceClass = 0x00, - .bDeviceSubClass = 0x00, - .bDeviceProtocol = 0x00, -#endif - - .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, - -#if CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID - .idVendor = USB_ESPRESSIF_VID, -#else - .idVendor = CONFIG_TINYUSB_DESC_CUSTOM_VID, -#endif - -#if CONFIG_TINYUSB_DESC_USE_DEFAULT_PID - .idProduct = USB_TUSB_PID, -#else - .idProduct = CONFIG_TINYUSB_DESC_CUSTOM_PID, -#endif - - .bcdDevice = CONFIG_TINYUSB_DESC_BCD_DEVICE, - - .iManufacturer = 0x01, - .iProduct = 0x02, - .iSerialNumber = 0x03, - - .bNumConfigurations = 0x01 -}; - -#if (TUD_OPT_HIGH_SPEED) -const tusb_desc_device_qualifier_t descriptor_qualifier_default = { - .bLength = sizeof(tusb_desc_device_qualifier_t), - .bDescriptorType = TUSB_DESC_DEVICE_QUALIFIER, - .bcdUSB = 0x0200, - -#if CFG_TUD_CDC - // Use Interface Association Descriptor (IAD) for CDC - // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1) - .bDeviceClass = TUSB_CLASS_MISC, - .bDeviceSubClass = MISC_SUBCLASS_COMMON, - .bDeviceProtocol = MISC_PROTOCOL_IAD, -#else - .bDeviceClass = 0x00, - .bDeviceSubClass = 0x00, - .bDeviceProtocol = 0x00, -#endif - - .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, - .bNumConfigurations = 0x01, - .bReserved = 0 -}; -#endif // TUD_OPT_HIGH_SPEED - -//------------- Array of String Descriptors -------------// -const char *descriptor_str_default[] = { - // array of pointer to string descriptors - (char[]){0x09, 0x04}, // 0: is supported language is English (0x0409) - CONFIG_TINYUSB_DESC_MANUFACTURER_STRING, // 1: Manufacturer - CONFIG_TINYUSB_DESC_PRODUCT_STRING, // 2: Product - CONFIG_TINYUSB_DESC_SERIAL_STRING, // 3: Serials, should use chip ID - -#if CONFIG_TINYUSB_CDC_ENABLED - CONFIG_TINYUSB_DESC_CDC_STRING, // 4: CDC Interface -#else - "", -#endif - -#if CONFIG_TINYUSB_MSC_ENABLED - CONFIG_TINYUSB_DESC_MSC_STRING, // 5: MSC Interface -#else - "", -#endif - -#if CONFIG_TINYUSB_NET_MODE_ECM_RNDIS || CONFIG_TINYUSB_NET_MODE_NCM - "USB net", // 6. NET Interface - "", // 7. MAC -#endif - NULL // NULL: Must be last. Indicates end of array -}; - -//------------- Interfaces enumeration -------------// -enum { -#if CFG_TUD_CDC - ITF_NUM_CDC = 0, - ITF_NUM_CDC_DATA, -#endif - -#if CFG_TUD_CDC > 1 - ITF_NUM_CDC1, - ITF_NUM_CDC1_DATA, -#endif - -#if CFG_TUD_MSC - ITF_NUM_MSC, -#endif - -#if CFG_TUD_NCM - ITF_NUM_NET, - ITF_NUM_NET_DATA, -#endif - - ITF_NUM_TOTAL -}; - -enum { - TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN + - CFG_TUD_CDC * TUD_CDC_DESC_LEN + - CFG_TUD_MSC * TUD_MSC_DESC_LEN + - CFG_TUD_NCM * TUD_CDC_NCM_DESC_LEN -}; - -//------------- USB Endpoint numbers -------------// -enum { - // Available USB Endpoints: 5 IN/OUT EPs and 1 IN EP - EP_EMPTY = 0, -#if CFG_TUD_CDC - EPNUM_0_CDC_NOTIF, - EPNUM_0_CDC, -#endif - -#if CFG_TUD_CDC > 1 - EPNUM_1_CDC_NOTIF, - EPNUM_1_CDC, -#endif - -#if CFG_TUD_MSC - EPNUM_MSC, -#endif - -#if CFG_TUD_NCM - EPNUM_NET_NOTIF, - EPNUM_NET_DATA, -#endif -}; - -//------------- STRID -------------// -enum { - STRID_LANGID = 0, - STRID_MANUFACTURER, - STRID_PRODUCT, - STRID_SERIAL, -#if CFG_TUD_CDC - STRID_CDC_INTERFACE, -#endif - -#if CFG_TUD_MSC - STRID_MSC_INTERFACE, -#endif - -#if CFG_TUD_NCM - STRID_NET_INTERFACE, - STRID_MAC, -#endif - -}; - -//------------- Configuration Descriptor -------------// -uint8_t const descriptor_fs_cfg_default[] = { - // Configuration number, interface count, string index, total length, attribute, power in mA - TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), - -#if CFG_TUD_CDC - // Interface number, string index, EP notification address and size, EP data address (out, in) and size. - TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, STRID_CDC_INTERFACE, 0x80 | EPNUM_0_CDC_NOTIF, 8, EPNUM_0_CDC, 0x80 | EPNUM_0_CDC, 64), -#endif - -#if CFG_TUD_CDC > 1 - // Interface number, string index, EP notification address and size, EP data address (out, in) and size. - TUD_CDC_DESCRIPTOR(ITF_NUM_CDC1, STRID_CDC_INTERFACE, 0x80 | EPNUM_1_CDC_NOTIF, 8, EPNUM_1_CDC, 0x80 | EPNUM_1_CDC, 64), -#endif - -#if CFG_TUD_MSC - // Interface number, string index, EP Out & EP In address, EP size - TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, STRID_MSC_INTERFACE, EPNUM_MSC, 0x80 | EPNUM_MSC, 64), -#endif - -#if CFG_TUD_NCM - // Interface number, description string index, MAC address string index, EP notification address and size, EP data address (out, in), and size, max segment size. - TUD_CDC_NCM_DESCRIPTOR(ITF_NUM_NET, STRID_NET_INTERFACE, STRID_MAC, (0x80 | EPNUM_NET_NOTIF), 64, EPNUM_NET_DATA, (0x80 | EPNUM_NET_DATA), 64, CFG_TUD_NET_MTU), -#endif -}; - -#if (TUD_OPT_HIGH_SPEED) -uint8_t const descriptor_hs_cfg_default[] = { - // Configuration number, interface count, string index, total length, attribute, power in mA - TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), - -#if CFG_TUD_CDC - // Interface number, string index, EP notification address and size, EP data address (out, in) and size. - TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, STRID_CDC_INTERFACE, 0x80 | EPNUM_0_CDC_NOTIF, 8, EPNUM_0_CDC, 0x80 | EPNUM_0_CDC, 512), -#endif - -#if CFG_TUD_CDC > 1 - // Interface number, string index, EP notification address and size, EP data address (out, in) and size. - TUD_CDC_DESCRIPTOR(ITF_NUM_CDC1, STRID_CDC_INTERFACE, 0x80 | EPNUM_1_CDC_NOTIF, 8, EPNUM_1_CDC, 0x80 | EPNUM_1_CDC, 512), -#endif - -#if CFG_TUD_MSC - // Interface number, string index, EP Out & EP In address, EP size - TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, STRID_MSC_INTERFACE, EPNUM_MSC, 0x80 | EPNUM_MSC, 512), -#endif - -#if CFG_TUD_NCM - // Interface number, description string index, MAC address string index, EP notification address and size, EP data address (out, in), and size, max segment size. - TUD_CDC_NCM_DESCRIPTOR(ITF_NUM_NET, STRID_NET_INTERFACE, STRID_MAC, (0x80 | EPNUM_NET_NOTIF), 64, EPNUM_NET_DATA, (0x80 | EPNUM_NET_DATA), 512, CFG_TUD_NET_MTU), -#endif -}; -#endif // TUD_OPT_HIGH_SPEED - -#if CFG_TUD_NCM -uint8_t tusb_get_mac_string_id(void) -{ - return STRID_MAC; -} -#endif -/* End of Kconfig driven Descriptor */ diff --git a/examples/espidf-peripherals-usb/components/esp_tinyusb/vfs_tinyusb.c b/examples/espidf-peripherals-usb/components/esp_tinyusb/vfs_tinyusb.c deleted file mode 100644 index 8b8cea9..0000000 --- a/examples/espidf-peripherals-usb/components/esp_tinyusb/vfs_tinyusb.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "esp_attr.h" -#include "esp_log.h" -#include "esp_vfs.h" -#include "esp_vfs_dev.h" -#include "tinyusb.h" -#include "tusb_cdc_acm.h" -#include "vfs_tinyusb.h" -#include "sdkconfig.h" - -const static char *TAG = "tusb_vfs"; - -// Token signifying that no character is available -#define NONE -1 - -#define FD_CHECK(fd, ret_val) do { \ - if ((fd) != 0) { \ - errno = EBADF; \ - return (ret_val); \ - } \ - } while (0) - - - -#if CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF -# define DEFAULT_TX_MODE ESP_LINE_ENDINGS_CRLF -#elif CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR -# define DEFAULT_TX_MODE ESP_LINE_ENDINGS_CR -#else -# define DEFAULT_TX_MODE ESP_LINE_ENDINGS_LF -#endif - -#if CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF -# define DEFAULT_RX_MODE ESP_LINE_ENDINGS_CRLF -#elif CONFIG_NEWLIB_STDIN_LINE_ENDING_CR -# define DEFAULT_RX_MODE ESP_LINE_ENDINGS_CR -#else -# define DEFAULT_RX_MODE ESP_LINE_ENDINGS_LF -#endif - -typedef struct { - _lock_t write_lock; - _lock_t read_lock; - esp_line_endings_t tx_mode; // Newline conversion mode when transmitting - esp_line_endings_t rx_mode; // Newline conversion mode when receiving - uint32_t flags; - char vfs_path[VFS_TUSB_MAX_PATH]; - int cdc_intf; -} vfs_tinyusb_t; - -static vfs_tinyusb_t s_vfstusb; - - -static esp_err_t apply_path(char const *path) -{ - if (path == NULL) { - path = VFS_TUSB_PATH_DEFAULT; - } - - size_t path_len = strlen(path) + 1; - if (path_len > VFS_TUSB_MAX_PATH) { - ESP_LOGE(TAG, "The path is too long; maximum is %d characters", VFS_TUSB_MAX_PATH); - return ESP_ERR_INVALID_ARG; - } - strncpy(s_vfstusb.vfs_path, path, (VFS_TUSB_MAX_PATH - 1)); - ESP_LOGV(TAG, "Path is set to `%s`", path); - return ESP_OK; -} - -/** - * @brief Fill s_vfstusb - * - * @param cdc_intf - interface of tusb for registration - * @param path - a path where the CDC will be registered - * @return esp_err_t ESP_OK or ESP_ERR_INVALID_ARG - */ -static esp_err_t vfstusb_init(int cdc_intf, char const *path) -{ - s_vfstusb.cdc_intf = cdc_intf; - s_vfstusb.tx_mode = DEFAULT_TX_MODE; - s_vfstusb.rx_mode = DEFAULT_RX_MODE; - - return apply_path(path); -} - -/** - * @brief Clear s_vfstusb to default values - */ -static void vfstusb_deinit(void) -{ - memset(&s_vfstusb, 0, sizeof(s_vfstusb)); -} - -static int tusb_open(const char *path, int flags, int mode) -{ - (void) mode; - (void) path; - s_vfstusb.flags = flags | O_NONBLOCK; // for now only non-blocking mode is implemented - return 0; -} - -static ssize_t tusb_write(int fd, const void *data, size_t size) -{ - FD_CHECK(fd, -1); - size_t written_sz = 0; - const char *data_c = (const char *)data; - _lock_acquire(&(s_vfstusb.write_lock)); - for (size_t i = 0; i < size; i++) { - int c = data_c[i]; - if (c != '\n') { - if (!tinyusb_cdcacm_write_queue_char(s_vfstusb.cdc_intf, c)) { - break; // can't write anymore - } - } else { - if (s_vfstusb.tx_mode == ESP_LINE_ENDINGS_CRLF || s_vfstusb.tx_mode == ESP_LINE_ENDINGS_CR) { - char cr = '\r'; - if (!tinyusb_cdcacm_write_queue_char(s_vfstusb.cdc_intf, cr)) { - break; // can't write anymore - } - } - if (s_vfstusb.tx_mode == ESP_LINE_ENDINGS_CRLF || s_vfstusb.tx_mode == ESP_LINE_ENDINGS_LF) { - char lf = '\n'; - if (!tinyusb_cdcacm_write_queue_char(s_vfstusb.cdc_intf, lf)) { - break; // can't write anymore - } - } - } - written_sz++; - } - tud_cdc_n_write_flush(s_vfstusb.cdc_intf); - _lock_release(&(s_vfstusb.write_lock)); - return written_sz; -} - -static int tusb_close(int fd) -{ - FD_CHECK(fd, -1); - return 0; -} - -static ssize_t tusb_read(int fd, void *data, size_t size) -{ - FD_CHECK(fd, -1); - char *data_c = (char *) data; - size_t received = 0; - _lock_acquire(&(s_vfstusb.read_lock)); - - if (tud_cdc_n_available(s_vfstusb.cdc_intf) == 0) { - goto finish; - } - while (received < size) { - int c = tud_cdc_n_read_char(s_vfstusb.cdc_intf); - if ( c == NONE) { // if data ends - break; - } - - // Handle line endings. From configured mode -> LF mode - if (s_vfstusb.rx_mode == ESP_LINE_ENDINGS_CR) { - // Change CRs to newlines - if (c == '\r') { - c = '\n'; - } - } else if (s_vfstusb.rx_mode == ESP_LINE_ENDINGS_CRLF) { - if (c == '\r') { - uint8_t next_char = NONE; - // Check if next char is newline. If yes, we got CRLF sequence - tud_cdc_n_peek(s_vfstusb.cdc_intf, &next_char); - if (next_char == '\n') { - c = tud_cdc_n_read_char(s_vfstusb.cdc_intf); // Remove '\n' from the fifo - } - } - } - - data_c[received] = (char) c; - ++received; - if (c == '\n') { - break; - } - } -finish: - _lock_release(&(s_vfstusb.read_lock)); - if (received > 0) { - return received; - } - errno = EWOULDBLOCK; - return -1; -} - -static int tusb_fstat(int fd, struct stat *st) -{ - FD_CHECK(fd, -1); - memset(st, 0, sizeof(*st)); - st->st_mode = S_IFCHR; - return 0; -} - -static int tusb_fcntl(int fd, int cmd, int arg) -{ - FD_CHECK(fd, -1); - int result = 0; - switch (cmd) { - case F_GETFL: - result = s_vfstusb.flags; - break; - case F_SETFL: - s_vfstusb.flags = arg; - break; - default: - result = -1; - errno = ENOSYS; - break; - } - return result; -} - -esp_err_t esp_vfs_tusb_cdc_unregister(char const *path) -{ - ESP_LOGD(TAG, "Unregistering CDC-VFS driver"); - int res; - - if (path == NULL) { // NULL means using the default path for unregistering: VFS_TUSB_PATH_DEFAULT - path = VFS_TUSB_PATH_DEFAULT; - } - res = strcmp(s_vfstusb.vfs_path, path); - - if (res) { - res = ESP_ERR_INVALID_ARG; - ESP_LOGE(TAG, "There is no CDC-VFS driver registered to path '%s' (err: 0x%x)", path, res); - return res; - } - - res = esp_vfs_unregister(s_vfstusb.vfs_path); - if (res != ESP_OK) { - ESP_LOGE(TAG, "Can't unregister CDC-VFS driver from '%s' (err: 0x%x)", s_vfstusb.vfs_path, res); - } else { - ESP_LOGD(TAG, "Unregistered CDC-VFS driver"); - vfstusb_deinit(); - } - return res; -} - -esp_err_t esp_vfs_tusb_cdc_register(int cdc_intf, char const *path) -{ - ESP_LOGD(TAG, "Registering CDC-VFS driver"); - int res; - if (!tusb_cdc_acm_initialized(cdc_intf)) { - ESP_LOGE(TAG, "TinyUSB CDC#%d is not initialized", cdc_intf); - return ESP_ERR_INVALID_STATE; - } - - res = vfstusb_init(cdc_intf, path); - if (res != ESP_OK) { - return res; - } - - esp_vfs_t vfs = { - .flags = ESP_VFS_FLAG_DEFAULT, - .close = &tusb_close, - .fcntl = &tusb_fcntl, - .fstat = &tusb_fstat, - .open = &tusb_open, - .read = &tusb_read, - .write = &tusb_write, - }; - - res = esp_vfs_register(s_vfstusb.vfs_path, &vfs, NULL); - if (res != ESP_OK) { - ESP_LOGE(TAG, "Can't register CDC-VFS driver (err: %x)", res); - } else { - ESP_LOGD(TAG, "CDC-VFS registered (%s)", s_vfstusb.vfs_path); - } - return res; -} - -void esp_vfs_tusb_cdc_set_rx_line_endings(esp_line_endings_t mode) -{ - _lock_acquire(&(s_vfstusb.read_lock)); - s_vfstusb.rx_mode = mode; - _lock_release(&(s_vfstusb.read_lock)); -} - -void esp_vfs_tusb_cdc_set_tx_line_endings(esp_line_endings_t mode) -{ - _lock_acquire(&(s_vfstusb.write_lock)); - s_vfstusb.tx_mode = mode; - _lock_release(&(s_vfstusb.write_lock)); -} diff --git a/examples/espidf-peripherals-usb/src/idf_component.yml b/examples/espidf-peripherals-usb/src/idf_component.yml new file mode 100644 index 0000000..ff67b5d --- /dev/null +++ b/examples/espidf-peripherals-usb/src/idf_component.yml @@ -0,0 +1,4 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/esp_tinyusb: "^1" + idf: "^5.0" diff --git a/examples/espidf-peripherals-usb/src/tusb_serial_device_main.c b/examples/espidf-peripherals-usb/src/tusb_serial_device_main.c index 0a2cc3a..cc11118 100644 --- a/examples/espidf-peripherals-usb/src/tusb_serial_device_main.c +++ b/examples/espidf-peripherals-usb/src/tusb_serial_device_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -8,32 +8,61 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "freertos/queue.h" #include "tinyusb.h" #include "tusb_cdc_acm.h" #include "sdkconfig.h" static const char *TAG = "example"; -static uint8_t buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE + 1]; +static uint8_t rx_buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE + 1]; +/** + * @brief Application Queue + */ +static QueueHandle_t app_queue; +typedef struct { + uint8_t buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE + 1]; // Data buffer + size_t buf_len; // Number of bytes received + uint8_t itf; // Index of CDC device interface +} app_message_t; + +/** + * @brief CDC device RX callback + * + * CDC device signals, that new data were received + * + * @param[in] itf CDC device index + * @param[in] event CDC event type + */ void tinyusb_cdc_rx_callback(int itf, cdcacm_event_t *event) { /* initialization */ size_t rx_size = 0; /* read */ - esp_err_t ret = tinyusb_cdcacm_read(itf, buf, CONFIG_TINYUSB_CDC_RX_BUFSIZE, &rx_size); + esp_err_t ret = tinyusb_cdcacm_read(itf, rx_buf, CONFIG_TINYUSB_CDC_RX_BUFSIZE, &rx_size); if (ret == ESP_OK) { - ESP_LOGI(TAG, "Data from channel %d:", itf); - ESP_LOG_BUFFER_HEXDUMP(TAG, buf, rx_size, ESP_LOG_INFO); - } else { - ESP_LOGE(TAG, "Read error"); - } - /* write back */ - tinyusb_cdcacm_write_queue(itf, buf, rx_size); - tinyusb_cdcacm_write_flush(itf, 0); + app_message_t tx_msg = { + .buf_len = rx_size, + .itf = itf, + }; + + memcpy(tx_msg.buf, rx_buf, rx_size); + xQueueSend(app_queue, &tx_msg, 0); + } else { + ESP_LOGE(TAG, "Read Error"); + } } +/** + * @brief CDC device line change callback + * + * CDC device signals, that the DTR, RTS states changed + * + * @param[in] itf CDC device index + * @param[in] event CDC event type + */ void tinyusb_cdc_line_state_changed_callback(int itf, cdcacm_event_t *event) { int dtr = event->line_state_changed_data.dtr; @@ -43,12 +72,23 @@ void tinyusb_cdc_line_state_changed_callback(int itf, cdcacm_event_t *event) void app_main(void) { + // Create FreeRTOS primitives + app_queue = xQueueCreate(5, sizeof(app_message_t)); + assert(app_queue); + app_message_t msg; + ESP_LOGI(TAG, "USB initialization"); const tinyusb_config_t tusb_cfg = { .device_descriptor = NULL, .string_descriptor = NULL, .external_phy = false, +#if (TUD_OPT_HIGH_SPEED) + .fs_configuration_descriptor = NULL, + .hs_configuration_descriptor = NULL, + .qualifier_descriptor = NULL, +#else .configuration_descriptor = NULL, +#endif // TUD_OPT_HIGH_SPEED }; ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg)); @@ -80,4 +120,21 @@ void app_main(void) #endif ESP_LOGI(TAG, "USB initialization DONE"); + while (1) { + if (xQueueReceive(app_queue, &msg, portMAX_DELAY)) { + if (msg.buf_len) { + + /* Print received data*/ + ESP_LOGI(TAG, "Data from channel %d:", msg.itf); + ESP_LOG_BUFFER_HEXDUMP(TAG, msg.buf, msg.buf_len, ESP_LOG_INFO); + + /* write back */ + tinyusb_cdcacm_write_queue(msg.itf, msg.buf, msg.buf_len); + esp_err_t err = tinyusb_cdcacm_write_flush(msg.itf, 0); + if (err != ESP_OK) { + ESP_LOGE(TAG, "CDC ACM write flush error: %s", esp_err_to_name(err)); + } + } + } + } } diff --git a/monitor/filter_exception_decoder.py b/monitor/filter_exception_decoder.py index 7f2bfba..8a4f1cb 100644 --- a/monitor/filter_exception_decoder.py +++ b/monitor/filter_exception_decoder.py @@ -16,6 +16,7 @@ import os import re import subprocess import sys +import glob from platformio.compat import IS_WINDOWS from platformio.exception import PlatformioException @@ -23,23 +24,75 @@ from platformio.public import ( DeviceMonitorFilterBase, load_build_metadata, ) +from platformio.package.manager.tool import ToolPackageManager # By design, __init__ is called inside miniterm and we can't pass context to it. # pylint: disable=attribute-defined-outside-init class Esp32ExceptionDecoder(DeviceMonitorFilterBase): + """ + PlatformIO device monitor filter for decoding ESP32 exception backtraces. + + This filter automatically decodes memory addresses from ESP32 crash dumps + into human-readable function names and source code locations using addr2line. + It supports both application code and ROM addresses via ESP ROM ELF files. + """ + NAME = "esp32_exception_decoder" - ADDR_PATTERN = re.compile(r"((?:0x[0-9a-fA-F]{8}[: ]?)+)") + # More specific pattern for PC:SP pairs in backtraces + ADDR_PATTERN = re.compile(r"((?:0x[0-9a-fA-F]{8}:0x[0-9a-fA-F]{8}(?: |$))+)") ADDR_SPLIT = re.compile(r"[ :]") PREFIX_RE = re.compile(r"^ *") + + # Patterns that indicate we're in an exception/backtrace context + BACKTRACE_KEYWORDS = re.compile( + r"(Backtrace:|" + r"\bPC:\s*0x[0-9a-fA-F]{8}\b|" + r"abort\(\) was called at PC|" + r"Guru Meditation Error:|" + r"panic'ed|" + r"register dump:|" + r"Stack smashing protect failure!|" + r"CORRUPT HEAP:|" + r"assertion .* failed:|" + r"Debug exception reason:|" + r"Undefined behavior of type)", + re.IGNORECASE + ) + + # Chip name mapping for ROM ELF files + CHIP_NAME_MAP = { + "esp32": "esp32", + "esp32s2": "esp32s2", + "esp32s3": "esp32s3", + "esp32c2": "esp32c2", + "esp32c3": "esp32c3", + "esp32c5": "esp32c5", + "esp32c6": "esp32c6", + "esp32h2": "esp32h2", + "esp32p4": "esp32p4", + } def __call__(self): + """ + Initialize the filter instance. + + This method is called when the monitor filter is activated. + Sets up internal state and locates required tools and files. + + Returns: + self: The initialized filter instance + """ self.buffer = "" + self.in_backtrace_context = False + self.lines_since_context = 0 + self.max_context_lines = 50 # Maximum lines to process after context keyword self.firmware_path = None self.addr2line_path = None + self.rom_elf_path = None self.enabled = self.setup_paths() if self.config.get("env:" + self.environment, "build_type") != "debug": @@ -53,11 +106,134 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html return self + def get_chip_name(self, data): + """ + Determine the ESP32 chip name from build metadata. + + Tries multiple methods to detect the chip type by examining + the board name and MCU configuration. + + Args: + data: Build metadata dictionary containing board and MCU information + + Returns: + str: Chip name (e.g., "esp32", "esp32s3") or "esp32" as fallback + """ + # Try to get from board definition + board = data.get("board", "").lower() + + # Sort by length (longest first) to match more specific chips first + # This prevents "esp32" from matching in "esp32s3", "esp32c3", etc. + sorted_chips = sorted(self.CHIP_NAME_MAP.keys(), key=len, reverse=True) + + # Check if board name contains chip identifier + for chip_key in sorted_chips: + if chip_key in board: + return self.CHIP_NAME_MAP[chip_key] + + # Try to get from MCU + mcu = data.get("mcu", "").lower() + for chip_key in sorted_chips: + if chip_key in mcu: + return self.CHIP_NAME_MAP[chip_key] + + # Default to esp32 if not found + return "esp32" + + def find_rom_elf(self, chip_name): + """ + Find the appropriate ROM ELF file for the specified chip. + + Uses ToolPackageManager to access the tool-esp-rom-elfs package. + The package must be defined as a dependency in platform.json and + will be automatically installed when the platform is installed. + + Searches for ROM ELF files with various naming patterns and selects + the one with the lowest revision number for maximum compatibility. + + Args: + chip_name: Name of the ESP32 chip variant (e.g., "esp32s3") + + Returns: + str: Path to the ROM ELF file, or None if not found + """ + try: + # Use ToolPackageManager to access already installed packages + pm = ToolPackageManager() + + # Get the tool-esp-rom-elfs package (must be defined in platform.json) + pkg = pm.get_package("tool-esp-rom-elfs") + + if not pkg: + sys.stderr.write( + "%s: tool-esp-rom-elfs package not found. " + "Ensure it is defined in platform.json dependencies.\n" + % self.__class__.__name__ + ) + return None + + rom_elfs_dir = pkg.path + + if not rom_elfs_dir or not os.path.isdir(rom_elfs_dir): + sys.stderr.write( + "%s: ROM ELFs directory not found at %s\n" + % (self.__class__.__name__, rom_elfs_dir) + ) + return None + + # Patterns commonly seen: _rev_rom.elf, _rev.elf, *_rom.elf + patterns = [ + os.path.join(rom_elfs_dir, f"{chip_name}_rev*_rom.elf"), + os.path.join(rom_elfs_dir, f"{chip_name}_rev*.elf"), + os.path.join(rom_elfs_dir, f"{chip_name}*_rom.elf"), + os.path.join(rom_elfs_dir, f"{chip_name}*.elf"), + ] + + rom_files = [] + for pattern in patterns: + rom_files.extend(glob.glob(pattern)) + + # Remove duplicates and sort + rom_files = sorted(set(rom_files)) + + if not rom_files: + sys.stderr.write( + "%s: No ROM ELF files found for chip %s in %s\n" + % (self.__class__.__name__, chip_name, rom_elfs_dir) + ) + return None + + # Sort by numeric revision (lowest first) if present; otherwise push to the end + def _rev_key(path): + m = re.search(r"_rev(\d+)", os.path.basename(path)) + return int(m.group(1)) if m else 10**9 + + rom_files.sort(key=_rev_key) + return rom_files[0] + + except (PlatformioException, OSError) as e: + sys.stderr.write( + "%s: Error accessing ROM ELF package: %s\n" + % (self.__class__.__name__, e) + ) + return None + def setup_paths(self): + """ + Setup paths for firmware ELF, addr2line tool, and ROM ELF files. + + Loads build metadata to locate the compiled firmware and toolchain, + then attempts to find the appropriate ROM ELF file for the target chip. + + Returns: + bool: True if setup was successful and filter can be enabled, + False if critical components are missing + """ self.project_dir = os.path.abspath(self.project_dir) try: data = load_build_metadata(self.project_dir, self.environment, cache=True) + # Locate firmware ELF file self.firmware_path = data["prog_path"] if not os.path.isfile(self.firmware_path): sys.stderr.write( @@ -66,24 +242,105 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html ) return False + # Locate addr2line tool from compiler path cc_path = data.get("cc_path", "") if "-gcc" in cc_path: path = cc_path.replace("-gcc", "-addr2line") if os.path.isfile(path): self.addr2line_path = path - return True + elif "-clang" in cc_path: + # Support for Clang toolchain + path = cc_path.replace("-clang", "-addr2line") + if os.path.isfile(path): + self.addr2line_path = path + + if not self.addr2line_path: + sys.stderr.write( + "%s: disabling, failed to find addr2line.\n" % self.__class__.__name__ + ) + return False + + # Try to find ROM ELF file for chip-specific ROM addresses + chip_name = self.get_chip_name(data) + self.rom_elf_path = self.find_rom_elf(chip_name) + + if self.rom_elf_path: + sys.stderr.write( + "%s: ROM ELF found at %s\n" + % (self.__class__.__name__, self.rom_elf_path) + ) + else: + sys.stderr.write( + "%s: ROM ELF not found for chip %s, ROM addresses will not be decoded\n" + % (self.__class__.__name__, chip_name) + ) + + return True + except PlatformioException as e: sys.stderr.write( "%s: disabling, exception while looking for addr2line: %s\n" % (self.__class__.__name__, e) ) return False - sys.stderr.write( - "%s: disabling, failed to find addr2line.\n" % self.__class__.__name__ - ) + + def is_backtrace_context(self, line): + """ + Check if a line indicates we're entering a backtrace context. + + Args: + line: Text line to check + + Returns: + bool: True if line contains backtrace keywords + """ + return self.BACKTRACE_KEYWORDS.search(line) is not None + + def should_process_line(self, line): + """ + Determine if a line should be processed for address decoding. + + Only processes lines that are part of an exception/backtrace context + to avoid false positives on random hex values in normal output. + + Args: + line: Text line to evaluate + + Returns: + bool: True if line should be processed for address decoding + """ + # Check if this line starts a backtrace context + if self.is_backtrace_context(line): + self.in_backtrace_context = True + self.lines_since_context = 0 + return True + + # If we're in context, track how many lines we've processed + if self.in_backtrace_context: + self.lines_since_context += 1 + + # Exit context after max_context_lines or if we see an empty line + if self.lines_since_context > self.max_context_lines or line.strip() == "": + self.in_backtrace_context = False + return False + + return True + return False def rx(self, text): + """ + Process received text from the serial monitor. + + Scans incoming text for backtrace address patterns and decodes them + into human-readable function names and source locations. + + Args: + text: Raw text received from device + + Returns: + str: Text with decoded backtraces inserted + """ if not self.enabled: return text @@ -101,6 +358,10 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html self.buffer = "" last = idx + 1 + # Only process line if it's in the right context + if not self.should_process_line(line): + continue + m = self.ADDR_PATTERN.search(line) if m is None: continue @@ -112,16 +373,83 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html return text def is_address_ignored(self, address): + """ + Check if an address should be ignored during decoding. + + Args: + address: Memory address string + + Returns: + bool: True if address should be skipped + """ return address in ("", "0x00000000") - def filter_addresses(self, adresses_str): - addresses = self.ADDR_SPLIT.split(adresses_str) + def filter_addresses(self, addresses_str): + """ + Extract and filter valid addresses from a string. + + Splits the address string and removes trailing null/invalid addresses. + + Args: + addresses_str: String containing colon-separated address pairs + + Returns: + list: List of valid address strings + """ + addresses = self.ADDR_SPLIT.split(addresses_str) size = len(addresses) while size > 1 and self.is_address_ignored(addresses[size-1]): size -= 1 return addresses[:size] + def decode_address(self, addr, elf_path): + """ + Decode a single address using addr2line. + + Args: + addr: Memory address to decode (e.g., "0x400d1234") + elf_path: Path to ELF file containing debug symbols + + Returns: + str: Decoded function and location, or None if decoding failed + """ + enc = "mbcs" if IS_WINDOWS else "utf-8" + args = [self.addr2line_path, u"-fipC", u"-e", elf_path, addr] + + try: + output = ( + subprocess.check_output(args) + .decode(enc) + .strip() + ) + + # Newlines happen with inlined methods + output = output.replace("\n", "\n ") + + # Check if address was found in ELF (handle common variants) + if output in ("?? ??:0", "??:0") or output.strip().startswith("?? ") or output.strip() == "??": + return None + + return output + + except subprocess.CalledProcessError: + return None + def build_backtrace(self, line, address_match): + """ + Build a decoded backtrace from a line containing addresses. + + Attempts to decode each address first from the application ELF, + then from the ROM ELF if not found. Addresses successfully decoded + from ROM are marked with "in ROM" suffix. + + Args: + line: Original line containing the backtrace + address_match: Matched address string from regex + + Returns: + str: Formatted decoded backtrace, or empty string if nothing decoded + """ addresses = self.filter_addresses(address_match) if not addresses: return "" @@ -130,29 +458,37 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html prefix = prefix_match.group(0) if prefix_match is not None else "" trace = "" - enc = "mbcs" if IS_WINDOWS else "utf-8" - args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path] try: i = 0 for addr in addresses: - output = ( - subprocess.check_output(args + [addr]) - .decode(enc) - .strip() - ) - - # newlines happen with inlined methods - output = output.replace( - "\n", "\n " - ) - - # throw out addresses not from ELF - if output == "?? ??:0": + # First try to decode with application ELF + output = self.decode_address(addr, self.firmware_path) + is_rom = False + + # If not found in app ELF, try ROM ELF + if output is None and self.rom_elf_path: + output = self.decode_address(addr, self.rom_elf_path) + if output is not None: + is_rom = True + + # Skip if address couldn't be decoded + if output is None: continue output = self.strip_project_dir(output) + + # Add "in ROM" suffix for ROM addresses + if is_rom: + # Extract function name (first part before "at") + parts = output.split(" at ", 1) + if len(parts) == 2: + output = f"{parts[0]} in ROM" + else: + output = f"{output} in ROM" + trace += "%s #%-2d %s in %s\n" % (prefix, i, addr, output) i += 1 + except subprocess.CalledProcessError as e: sys.stderr.write( "%s: failed to call %s: %s\n" @@ -162,6 +498,17 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html return trace + "\n" if trace else "" def strip_project_dir(self, trace): + """ + Remove project directory prefix from file paths in trace output. + + This makes the output more readable by showing only relative paths. + + Args: + trace: Decoded trace string containing file paths + + Returns: + str: Trace with project directory paths removed + """ while True: idx = trace.find(self.project_dir) if idx == -1: diff --git a/platform.json b/platform.json index 43492e4..50d7b6b 100644 --- a/platform.json +++ b/platform.json @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/pioarduino/platform-espressif32.git" }, - "version": "55.03.32", + "version": "55.03.33", "frameworks": { "arduino": { "script": "builder/frameworks/arduino.py" @@ -33,13 +33,13 @@ "type": "framework", "optional": true, "owner": "espressif", - "version": "https://github.com/espressif/arduino-esp32/releases/download/3.3.2/esp32-3.3.2.tar.xz" + "version": "https://github.com/espressif/arduino-esp32/releases/download/3.3.3/esp32-3.3.3.tar.xz" }, "framework-arduinoespressif32-libs": { "type": "framework", "optional": true, "owner": "espressif", - "version": "https://github.com/espressif/arduino-esp32/releases/download/3.3.2/esp32-3.3.2-libs.tar.xz" + "version": "https://github.com/espressif/arduino-esp32/releases/download/3.3.3/esp32-3.3.3-libs.tar.xz" }, "framework-arduino-c2-skeleton-lib": { "type": "framework", @@ -51,7 +51,7 @@ "type": "framework", "optional": true, "owner": "pioarduino", - "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.5.1.250929/esp-idf-v5.5.1.tar.xz" + "version": "https://github.com/pioarduino/esp-idf/releases/download/v5.5.1.251017/esp-idf-v5.5.1.tar.xz" }, "toolchain-xtensa-esp-elf": { "type": "toolchain", diff --git a/platform.py b/platform.py index 3ed4fe1..752ddbd 100644 --- a/platform.py +++ b/platform.py @@ -12,11 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Python Version Check +import sys + +if not ((3, 10) <= sys.version_info < (3, 14)): + print("ERROR: Python version must be between 3.10 and 3.13.", file=sys.stderr) + print(f"Current Python version: {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", file=sys.stderr) + print("Supported versions: 3.10, 3.11, 3.12, 3.13", file=sys.stderr) + raise SystemExit(1) + # LZMA support check try: import lzma as _lzma except ImportError: - import sys print("ERROR: Python's lzma module is unavailable or broken in this interpreter.", file=sys.stderr) print("LZMA (liblzma) support is required for tool/toolchain installation.", file=sys.stderr) print("Please install Python built with LZMA support.", file=sys.stderr) @@ -34,7 +42,6 @@ import requests import shutil import socket import subprocess -import sys from pathlib import Path from typing import Optional, Dict, List, Any, Union @@ -53,12 +60,14 @@ spec.loader.exec_module(penv_setup_module) setup_penv_minimal = penv_setup_module.setup_penv_minimal get_executable_path = penv_setup_module.get_executable_path +has_internet_connection = penv_setup_module.has_internet_connection # Constants DEFAULT_DEBUG_SPEED = "5000" DEFAULT_APP_OFFSET = "0x10000" tl_install_name = "tool-esp_install" +ARDUINO_ESP32_PACKAGE_URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/master/package/package_esp32_index.template.json" # MCUs that support ESP-builtin debug ESP_BUILTIN_DEBUG_MCUS = frozenset([ @@ -119,6 +128,13 @@ pm = ToolPackageManager() # Configure logger logger = logging.getLogger(__name__) +def is_internet_available(): + """ + Check if connected to Internet. + Uses the centralized internet check from penv_setup module. + """ + return has_internet_connection() + def safe_file_operation(operation_func): """Decorator for safe filesystem operations with error handling.""" def wrapper(*args, **kwargs): @@ -546,10 +562,11 @@ class Espressif32Platform(PlatformBase): if "arduino" not in frameworks: return + safe_remove_directory_pattern(Path(self.packages_dir), f"framework-arduinoespressif32@*") + safe_remove_directory_pattern(Path(self.packages_dir), f"framework-arduinoespressif32.*") self.packages["framework-arduinoespressif32"]["optional"] = False self.packages["framework-arduinoespressif32-libs"]["optional"] = False - def _configure_espidf_framework( self, frameworks: List[str], variables: Dict, board_config: Dict, mcu: str ) -> None: @@ -562,6 +579,8 @@ class Espressif32Platform(PlatformBase): if custom_sdkconfig is not None or len(str(board_sdkconfig)) > 3: frameworks.append("espidf") + safe_remove_directory_pattern(Path(self.packages_dir), f"framework-espidf@*") + safe_remove_directory_pattern(Path(self.packages_dir), f"framework-espidf.*") self.packages["framework-espidf"]["optional"] = False if mcu == "esp32c2": self.packages["framework-arduino-c2-skeleton-lib"]["optional"] = False @@ -645,6 +664,38 @@ class Espressif32Platform(PlatformBase): for package in COMMON_IDF_PACKAGES: self.install_tool(package) + def _check_exception_decoder_filter(self, variables: Dict) -> bool: + """ + Check if esp32_exception_decoder filter is configured in monitor_filters. + + Args: + variables: Build configuration variables from platformio.ini + + Returns: + bool: True if esp32_exception_decoder is configured, False otherwise + """ + monitor_filters = variables.get("monitor_filters", []) + + # Handle both list and string formats + if isinstance(monitor_filters, str): + monitor_filters = [f.strip() for f in monitor_filters.split(",")] + + return "esp32_exception_decoder" in monitor_filters + + def _configure_rom_elfs_for_exception_decoder(self, variables: Dict) -> None: + """ + Install tool-esp-rom-elfs if esp32_exception_decoder filter is enabled. + + The ESP32 exception decoder requires ROM ELF files to decode addresses + from ROM code regions in crash backtraces. + + Args: + variables: Build configuration variables from platformio.ini + """ + if self._check_exception_decoder_filter(variables): + logger.info("esp32_exception_decoder filter detected, installing tool-esp-rom-elfs") + self.install_tool("tool-esp-rom-elfs") + def _configure_check_tools(self, variables: Dict) -> None: """Configure static analysis and check tools based on configuration.""" check_tools = variables.get("check_tool", []) @@ -776,6 +827,7 @@ class Espressif32Platform(PlatformBase): if "espidf" in frameworks: self._install_common_idf_packages() + self._configure_rom_elfs_for_exception_decoder(variables) self._configure_check_tools(variables) self._configure_filesystem_tools(variables, targets) self._handle_dfuutil_tool(variables)