Skip to content

Instantly share code, notes, and snippets.

@Extacy
Last active September 10, 2025 02:06
Show Gist options
  • Select an option

  • Save Extacy/afe27a8b02f7b6c5b0aca452ccc0c5d5 to your computer and use it in GitHub Desktop.

Select an option

Save Extacy/afe27a8b02f7b6c5b0aca452ccc0c5d5 to your computer and use it in GitHub Desktop.

UCFK4 Install on WSL2

Install avr-gcc 5.4.0

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 amd64

Install 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.0

Install other stuff

$ sudo apt install avr-libc dfu-programmer dfu-util

Setup WSL to connect to USB devices

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 shared

Share the device, allowing it to be attached to WSL

$ usbipd bind --busid=1-14

Verify 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-14

Verify the device is now attached.

$ usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-14   03eb:2ff0  ATmega32U2 DFU                                                Attached

Now within WSL, you should now see the USB attached

$ lsusb
Bus 001 Device 005: ID 03eb:2ff0 Atmel Corp. atmega32u2 DFU bootloader

Configure udev rules

The 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.rules

Add the following line:

SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ff0", MODE="0666", GROUP="plugdev"

Reload

$ sudo udevadm control --reload

Loading Programs into UCFK4

After 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment