Skip to content

Commit

Permalink
Add VerifyMemory method (#271)
Browse files Browse the repository at this point in the history
***UPDATE_DEPENDENTS***
  • Loading branch information
josesimoes authored Nov 24, 2020
1 parent b1f3e37 commit 35b84ec
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,25 @@ public async Task<bool> DeployBinaryFileAsync(

progress?.Report($"Writing to device @ 0x{address:X8}...");

return DeployFile(
if(!DeployFile(
data,
address,
progress);
progress))
{
return false;
}

//progress?.Report($"Verifying image...");

//if (!VerifyMemory(
// data,
// address,
// progress))
//{
// return false;
//}

return true;
}

/// <summary>
Expand Down Expand Up @@ -663,6 +678,34 @@ private bool DeployFile(
return true;
}

private bool VerifyMemory(
byte[] buffer,
uint address,
IProgress<string> progress = null)
{
(byte[] ReadBuffer, uint ErrorCode, bool Success) = DebugEngine.ReadMemory(address, (uint)buffer.Length);
if (!Success)
{
progress?.Report($"Error reading from device memory, error {ErrorCode}.");

return false;
}

int index = 0;

foreach(var b in buffer)
{
if(ReadBuffer[index] != b)
{
progress?.Report($"Verification error @ 0x{(address + index):X8}.");
return false;
}
}

return true;
}


/// <summary>
/// Starts execution on the connected nanoDevice at the supplied address (parameter entrypoint).
/// This method is generally used after the Deploy method to jump into the code that was deployed.
Expand Down

0 comments on commit 35b84ec

Please sign in to comment.