| Author |
Message |
|
|
Posted: Nov 05, 2009 - 01:07 PM |
|

Joined: Dec 15, 2008
Posts: 923
Location: Brisbane, Australia
|
|
|
wandererwolf wrote:
I just got damien_d's port of the AVR1605 note to avr-gcc to work on the www.bostonandroid.com Xmega64a3 board. Some minor mods for page sizes and num pages. I also modified the avrdude.conf file included in winavr-20090313. It looks like the latest version of AVRDude is already configured for all the xmega chips, but I didn't see a precompiled exe for windows.
-Paul
Cool. Thanks. I never expected my dirty hack to be ported to anything else
-- Damien |
|
|
| |
|
|
|
|
|
Posted: Nov 05, 2009 - 01:14 PM |
|


Joined: Oct 30, 2006
Posts: 29
Location: Boston, MA
|
|
| Now that I've read the errata I'm surprised it works too! I loaded a simple test program with the bootloader that was only 600bytes but it loaded and verified without error and appeared to be running fine. I'll try with a much larger program and see if there are any issues. But as you say, perhaps I have a newer rev of the chip. I also just got a 128A3; I'll see if I can get that one working as well. |
|
|
| |
|
|
|
|
|
Posted: Nov 07, 2009 - 01:35 PM |
|


Joined: Oct 30, 2006
Posts: 29
Location: Boston, MA
|
|
Okay. So I got the bootloader to work on the 128A3 as well. But there was a serious problem with the chip. It appears the PORTD USART is not working. Transmit is fine but the receive flag never clears when you read the data buffer. I worked around the problem by moving to PORTE USART and all is working fine.
-Paul |
|
|
| |
|
|
|
|
|
Posted: Nov 08, 2009 - 02:17 AM |
|

Joined: Jan 15, 2009
Posts: 15
|
|
Just for the fun of it, I gave it a go on my Xmega256a3 and ended up with the exact same symptoms as obor00.
Code:
avrdude: verification error, first mismatch at byte 0x0000
0x0c != 0xff
|
|
|
| |
|
|
|
|
|
Posted: Nov 10, 2009 - 10:53 PM |
|

Joined: Aug 28, 2008
Posts: 82
Location: France
|
|
| I now have a bootloader working for my xmega192A3. It is a port of the workaround from Atmel application note 1008 (sleep to write) to the assembly code + some changes to the address size passing for some functions. The new bootloader compiles under avrstudio 4.17 with avr-gcc. Once it has been flashed with stk600 + avrstudio through USB, the xmega can be flashed on the stk600 from avrdude + USB/serial cable. |
|
|
| |
|
|
|
|
|
Posted: Nov 11, 2009 - 01:36 AM |
|

Joined: Jan 15, 2009
Posts: 15
|
|
|
obor00 wrote:
I now have a bootloader working for my xmega192A3. It is a port of the workaround from Atmel application note 1008 (sleep to write)
I'm pleased to hear that you were able to make it work, and that the workaround works in practice. |
_________________ -Raliegh
|
| |
|
|
|
|
|
Posted: Nov 11, 2009 - 10:02 PM |
|

Joined: Aug 28, 2008
Posts: 82
Location: France
|
|
Thanks Raliegh.
I have attached my new version of the bootloader with workaround for Atmega192a3. It should also probably work for x256a3 and lowers with some defines tuning and compilation option. It has been compiled and flash with avr-studio v4.17. Usart speed is set to 19200, Port D. Several options at compilation are needed. It's just a dirty hack.
Olivier |
|
|
| |
|
|
|
|
|
Posted: Nov 12, 2009 - 02:57 AM |
|

Joined: Jan 15, 2009
Posts: 15
|
|
Well done. I tweaked as needed and it works nicely on the x256a3.
Thank you. |
_________________ -Raliegh
|
| |
|
|
|
|
|
Posted: Dec 02, 2009 - 10:31 PM |
|


Joined: Mar 28, 2001
Posts: 20311
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
So that I don't have to spend the rest of my life reading this thread...
Does the Xmega128A1 bootloader now work?
Does it work with USARTC0?
Now that we seem to have the USART bridge working reasonably well in the Xplain board (ok a little slowish but 1M times better than original) can this bootloader be used wih the Xplain board? |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Dec 02, 2009 - 10:44 PM |
|

