Maker.io main logo

How to Flash the Raspberry Pi Compute Module 4 (CM4) eMMC with an OS

2021-08-23 | By ShawnHymel

License: Attribution Raspberry Pi

Some Raspberry Pi Compute Module 4 (CM4) boards come with a built-in eMMC flash chip for storing nonvolatile data. This chip replaces the need for a separate SD card, which can be useful if you want to save space on your expansion board or don’t want the user to flash an SD card.

This tutorial will show you how to flash the eMMC on the CM4 with the latest version of Raspberry Pi OS. This should work if you’re using the CM4IO Board or a custom expansion board.

Note that I will show images from my custom expansion board, but the process should be the same regardless of what board you are using with your CM4. The board should give you access to the USB data lines going to the CM4 as well as the ability to connect the nRPIBOOT pin to GND.

You can watch me assemble a custom CM4 carrier board and program the eMMC chip in this video:

 

Bootloader Mode

If your Raspberry Pi CM4 has an eMMC chip, then it should come with a special bootloader mode that will allow you to upload an operating system to the eMMC.

Attach the CM4 to the carrier board. Locate the nRPIBOOT pin on your carrier board and connect it to GND.

nRPIBOOT pin on CM4 carrier board schematic

If you have the IO board, look for the silkscreen note that says “Fit jumper to disable eMMC Boot.” You will want to connect this pin to the adjacent GND pin in order to enable bootloader mode (and prevent the Pi from booting the OS on the eMMC). 

If you are using something like my custom Base Carrier board, use a jumper wire to connect nRPIBOOT to GND.

Connecting nRPIBOOT to GND

Connect a USB cable between your computer and the micro-B port on the carrier board (or whichever port is used to transfer data between your computer and the CM4). Finally, provide power to the CM4 and carrier board (e.g. through the barrel jack or USB-C connector).

Powering the CM4 and carrier board

This should cause the CM4 to enumerate as an SD card on your computer.

Flash Operating System

Head to the software page of the Raspberry Pi site. Download and install the Raspberry Pi Imager software, accepting all the defaults. Run it, select your desired OS, and tell it to flash the eMMC chip (it will look like an SD card mounted on your host system). I used Raspberry Pi OS Lite for my particular project, as I did not need a full graphical user interface for the OS.

Flashing eMMC with Raspberry Pi Imager

(Optional) Enable UART Console

By default, the Raspberry Pi OS disables UART consoles for security reasons. However, if you are using a headless Raspberry Pi system (like I am for my project), you need some way of accessing the operating system. The easiest way I have found to do that is by enabling the UART and connecting a USB-to-Serial adapter to the TX/RX (GPIO14 and GPIO15) pins of the Raspberry Pi.

USB to serial adapter connected to Raspberry Pi CM4

To enable UART, you will need to leave the CM4 in RPIBOOT mode so that you can mount the eMMC as an SD card on your host system. This will give you access to the boot files.

Go into the mounted eMMC drive (the drive should be named boot) and open config.txt with a text editor. At the bottom, add the following line:

Copy Code
enable_uart=1

Enable UART on Raspberry Pi boot

 

Save the file.

Boot the System

Remove power from the CM4 and disconnect nRPIBOOT from GND. If you are using the UART console, connect your USB-to-Serial adapter to GPIO14 and GPIO15. Give the CM4 power, and it should boot from eMMC into the newly flashed operating system.

With a USB-to-Serial adapter, find the serial port on your host OS (e.g. COMx on Windows) and connect to the adapter with a baud rate of 115200. You should see the Linux boot process and be presented with a login prompt. Use the following default credentials to log in:

  • Username: pi
  • Password: raspberry

If everything worked, you should have a full Linux system at your fingertips!

Raspberry Pi serial UART console

Going Further

I hope this helps you get started with the Raspberry Pi CM4 module (specifically, the ones with onboard eMMC). At this point, you have endless possibilities with your embedded Linux device. You could whip something up in Python or enable wireless networking (assuming your CM4 has onboard wireless or you’re using a USB WiFi dongle).

The custom Base Carrier PCB design files can be found here: https://github.com/ShawnHymel/rpi-cm4-base-carrier

TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum