Re: Getting a CM4 to boot from USB?

Jan 05, 2024 Last reply: 2 years ago 12 Replies

On 1/5/2024 05:13, The Natural Philosopher wrote: > That's what my Pi 4 did on one version of Bookworm. > Try a different version


From what I understand, the Compute Module 4 cannot boot from SD card because it's literally missing the connections to the card - the card slot is only there so you can load the Pi OS onto the built-in eMMC. It's designed to boot from eMMC. If I'd paid attention, I would have picked up the 8GB eMMC version instead, but after waiting for a year I took what I could get.



If you put a card in, it doesn't do anything. As far as the eeprom, that shouldn't be an issue past 2021 or so - I can see it trying to boot from the flash stick, and I did try it without the modem as well.


The version of (official) OS is the only thing I did not try, if I have time I'll download the second-to-last version and try it this weekend. I did try the Armbian version, but I don't know that it specifically states CM4 compatibility.


You have it backwards: the Lite version has no eMMC which is why the official I/O board has an SD card socket to boot the Pi: "MicroSD card socket for Compute Module 4 Lite (without eMMC) variants"

formatting link
If you have a non-Lite board there's a way to flash the eMMC externally (via USB I think). If there is onboard eMMC the SD slot is not connected to the Pi (or maybe to the second MMC channel, not sure).

I wonder if there is something odd about the way they've wired the SD slot on your board? Maybe it needs a jumper or something? What does the documentation for your board say?

There can sometimes be firmware issues that means third party OSes won't boot on new variants of the same board like CM4 because of minor hardware differences, but these are usually ironed out fairly soon after release.

Theo

Ok, I do see the lite version SHOULD boot from uSD, so perhaps this is a problem with the actual OS version as well. There's also this little bit of info with some changes to config.txt:

formatting link
which I'll try.

I don't have a lot of information on the carrier itself, that seems to be somewhat lacking. Maybe the carrier is bad, being a Super High Quality Much Goodly Chinese device, who knows? There are reviews of it out there, but no real hard information. I'll dig into that as well.

The local Micro Center has a cheap carrier in stock of a different style, so I'm going to pick up one of those this weekend and give that a try as well, but I'll grab an older OS first to see how that goes.

This in config.txt: dtoverlay=dwc2,dr_mode=host

(there should not be a dot on the end)

overrides the USB 2 port into host mode, ie to accept USB sticks etc. I suppose that could be a reason why your CM4 won't USB boot. Ordinarily the port can detect whether to be in host or device more via the 5th pin on the micro USB connector, which is tied low in an OTG adapter to force host mode. Maybe your board doesn't do this correctly? Of course, if you can't boot you can't read config.txt to force the port to the right direction, so you'd have to rely on the pin being tied low.

Even without this, and even with no SD, I'd expect to see some sign of life on the HDMI: the Pi4 should display a 'BIOS' style boot screen that says what it's trying to boot from.

Good plan. Once you can get anything working, you can then take deltas against the setup you have to narrow down the problem. If absolutely nothing works then there are few clues.

Theo

There's a tool called rpiboot that you use to flash a CM4. Most carrier boards have a switch or jumper to enable or disable eMMC boot. Set it to disabled, then connect it in to your computer. Running rpiboot sends over a small program that causes the CM4's eMMC storage to show up as a USB storage device. At this point, you can use the RPi Imager, dd, or whatever to blast software onto it the same way you'd load up a MicroSD (or SD) card for other Raspberry Pis. When done, unplug it, set the switch or jumper back to enabled, and power it back up.

Some success here. I'm using the Bullseye version presented on the RPi OS page, instead of whatever the latest is.

I set the other carrier board up, it's marked as being made by "bigtreetech" and looks like a regular Pi once assembled. Trying the SD card in it's slot, I see the same things as with the other board, according to my router it's been offered an address - this happens over and over. No boot happens.

I took the SD card and put it in a USB reader, put it in a USB port on this carrier, and it booted. That would seem to indicate that the MCUZone carrier that I hoped to use is incapable of booting from USB - I assume the rainbow splash screen is a kernel panic at this point.

