From 18e5f53e971dcab1a15ab74b6c9762c7b791a9ea Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 22 Dec 2023 19:40:47 +0100 Subject: [PATCH] Add new board setting "download speed" to esp32x boards json (#20291) * add download_speed setting * add "download speed" * add / change up- download speed --- boards/esp32-fix.json | 3 +++ boards/esp32.json | 3 +++ boards/esp32_solo1.json | 3 +++ boards/esp32c2.json | 3 +++ boards/esp32c2_2M.json | 3 +++ boards/esp32c3.json | 3 +++ boards/esp32c3cdc.json | 5 ++++- boards/esp32c6.json | 3 +++ boards/esp32c6cdc.json | 5 ++++- boards/esp32s2.json | 3 +++ boards/esp32s2cdc.json | 5 ++++- boards/esp32s3-opi_opi.json | 3 +++ boards/esp32s3-qio_opi.json | 3 +++ boards/esp32s3-qio_qspi.json | 3 +++ boards/esp32s3cdc-opi_opi.json | 5 ++++- boards/esp32s3cdc-qio_opi.json | 5 ++++- boards/esp32s3cdc-qio_qspi.json | 5 ++++- pio-tools/custom_target.py | 11 +++++++---- 18 files changed, 64 insertions(+), 10 deletions(-) diff --git a/boards/esp32-fix.json b/boards/esp32-fix.json index 8287019b8..73cf149fa 100644 --- a/boards/esp32-fix.json +++ b/boards/esp32-fix.json @@ -41,6 +41,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://en.wikipedia.org/wiki/ESP32", "vendor": "Espressif" } diff --git a/boards/esp32.json b/boards/esp32.json index 4dd2a3602..10c117cd7 100644 --- a/boards/esp32.json +++ b/boards/esp32.json @@ -41,6 +41,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://en.wikipedia.org/wiki/ESP32", "vendor": "Espressif" } diff --git a/boards/esp32_solo1.json b/boards/esp32_solo1.json index f3d9913b0..b80a58156 100644 --- a/boards/esp32_solo1.json +++ b/boards/esp32_solo1.json @@ -41,6 +41,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://en.wikipedia.org/wiki/ESP32", "vendor": "Espressif" } diff --git a/boards/esp32c2.json b/boards/esp32c2.json index cabab4cb4..ea5cbae2c 100644 --- a/boards/esp32c2.json +++ b/boards/esp32c2.json @@ -39,6 +39,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", "vendor": "Espressif" } diff --git a/boards/esp32c2_2M.json b/boards/esp32c2_2M.json index 969ff519c..fbffa167c 100644 --- a/boards/esp32c2_2M.json +++ b/boards/esp32c2_2M.json @@ -39,6 +39,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", "vendor": "Espressif" } diff --git a/boards/esp32c3.json b/boards/esp32c3.json index 2bb2f7660..6a49ba922 100644 --- a/boards/esp32c3.json +++ b/boards/esp32c3.json @@ -39,6 +39,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html", "vendor": "Espressif" } diff --git a/boards/esp32c3cdc.json b/boards/esp32c3cdc.json index 8e46134b3..7ee0326f0 100644 --- a/boards/esp32c3cdc.json +++ b/boards/esp32c3cdc.json @@ -41,7 +41,10 @@ "maximum_ram_size": 327680, "maximum_size": 4194304, "require_upload_port": true, - "speed": 460800 + "speed": 2000000 + }, + "download": { + "speed": 2000000 }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html", "vendor": "Espressif" diff --git a/boards/esp32c6.json b/boards/esp32c6.json index 76e7620db..68feaec6e 100644 --- a/boards/esp32c6.json +++ b/boards/esp32c6.json @@ -39,6 +39,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", "vendor": "Espressif" } diff --git a/boards/esp32c6cdc.json b/boards/esp32c6cdc.json index eb8a6ffbb..9cde9e62b 100644 --- a/boards/esp32c6cdc.json +++ b/boards/esp32c6cdc.json @@ -41,7 +41,10 @@ "maximum_ram_size": 327680, "maximum_size": 4194304, "require_upload_port": true, - "speed": 460800 + "speed": 2000000 + }, + "download": { + "speed": 2000000 }, "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", "vendor": "Espressif" diff --git a/boards/esp32s2.json b/boards/esp32s2.json index aa9efca8b..18bd9200a 100644 --- a/boards/esp32s2.json +++ b/boards/esp32s2.json @@ -38,6 +38,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html", "vendor": "Espressif" } diff --git a/boards/esp32s2cdc.json b/boards/esp32s2cdc.json index f9a302699..c379be423 100644 --- a/boards/esp32s2cdc.json +++ b/boards/esp32s2cdc.json @@ -37,7 +37,10 @@ "maximum_size": 4194304, "require_upload_port": true, "before_reset": "usb_reset", - "speed": 460800 + "speed": 2000000 + }, + "download": { + "speed": 2000000 }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html", "vendor": "Espressif" diff --git a/boards/esp32s3-opi_opi.json b/boards/esp32s3-opi_opi.json index aa7e5db2a..92803a838 100644 --- a/boards/esp32s3-opi_opi.json +++ b/boards/esp32s3-opi_opi.json @@ -41,6 +41,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/", "vendor": "Espressif" } \ No newline at end of file diff --git a/boards/esp32s3-qio_opi.json b/boards/esp32s3-qio_opi.json index 4f2a06c47..614831574 100644 --- a/boards/esp32s3-qio_opi.json +++ b/boards/esp32s3-qio_opi.json @@ -41,6 +41,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/", "vendor": "Espressif" } diff --git a/boards/esp32s3-qio_qspi.json b/boards/esp32s3-qio_qspi.json index 42b20a4bc..9b11a31b0 100644 --- a/boards/esp32s3-qio_qspi.json +++ b/boards/esp32s3-qio_qspi.json @@ -41,6 +41,9 @@ "require_upload_port": true, "speed": 460800 }, + "download": { + "speed": 230400 + }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/", "vendor": "Espressif" } diff --git a/boards/esp32s3cdc-opi_opi.json b/boards/esp32s3cdc-opi_opi.json index a5992333c..684cba031 100644 --- a/boards/esp32s3cdc-opi_opi.json +++ b/boards/esp32s3cdc-opi_opi.json @@ -49,7 +49,10 @@ "maximum_ram_size": 327680, "maximum_size": 4194304, "require_upload_port": true, - "speed": 460800 + "speed": 2000000 + }, + "download": { + "speed": 2000000 }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/", "vendor": "Espressif" diff --git a/boards/esp32s3cdc-qio_opi.json b/boards/esp32s3cdc-qio_opi.json index 46ed77fca..46b363266 100644 --- a/boards/esp32s3cdc-qio_opi.json +++ b/boards/esp32s3cdc-qio_opi.json @@ -49,7 +49,10 @@ "maximum_ram_size": 327680, "maximum_size": 4194304, "require_upload_port": true, - "speed": 460800 + "speed": 2000000 + }, + "download": { + "speed": 2000000 }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/", "vendor": "Espressif" diff --git a/boards/esp32s3cdc-qio_qspi.json b/boards/esp32s3cdc-qio_qspi.json index 7e80448e3..fa90e8509 100644 --- a/boards/esp32s3cdc-qio_qspi.json +++ b/boards/esp32s3cdc-qio_qspi.json @@ -49,7 +49,10 @@ "maximum_ram_size": 327680, "maximum_size": 4194304, "require_upload_port": true, - "speed": 460800 + "speed": 2000000 + }, + "download": { + "speed": 2000000 }, "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/", "vendor": "Espressif" diff --git a/pio-tools/custom_target.py b/pio-tools/custom_target.py index a11d6a3ae..9623105aa 100644 --- a/pio-tools/custom_target.py +++ b/pio-tools/custom_target.py @@ -186,6 +186,7 @@ def parse_partition_table(content): def get_partition_table(): esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py") upload_port = join(env.get("UPLOAD_PORT", "none")) + download_speed = join(str(board.get("download.speed", "115200"))) if "none" in upload_port: env.AutodetectUploadPort() upload_port = join(env.get("UPLOAD_PORT", "none")) @@ -193,7 +194,7 @@ def get_partition_table(): esptoolpy_flags = [ "--chip", mcu, "--port", upload_port, - "--baud", env.subst("$UPLOAD_SPEED"), + "--baud", download_speed, "--before", "default_reset", "--after", "hard_reset", "read_flash", @@ -246,6 +247,7 @@ def download_fs(fs_info: FSInfo): print(fs_info) esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py") upload_port = join(env.get("UPLOAD_PORT", "none")) + download_speed = join(str(board.get("download.speed", "115200"))) if "none" in upload_port: env.AutodetectUploadPort() upload_port = join(env.get("UPLOAD_PORT", "none")) @@ -253,7 +255,7 @@ def download_fs(fs_info: FSInfo): esptoolpy_flags = [ "--chip", mcu, "--port", upload_port, - "--baud", env.subst("$UPLOAD_SPEED"), + "--baud", download_speed, "--before", "default_reset", "--after", "hard_reset", "read_flash", @@ -278,7 +280,7 @@ def unpack_fs(fs_info: FSInfo, downloaded_file: str): unpack_dir = env.GetProjectOption("custom_unpack_dir", "unpacked_fs") #unpack_dir = "unpacked_fs" if not os.path.exists(downloaded_file): - print(f"ERROR: {downloaded_file} with filesystem not found, maybe download failed due to upload_speed setting being too high.") + print(f"ERROR: {downloaded_file} with filesystem not found, maybe download failed due to download_speed setting being too high.") assert(0) try: if os.path.exists(unpack_dir): @@ -305,7 +307,7 @@ def display_fs(extracted_dir): print("Extracted " + str(file_count) + " file(s) from filesystem.") def command_download_fs(*args, **kwargs): - print("Entrypoint") + #print("Entrypoint") #print(env.Dump()) get_partition_table() info = get_fs_type_start_and_length() @@ -356,3 +358,4 @@ env.AddCustomTarget( title="Flash factory", description="Flash factory firmware" ) +