Making Demos work on ATMEGA32U2

65 views
Skip to first unread message

Dagzandstuff

unread,
Aug 23, 2021, 4:24:55 AM8/23/21
to LUFA Library Support List
Hi!

I just started using the LUFA Library to get some insight in how USB Communications work. I've made a ATMEGA32U2 breakout board and so far I've been able to upload an Arduino Caterina sketch to and make it work.

I'm trying to make some of the LUFA Demos compile for 32U2 (Mouse, MassStorage etc.), whereas it says in the notes they should be supported for this microcontroller. It compiles just fine with WinAVR when everything is left unchanged, however if I change the mcu in the makefile to "atmega32u2", I get the following output:

Compiling C: MassStorage.c
avr-gcc -c -mmcu=atmega32u2 -I. -gdwarf-2 -DF_CPU=16000000UL -DF_USB=16000000UL -DBOARD=BOARD_USBKEY -DARCH=ARCH_AVR8 -D USB_DEVICE_ONLY -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_FLASH_DESCRIPTORS -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -D INTERRUPT_CONTROL_ENDPOINT -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=./MassStorage.lst -I../../../../ -std=c99 -MMD -MP -MF .dep/MassStorage.o.d MassStorage.c -o MassStorage.o
In file included from ../../../../LUFA/Drivers/Board/Dataflash.h:238,
                 from Lib/DataflashManager.h:47,
                 from Lib/SCSI.h:49,
                 from MassStorage.h:47,
                 from MassStorage.c:38:
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h: In function 'Dataflash_Init':
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h:94: error: 'DDRE' undeclared (first use in this function)
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h:94: error: (Each undeclared identifier is reported only once
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h:94: error: for each function it appears in.)
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h:95: error: 'PORTE' undeclared (first use in this function)
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h: In function 'Dataflash_GetSelectedChip':
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h:106: error: 'PORTE' undeclared (first use in this function)
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h: In function 'Dataflash_SelectChip':
../../../../LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h:117: error: 'PORTE' undeclared (first use in this function)
MassStorage.c: In function 'SetupHardware':
MassStorage.c:75: warning: implicit declaration of function 'clock_prescale_set'
MassStorage.c:75: error: 'clock_div_1' undeclared (first use in this function)
make: *** [MassStorage.o] Error 1

I'm not sure how I would go about solving this, and I'd assume it's not that complicated considering it should work for this controller. Anyone able to help me out with this?
Thanks!

Dean Camera

unread,
Aug 23, 2021, 4:31:37 AM8/23/21
to lufa-s...@googlegroups.com, Dagzandstuff

For the port related errors - your Makefile is using `BOARD_USBKEY` as the board, which normally has an AT90USB1297 MCU on it. You'll need to set that to the `USER` board, and supply your own dataflash routines to suit your chosen board. If you're not using a Dataflash IC, you can rip out all the Dataflash references and replace them with your own storage driver.

For the `clock_div_1` error, I suspect this is due to an outdated avr-libc package. Are you *really* still using WinAVR, which was last released back in 2010? If so try downloading the latest AVR8 toolchain from the Atmel/Microchip website.

- Dean
--
You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lufa-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lufa-support/51a04e79-cd44-47c9-b867-2b2866e525fbn%40googlegroups.com.

Dagzandstuff

unread,
Aug 27, 2021, 1:04:49 PM8/27/21
to LUFA Library Support List
Ok, so I've looked into this a little bit now.
I was completely blind to the fact that the "board" part is different type of development board to work with. I'm generally not interested in the "functionality" of the different demos, rather just witnessing how the mcu establishes communication with the computer using the different softwares, so I was really just interested in how to easily compile the demos for an atmega32u2. The easy fix here was simply to change the board type to STK526, which is set up to work with this mcu, and also supports most of the functions. Through this I was able to compile and test most of the demos. The MassStorage however comes up with an error when connected to the computer. I guess it runs pretty poorly when there's no actual Data Flash connected to the mcu, I haven't studied the code...
Also, I avoided AVR8 toolchain just because I didn't want to sign up for that website. I've got it now, and you we're right, that did clear out that error.
Thanks for the response!
Reply all
Reply to author
Forward
0 new messages