Joined: Dec 15, 2008
Posts: 923
Location: Brisbane, Australia
|
|
|
js wrote:
So that I don't have to spend the rest of my life reading this thread...
Does the Xmega128A1 bootloader now work?
Yes. But check the caveat of the chip revision at the start. About halfway down the first page there is a version wiht fixes.
Quote:
Does it work with USARTC0?
Yes, but you'll need to adjust the config file to suit (simple).
Quote:
Now that we seem to have the USART bridge working reasonably well in the Xplain board (ok a little slowish but 1M times better than original) can this bootloader be used wih the Xplain board?
No idea. Haven't touch an xplain board. |
|
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 07:52 AM |
|


Joined: Mar 28, 2001
Posts: 20311
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
|
Quote:
Haven't touch an xplain board.
That's where I come in well if I can get my head around the bootloader mods. |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 11:17 AM |
|

Joined: Aug 28, 2008
Posts: 82
Location: France
|
|
By the way, I have modified my version of the bootloader to work in 57600bps and not use any pin to enter bootload mode, but timeout (similarly to an arduino).
If anyone is interested, I can put it somewhere in the forum.
Olivier |
|
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 11:18 AM |
|

Joined: Dec 15, 2008
Posts: 923
Location: Brisbane, Australia
|
|
|
obor00 wrote:
By the way, I have modified my version of the bootloader to work in 57600bps and not use any pin to enter bootload mode, but timeout (similarly to an arduino).
If anyone is interested, I can put it somewhere in the forum.
Olivier
More the merrier.
-- Damien |
|
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 12:06 PM |
|

Joined: Feb 12, 2005
Posts: 16255
Location: Wormshill, England
|
|
John,
The AVR1605 bootloader works fine on the Xplain board. I just configured for USART #C0 and used PORTF.3 as a handy push-button to hold down during reset.
The supplied AVROSP scripts will not allow a port > COM9. But this is the fault of AvrOsp.exe. I found it easier to reassign to COM8.
The Bootloader will not work with Studio, because Studio will not try 9600 baud.
CodeVision will recognise the Bootloader, but since it does not believe that a STK500 can program an xmega, this does not work either.
However you should find no problem with AvrOsp.exe or with AvrDude.exe
David. |
|
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 06:33 PM |
|


Joined: Oct 30, 2006
Posts: 29
Location: Boston, MA
|
|
| Has anyone been able to program Xmega fuse bits with this bootloader? I have not been able to read or write fuse bits with avrdude 5.6 and ATXMega128a3 with my version of the bootloader. Flash and EEPROM work just fine to read or write. |
|
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 06:46 PM |
|


Joined: Jul 18, 2005
Posts: 62209
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
I have not been able to read or write fuse bits with avrdude 5.6 and ATXMega128a3 with my version of the bootloader. Flash and EEPROM work just fine to read or write.
The Xmega allow running code to write their own fuses do they? No previous AVRs allowed this - it was the common limitation of using a bootloader that not only did you need ISP/JTAG to get the bootloader image programmed in the first place but also to make any fuse adjustments then or later on. |
_________________
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 09:28 PM |
|


Joined: Mar 28, 2001
Posts: 20311
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)
|
|
|
Quote:
The AVR1605 bootloader works fine on the Xplain board.
Well then, no need for me to go any further I may mess around if I get time, but I don't really need it.
So it may be good to try to push the usart bridge to run a little faster for bootloading purposes?
Anyway if Dean gets the PDI programming working that will be the best solution.
In order to switch between usart bridge and programmer the 2 pins near the SDRAM could be used (GND and PDI), if a link is fitted then go into programming mode otherwise usart bridge mode. |
_________________ John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
|
| |
|
|
|
|
|
Posted: Dec 03, 2009 - 09:58 PM |
|

Joined: Feb 12, 2005
Posts: 16255
Location: Wormshill, England
|
|
I spoke too soon. I have the AVR1605 loading/saving memory via AVROSP quite happily.
However I am not running bootloaded programs yet. It seems to be in permanent boot mode.
When the PDI programming is working, the xmega should be able to receive the instructions as fast as the 1287 hardware USART can send it.
AVR1605 bootloading at 9600 baud is not for the faint hearted. But the PDI will be the same speed as JTAG.
David. |
|
|
| |
|
|
|
|
|
Posted: Dec 04, 2009 - 01:57 PM |
|


