From d5647afb9a17126b6b5c02c3ea99d4a862b3d36e Mon Sep 17 00:00:00 2001 From: Adrian Soundy Date: Fri, 6 Dec 2024 14:17:48 +1300 Subject: [PATCH] Add support for 32MB and 64Mb flashing and Esp32-P4 support (#304) --- nanoFirmwareFlasher.Library/Esp32Firmware.cs | 27 ++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/nanoFirmwareFlasher.Library/Esp32Firmware.cs b/nanoFirmwareFlasher.Library/Esp32Firmware.cs index b89e431e..f80dd2c2 100644 --- a/nanoFirmwareFlasher.Library/Esp32Firmware.cs +++ b/nanoFirmwareFlasher.Library/Esp32Firmware.cs @@ -19,9 +19,9 @@ internal class Esp32Firmware : FirmwarePackage public const int CLRAddress = 0x10000; /// - /// ESP32 nanoCLR is available for 2MB, 4MB, 8MB and 16MB flash sizes + /// ESP32 nanoCLR is available for 2MB, 4MB, 8MB, 16MB, 32MB and 64MB flash sizes if supported. /// - private List SupportedFlashSizes => [0x200000, 0x400000, 0x800000, 0x1000000]; + private List SupportedFlashSizes => [0x200000, 0x400000, 0x800000, 0x1000000, 0x2000000, 0x4000000]; internal string BootloaderPath; @@ -76,15 +76,26 @@ internal async System.Threading.Tasks.Task DownloadAndExtractAsync(Es { BootloaderPath = "bootloader.bin"; + // Boot loader goes to 0x1000, except for ESP32_C3/C6/H2/S3, which goes to 0x0 + // and ESP32_P4 where it goes at 0x2000 + int BootLoaderAddress = 0x1000; + if (deviceInfo.ChipType == "ESP32-C3" + || deviceInfo.ChipType == "ESP32-C6" + || deviceInfo.ChipType == "ESP32-H2" + || deviceInfo.ChipType == "ESP32-S3") + { + BootLoaderAddress = 0; + } + if (deviceInfo.ChipType == "ESP32-P4") + { + BootLoaderAddress = 0x2000; + } + // get ESP32 partitions FlashPartitions = new Dictionary { - // bootloader goes to 0x1000, except for ESP32_C3/C6/H2/S3, which goes to 0x0 - { - deviceInfo.ChipType == "ESP32-C3" - || deviceInfo.ChipType == "ESP32-C6" - || deviceInfo.ChipType == "ESP32-H2" - || deviceInfo.ChipType == "ESP32-S3" ? 0x0 : 0x1000, Path.Combine(LocationPath, BootloaderPath) }, + // BootLoader goes to an address depending on chip type + { BootLoaderAddress, Path.Combine(LocationPath, BootloaderPath) }, // nanoCLR goes to 0x10000 { CLRAddress, Path.Combine(LocationPath, "nanoCLR.bin") },