Flash an image to a Compute Module

The Compute Module has an on-board eMMC device connected to the primary SD card interface. This guide explains how to flash (write) an operating system image to the eMMC storage of a single Compute Module.

Lite variants of Compute Modules don’t have on-board eMMC. Instead, follow the procedure to flash a storage device for other Raspberry Pi devices at Install an operating system.

To flash the same image to multiple Compute Modules, use the Raspberry Pi Secure Boot Provisioner. To customise an OS image to flash onto those devices, use pi-gen.

For CM5, we provide the Compute Module 5 Programming Jig. The jig connects directly with one CM5 at a time and programs it with an operating system and security configuration. For more information, see the jig documentation.

Prerequisites

To flash the Compute Module eMMC, you need the following:

  • Another computer, referred to in this guide as the host device. You can use Linux (we recommend Raspberry Pi OS or Ubuntu), Windows 11, or macOS.

  • The Compute Module IO Board that corresponds to your Compute Module model.

  • A micro USB cable, or a USB-C cable for Compute Module models since CM5IO.

In some cases, USB hubs can prevent the host device from recognising the Compute Module. If your host device doesn’t recognise the Compute Module, try connecting the Compute Module directly to the host device. For more diagnostic tips, see the usbboot troubleshooting guide.

Set up the IO Board

To begin, physically set up your IO Board. This includes connecting the Compute Module and host device to the IO Board.

Compute Module 5 IO Board

To set up the Compute Module 5 IO Board:

  1. Connect the Compute Module to the IO board. When connected, the Compute Module should lie flat.

  2. Fit nRPI_BOOT to J2 (disable eMMC Boot) on the IO board jumper.

  3. Connect a cable from USB-C slave port J11 on the IO board to the host device.

Compute Module 4 IO Board

To set up the Compute Module 4 IO Board:

  1. Connect the Compute Module to the IO board. When connected, the Compute Module should lie flat.

  2. Fit nRPI_BOOT to J2 (disable eMMC Boot) on the IO board jumper.

  3. Connect a cable from micro USB slave port J11 on the IO board to the host device.

Compute Module IO Board

To set up the Compute Module IO Board:

  1. Connect the Compute Module to the IO board. When connected, the Compute Module should lie parallel to the board, with the engagement clips firmly clicked into place.

  2. Set J4 (USB SLAVE BOOT ENABLE) to 1-2 = (USB BOOT ENABLED)

  3. Connect a cable from micro USB slave port J15 on the IO board to the host device.

Set up the host device

To flash an operating system to the Compute Module, the host device must see the Compute Module as a USB mass storage device.

You can configure this in one of the following ways:

For a host device, we recommend a Raspberry Pi 4 or newer running 64-bit Raspberry Pi OS.

Configure RPIBOOT support in Imager

You can configure Raspberry Pi Imager so that it can use rpiboot to detect the Compute Module and treat it as a mass storage device.

  1. Install Raspberry Pi Imager and start it. For more information, see Install and launch Imager.

  2. Configure RPIBOOT support:

    1. Open Debug Options:

      • On Windows or Linux, enter Ctrl+Alt+S.

      • On macOS, enter Cmd+Option+S.

    2. Scroll to Advanced Features.

    3. Use the toggle to select Enable Rpiboot/Fastboot Support.

    4. Select Apply to save your changes and exit the Debug Options dialog.

This setting is saved by Imager and applied whenever it starts.

Install rpiboot on your host device

Linux

To set up software on a Linux host device:

  1. Run the following command to install rpiboot (or, alternatively, build rpiboot from source):

    $ sudo apt install rpiboot
  2. Connect the IO Board to power.

  3. Then, run rpiboot:

    $ sudo rpiboot
  4. After a few seconds, the Compute Module appears as a mass storage device. Check the /dev/ directory, likely /dev/sda or /dev/sdb, for the device. Alternatively, run lsblk and search for a device with a storage capacity that matches the capacity of your Compute Module.

macOS

To set up software on a macOS host device:

  1. First, build rpiboot from source.

  2. Connect the IO Board to power.

  3. Then, run the rpiboot executable with the following command:

    $ rpiboot -d mass-storage-gadget64
  4. When the command finishes running, a message stating "The disk you inserted was not readable by this computer" appears. Select Ignore. Your Compute Module now appears as a mass storage device.

Windows

To set up software on a Windows 11 host device:

  1. Download the latest Windows installer from the releases page or build rpiboot from source.

  2. Run the installer by double-clicking on it. This installs the drivers and boot tool. Don’t close any driver installation windows that appear during the installation process.

  3. Reboot

  4. Connect the IO Board to power. Windows should discover the hardware and configure the required drivers.

  5. Select rpiboot - Mass Storage Gadget from the start menu. After a few seconds, the Compute Module eMMC, NVMe or SD card appears as a USB mass storage device. This also provides a debug console as a serial port gadget.

Flash the eMMC

You can use Raspberry Pi Imager to flash an operating system image to a Compute Module.

Alternatively, use dd to write a raw OS image (such as Raspberry Pi OS) to your Compute Module. Run the following command, replacing /dev/sdX with the path to the mass storage device representation of your Compute Module and raw_os_image.img with the path to your raw OS image:

$ sudo dd if=raw_os_image.img of=/dev/sdX bs=4MiB

After the image has been written, disconnect and reconnect the Compute Module. You now see two partitions (for Raspberry Pi OS):

/dev/sdX    <- Device
/dev/sdX1   <- First partition (FAT)
/dev/sdX2   <- Second partition (Linux filesystem)

You can mount the /dev/sdX1 and /dev/sdX2 partitions normally.

Boot from eMMC

Compute Module 5 IO Board

Disconnect nRPI_BOOT from J2 (disable eMMC Boot) on the IO board jumper.

Compute Module 4 IO Board

Disconnect nRPI_BOOT from J2 (disable eMMC Boot) on the IO board jumper.

Compute Module IO Board

Set J4 (USB SLAVE BOOT ENABLE) to 2-3 (USB BOOT DISABLED).

Boot

Disconnect the USB slave port. Power-cycle the IO board to boot the Compute Module from the new image you just wrote to eMMC.

Known issues

  • A small percentage of CM3 devices might experience problems booting. We have traced these back to the method used to create the FAT32 partition; we believe the problem is due to a difference in timing between the CPU and eMMC. If you have trouble booting your CM3, create the partitions manually with the following commands:

    $ sudo parted /dev/<device>
    (parted) mkpart primary fat32 4MiB 64MiB
    (parted) q
    $ sudo mkfs.vfat -F32 /dev/<device>
    $ sudo cp -r <files>/* <mountpoint>
  • The CM1 bootloader returns a slightly incorrect USB packet to the host. Most USB hosts ignore it, but some USB ports don’t work due to this bug. CM3 fixed this bug.

  • The rpiboot version distributed with Ubuntu 24.04 and earlier has been known to fail to communicate with the device. To resolve this issue, build rpiboot from source.