Skip to content

Commit 28147b7

Browse files
committed
Added verification word mask for missing config bits
1 parent 550f656 commit 28147b7

File tree

6 files changed

+32
-4
lines changed

6 files changed

+32
-4
lines changed

src/families/family-mx1.c

+4
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,7 @@ void print_mx1(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
356356
else
357357
printf(" VBuson pin: controlled by port\n");
358358
}
359+
360+
unsigned word_mask_mx1(unsigned address, unsigned word) {
361+
return word;
362+
}

src/families/family-mx3.c

+4
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,7 @@ void print_mx3(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
382382
else
383383
printf(" VBuson pin: controlled by port\n");
384384
}
385+
386+
unsigned word_mask_mx3(unsigned address, unsigned word) {
387+
return word;
388+
}

src/families/family-mz.c

+4
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,7 @@ void print_mz(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
374374
else
375375
printf(" USBID pin: controlled by port\n");
376376
}
377+
378+
unsigned word_mask_mz(unsigned address, unsigned word) {
379+
return word;
380+
}

src/families/family-xlp.c

+8
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,11 @@ void print_xlp(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3)
410410
else
411411
printf(" VBuson pin: controlled by port\n");
412412
}
413+
414+
unsigned word_mask_xlp(unsigned address, unsigned word) {
415+
// DEVCFG0's highest bit doesn't exist.
416+
if (address == 0x9FC02FFC) {
417+
return word & 0x7FFFFFFF;
418+
}
419+
return word;
420+
}

src/include/target.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
#include "adapter.h"
1616

1717
typedef void print_func_t(unsigned cfg0, unsigned cfg1, unsigned cfg2, unsigned cfg3);
18+
typedef unsigned word_mask_func_t(unsigned address, unsigned word);
1819

1920
typedef struct {
2021
const char *name;
2122
unsigned boot_kbytes;
2223
unsigned devcfg_offset;
2324
unsigned bytes_per_row;
2425
print_func_t *print_devcfg;
26+
word_mask_func_t *word_mask;
2527
const unsigned *pe_code;
2628
unsigned pe_nwords;
2729
unsigned pe_version;

src/target.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ extern print_func_t print_mx3;
2929
extern print_func_t print_mz;
3030
extern print_func_t print_xlp;
3131

32+
extern word_mask_func_t word_mask_mx1;
33+
extern word_mask_func_t word_mask_mx3;
34+
extern word_mask_func_t word_mask_xlp;
35+
extern word_mask_func_t word_mask_mz;
36+
3237
extern unsigned long open_retries;
3338

3439
/*
@@ -37,16 +42,16 @@ extern unsigned long open_retries;
3742
/*-Boot-Devcfg--Row---Print------Code--------Nwords-Version-*/
3843
static const
3944
family_t family_mx1 = { "mx1",
40-
3, 0x0bf0, 128, print_mx1, pic32_pemx1, 422, 0x0301 };
45+
3, 0x0bf0, 128, print_mx1, word_mask_mx1, pic32_pemx1, 422, 0x0301 };
4146
static const
4247
family_t family_xlp = { "xlp",
43-
12, 0x2ff0, 512, print_xlp, pic32_pemx3, 1044, 0x0201 };
48+
12, 0x2ff0, 512, print_xlp, word_mask_xlp, pic32_pemx3, 1044, 0x0201 };
4449
static const
4550
family_t family_mx3 = { "mx3",
46-
12, 0x2ff0, 512, print_mx3, pic32_pemx3, 1044, 0x0201 };
51+
12, 0x2ff0, 512, print_mx3, word_mask_mx3, pic32_pemx3, 1044, 0x0201 };
4752
static const
4853
family_t family_mz = { "mz",
49-
80, 0xffc0, 2048, print_mz, pic32_pemz, 1052, 0x0502 };
54+
80, 0xffc0, 2048, print_mz, word_mask_mz, pic32_pemz, 1052, 0x0502 };
5055
/*
5156
* This one is a special one for the bootloader. We have no idea what we're
5257
* 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,
773778
t->adapter->read_data(t->adapter, addr, nwords, block);
774779
for (i=0; i<nwords; i++) {
775780
expected = data [i];
781+
expected = t->family->word_mask(addr + (i<<2), expected);
776782
word = block [i];
777783
if (word != expected) {
778784
conprintf(_("\nerror at address %08X: file=%08X, mem=%08X\n"),

0 commit comments

Comments
 (0)