USB 2.0 ports not working on the Compute Module 4? Check your overlays!

Out of the box, to conserve power, the new Raspberry Pi Compute Module 4 doesn't enable its built-in USB 2.0 ports.

Compute Module 4 IO Board USB 2.0 ports are disabled by default

You might notice that if you plug something into one of the USB 2 ports on the IO Board and don't see it using lsusb -t. In fact, you see nothing, by default, if you run lsusb -t.

To enable the USB 2.0 ports on the Compute Module 4, you need to edit the boot config file (/boot/config.txt) and add:

dtoverlay=dwc2,dr_mode=host

Then reboot the Pi. Now you should be able to use the built-in USB 2.0 ports!

Comments

Also note this is documented in the CM4 datasheet section 2.4

:)

I rolled my own IO board for the CM4 and was convinced I'd done something wrong when the USB didn't work. I finally stumbled upon the line in the datasheet that mentions this. I kinda feel like this should be on by default....

Doesn't work in the config.txt that's in the NOOBS SD. Works with the Raspbian image though. Probably related to existence of a ...cm4...dtb file in the Raspbian FAT partition.

That was really frustrating for a while there.

Thanks.. I was wondering why I couldn't get my CM4 to USB boot.. Seems that USB needs to be enabled.. Which means the IO board can't boot from USB without having a boot partition on the SD/NVM card.

I've taken a copy of the Ubuntu 20.04 LTE boot partition on the a 500MB SD boot partition and then that boots of the Usb volume labeled writable. However it then gets stuff waiting for dev to complete so show knows what the next problem is..

Once step forwards..

In Ubuntu 20.04 image there is a line to uncoment in /boot/firmware/config.txt as explained by the comment above it.

Hello Sir, Which line I need to uncomment since the file says -> Please DO NOT modify this file; if you need to modify the boot config, the "usercfg.txt" file is the place to include user changes

Just a comment to keep someone else from falling into the same pit I did. I added this line to config.txt by connecting it via J11 and letting boot as a USB storage device. Once I could see it in Windows I edited config.txt. But no matter what the USB mouse and keyboard would never work. Finally I realized I still had power applied to J11 via the microusb cable. I recall from the schematic this flips a switch that re-routes the USB signals from the HUB and instead to J11. Unpluged from J11 and all if FINE! Only 20 minutes lost on this. :-) Not unusual for unfamiliar hardware. Lesson learned. Hope this helps someone else not waste 20 min or more.

Disable USB by default - what a stupid idea...

thanks for enlightening us JG :)

Ditto - Thank you so much I would have spent days figuring that out, assuming something was wrong with the board. Of all things...

I did all this and it still did not work - no matter how many times I unplugged / replugged, unplugged all the other devices in my Mac (and PC and Debian) system, the rpiboot would never recognize the CM4's on-board SSD.

I was using hobby cable jumpers; I switched to the standard PC board jumper plug.
I was using not-so-great microUSB cables, I switched to a high-quality one - eureka - it mounted and I was able to edit the boot config.txt on my Mac, and now USB 2 works.

So if anyone is frustrated after following the above instructions, make sure you have a tight jumper and good quality microUSB cable.

Thanks so much for this guide - now it's time to get to work!

Is there actually a way to boot off an USB MSD connected to the USB ports on the CM4 IO board if the CM4 has eMMC?

I tried changing the boot order in the bootloader but I think I've ending up with a chicken and egg situation where you cant boot off an USB MSD if the USB ports are disabled because it needs to load config.txt to enable the USB ports. The documentation even says you want to be able to do USB MSD boot if the onboard eMMC is corrupted but it doesn't address having to enable the USB ports. I think the only other option would be using a USB card in the PCIe slot.

Mine too i wasted time search for a power or other issue that didn't exist
thanks you for this post

Thankyou!

I was setting this up to run ocotpi with some custom hardware additions.
I was closed to giving up getting the webcam going.

You saved the project.

:-)

Thank you! this saved me a lot of time.
I actually bought a raspberry PI, Compute Module 4 (CM4) and a Compute Module 4 PoE (B) from WaveShare

I was struggling to figure out why I couldn't get the USB to work!!! finally after hours of setting up SSH and VNC and updating and troubleshooting drivers.... I found this.

Hi I'm not sure if this is related but I'm trying to run Oracle Linux 8.4 on my CM4 with 4GB RAM and 32GB eMMC. I have flashed the eMMC with the image and at boot I get a list of things not starting including USB and then just get a U-Boot> prompt but from here I'm unable to do anything because I have no keyboard. I have updated the config.txt with the above dtoverlay line but still nothing. If anyone else has been able to get Oracle Linux on a CM4 I would greatly appreciate any assistance. I am very new and green when it comes to all things Linux and Raspberry Pi.

This is the dumbest default ever. I know there is a reason, but even knowing it, working with multiple CM4 modules it causes headaches. FSUSB42 soldered wrong? Oh no, it's just that damn USB isn't enabled yet...

