Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on DeploymentExecuteIncremental #189

Merged
merged 3 commits into from
Mar 12, 2019
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright (c) 2017 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -2697,7 +2697,7 @@ private bool DeploymentExecuteIncremental(List<byte[]> assemblies, IProgress<str
if(deploymentBlob.ToDeploymentBlockList().Sum(b => b.Size) < deployLength)
{
// compose error message
string errorMessage = $"Deployment storage (total size: {deploymentBlob.ToDeploymentBlockList().Sum(b => b.Size)} bytes) was not large enough to fit assemblies to deploy (total size: {deployLength} bytes)";
string errorMessage = $"Deployment storage (available size: {deploymentBlob.ToDeploymentBlockList().Sum(b => b.Size)} bytes) is not large enough for assemblies to deploy (total size: {deployLength} bytes).";

progress?.Report(errorMessage);

Expand Down Expand Up @@ -2755,7 +2755,7 @@ private bool DeploymentExecuteIncremental(List<byte[]> assemblies, IProgress<str
else
{
// shouldn't happen, but couldn't find enough space to deploy all the assemblies!!
string errorMessage = $"Couldn't find a free deployment block to complete the deployment (remaining: {remainingBytes} bytes)";
string errorMessage = $"Couldn't find a free deployment block to complete the deployment (remaining: {remainingBytes} bytes).";

progress?.Report(errorMessage);

Expand All @@ -2771,30 +2771,31 @@ private bool DeploymentExecuteIncremental(List<byte[]> assemblies, IProgress<str
var eraseResult = EraseMemory((uint)block.StartAddress, 1);
if (!eraseResult.Success)
{
progress?.Report(($"FAILED to erase device memory @0x{block.StartAddress.ToString("X8")} with Length=0x{block.Size.ToString("X8")}"));
progress?.Report(($"Error erasing device memory @ 0x{block.StartAddress.ToString("X8")}."));

return false;
}

var writeResult = WriteMemory((uint)block.StartAddress, block.DeploymentData);
if (!writeResult.Success)
{
progress?.Report(($"FAILED to write device memory @0x{block.StartAddress.ToString("X8")} with Length={block.Size.ToString("X8")}"));
progress?.Report(($"Error writing to device memory @ 0x{block.StartAddress.ToString("X8")} ({block.DeploymentData.Length} bytes)."));

return false;
}

// report progress
// progress?.Report($"Deployed assemblies for a total size of {blocksToDeploy.Sum(b => b.Size)} bytes");
progress?.Report($"Deployed assemblies with a total size of {blocksToDeploy.Sum(b => b.Size)} bytes.");
}

// deployment successful
return true;
}

// invalid flash map
// TODO provide feedback to user
return false;
progress?.Report("Error retrieving device flash map.");

throw new Exception("Error retrieving device flash map.");
}

private bool DeploymentExecuteFull(List<byte[]> assemblies, IProgress<string> progress)
Expand Down Expand Up @@ -2886,7 +2887,7 @@ public bool DeploymentExecute(List<byte[]> assemblies, bool fRebootAfterDeploy =

if (Capabilities.IncrementalDeployment)
{
progress?.Report("Incrementally deploying assemblies to device");
progress?.Report("Incrementally deploying assemblies to the device");

fDeployedOK = DeploymentExecuteIncremental(assemblies, progress);
}
Expand All @@ -2900,11 +2901,11 @@ public bool DeploymentExecute(List<byte[]> assemblies, bool fRebootAfterDeploy =

if (!fDeployedOK)
{
progress?.Report("Assemblies not successfully deployed to device.");
progress?.Report("Error deploying assemblies to the device.");
}
else
{
progress?.Report("Assemblies successfully deployed to device.");
progress?.Report("Assemblies successfully deployed to the device.");

if (fRebootAfterDeploy)
{
Expand Down Expand Up @@ -3733,5 +3734,5 @@ private DeviceConfiguration.DeviceConfigurationOption GetDeviceConfigurationOpti

#endregion

}
}
}