atMega32U4 - Leonardo Bootloader - Compiling - question

Hello All

I have been away from Arduino for quite a while, and just coming back but am a little stuck with a new project I am plugging away at.

I have a custom board based on the Leonardo which I am wanting to slightly modify the bootloader, compile it and load it on, but am a little stuck.

I have been reading for a few hours, from posts which go back to 2012, but have got myself a little confused and I am hoping someone can put me back on the right track.

I have also never done this, so please bear with me.

What I am wanting to do is modify the Leonardo bootloader source, to remove the RX and TX LED code, as I have utilised those two GPIO's for other things. I want it otherwise left the same. I guess changing the name of what it comes up with would be a bonus too. I think I can modify the source OK, but I am unsure how to compile, or what programs I need.

I am on a windows machine.

I have seen WinAVR referenced, and in the Caterina-Leonardo.txt file in the bootloader folder, it states something about LUFA and then the various versions of things used. Do I need to use and install the same version of all of these in order to compile this bootloader? It mentions CrossPack too, which I can only gather is for Mac?

Basically if someone is able to tell me what I need to download, that would be a great start.

I looked at the Makefile, but am a little confused there too. It also talks about this LUFA thing, which from what I can understand is a way to get this chip to act like other USB devices, like a Keyboard etc, is that right? Or is it also used for default behaviour as per the Leonardo as it ships from factory?

Sorry - just confused.
Have been reading for too long I think, and unsure if information on older posts/sites is still relevant.

Some help would be greatly appreciated.

Regards
WanaGo

I found this post

http://forum.arduino.cc/index.php?topic=267125.0

Which is basically what I am wanting to do also!
Got up to Step 5, but I get:

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

make: *** No rule to make target Caterina.elf', needed by elf'. Stop.

ok that one seemed to have to do with my path in the Makefile.

I now get

C:\Users\James\Documents\4Duino>make

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling C: Caterina.c
avr-gcc -c -mmcu=atmega32u4 -I. -gdwarf-2 -DF_CPU=16000000UL -DF_USB=16000000UL -DBOARD=BOARD_USER -DARCH=ARCH_AVR8 -DBOOT_START_ADDR=0x7000UL -DDEVICE_VID=0x2341UL -DDEVICE_PID=0x
0036UL -D USB_DEVICE_ONLY -D DEVICE_STATE_AS_GPIOR=0 -D ORDERED_EP_CONFIG -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_RAM_DESCRIPTORS -D USE_STATIC_OPTION
S="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -D NO_INTERNAL_SERIAL -D NO_DEVICE_SELF_POWER -D NO_DEVICE_REMOTE_WAKEUP -D NO_SOF_EVENTS -D NO_LOCK_BYTE_WR
ITE_SUPPORT -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,
-adhlns=./Caterina.lst -I/LUFA/LUFA-111009/ -std=c99 -MMD -MP -MF .dep/Caterina.o.d Caterina.c -o Caterina.o
In file included from Caterina.h:48,
from Caterina.c:37:
Descriptors.h:40:36: warning: LUFA/Drivers/USB/USB.h: No such file or directory
In file included from Caterina.h:48,
from Caterina.c:37:
Descriptors.h:117: error: expected specifier-qualifier-list before 'USB_Descriptor_Configuration_Header_t'
Descriptors.h: In function 'CALLBACK_USB_GetDescriptor':
Descriptors.h:136: error: expected declaration specifiers before 'ATTR_WARN_UNUSED_RESULT'
In file included from Caterina.c:37:
Caterina.h:88: error: expected '=', ',', ';', 'asm' or 'attribute' before 'ATTR_NO_RETURN'
Caterina.h:101: error: storage class specified for parameter 'ReadWriteMemoryBlock'
Caterina.h:103: error: storage class specified for parameter 'FetchNextCommandByte'
Caterina.h:104: error: storage class specified for parameter 'WriteNextResponseByte'
Caterina.c:42: error: expected '=', ',', ';', 'asm' or 'attribute' before 'LineEncoding'
Caterina.c:45: error: expected declaration specifiers before ';' token
Caterina.c:51: error: storage class specified for parameter 'CurrAddress'
Caterina.c:57: error: storage class specified for parameter 'RunBootloader'
Caterina.c:57: error: parameter 'RunBootloader' is initialized
Caterina.c:66: error: parameter 'Timeout' is initialized
Caterina.c:68: error: parameter 'bootKey' is initialized
Caterina.c:69: error: parameter 'bootKeyPtr' is initialized
Caterina.c:72: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:96: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:112: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:163: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:197: warning: 'signal' attribute only applies to functions
Caterina.c:197: warning: 'used' attribute ignored
Caterina.c:197: warning: 'externally_visible' attribute ignored
Caterina.c:198: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:217: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:237: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:280: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:402: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:428: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:469: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Caterina.c:715: error: old-style parameter declarations in prototyped function definition
Caterina.c:713: error: expected '{' at end of input
Caterina.c:713: warning: no return statement in function returning non-void
make: *** [Caterina.o] Error 1

