bugAVR Downloader/UploaDEr - Bugs: bug #51117, Problems with extended address...


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

bug #51117: Problems with extended address (>128K) and buffer size

Submitter:  Stephan Schreiber <tozzi>
Submitted:  Thu 25 May 2017 11:16:43 PM UTC
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Privacy:  Public
Assigned to:  None Originator Name:  Stephan Schreiber
Open/Closed:  Open Release:  6.3
Programmer hardware:  AVROSP (Butterfly) Device type:  ATXMega256A3(U)

Jump to the original submission

Fri 16 Jun 2017 03:34:35 AM UTC, comment #6: 

And as I am looking at all of this, please excuse my ignorance, would changes to the butterfly.c file have any affect on my circumstance where I am attempting to use the "linuxgpio" programmer?

Mike <smbrandonjr>
Fri 16 Jun 2017 03:28:40 AM UTC, comment #5: 

So I got avrdude reinstalled on my raspberry pi and working the way it was before...which was the verification was failing on a flash where file is 152kb.

I made changes to the butterfly.c file but am not sure I am taking the proper steps afterwards. The steps I did take were to:

sudo make install

My thought process was that this would recompile avrdude with my changes to butterfly.c. Am I wrong on this? Apologies as this is a new realm for me and I am learning as I go.

Mike <smbrandonjr>
Fri 16 Jun 2017 01:37:18 AM UTC, comment #4: 

I hope the maintainer of this project returns and takes care of our issues.
Do let me know if the patch worked for you! Fingers crossed.

Stephan Schreiber <tozzi>
Fri 16 Jun 2017 01:31:54 AM UTC, comment #3: 

I totally understand. I made the changes manually. Reason I am not using 6.3 is because I ran into issues using GPIO on my raspberry pi with 6.3. Could never get it work but 6.1 would work fine. Thanks for the patch, I will report back if it is successful in 6.1 (running into other issues with my raspberry pi preventing me from testing it at the moment).

Mike <smbrandonjr>
Thu 15 Jun 2017 10:24:46 PM UTC, comment #2: 

I'd love to help, but I'm actually still quite busy reinventing the wheel and porting the whole thing to Swift, using ORSSerial Library.
Can't you switch to 6.3? OTOH, this patch would be quite easy to apply manually.
Just look for the corresponding section in butterfly.c (butterfly_set_addr).

Stephan Schreiber <tozzi>
Thu 15 Jun 2017 09:07:03 PM UTC, comment #1: 

Any chance you have or could create a patch for version 6.1? I tried to applyu this patch but get a malformed patch at line 13. I assume due to differing butterfly.c files betwen version 6.1 and 6.3.

Mike <smbrandonjr>
Thu 25 May 2017 11:16:43 PM UTC, original submission:  

Using a black-box (client-provided) which is connected via Ft232R USB adapter, most likely ancient boot loader, following AVROSP protocol (and working correctly with avrosp.exe).
My job here is to port a Windows Firmware Updater (using avrosp.exe) to Mac OS X.

ATXMega256A3 (might be -U, can't find out without disassembling the unit which I am clearly not supposed to do).

Due to NDA I cannot disclose any further details, but I can provide a partial serial log if you're interested.
I've analyzed serial communications and that's how I finally found out what is going wrong there.

For some reason, buffer size is reported as 0x0080 (128 bytes) and the update process fails, as 512 bytes (page size correctly given in avrdude.conf). are expected.

The even more serious problem, however, is that extended addressing is not being used by avrdude in this case.
"A" 0xff00" becomes "A" 0x0000 instead of "H" 0x010000", thus overwriting flash memory from the beginning instead of appending the code properly.

I have applied this (rough) patch, which makes it work; just wanted to let you know.
I probably can't use avrdude anyway, because of the restrictions GPL would impose.

Anyway, here's the patch:

--- butterfly.c.orig 2014-07-16 22:14:58.000000000 +0200
+++ butterfly.c 2017-05-23 22:49:20.000000000 +0200
@@ -321,6 +321,10 @@
   PDATA(pgm)->buffersize = (unsigned int)(unsigned char)c<<8;
   butterfly_recv(pgm, &c, 1);
   PDATA(pgm)->buffersize += (unsigned int)(unsigned char)c;
+  // overriding it for now
+  PDATA(pgm)->buffersize = 512;
   avrdude_message(MSG_INFO, "Programmer supports buffered memory access with buffersize=%i bytes.\n",
@@ -424,6 +428,7 @@
 static void butterfly_set_addr(PROGRAMMER * pgm, unsigned long addr)
+if( addr < 0x10000 ) {
   char cmd[3];
   cmd[0] = 'A';
@@ -432,6 +437,19 @@
   butterfly_send(pgm, cmd, sizeof(cmd));
   butterfly_vfy_cmd_sent(pgm, "set addr");
+  } else {
+  char cmd[4];
+  cmd[0] = 'H';
+  cmd[1] = (addr >> 16) & 0xff;
+  cmd[2] = (addr >> 8) & 0xff;
+  cmd[3] = addr & 0xff;
+  butterfly_send(pgm, cmd, sizeof(cmd));
+  butterfly_vfy_cmd_sent(pgm, "set extaddr"); 
+  }

Best regards,

Stephan Schreiber <tozzi>


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

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by tozzi (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.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code