Skip to content

Commit

Permalink
Added unlock command
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Jul 13, 2018
1 parent 2ea21cb commit a7f08a4
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion jtagclient/main.cpp
Expand Up @@ -130,7 +130,8 @@ int main(int argc, char* argv[])
MODE_ERASE,
MODE_REBOOT,
MODE_DUMP,
MODE_LOCK
MODE_LOCK,
MODE_UNLOCK
} mode = MODE_NONE;

//Device index
Expand Down Expand Up @@ -202,6 +203,18 @@ int main(int argc, char* argv[])
mode = MODE_LOCK;
devnum = atoi(argv[++i]);
}
else if(s == "--unlock")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --lock\n");
return 1;
}

//Expect device index
mode = MODE_UNLOCK;
devnum = atoi(argv[++i]);
}
else if(s == "--dump")
{
if(i+2 >= argc)
Expand Down Expand Up @@ -526,6 +539,31 @@ int main(int argc, char* argv[])
pdev->SetReadLock();
};

case MODE_UNLOCK:
{
//Get the device
JtagDevice* device = iface.GetDevice(devnum);
if(device == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}

//Make sure it's a lockable device
LockableDevice* pdev = dynamic_cast<LockableDevice*>(device);
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is not lockable, cannot continue",
"");
}

//Lock it
LogNotice("Unlocking (will probably trigger bulk flash erase)...\n");
pdev->ClearReadLock();
};

default:
break;
}
Expand Down

0 comments on commit a7f08a4

Please sign in to comment.