I have tried compiling a version of the Caterina bootloader for an atmega32u2 chip. Both the compile and flashing of the bootloader work, except for one problem - no USB device shows up (using a Linux computer), but the D13 led flashes, so I know the bootloader is running.
I figure I must be missing something in either the descriptors.h file or the make file. Any suggestions? Does anyone have experience in working with the Caterina bootloader?
I've made several modified version of the Caterina bootloader but that's not so easy. To make it useful for the intended purpose you need to keep the size of the compiled code under 4kB, otherwise it won't fit into the reserved bootloader area. I got that running using the current IDE but not with the current LUFA code. What version of the LUFA code did you use? What size did you get?
Hmm. I am not sure how I am supposed to figure the size - both ways are way over 4k. Here is what I mean:
My hex file is 11k: -rw-rw----+ 1 scott scott 11K Feb 24 13:11 Caterina.hex
And avrdude says: avrdude: input file ./Caterina.hex contains 32468 bytes
If I compare to the stock Leonardo bootloader I get:
Hex file size = 75.9k
And avrdude says it is 32730 bytes
So it looks like my bootloader is a bit smaller, but I am confused how avrdude says it is 32k instead of less than 4k. If avrdude is reporting the number of bits instead of bytes, both do work out to be just under 4k. I am guessing that is it.
I also just ran make again, and it reports:
Program: 3796 bytes (11.6% Full)
(.text + .data + .bootloader)
The make file I am using is the one from Sparkfun (Caterina-LilyPadUSB) and I am using the specified LUFA-111009 . I tried using the VID/PID for Atmel 32u2 as well as Arduino Leonardo VID/PID - specified in the makefile.
Can you think of anything else I am missing or doing wrong?
The hex file contains a complete image of the ATmega flash memory. You can use avr-size to get the size of the contained segements. Relevant is the size of the segments in the .elf file, I never checked if the sizes in the hex file are the same.
The output of the "Program:" line is relevant, that seems to be less than 4k.
No you can send the bootloader to the board by calling:
make program
That should call avrdude with the appropriate flags.
It interesting that you get such a big .hex file, mine is about 11k with booloader code of 4028 bytes.
If that doesn't work, post your complete code, maybe we find something in there that doesn't do what you intended it to do.