diff --git a/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs b/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs index 729dc030..7e20dfe0 100644 --- a/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs +++ b/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs @@ -556,6 +556,12 @@ public async Task DeployUpdateAsync(StorageFile comprFilePath, Cancellatio /// Address to write to. /// Returns false if the deployment fails, true otherwise. /// + /// + /// To perform the update the device has to be running: + /// - nanoCLR if this is meant to update the deployment region. + /// - nanoBooter if this is meant to update nanoCLR + /// Failing to meet this condition will abort the operation. + /// public async Task DeployBinaryFileAsync( string binFile, uint address, @@ -576,7 +582,6 @@ public async Task DeployBinaryFileAsync( var data = File.ReadAllBytes(binFile); if (!await PrepareForDeployAsync( - data, address, cancellationToken, progress)) @@ -684,6 +689,7 @@ private bool DeployFile( address, buffer, progress); + if (!Success) { progress?.Report($"Error writing to device memory @ 0x{address:X8}, error {ErrorCode}."); @@ -1325,13 +1331,11 @@ private async Task PreProcesSrecAsync(StorageFile srecFile) } private async Task PrepareForDeployAsync( - byte[] buffer, uint address, CancellationToken cancellationToken, IProgress progress = null) { return await PrepareForDeployAsync( - buffer, address, null, cancellationToken, @@ -1344,7 +1348,6 @@ private async Task PrepareForDeployAsync( IProgress progress = null) { return await PrepareForDeployAsync( - null, 0, blocks, cancellationToken, @@ -1352,18 +1355,11 @@ private async Task PrepareForDeployAsync( } private async Task PrepareForDeployAsync( - byte[] buffer, uint address, List blocks, CancellationToken cancellationToken, IProgress progress = null) { - // make sure we are connected - if(!await DebugEngine.ConnectAsync(5000, true)) - { - return false; - } - // get flash sector map, only if needed List flashSectorsMap = DebugEngine.FlashSectorMap; @@ -1379,8 +1375,6 @@ private async Task PrepareForDeployAsync( bool updatesClr = false; bool updatesBooter = false; - long totalLength; - if (blocks != null) { foreach (SRecordFile.Block bl in blocks) @@ -1393,8 +1387,6 @@ private async Task PrepareForDeployAsync( updatesBooter ^= (startSector.m_flags & Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_MASK) == Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_BOOTSTRAP; } } - - totalLength = blocks.Sum(b => b.data.Length); } else { @@ -1405,14 +1397,15 @@ private async Task PrepareForDeployAsync( updatesClr = (startSector.m_flags & Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_MASK) == Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_CODE; updatesBooter = (startSector.m_flags & Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_MASK) == Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_BOOTSTRAP; } - - totalLength = buffer.Length; } // sanity check if (updatesBooter) { // can't handle this update because it touches nanoBooter + + progress?.Report("Can't deploy file because it updates nanoBooter."); + return false; } @@ -1425,11 +1418,15 @@ private async Task PrepareForDeployAsync( return false; } - if (updatesClr && - DebugEngine.ConnectionSource != ConnectionSource.nanoBooter) + if (updatesClr) { // if this is updating the CLR need to launch nanoBooter - await ConnectToNanoBooterAsync(cancellationToken); + if (DebugEngine.ConnectionSource != ConnectionSource.nanoBooter) + { + progress?.Report("Need to launch nanoBooter before updating the firmware."); + + return false; + } } // erase whatever blocks are required diff --git a/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj b/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj index dbf313d3..fcea0181 100644 --- a/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj +++ b/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj @@ -56,7 +56,7 @@ bin\x86\Release\ TRACE;NETFX_CORE;WINDOWS_UWP true - ;2008 + $(NoWarn);NU1603;2008 pdbonly x86 false @@ -79,7 +79,7 @@ bin\ARM\Release\ TRACE;NETFX_CORE;WINDOWS_UWP true - ;2008 + $(NoWarn);NU1603;2008 pdbonly ARM false @@ -101,7 +101,7 @@ bin\x64\Release\ TRACE;NETFX_CORE;WINDOWS_UWP true - ;2008 + $(NoWarn);NU1603;2008 pdbonly x64 false @@ -140,6 +140,9 @@ 7.2.1 + + 1.1.1 + 2.6.1