Skip to content

Commit 7239fa4

Browse files
authored
Add support for new ESP32 series (C3, C6 and H2) (#269)
***NO_CI***
1 parent 081e667 commit 7239fa4

File tree

2 files changed

+86
-24
lines changed

2 files changed

+86
-24
lines changed

nanoFirmwareFlasher.Library/Esp32Firmware.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ internal async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync(Es
8282
// get ESP32 partitions
8383
FlashPartitions = new Dictionary<int, string>
8484
{
85-
// bootloader goes to 0x1000, except for ESP32_C3 and ESP32_S3, which goes to 0x0
86-
{ deviceInfo.ChipType == "ESP32-C3" || deviceInfo.ChipType == "ESP32-S3" ? 0x0 : 0x1000, Path.Combine(LocationPath, BootloaderPath) },
85+
// bootloader goes to 0x1000, except for ESP32_C3/C6/H2/S3, which goes to 0x0
86+
{
87+
deviceInfo.ChipType == "ESP32-C3"
88+
|| deviceInfo.ChipType == "ESP32-C6"
89+
|| deviceInfo.ChipType == "ESP32-H2"
90+
|| deviceInfo.ChipType == "ESP32-S3" ? 0x0 : 0x1000, Path.Combine(LocationPath, BootloaderPath) },
8791

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

nanoFirmwareFlasher.Library/Esp32Operations.cs

Lines changed: 80 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
129129

130130
// perform sanity checks for the specified target against the connected device details
131131
if (esp32Device.ChipType != "ESP32" &&
132-
esp32Device.ChipType != "ESP32-S2" &&
133132
esp32Device.ChipType != "ESP32-C3" &&
133+
esp32Device.ChipType != "ESP32-C6" &&
134+
esp32Device.ChipType != "ESP32-H2" &&
135+
esp32Device.ChipType != "ESP32-S2" &&
134136
esp32Device.ChipType != "ESP32-S3")
135137
{
136138
// connected to a device not supported
@@ -221,26 +223,6 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
221223
}
222224
}
223225
}
224-
else if (esp32Device.ChipType == "ESP32-S2")
225-
{
226-
// version schema for ESP32-S2
227-
//Previously Used Schemes | Previous Identification | vM.X
228-
// n/a | 0 | v0.0
229-
// ECO1 | 1 | v1.0
230-
231-
// can't guess with certainty for this series, better request a target name to the user
232-
233-
Console.ForegroundColor = ConsoleColor.Red;
234-
235-
Console.WriteLine("");
236-
Console.WriteLine($"For ESP32-S2 series nanoff isn't able to make an educated guess on the best target to use.");
237-
Console.WriteLine($"Please provide a valid target name using this option '--target MY_ESP32_S2_TARGET' instead of '--platform esp32'.");
238-
Console.WriteLine("");
239-
240-
Console.ForegroundColor = ConsoleColor.White;
241-
242-
return ExitCodes.E9000;
243-
}
244226
else if (esp32Device.ChipType == "ESP32-C3")
245227
{
246228
// version schema for ESP32-C3
@@ -277,6 +259,80 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
277259
// compose target name
278260
targetName = $"ESP32_C3{revisionSuffix}";
279261
}
262+
else if (esp32Device.ChipType == "ESP32-C6")
263+
{
264+
// version schema for ESP32-C6
265+
266+
string revisionSuffix;
267+
268+
// so far we are only offering a single ESP32_C6 build
269+
if (esp32Device.ChipName.Contains("revision v0.0") || esp32Device.ChipName.Contains("revision v0.1"))
270+
{
271+
revisionSuffix = "";
272+
}
273+
else
274+
{
275+
Console.ForegroundColor = ConsoleColor.Red;
276+
277+
Console.WriteLine("");
278+
Console.WriteLine($"Unsupported ESP32_C6 revision.");
279+
Console.WriteLine("");
280+
281+
Console.ForegroundColor = ConsoleColor.White;
282+
283+
return ExitCodes.E9000;
284+
}
285+
286+
// compose target name
287+
targetName = $"ESP32_C6{revisionSuffix}";
288+
}
289+
else if (esp32Device.ChipType == "ESP32-H2")
290+
{
291+
// version schema for ESP32-H2
292+
293+
string revisionSuffix;
294+
295+
// so far we are only offering a single ESP32_H2 build
296+
if (esp32Device.ChipName.Contains("revision v0.1") || esp32Device.ChipName.Contains("revision v0.2"))
297+
{
298+
revisionSuffix = "";
299+
}
300+
else
301+
{
302+
Console.ForegroundColor = ConsoleColor.Red;
303+
304+
Console.WriteLine("");
305+
Console.WriteLine($"Unsupported ESP32_H2 revision.");
306+
Console.WriteLine("");
307+
308+
Console.ForegroundColor = ConsoleColor.White;
309+
310+
return ExitCodes.E9000;
311+
}
312+
313+
// compose target name
314+
targetName = $"ESP32_H2{revisionSuffix}";
315+
}
316+
else if (esp32Device.ChipType == "ESP32-S2")
317+
{
318+
// version schema for ESP32-S2
319+
//Previously Used Schemes | Previous Identification | vM.X
320+
// n/a | 0 | v0.0
321+
// ECO1 | 1 | v1.0
322+
323+
// can't guess with certainty for this series, better request a target name to the user
324+
325+
Console.ForegroundColor = ConsoleColor.Red;
326+
327+
Console.WriteLine("");
328+
Console.WriteLine($"For ESP32-S2 series nanoff isn't able to make an educated guess on the best target to use.");
329+
Console.WriteLine($"Please provide a valid target name using this option '--target MY_ESP32_S2_TARGET' instead of '--platform esp32'.");
330+
Console.WriteLine("");
331+
332+
Console.ForegroundColor = ConsoleColor.White;
333+
334+
return ExitCodes.E9000;
335+
}
280336
else if (esp32Device.ChipType == "ESP32-S3")
281337
{
282338
// version schema for ESP32-S3
@@ -562,8 +618,10 @@ public static async System.Threading.Tasks.Task<ExitCodes> DeployApplicationAsyn
562618

563619
// perform sanity checks for the specified target against the connected device details
564620
if (esp32Device.ChipType != "ESP32" &&
565-
esp32Device.ChipType != "ESP32-S2" &&
566621
esp32Device.ChipType != "ESP32-C3" &&
622+
esp32Device.ChipType != "ESP32-C6" &&
623+
esp32Device.ChipType != "ESP32-H2" &&
624+
esp32Device.ChipType != "ESP32-S2" &&
567625
esp32Device.ChipType != "ESP32-S3")
568626
{
569627
// connected to a device not supported

0 commit comments

Comments
 (0)