Skip to content

Commit

Permalink
jtagclient can now set read protection on LockableDevice's
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Jul 13, 2018
1 parent c169454 commit 2ea21cb
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions jtagclient/main.cpp
Expand Up @@ -129,7 +129,8 @@ int main(int argc, char* argv[])
MODE_DEVINFO,
MODE_ERASE,
MODE_REBOOT,
MODE_DUMP
MODE_DUMP,
MODE_LOCK
} mode = MODE_NONE;

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

//Expect device index
mode = MODE_LOCK;
devnum = atoi(argv[++i]);
}
else if(s == "--dump")
{
if(i+2 >= argc)
Expand Down Expand Up @@ -483,11 +496,36 @@ int main(int argc, char* argv[])
}

//Erase it
printf("Rebooting...\n");
LogNotice("Rebooting...\n");
pdev->Reboot();
}
break;

case MODE_LOCK:
{
//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("Locking...\n");
pdev->SetReadLock();
};

default:
break;
}
Expand Down

0 comments on commit 2ea21cb

Please sign in to comment.