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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Joerg Wunsch-6
URL:
  <http://savannah.nongnu.org/bugs/?51117>

                 Summary: Problems with extended address (>128K) and buffer
size
                 Project: AVR Downloader/UploaDEr
            Submitted by: tozzi
            Submitted on: 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
        Originator Email:
             Open/Closed: Open
                 Release: 6.3
         Discussion Lock: Any
     Programmer hardware: AVROSP (Butterfly)
             Device type: ATXMega256A3(U)

    _______________________________________________________

Details:

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",
                   PDATA(pgm)->buffersize);
 
@@ -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




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51117>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Joerg Wunsch-6
Follow-up Comment #1, bug #51117 (project avrdude):

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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51117>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Joerg Wunsch-6
Follow-up Comment #2, bug #51117 (project avrdude):

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).

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51117>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Joerg Wunsch-6
Follow-up Comment #3, bug #51117 (project avrdude):

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).

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51117>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Joerg Wunsch-6
Follow-up Comment #4, bug #51117 (project avrdude):

Thanks!
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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51117>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Joerg Wunsch-6
Follow-up Comment #5, bug #51117 (project avrdude):

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:

make
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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51117>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Joerg Wunsch-6
Follow-up Comment #6, bug #51117 (project avrdude):

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?

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51117>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Loading...