Skip to content

Commit

Permalink
add option to skip reading chip-id completely
Browse files Browse the repository at this point in the history
  • Loading branch information
raybellis committed Feb 20, 2018
1 parent 86185f7 commit 40007e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 16 additions & 3 deletions main.c
Expand Up @@ -25,7 +25,8 @@ struct {
int size_nowarn;
int verify;
int icsp;
int idcheck_continue;
int idcheck_skip;
int idcheck_continue;
} cmdopts;

void print_help_and_exit(char *progname) {
Expand All @@ -47,6 +48,7 @@ void print_help_and_exit(char *progname) {
" -I Use ICSP (without enabling Vcc)\n"
" -s Do NOT error on file size mismatch (only a warning)\n"
" -S No warning message for file size mismatch (can't combine with -s)\n"
" -x Do NOT attempt to read ID (only valid in read mode)\n"
" -y Do NOT error on ID mismatch\n";
fprintf(stderr, usage, VERSION, basename(progname));
exit(-1);
Expand All @@ -73,7 +75,7 @@ void parse_cmdline(int argc, char **argv) {
int8_t c;
memset(&cmdopts, 0, sizeof(cmdopts));

while((c = getopt(argc, argv, "leuPvyr:w:p:c:iIsS")) != -1) {
while((c = getopt(argc, argv, "leuPvxyr:w:p:c:iIsS")) != -1) {
switch(c) {
case 'l':
print_devices_and_exit();
Expand All @@ -94,6 +96,10 @@ void parse_cmdline(int argc, char **argv) {
cmdopts.verify=1; // 1= do not verify
break;

case 'x':
cmdopts.idcheck_skip=1; // 1= do not test id at all
break;

case 'y':
cmdopts.idcheck_continue=1; // 1= do not stop on id mismatch
break;
Expand Down Expand Up @@ -494,6 +500,11 @@ int main(int argc, char **argv) {
USAGE_ERROR("Device required");
}

// don't permit skipping the ID read in write-mode
if (cmdopts.action == action_write && cmdopts.idcheck_skip) {
print_help_and_exit(argv[0]);
}

device_t *device = cmdopts.device;
minipro_handle_t *handle = minipro_open(device);
handle->icsp = cmdopts.icsp;
Expand All @@ -504,7 +515,9 @@ int main(int argc, char **argv) {
printf("Found Minipro %s v%s\n", info.model_str, info.firmware_str);

// Verifying Chip ID (if applicable)
if(device->chip_id_bytes_count && device->chip_id) {
if(cmdopts.idcheck_skip) {
printf("WARNING: skipping Chip ID test\n");
} else if(device->chip_id_bytes_count && device->chip_id) {
minipro_begin_transaction(handle);
unsigned int chip_id = minipro_get_chip_id(handle);
minipro_end_transaction(handle);
Expand Down
5 changes: 5 additions & 0 deletions man/minipro.1
Expand Up @@ -80,6 +80,11 @@ Do NOT error on file size mismatch (only a warning).
.B \-S
No warning message for file size mismatch (can't combine with -s).

.TP
.B -x
Do NOT attempt to read ID (only valid in read mode). Avoids sending
high Chip ID read voltages to unknown pins.

.TP
.B \-y
Do NOT error on ID mismatch.
Expand Down

0 comments on commit 40007e6

Please sign in to comment.