Skip to content

Commit

Permalink
Improve output during backup/flash process
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryCharlton committed Jun 24, 2024
1 parent 6f50e27 commit dd7153a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
20 changes: 12 additions & 8 deletions nanoFirmwareFlasher.Library/Esp32Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -513,7 +506,11 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
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...");
}

// compose path to partition file
string partitionCsvFile = Path.Combine(firmware.LocationPath, $"partitions_nanoclr_{Esp32DeviceInfo.GetFlashSizeAsString(esp32Device.FlashSize).ToLowerInvariant()}.csv");
Expand Down Expand Up @@ -543,6 +540,13 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
}
}

Console.ForegroundColor = ConsoleColor.White;

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

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

Expand Down
8 changes: 4 additions & 4 deletions nanoFirmwareFlasher.Library/EspTool.cs
Original file line number Diff line number Diff line change
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,12 +745,12 @@ 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)
{
// need to print the first line of the progress message
Console.Write("\r");
Console.WriteLine();

progressStarted = true;
}
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

0 comments on commit dd7153a

Please sign in to comment.