PCIe NVME on Raspberry Pi CM4

I’m trying to boot directly from PCIe NVME on the Raspberry Pi CM4. I am pretty sure that the only way to get a PCIe drive to initialize at the bootloader level is with these settings in the kernel:

CONFIG_BLK_DEV_NVME=y
CONFIG_NVMEM_RMEM=m

Along with the newest version of firmware from RPi in the boot directory, this should allow CM4 users to boot directly from their NVME drives over the PCI-e slot.

OSMC images expect the filesystem to be on SD card (mmcblk). It ought to be easy to patch the installer to change that for USB drives (sda), but no-one’s got around to that yet.

It could be that a similar patch would work for PCIe (substitute nvme0n1 etc for sda1??) but I don’t know how different CMs are from standard RPis. Further tweaks may be necessary. You could compare a PiOS install with an OSMC RPi install to find out.

Where are you getting stuck? As @grahamh says, the root= parameter will trip you up

I’d suggest installing on an SD and then copying the filesystems manually to NVME and seeing where your issue is from there.

It could well be that the kernel has everything needed already.

The NVME drive is not initialized at the bootloader stage. I had already tried the above recommendation, but the NVME does not show up at all using the df command in shell. Here is a link to a github comment from Phil Elwell from RPi Foundation on the same topic:

I looked at config.gz last night and confirmed that CONFIG_BLK_DEV_NVME=m (rather than y)

The second config is to allocate memory on the NVME drive for the firmware files and was also recommended by Elwell in another post and is used in RPOS. Note that since the linked post, the newest firmware can now boot natively (previously the boot folder still had to be on either SD card or eMMC) as long as the above changes are in effect.

On a side note, one easy thing to do for CM4 users that would be very helpful to enable USB (not enabled by default on CM4), would be to add the line:

i2c-dev

to the /etc/modules file
and the lines:

[cm4]
otg_mode=1

to config.txt in the boot folder
Since it has the CM4 parameter, it should not have any negative effect (or any effect) for users of other Pi devices. I was able to mount the device on Ubuntu to add this, but other users may not know to.

Hi,

I’m happy to accept a PR to enable this functionality.

I’m not keen on enabling i2c-dev module on all devices regardless of model.

Have you verified the effect of this on OSMC? We don’t do anything special for OTG devices presently.

Sam

The “otg_mode=1” enables the XHCI port so that USB is accessible, it’s just enabling USB in host mode only. Since the CM4 doesn’t offer any USB without explicit activation in config.txt, either DWC2 “dtoverlay=dwc2,dr_mode=host” or XHCI “otg_mode=1” must be present and have a module in the OS. The i2c-dev module is present in most new RPi4B OS’s and in Raspberry Pi OS itself. I’m not familiar with the normal installation process because I use PINN (NOOBS), so if there is no separate 4B installer than I see your point.
I compiled the kernel with the two patches I mentioned above and was able to boot up straight into NVME with no problem. I will try to figure out how to make a pull request, thanks!