Skip to content

Commit

Permalink
Added verification word mask for missing config bits
Browse files Browse the repository at this point in the history
  • Loading branch information
majenkotech committed Apr 18, 2018
1 parent 550f656 commit 28147b7
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/families/family-mx1.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,7 @@ void print_mx1(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
else
printf(" VBuson pin: controlled by port\n");
}

unsigned word_mask_mx1(unsigned address, unsigned word) {
return word;
}
4 changes: 4 additions & 0 deletions src/families/family-mx3.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,7 @@ void print_mx3(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
else
printf(" VBuson pin: controlled by port\n");
}

unsigned word_mask_mx3(unsigned address, unsigned word) {
return word;
}
4 changes: 4 additions & 0 deletions src/families/family-mz.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,7 @@ void print_mz(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
else
printf(" USBID pin: controlled by port\n");
}

unsigned word_mask_mz(unsigned address, unsigned word) {
return word;
}
8 changes: 8 additions & 0 deletions src/families/family-xlp.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,11 @@ void print_xlp(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
else
printf(" VBuson pin: controlled by port\n");
}

unsigned word_mask_xlp(unsigned address, unsigned word) {
// DEVCFG0's highest bit doesn't exist.
if (address == 0x9FC02FFC) {
return word & 0x7FFFFFFF;
}
return word;
}
2 changes: 2 additions & 0 deletions src/include/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
#include "adapter.h"

typedef void print_func_t(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3);
typedef unsigned word_mask_func_t(unsigned address, unsigned word);

typedef struct {
const char *name;
unsigned boot_kbytes;
unsigned devcfg_offset;
unsigned bytes_per_row;
print_func_t *print_devcfg;
word_mask_func_t *word_mask;
const unsigned *pe_code;
unsigned pe_nwords;
unsigned pe_version;
Expand Down
14 changes: 10 additions & 4 deletions src/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ extern print_func_t print_mx3;
extern print_func_t print_mz;
extern print_func_t print_xlp;

extern word_mask_func_t word_mask_mx1;
extern word_mask_func_t word_mask_mx3;
extern word_mask_func_t word_mask_xlp;
extern word_mask_func_t word_mask_mz;

extern unsigned long open_retries;

/*
Expand All @@ -37,16 +42,16 @@ extern unsigned long open_retries;
/*-Boot-Devcfg--Row---Print------Code--------Nwords-Version-*/
static const
family_t family_mx1 = { "mx1",
3, 0x0bf0, 128, print_mx1, pic32_pemx1, 422, 0x0301 };
3, 0x0bf0, 128, print_mx1, word_mask_mx1, pic32_pemx1, 422, 0x0301 };
static const
family_t family_xlp = { "xlp",
12, 0x2ff0, 512, print_xlp, pic32_pemx3, 1044, 0x0201 };
12, 0x2ff0, 512, print_xlp, word_mask_xlp, pic32_pemx3, 1044, 0x0201 };
static const
family_t family_mx3 = { "mx3",
12, 0x2ff0, 512, print_mx3, pic32_pemx3, 1044, 0x0201 };
12, 0x2ff0, 512, print_mx3, word_mask_mx3, pic32_pemx3, 1044, 0x0201 };
static const
family_t family_mz = { "mz",
80, 0xffc0, 2048, print_mz, pic32_pemz, 1052, 0x0502 };
80, 0xffc0, 2048, print_mz, word_mask_mz, pic32_pemz, 1052, 0x0502 };
/*
* This one is a special one for the bootloader. We have no idea what we're
* programming, so set the values to the maximum out of all the others.
Expand Down Expand Up @@ -773,6 +778,7 @@ void target_verify_block(target_t *t, unsigned addr,
t->adapter->read_data(t->adapter, addr, nwords, block);
for (i=0; i<nwords; i++) {
expected = data [i];
expected = t->family->word_mask(addr + (i<<2), expected);
word = block [i];
if (word != expected) {
conprintf(_("\nerror at address %08X: file=%08X, mem=%08X\n"),
Expand Down

0 comments on commit 28147b7

Please sign in to comment.