summaryrefslogtreecommitdiff
path: root/devel/arduino-avrdude/files/patch-avr.c
diff options
context:
space:
mode:
authorBoris Samorodov <bsam@FreeBSD.org>2017-04-19 19:36:33 +0000
committerBoris Samorodov <bsam@FreeBSD.org>2017-04-19 19:36:33 +0000
commitbdbfd539751bd7b4cb86365691fc200d73cdbc53 (patch)
tree61716a0faf310e819846d965e6c08115214c8b93 /devel/arduino-avrdude/files/patch-avr.c
parentdevel/arduino-ctags: Update arduino-ctags to 5.8-arduino11; (diff)
AVRDUDE - AVR Downloader/UploaDEr - is a program for updating the
flash, eeprom, and fuse bit memories of Atmel AVR microcontrollers. It operates with several programmers including STK500 and most directly connect parallel port style programmers. WWW: http://www.nongnu.org/avrdude/ PR: 218234 Submitted by: bsdports@kyle-evans.net
Diffstat (limited to 'devel/arduino-avrdude/files/patch-avr.c')
-rw-r--r--devel/arduino-avrdude/files/patch-avr.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/devel/arduino-avrdude/files/patch-avr.c b/devel/arduino-avrdude/files/patch-avr.c
new file mode 100644
index 000000000000..ad743233b785
--- /dev/null
+++ b/devel/arduino-avrdude/files/patch-avr.c
@@ -0,0 +1,67 @@
+--- avr.c.orig 2017-03-30 13:30:41 UTC
++++ avr.c
+@@ -1058,7 +1058,40 @@ int avr_signature(PROGRAMMER * pgm, AVRPART * p)
+ return 0;
+ }
+
++uint8_t get_fuse_bitmask(AVRMEM * m) {
++ uint8_t bitmask_r = 0;
++ uint8_t bitmask_w = 0;
++ int i, j;
+
++ if (m->size > 1) {
++ // not a fuse, compare bytes directly
++ return 0xFF;
++ }
++
++ for (i=0; i<AVR_OP_MAX; i++) {
++ if (m->op[i] && i == AVR_OP_READ) {
++ for (j=7; j>=0; j--) {
++ bitmask_r |= (m->op[i]->bit[j].type != AVR_CMDBIT_IGNORE) << j;
++ }
++ }
++ if (m->op[i] && i == AVR_OP_WRITE) {
++ for (j=7; j>=0; j--) {
++ bitmask_w |= (m->op[i]->bit[j].type != AVR_CMDBIT_VALUE &&
++ m->op[i]->bit[j].type != AVR_CMDBIT_IGNORE) << j;
++ }
++ }
++ }
++ return bitmask_r & bitmask_w;
++}
++
++int compare_memory_masked(AVRMEM * m, unsigned char buf1, unsigned char buf2) {
++ uint8_t bitmask = 0xFF;
++ if(m) {
++ bitmask = get_fuse_bitmask(m);
++ }
++ return ((buf1 & bitmask) != (buf2 & bitmask));
++}
++
+ /*
+ * Verify the memory buffer of p with that of v. The byte range of v,
+ * may be a subset of p. The byte range of p should cover the whole
+@@ -1104,11 +1137,18 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtyp
+ for (i=0; i<size; i++) {
+ if ((b->tags[i] & TAG_ALLOCATED) != 0 &&
+ buf1[i] != buf2[i]) {
+- avrdude_message(MSG_INFO, "%s: verification error, first mismatch at byte 0x%04x\n"
+- "%s0x%02x != 0x%02x\n",
+- progname, i,
+- progbuf, buf1[i], buf2[i]);
+- return -1;
++ if(compare_memory_masked(a , buf1[i], buf2[i])) {
++ avrdude_message(MSG_INFO, "%s: verification error, first mismatch at byte 0x%04x\n"
++ "%s0x%02x != 0x%02x\n",
++ progname, i,
++ progbuf, buf1[i], buf2[i]);
++ return -1;
++ } else {
++ avrdude_message(MSG_INFO, "%s: WARNING: invalid value for unused bits in fuse \"%s\", should be set to 1 according to datasheet\n"
++ "This behaviour is deprecated and will result in an error in future version\n"
++ "You probably want to use 0x%02x instead of 0x%02x (double check with your datasheet first).\n",
++ progname, memtype, buf1[i], buf2[i]);
++ }
+ }
+ }
+