(I can't see anything visual on the bigtreetech carrier, it has micro-HDMI and I can't find my adapters.)

Going back to the MCUZone carrier, I put the known good card in the SD slot. Here's what I see:

formatting link
The device eventually gets an address like it's waiting for something else, and does this over and over, never booting. I should mention this carrier has a run/boot jumper, this is in the boot position. Putting it in the run position (I assume, it's not clear) gives me a black screen and nothing else. Putting the card in the known good reader gives me the same rainbow screen.

One thing I notice is the boot order, which has a "1" for SD card at the end of the list. However, I also see "SD card not detected" - is it possible that the boot order needs to be changed so it's looking for the SD card first? Doing this is something I'd have to research before attempting.

In any event, the MCUZone device won't boot from USB, and none of them boot from SD at this point.

But looking a little closer, it looks like it's trying all the boot devices from right to left - it doesn't see the SD card so it goes to the next one. So it probably won't matter if I change the boot order, it would just never get to the SD card.

If you can boot the CM4 by any means, that also allows you to run an EEPROM update to upgrade the firmware on the CM4. It's possible the board has old firmware which won't boot new images or carrier boards, and doing an update might imorove matters.

Theo

As I mentioned in my other post, I'd boot from USB and try upgrading the bootloader in EEPROM on the board:

formatting link
I also note there are some CM4 specific settings:
formatting link

I found out why my device won't see the SD card. But first:

I can't update the onboard eeprom without using the imaging tool, that's apparently by design. The CM4 won't let you touch that stuff because it's "impossible to remove the eMMC if something goes wrong." Makes sense, but still a PITA for those of us not using the thing in production.

However, the real reason I'm having all these issues is because, after inspection, my vendor sent me the 8GB eMMC version instead of the no eMMC version I asked for. That sucks because I don't really want storage I can't ever change because it likes to go bad, but there it is.

I believe the reason the device won't USB boot on the MCUZone carrier is because it is indeed going into panic at boot - I've seen some information about the USB device on this being problematic.

My next step is to try and flash the eMMC on this one the see what happens. I'll let you know.

Last update -

I tried connecting the CM4 device to my laptop to flash via the imaging tool. The only machine I have that's not a Pi or associated device (or something even older) is my old Win7 gaming laptop. You can install the imaging tool on Win7, and it "supports" it, but there's apparently no driver for the BCM2711 boot device, so you can't access it. That was a waste of my time.

I found some instructions on flashing an image direct to eMMC from the OS itself, meaning on the Pi:

formatting link
wget raspbian imgage extract image file sudo dd if=image of=/dev/mmcblk0 bs=10MB clean shutdown CM4, remove USB drive and power on CM4 again you should end up with a booting CM4

I downloaded the image, unzipped it, and SCP'd it over to the Pi. I then used these instructions to flash the Pi, and it booted with no external devices. Yay!

For now, I'm going to use this as-is, as I need the 4G modem to replace some old 2G stuff that's offline in a few months here in the USA. Otherwise, I will probably look to purchase a real Lite version at some point in the future and pass this board on to someone who would like, but can't afford one.

Thank you for the help - sometimes it takes someone going "well, look at this instead" to break out of the tunnel vision and find the information you need.

Glad you got it sorted. One thing you can do, at the expense of a slightly non-standard setup, is to keep your /boot partition on the eMMC, and set config.txt to use a root partition on your USB. So most of your OS lives on the USB and only the kernel, firmware and device trees live on the eMMC. That means you aren't limited by the eMMC size for your OS install.

To do this you flash the OS to your USB as well as the eMMC, then boot the Pi from eMMC and alter:

root=/dev/mmcblk0p2

to

root=/dev/sda2

in config.txt. You'll also need to amend /etc/fstab on the USB to match.

Theo

I used to do that with NFS booting on an older Pi 2 - probably will at some point. Thank you for the reminder.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required