Thanks Jeff !!!
Note , how I lost USB access :
When booting the CM4 with EMMC ( i have the 8/32/wifi versions )
the FIRST time before an OS is loaded on the emmc
YOU MUST edit the flashed emmc /boot/config.txt before you reboot !!
Method tested : which crashed without editing before reboot
1. I load an SD card with Manjaro-pi and put it in a thumb drive adapter.
2. Boot to Manjaro-pi , update OS, install RPI-imager, and download distributions that can be flashed onto the emmc ( or any RPI or CM4
3. If you do the following you will have access to your usb and are able to have an overclocked device
NOTE : I installed a waveshare heatsink/fan combo on all my CM4's

Mount your emmc storage :

[triplr@triplr-pi-test:]$LSBLK
NAME SIZE VENDOR MODEL TYPE FSTYPE UUID MOUNTPOINT
sda 119.1G Generic STORAGE DEVICE disk
├─sda1 213.6M part vfat 4EDD-A307 /boot
└─sda2 118.8G part ext4 d1684ccb-e8af-4276-8262-57c7ab0fa08e /
mmcblk0 29.1G disk
├─mmcblk0p1 213.6M part vfat 4EDD-A307 /tmp/mmcblk0p1
└─mmcblk0p2 5.8G part ext4 d1684ccb-e8af-4276-8262-57c7ab0fa08e
mmcblk0boot0 4M disk
mmcblk0boot1 4M disk
zram0 11.4G disk [SWAP]
[10:55:14:Fri Oct 29:~]
[triplr@triplr-pi-test:]$

Edit your emmc config.txt ( this is my basic configuration adding the overclock and usb )

[11:01:37:Fri Oct 29:/tmp/mmcblk0p1]
[root@triplr-pi-test:]$cat config.txt
# See /boot/overlays/README for all available options

initramfs initramfs-linux.img followkernel
kernel=kernel8.img
arm_64bit=1
disable_overscan=1

#enable sound
dtparam=audio=on
#hdmi_drive=2

#enable vc4
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
disable_splash=1

# enable usb CM4
dtoverlay=dwc2,dr_mode=host

# enable overclock CM4 WARNING Heatsink and or fan required
#uncomment to overclock the arm. 700 MHz is the default.
over_voltage=6
arm_freq=2000

# gpu settings and overclock
gpu_mem=64
gpu_freq=700

[11:01:44:Fri Oct 29:/tmp/mmcblk0p1]
[root@triplr-pi-test:]$

Then reboot your device.
I had to fix my first emmc by doing the windows bootloader access described by Jeff. What a pain RPI foundation.

Happy flashing

THANK YOU
I've everything else working on 64 bit Pi OS including nvme, but could not figure out why the kernel wasnt picking up the USB devices. Now USB is working fine on my CM4. Awesome.

By some strange reason I still don't get it to work.

I also had to add this before the USB ports came alive:

otg_mode=1

I'm running OpenWrt 21.02.1:

I lost a whole day to find this, it's stupid to disable this by default.
Thanks a lot, Dirk

I ran into this. What I found was that the CM4 will read the line in config.txt correctly on power up boot. All good. But if I do a

sudo reboot (from an ssh or whatever)

the rebooted unit does not enable the usb device. If I

sudo shutdown

remove power and connect power it reboots correctly.

I was going crazy editing the file and checking... putting the line last in the file. all kinds of futility. Who would have that that the reboot and shutdown reboot would be different. not me!

I don't understand Jeff how can you enter commands if you can't get into the Compute module 4 because your mouse and keyboard won't work how do you enter it, you can't click, type or do anything the Board USB won't work????

In this case, you'd configure the /boot/config.txt file from another computer (either mounting the eMMC via rpiboot, or by pulling the microSD card and plugging it into another computer.

Alternatively, you can plug in a serial connection on the CM4 (assuming you have serial console enabled), or SSH into it over the network to configure the option (assuming you have SSH enabled and the Pi's connected to a network).

I upgraded parts on my CM4 kit to include the PCIe to USB 3.1 adapter. Wanted to flash a STABLE bootloader on my unit, a compute module 4 motherboard, now with 8 USB ports! I "Only" use the front 2-2.0 ports for my keyboard and mouse the extra 2-2.0 are on a modified arm and screwed to the rear corner of a Waveshare base, looks terrible, but functional, till i get a 3D printer. The 2.0 ports WOULD work with the PCIe to M.2 adapter in place, but not with the PCIe to USB 3.1? What was the issue? Ended up that... this edit HAD to be added to config.txt on my USB drives only and not the M.2 drives. Not sure WHY, but all is well now. Thanks for the info. Looking high & low all over the internet and 1,000 post(s), only this one had the "correct" fix. Awesome. Be well and keep up the great work.

Seems like I'm encountering something similar to this. I used to use RPi4 B with UEFI+ACPI (https://github.com/pftf/RPi4) then installing plain ARM64 Debian Linux from ARM64 netinst installer. Works great with RPi4 B. No uboot, no devicetree, no RPI specific kernel. Just UEFI + GRUB + Vanilla Linux kernel.

I now gave CM4 a try, using the exact same setup. Within UEFI and even in GRUB menu, USB keyboard and storage is working. But as soon as GRUB boots the Linux kernel it seems like USB ports on CM4 are dead.

I tried anything I could imagine so if someone has an idea on how to get USB 2.0 port working on CM4 in such a setup, help would be highly appreciated.

No, didn't find any solution yet. CM4 would be so much better for my needs than RPi4B, especially being able to properly implement M.2 NVMe. But due to running out of ideas and zero feedback I'm currently stuck on this one.

I have tried all things/suggestions and cannot get USB or wifi up on my CM4. I had my CM4 checked out and it apparently was fine but .. Gettting frustrated with this. All my other Pi work flawlessly out of the box.

I want to interface the device to Raspberry pi CM4 through USB port. I am trying to install xr_usb_serial_common.ko drive to CM4, but getting error in last step. Could you please help me? What could be the reason?

Help. I am trying to edit my config.txt file, but can't find it anywhere. Can you give the full path? I am able to see 4 "mounts" or partitions after rpiboot and then installing my os, in my cae HASSIO, but I can't find any config.txt file anywhere.
Thanks,
Alan

I've spent 6 hours today trying to bring up a Pi CM4 on a Turing Pi 2... Your blogs have been invaluable, and this was the last one I needed to get it working. THANK YOU!