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 avrdude-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/avrdude-dev