Joined: Sep 27, 2001
Posts: 206
Location: North of Pittsburgh
|
|
|
clawson wrote:
Quote:
I have not been able to read or write fuse bits with avrdude 5.6 and ATXMega128a3 with my version of the bootloader. Flash and EEPROM work just fine to read or write.
The Xmega allow running code to write their own fuses do they?
Not really, unless you can issue a PDI Write from inside the running code, which I do not think is possible.
Code:
30.12.3NVM Commands
The NVM commands that can be used for accessing the NVM memories from external programming are listed in Table 30-5. This is a super-set of the commands available for self-programming.
Fuse Write is one of the 'super-set' commands.
Don't know if the A3 is the same as A1, this is what I do in the A1:
Code:
if(
/* (FUSEBYTE0 == SP_ReadFuseByte( 0 ) ) && Manual doesn't match reality, we don't use JTAGID */
(FUSEBYTE1 == SP_ReadFuseByte( 1 )) &&
(FUSEBYTE2 == SP_ReadFuseByte( 2 )) &&
/* There is no FUSEBYTE3 */
(FUSEBYTE4 == SP_ReadFuseByte( 4 )) &&
(FUSEBYTE5 == SP_ReadFuseByte( 5 )) &&
(LOCK_BITS == NVM_LOCKBITS)
)
)
{
selftest_u16 &= ((uint16_t) ~SELFTEST_FUSES); /* Passed */
}
Code:
#include <avr/io.h>
#define NVM_CMD_READ_FUSES_gc (0x07<<0) // Read fuse byte
.extern SP_CommonCMD
; ---
; This routine reads the fuse byte given by the index in R24.
;
; Input:
; R24 - Byte index.
;
; Returns:
; R24 - Fuse byte.
; ---
.section .text
.global SP_ReadFuseByte
SP_ReadFuseByte:
sts NVM_ADDR0, r24 ; Load fuse byte index into NVM Address Register 0.
clr r24 ; Prepare a zero.
sts NVM_ADDR1, r24 ; Load zero into NVM Address Register 1.
sts NVM_ADDR2, r24 ; Load zero into NVM Address Register 2.
ldi r20, NVM_CMD_READ_FUSES_gc ; Prepare NVM command in R20.
rcall SP_CommonCMD ; Jump to common NVM Action code.
movw r24, r22 ; Move low byte to 1 byte return address.
ret
Broken out of one of the XMega app. notes:
Code:
#include <avr/io.h>
#define NVM_CMD_NO_OPERATION_gc (0x00<<0) // NoOp/Ordinary LPM
#define CCP_IOREG_gc (0xD8<<0) // IO Register Protection
; ---
; This routine is called by several other routines, and contains common code
; for executing an NVM command, including the return statement itself.
;
; If the operation (NVM command) requires the NVM Address registers to be
; prepared, this must be done before jumping to this routine.
;
; Note that R25:R24:R23:R22 is used for returning results, even if the
; C-domain calling function only expects a single byte or even void.
;
; Input:
; R20 - NVM Command code.
;
; Returns:
; R25:R24:R23:R22 - 32-bit result from NVM operation.
; ---
.section .text
.global SP_CommonCMD
SP_CommonCMD:
sts NVM_CMD, r20 ; Load command into NVM Command register.
ldi r18, CCP_IOREG_gc ; Prepare Protect IO-register signature in R18.
ldi r19, NVM_CMDEX_bm ; Prepare bitmask for setting NVM Command Execute bit into R19.
sts CCP, r18 ; Enable IO-register operation (this disables interrupts for 4 cycles).
sts NVM_CTRLA, r19 ; Load bitmask into NVM Control Register A, which executes the command.
lds r22, NVM_DATA0 ; Load NVM Data Register 0 into R22.
lds r23, NVM_DATA1 ; Load NVM Data Register 1 into R23.
lds r24, NVM_DATA2 ; Load NVM Data Register 2 into R24.
ldi r25, NVM_CMD_NO_OPERATION_gc ; Prepare NVM command code
sts NVM_CMD, r25 ; Set NVM command to No Operation for clean operation to follow
clr r25 ; Clear R25 in order to return a clean 32-bit value.
ret
|
|
|
| |
|
|
|
|
|
Posted: Dec 04, 2009 - 01:59 PM |
|


Joined: Sep 27, 2001
Posts: 206
Location: North of Pittsburgh
|
|
| [quote="js"]
Quote:
So it may be good to try to push the usart bridge to run a little faster for bootloading purposes?
There is no gain if the memory write time is the speed limiting factor. |
|
|
| |
|
|
|
|
|