diff --git a/README.md b/README.md index 463566da..4a85894a 100644 --- a/README.md +++ b/README.md @@ -138,22 +138,21 @@ nanoff --platform esp32 --serialport COM31 --devicedetails ### Deploy a managed application to an ESP32 target -To deploy a managed application to an ESP32_PSRAM_REV0 target connected to COM31, which has the deployment region at 0x190000 flash address. +To deploy a managed application to an ESP32_PSRAM_REV0 target connected to COM31. >Note: The binary file with the deployment image can be found on the Release or Debug folder of a Visual Studio project after a successful build. This file contains everything that's required to deploy a managed application to a target (meaning application executable and all referenced libraries and assemblies). ```console -nanoff --target ESP32_PSRAM_REV0 --serialport COM12 --deploy --image "E:\GitHub\nf-Samples\samples\Blinky\Blinky\bin\Debug\Blinky.bin" --address 0x190000 +nanoff --target ESP32_PSRAM_REV0 --serialport COM12 --deploy --image "E:\GitHub\nf-Samples\samples\Blinky\Blinky\bin\Debug\Blinky.bin" ``` ### Update the firmware of an ESP32 target along with a managed application -To update the firmware of an ESP32 target connected to COM31, to the latest available development version. -You have to specify the path to the managed application. -This example uses the binary format file that was saved on a previous backup operation. +To deploy an application on an ESP32 target connected to COM31, with your application, you have to specify the path to the managed application. Optionally you can provide an address which will override the default deployment address. +This example uses the binary format file that you can find when you are building an application. Note, as only application can run, when you are building a library, a bin file is not created automatically. Only for applications. ```console -nanoff --update --target ESP32_PSRAM_REV0 --serialport COM31 --deployment "c:\eps32-backups\my_awesome_app.bin" +nanoff --target ESP32_PSRAM_REV0 --update --serialport COM31 --deploy --image "c:\eps32-backups\my_awesome_app.bin" --address 0x1B000 ``` ## STMP32 usage examples diff --git a/nanoFirmwareFlasher/Esp32Firmware.cs b/nanoFirmwareFlasher/Esp32Firmware.cs index 265d7688..d03e5923 100755 --- a/nanoFirmwareFlasher/Esp32Firmware.cs +++ b/nanoFirmwareFlasher/Esp32Firmware.cs @@ -33,9 +33,9 @@ internal class Esp32Firmware : FirmwarePackage internal PartitionTableSize? _partitionTableSize; /// - /// Address of the deployment partition. + /// Default address of the deployment partition. /// - internal int DeploymentPartitionAddress => 0x110000; + internal int DeploymentPartitionAddress => 0x1B0000; public Esp32Firmware( string targetName, diff --git a/nanoFirmwareFlasher/Esp32Operations.cs b/nanoFirmwareFlasher/Esp32Operations.cs index 9859fa1b..b932b459 100755 --- a/nanoFirmwareFlasher/Esp32Operations.cs +++ b/nanoFirmwareFlasher/Esp32Operations.cs @@ -251,10 +251,10 @@ internal static async System.Threading.Tasks.Task UpdateFirmwareAsync // check application file if (File.Exists(applicationPath)) { - if (!updateFw) + // this operation includes a deployment image + // try parsing the deployment address from parameter, if provided + if (!string.IsNullOrEmpty(deploymentAddress)) { - // this is a deployment operation only - // try parsing the deployment address from parameter // need to remove the leading 0x and to specify that hexadecimal values are allowed if (!uint.TryParse(deploymentAddress.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier, System.Globalization.CultureInfo.InvariantCulture, out address)) { @@ -263,10 +263,12 @@ internal static async System.Threading.Tasks.Task UpdateFirmwareAsync } string applicationBinary = new FileInfo(applicationPath).FullName; + + // add DEPLOYMENT partition with the address provided in the command OR the address from the partition table firmware.FlashPartitions = new Dictionary() { { - updateFw ? firmware.DeploymentPartitionAddress : (int)address, + address != 0 ? (int)address : firmware.DeploymentPartitionAddress, applicationBinary } }; @@ -277,44 +279,35 @@ internal static async System.Threading.Tasks.Task UpdateFirmwareAsync } } - if (verbosity >= VerbosityLevel.Normal) - { - Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine($"Erasing flash..."); - } - if (updateFw) { + // updating fw calls for a flash erase + if (verbosity >= VerbosityLevel.Normal) + { + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine($"Erasing flash..."); + } + // erase flash operationResult = espTool.EraseFlash(); - } - else - { - // erase flash segment - - // need to get deployment address here - // length must both be multiples of the SPI flash erase sector size. This is 0x1000 (4096) bytes for supported flash chips. - - var fileStream = File.OpenRead(firmware.BootloaderPath); - uint fileLength = (uint)Math.Ceiling((decimal)fileStream.Length / 0x1000) * 0x1000; - - operationResult = espTool.EraseFlashSegment(address, fileLength); + if (operationResult == ExitCodes.OK) + { + if (verbosity >= VerbosityLevel.Normal) + { + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("OK"); + } + else + { + Console.WriteLine(""); + } + } } if (operationResult == ExitCodes.OK) { - if (verbosity >= VerbosityLevel.Normal) - { - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine("OK"); - } - else - { - Console.WriteLine(""); - } - - Console.ForegroundColor = ConsoleColor.White; + Console.ForegroundColor = ConsoleColor.White; if (verbosity >= VerbosityLevel.Normal) { diff --git a/nanoFirmwareFlasher/Program.cs b/nanoFirmwareFlasher/Program.cs index 4a1d0b79..296c74db 100644 --- a/nanoFirmwareFlasher/Program.cs +++ b/nanoFirmwareFlasher/Program.cs @@ -449,18 +449,13 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o) if (o.Deploy) { // need to take care of flash address - string appFlashAddress = null; + string appFlashAddress = string.Empty; if (o.FlashAddress.Any()) { // take the first address, it should be the only one valid appFlashAddress = o.FlashAddress.ElementAt(0); } - else - { - _exitCode = ExitCodes.E9009; - return; - } // this to flash a deployment image without updating the firmware try @@ -469,7 +464,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o) _exitCode = await Esp32Operations.UpdateFirmwareAsync( espTool, esp32Device, - null, + o.TargetName, false, null, false, diff --git a/version.json b/version.json index 00c47c61..d457eac1 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.28", + "version": "1.29", "assemblyVersion": { "precision": "minor" },