Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions nanoFirmwareFlasher.Library/Esp32Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
if (verbosity >= VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK");
Console.WriteLine("OK".PadRight(110));
}
else
{
Expand All @@ -495,13 +495,6 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(

if (operationResult == ExitCodes.OK)
{
Console.ForegroundColor = ConsoleColor.White;

if (verbosity >= VerbosityLevel.Normal)
{
Console.Write($"Flashing firmware...");
}

int configPartitionAddress = 0;
int configPartitionSize = 0;
string configPartitionBackup = Path.GetRandomFileName();
Expand All @@ -512,9 +505,13 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
// check if the update file includes a partition table
if (File.Exists(Path.Combine(firmware.LocationPath, $"partitions_nanoclr_{Esp32DeviceInfo.GetFlashSizeAsString(esp32Device.FlashSize).ToLowerInvariant()}.csv")))
{
// can't do this without a partition table

if (verbosity >= VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"Backup configuration...");
}

// can't do this without a partition table
// compose path to partition file
string partitionCsvFile = Path.Combine(firmware.LocationPath, $"partitions_nanoclr_{Esp32DeviceInfo.GetFlashSizeAsString(esp32Device.FlashSize).ToLowerInvariant()}.csv");

Expand All @@ -538,18 +535,46 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
configPartitionBackup,
configPartitionAddress,
configPartitionSize);


if (verbosity >= VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"Backup configuration...");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK".PadRight(110));
}

firmware.FlashPartitions.Add(configPartitionAddress, configPartitionBackup);
}
}

Console.ForegroundColor = ConsoleColor.White;

if (verbosity < VerbosityLevel.Normal)
{
// output the start of operation message for verbosity lower than normal
// otherwise the progress from esptool is shown
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"Flashing firmware...");
}

// write to flash
operationResult = espTool.WriteFlash(firmware.FlashPartitions);

if (operationResult == ExitCodes.OK)
{
if (verbosity < VerbosityLevel.Normal)
{
// operation completed output
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK".PadRight(110));
}

if (verbosity >= VerbosityLevel.Normal)
{
// output the full message as usual after the progress from esptool
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"Flashing firmware...");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK".PadRight(110));

Expand Down
8 changes: 4 additions & 4 deletions nanoFirmwareFlasher.Library/EspTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public Esp32DeviceInfo GetDeviceDetails(
if (Verbosity >= VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK");
Console.WriteLine("OK".PadRight(110));
Console.ForegroundColor = ConsoleColor.White;
}

Expand Down Expand Up @@ -474,7 +474,7 @@ internal ExitCodes BackupConfigPartition(
false,
true,
false,
null,
(char)8,
out string messages))
{
throw new ReadEsp32FlashException(messages);
Expand Down Expand Up @@ -745,7 +745,7 @@ private bool RunEspTool(

// try to find a progress message
string progress = FindProgress(messageBuilder, progressTestChar.Value);
if (progress != null && Verbosity >= VerbosityLevel.Detailed)
if (progress != null && Verbosity >= VerbosityLevel.Normal)
{
if (!progressStarted)
{
Expand All @@ -764,7 +764,7 @@ private bool RunEspTool(
}
else
{
if (Verbosity >= VerbosityLevel.Detailed)
if (Verbosity >= VerbosityLevel.Normal)
{
// need to clear all progress lines
for (int i = 0; i < messageBuilder.Length; i++)
Expand Down