avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] ATMega2560 and stk500


From: Alan Horstmann
Subject: [avrdude-dev] ATMega2560 and stk500
Date: Sat, 7 Dec 2013 13:46:27 +0000
User-agent: KMail/1.9.1

Hi list,

I have subscribed in order to report/discuss an issue with avrdude, and one 
working solution.  Apologies if this is not the preferred way.  Also I am 
aware it is possible I may have mis-diagnosed.

In brief:
When programming the ATMega2560 using an stk500 (v1) compatible ISP, avrdude 
doesn't set the extended address byte in the target device.  As a result it 
cannot be certain whether it is programming above or below the 128K bytes 
threshold.  One manifestation of this is reports of verify errors at 0x1e000 
when programming the Mega2560 bootloader using the ArduinoISP.  A patch that 
resolves this is attached - modifying the stk500 code to set the extended 
byte when necessary.

More details:
The stk500 v1 protocol only allows 2 bytes for the (word) address, so with 
this type of programmer, flash >128K has to be handled specially (within 
avrdude).  Since stk500 also does not include a dedicated means to set the 
extended addr byte, it has to be done using cmd-universal direct to the 
target SPI.

The stk500 programming process has been studied in detail with a logic 
analyser, capturing Tx, Rx and all SPI signals for the whole 90s of a 
bootloader programming cycle on the Mega2560.  Nowhere is the ext-addr-byte 
set.  When the whole of flash is read for the verify, whichever half is 
presently set in the target device is actually read through twice. On my test 
unit, this was always the upper half, so the bootloader appears to 
avrdude-read 'ghosted' at the top of the lower half of flash as well as at 
the top of the upper half.  This gives the verify error.  It is in this case 
not possible to read or write the real lower half of flash.

At present I have continued to use avrdude 5.11.1 as 6.0.1 doesn't build 
(separate issue) but I don't see any indication that the ext addr has been 
identified and resolved in the later release - please correct me if it has.

The patch here for stk500.c adds an extended address byte cmd for any device 
where the flash size >128K, and sets it initially and when a 128K boundary is 
crossed.  With these changes the bootloader program completes without errors, 
and it is clear from the analyser that the correct memory locations are now 
being accessed.  This is not necessarily a 'final' patch, but should apply to 
6.01 cleanly.

This could be fixed in other different ways - and may be better pushed up the 
layers in avrdude into avr.c; I am posting for your comments, awareness etc.  
If there is important info missed, ask and I will try to respond.

Hope this is useful,

Regards

Alan

Attachment: stk500-256K-fix.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]