hmm

ok still paths related.
Solved now.

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling C: Caterina.c
avr-gcc -c -mmcu=atmega32u4 -I. -gdwarf-2 -DF_CPU=16000000UL -DF_USB=16000000UL -DBOARD=BOARD_USER -DARCH=ARCH_AVR8 -DBOOT_START_ADDR=0x7000UL -DDEVICE_VID=0x2341UL -DDEVICE_PID=0x
0036UL -D USB_DEVICE_ONLY -D DEVICE_STATE_AS_GPIOR=0 -D ORDERED_EP_CONFIG -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_RAM_DESCRIPTORS -D USE_STATIC_OPTION
S="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -D NO_INTERNAL_SERIAL -D NO_DEVICE_SELF_POWER -D NO_DEVICE_REMOTE_WAKEUP -D NO_SOF_EVENTS -D NO_LOCK_BYTE_WR
ITE_SUPPORT -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,
-adhlns=./Caterina.lst -I../../../../../../LUFA/LUFA-111009/ -std=c99 -MMD -MP -MF .dep/Caterina.o.d Caterina.c -o Caterina.o

Compiling C: Descriptors.c
avr-gcc -c -mmcu=atmega32u4 -I. -gdwarf-2 -DF_CPU=16000000UL -DF_USB=16000000UL -DBOARD=BOARD_USER -DARCH=ARCH_AVR8 -DBOOT_START_ADDR=0x7000UL -DDEVICE_VID=0x2341UL -DDEVICE_PID=0x
0036UL -D USB_DEVICE_ONLY -D DEVICE_STATE_AS_GPIOR=0 -D ORDERED_EP_CONFIG -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_RAM_DESCRIPTORS -D USE_STATIC_OPTION
S="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -D NO_INTERNAL_SERIAL -D NO_DEVICE_SELF_POWER -D NO_DEVICE_REMOTE_WAKEUP -D NO_SOF_EVENTS -D NO_LOCK_BYTE_WR
ITE_SUPPORT -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,
-adhlns=./Descriptors.lst -I../../../../../../LUFA/LUFA-111009/ -std=c99 -MMD -MP -MF .dep/Descriptors.o.d Descriptors.c -o Descriptors.o

////// EDITED OUT STUFF SO I COULD POST

Creating load file for Flash: Caterina.hex
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock Caterina.elf Caterina.hex

Creating load file for EEPROM: Caterina.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load"
--change-section-lma .eeprom=0 --no-change-warnings -O ihex Caterina.elf Caterina.eep || exit 0

Creating Extended Listing: Caterina.lss
avr-objdump -h -S -z Caterina.elf > Caterina.lss

Creating Symbol Table: Caterina.sym
avr-nm -n Caterina.elf > Caterina.sym

Size after:
AVR Memory Usage

Device: atmega32u4

Program: 4058 bytes (12.4% Full)
(.text + .data + .bootloader)

Data: 190 bytes (7.4% Full)
(.data + .bss + .noinit)

-------- end --------