bugAVR Downloader/UploaDEr - Bugs: bug #50261, JTAG1 unable to write fuse and...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #50261: JTAG1 unable to write fuse and lock bits

Submitter:  None
Submitted:  Thu 09 Feb 2017 09:40:51 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Privacy:  Public
Assigned to:  None Originator Name:  Stefan Mavrodiev
Originator Email:  -email is unavailable- Open/Closed:  Open
Release:  SVN snapshot Programmer hardware: 
Device type: 

Thu 09 Feb 2017 09:40:51 AM UTC, original submission:  

Hello,

I'm using AVR-JTAG-USB from Olimex, witch is clone to AVR-JTAGICE.
I was unable to write fuses and lock bits.

$ avrdude -c jtag1 -p c128 -P /dev/ttyUSB0 -b19200 -U lfuse:w:0xCF:m

avrdude: jtagmkI_initialize(): warning: OCDEN fuse not programmed, single-byte EEPROM updates not possible
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e9781 (probably c128)
avrdude: reading input file "0xCF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xCF:
avrdude: load data lfuse data from input file 0xCF:
avrdude: input file 0xCF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading |                                                    | 0% 0.00savrdude: jtagmkI_read_byte(): timeout/error communicating with programmer (resp )
avr_read(): error reading address 0x0000
    read operation not supported for memory "lfuse"
avrdude: failed to read all of lfuse memory, rc=-2

avrdude: jtagmkI_read_byte(): timeout/error communicating with programmer (resp )
avrdude: jtagmkI_read_byte(): timeout/error communicating with programmer (resp )
avrdude: jtagmkI_read_byte(): timeout/error communicating with programmer (resp )
avrdude: jtagmkI_read_byte(): timeout/error communicating with programmer (resp )
avrdude: safemode: Sorry, reading back fuses was unreliable. I have given up and exited programming mode

avrdude done.  Thank you.

This is the same with lock and calibration bits.

I've notice that after write the response message has one additional ACK byte.

avrdude: jtagmkI_send(): sending 6 bytes
avrdude: Send: W [57] . [b2] . [00] . [00] . [00] . [00]   [20]   [20]
avrdude: Recv: A [41]

avrdude: jtagmkI_send(): sending 2 bytes
avrdude: Send: h [68] . [cf]   [20]   [20]
avrdude: Recv: A [41]

Here you can see write is ok, but on following read:
avrdude: jtagmkI_send(): sending 6 bytes
avrdude: Send: R [52] . [b2] . [02] . [00] . [00] . [00]   [20]   [20]
avrdude: Recv: A [41] A [41] . [cf] . [99] . [fe] . [00]

You can see the extra 'A'. Maybe this is AVR-JTAGICE bug.

What I did in the patch is after sending datacmd read 2 bytes, not 1.

Index: jtagmkI.c
===================================================================
--- jtagmkI.c (revision 1392)
+++ jtagmkI.c (working copy)
@@ -1056,7 +1056,7 @@
 {
   unsigned char cmd[6], datacmd[1 * 2 + 1];
   unsigned char resp[1], writedata;
-  int len, need_progmode = 1;
+  int len, need_progmode = 1, need_dummy_read = 0;
 
   avrdude_message(MSG_NOTICE2, "%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n",
      progname, mem->desc, addr);
@@ -1073,17 +1073,22 @@
     PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
   } else if (strcmp(mem->desc, "lfuse") == 0) {
     cmd[1] = MTYPE_FUSE_BITS;
+    need_dummy_read = 1;
     addr = 0;
   } else if (strcmp(mem->desc, "hfuse") == 0) {
     cmd[1] = MTYPE_FUSE_BITS;
+    need_dummy_read = 1;
     addr = 1;
   } else if (strcmp(mem->desc, "efuse") == 0) {
     cmd[1] = MTYPE_FUSE_BITS;
+    need_dummy_read = 1;
     addr = 2;
   } else if (strcmp(mem->desc, "lock") == 0) {
     cmd[1] = MTYPE_LOCK_BITS;
+    need_dummy_read = 1;
   } else if (strcmp(mem->desc, "calibration") == 0) {
     cmd[1] = MTYPE_OSCCAL_BYTE;
+    need_dummy_read = 1;
   } else if (strcmp(mem->desc, "signature") == 0) {
     cmd[1] = MTYPE_SIGN_JTAG;
   }
@@ -1152,6 +1157,8 @@
       avrdude_message(MSG_NOTICE2, "OK\n");
   }
 
+  if(need_dummy_read)
+    jtagmkI_recv(pgm, resp, 1);
   return 0;
 }


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #39707:  jtagmkI.patch added by None (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-02-09 None Attached File- Added jtagmkI.patch, #39707

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code