Page 1 of 2

AVRUSBBoot ATMega1281

Posted: Fri Mar 28, 2008 2:10 pm
by Ludger
Hi there,

I tried to compile the AVRUSBBoot from www.fischl.de for the ATMEga1281. I changed the GICR to MCUCR because the IVCE and the IVSEL Bits are there.

If I copile it with BOOTLOADER_ADDRESS = 0 it seems to work fine (AVRUSBBoot is detected by libusb win32 Devices). If I compile it with BOOTLOADER_ADDRESS = 1f800 and program the corresponding Fuse Bits in the high fuse to 0x9c (1024 words of BootSize and Reset vector to boot area) I get always Unkown Device from my Win2k prof.

At least, I changed the PRG_RDB so that it uses elpm and not lpm and also set RAMPZ to 1.

All ideas are welcome :-)

Posted: Fri Mar 28, 2008 3:11 pm
by christian
The compiler uses absolute addressing on bigger devices. Have you told the linker to set the base address accordingly?

Posted: Fri Mar 28, 2008 4:14 pm
by Ludger
I don't know if I've understand correct. I told the Linker following line:

LDFLAGS += -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS)

while BOOTLOADER_ADDRESS = 1f800 as in my question posted.

Posted: Fri Mar 28, 2008 4:33 pm
by christian
That should be correct, but I have never tried so large devices myself, so I don't know for sure.

Posted: Fri Mar 28, 2008 6:33 pm
by Ludger
I checked my Hex File and it seems to be ok (Addresses start at 1f800). Also I've made a WinAVR Version of an AVR Assembler Bootloader so I think worked with the BootFuses more than once.

I think the problem reside either round the interrupt shifting or in the access of the VID and PID and strings out of the program aerea which is greater than 0x10000.

Posted: Sat Mar 29, 2008 2:00 pm
by christian
Please try enabling debug mode in a 4k boot section. If it's a problem with descriptor addressing, you should see that wrong data is sent to the host for getDescriptor requests. If it's a problem with interrupt vectors, the program should crash pretty soon.

Posted: Sat Mar 29, 2008 11:33 pm
by Ludger
I got it working :-)

With bootloader address at 1e000 (4k words of bootsection) it works.
I've not tried yet the other section sizes. If I know more about the problem I will post it again.

Posted: Mon Mar 31, 2008 2:32 pm
by christian
It's possible that the code exceeds 2k due to the longer addressing instructions. You van check the size with avr-size main.hex.

Posted: Mon Mar 31, 2008 5:37 pm
by Ludger
No, IO checked it and the size was ~ 2000 Byte. But I've another problem. I tried to program a bigger application into my ATMega1281 from ~ 22kByte in Size. Always it runs up to page 48 and while programming the 49th page a "wrong bytecount in writepage: 0 !" appears. Is there any limitation in the USB driver, which could cause this problem?

Thanks in advance and for your information up to know, Ludger

Posted: Tue Apr 01, 2008 2:55 pm
by christian
This can't be a limitation of the driver because the same request is used for all pages. It may be a limitation of the bootloader, though.

Posted: Tue Apr 01, 2008 11:57 pm
by Ludger
Now it works fine :-) I've had a bug in my AVR Firmware. Unfortunately uploding works only for the first 64kByte and I'm not very firm with CPP.

It doesn't matter at least, because I got the ATMega1281 from a collegue and put it on my old STK300 from Kanda only for fun After that I discovered the USBDRV and soldered a USB Tybe-B at PORTD and tried to convert the software from www.fischl.de. I've not often needed more than 64kByte on an AVR and so I'm happy with the state I've reached now. :)

Posted: Wed Apr 02, 2008 10:48 am
by christian
You can try USBaspLoader. It requires some changes in the source code because it needs to know the signature bytes of the target chip, but it has an option for >64k flash blocks (although that has not been tested yet). For >64k addressing, you probably have to drop EEPROM support so that it fits into 2k boot sections.

Posted: Fri Apr 11, 2008 4:55 pm
by Ludger
My AVRUSBBoot on the ATMega1281 is still working now. I've made some changes at the C++ software to use hexfiles > 0x10000 and now I'm happy. If anyone is interested in code please give me a short reply where I should upload it :-)

Posted: Sat Apr 12, 2008 8:56 pm
by christian
You can mail patches to Thomas Fischl. If he does not respond, please consider adding something to our Wiki at http://avrusb.wikidot.com/, then post a link here in the forum.

Posted: Mon Aug 11, 2008 12:45 am
by drTuk
Ludger,

Do you got these errors?

Code: Select all

> "make.exe" all
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega128 -c usbdrv/usbdrv.c -o usbdrv/usbdrv.o
usbdrv/usbdrv.c: In function 'usbInit':
usbdrv/usbdrv.c:503: warning: cast from pointer to integer of different size
usbdrv/usbdrv.c:504: warning: cast from pointer to integer of different size
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega128 -x assembler-with-cpp -c usbdrv/usbdrvasm.s -o usbdrv/usbdrvasm.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega128 -c usbdrv/oddebug.c -o usbdrv/oddebug.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega128 -c main.c -o main.o
In file included from main.c:25:
c:/winavr-20080610/lib/gcc/../../avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete.  Use <avr/interrupt.h>."
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega128 -o main.bin usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,--section-start=.text=1e000
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
./checksize main.bin
process_begin: CreateProcess(NULL, ./checksize main.bin, ...) failed.
make (e=193): Error 193
make.exe: *** [main.hex] Error 193




If yes please can tell me how to solve it?

Do you tryied to make a AES crypto uploader like Oleg´s code?
Because I need a solution like Oleg´s code but only have troubles to port it to avr-gcc and m128 device.

please, if you have some idea, look here my situation:

http://forums.obdev.at/viewtopic.php?t= ... 6336480218

regards

DrTK