Skip to content

Commit d5647af

Browse files
authored
Add support for 32MB and 64Mb flashing and Esp32-P4 support (#304)
1 parent 30174e7 commit d5647af

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

nanoFirmwareFlasher.Library/Esp32Firmware.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ internal class Esp32Firmware : FirmwarePackage
1919
public const int CLRAddress = 0x10000;
2020

2121
/// <summary>
22-
/// ESP32 nanoCLR is available for 2MB, 4MB, 8MB and 16MB flash sizes
22+
/// ESP32 nanoCLR is available for 2MB, 4MB, 8MB, 16MB, 32MB and 64MB flash sizes if supported.
2323
/// </summary>
24-
private List<int> SupportedFlashSizes => [0x200000, 0x400000, 0x800000, 0x1000000];
24+
private List<int> SupportedFlashSizes => [0x200000, 0x400000, 0x800000, 0x1000000, 0x2000000, 0x4000000];
2525

2626
internal string BootloaderPath;
2727

@@ -76,15 +76,26 @@ internal async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync(Es
7676
{
7777
BootloaderPath = "bootloader.bin";
7878

79+
// Boot loader goes to 0x1000, except for ESP32_C3/C6/H2/S3, which goes to 0x0
80+
// and ESP32_P4 where it goes at 0x2000
81+
int BootLoaderAddress = 0x1000;
82+
if (deviceInfo.ChipType == "ESP32-C3"
83+
|| deviceInfo.ChipType == "ESP32-C6"
84+
|| deviceInfo.ChipType == "ESP32-H2"
85+
|| deviceInfo.ChipType == "ESP32-S3")
86+
{
87+
BootLoaderAddress = 0;
88+
}
89+
if (deviceInfo.ChipType == "ESP32-P4")
90+
{
91+
BootLoaderAddress = 0x2000;
92+
}
93+
7994
// get ESP32 partitions
8095
FlashPartitions = new Dictionary<int, string>
8196
{
82-
// bootloader goes to 0x1000, except for ESP32_C3/C6/H2/S3, which goes to 0x0
83-
{
84-
deviceInfo.ChipType == "ESP32-C3"
85-
|| deviceInfo.ChipType == "ESP32-C6"
86-
|| deviceInfo.ChipType == "ESP32-H2"
87-
|| deviceInfo.ChipType == "ESP32-S3" ? 0x0 : 0x1000, Path.Combine(LocationPath, BootloaderPath) },
97+
// BootLoader goes to an address depending on chip type
98+
{ BootLoaderAddress, Path.Combine(LocationPath, BootloaderPath) },
8899

89100
// nanoCLR goes to 0x10000
90101
{ CLRAddress, Path.Combine(LocationPath, "nanoCLR.bin") },

0 commit comments

Comments
 (0)