diff --git a/src/families/family-mx1.c b/src/families/family-mx1.c index 8cdcf81..dbbb8db 100644 --- a/src/families/family-mx1.c +++ b/src/families/family-mx1.c @@ -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; +} diff --git a/src/families/family-mx3.c b/src/families/family-mx3.c index 613e965..be09b05 100644 --- a/src/families/family-mx3.c +++ b/src/families/family-mx3.c @@ -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; +} diff --git a/src/families/family-mz.c b/src/families/family-mz.c index 769d5a9..f71a2de 100644 --- a/src/families/family-mz.c +++ b/src/families/family-mz.c @@ -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; +} diff --git a/src/families/family-xlp.c b/src/families/family-xlp.c index cac0691..aa7ed27 100644 --- a/src/families/family-xlp.c +++ b/src/families/family-xlp.c @@ -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; +} diff --git a/src/include/target.h b/src/include/target.h index b84f5c7..8fb6ab3 100644 --- a/src/include/target.h +++ b/src/include/target.h @@ -15,6 +15,7 @@ #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; @@ -22,6 +23,7 @@ typedef struct { 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; diff --git a/src/target.c b/src/target.c index a07fed5..3f57395 100644 --- a/src/target.c +++ b/src/target.c @@ -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; /* @@ -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. @@ -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; ifamily->word_mask(addr + (i<<2), expected); word = block [i]; if (word != expected) { conprintf(_("\nerror at address %08X: file=%08X, mem=%08X\n"),