Older versions of avr-gcc seem to work fine, but here are the steps to install 5.4.0 specifically.
List available versions of gcc-avr
$ apt list -a gcc-avr
Listing... Done
gcc-avr/jammy 1:5.4.0+Atmel3.6.2-3 amd64Install gcc-avr 5.4.0
$ sudo apt install gcc-avr=1:5.4.0+Atmel3.6.2-3
$ avr-gcc --version
avr-gcc (GCC) 5.4.0Install other stuff
$ sudo apt install avr-libc dfu-programmer dfu-util- https://learn.microsoft.com/en-us/windows/wsl/connect-usb
- https://github.com/dorssel/usbipd-win/wiki/WSL-support
Need to be running Linux kernel version 5.10.60.1 or higher
$ uname -a
Linux DESKTOP-IGTSND9 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux(On windows) Download and run the latest .msi installer from https://github.com/dorssel/usbipd-win/releases
Open an elvated (administrator) powershell terminal: List the USB devices connected to windows. The busid 1-14 will probably be different.
$ usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-14 03eb:2ff0 ATmega32U2 DFU Not sharedShare the device, allowing it to be attached to WSL
$ usbipd bind --busid=1-14Verify the device is now shared.
$ usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-14 03eb:2ff0 ATmega32U2 DFU Shared From this step we don't need administrator privileges, you can use a regular powershell terminal. Attach the USB device to WSL
$ usbipd attach --wsl --busid=1-14Verify the device is now attached.
$ usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-14 03eb:2ff0 ATmega32U2 DFU AttachedNow within WSL, you should now see the USB attached
$ lsusb
Bus 001 Device 005: ID 03eb:2ff0 Atmel Corp. atmega32u2 DFU bootloaderThe udev rules need to be configured to allow non-root users to access the device.
The easier solution is to just run make program as the root user. (You can use sudo su to become root)
But to configure udev properly:
From the lsusb command above, we can see the ID of the UCFK4: ID 03eb:2ff0, yours may be different
$ sudoedit /etc/udev/rules.d/99-atmega32u2.rulesAdd the following line:
SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff0", MODE="0666", GROUP="plugdev"Reload
$ sudo udevadm control --reloadAfter running make program, the device seems to automatically detach from WSL.
You can run the command usbipd attach --wsl --auto-attach --busid 1-14 to automatically reattach each time you hit the reset button on the UFCK4, just keep this command open.