Burning images to multiple CM4 units


We have an energy monitoring gateway that boots on RPi devices and I have been testing the Wavshare CM4-IO-WIRELESS-BASE which is nice in that it has two RS-485 ports and 4G options. Does anyone know of the best way to burn a Debian based image to several CM4 boards - I have used the Raspberry Pi Compute Module 4 and I/O Board. Or are there companies that can do this and also assemble and test enclosures/panels?

Thanks, John

Hi John,

Thanks for posting!

What an interesting question, multiple dd processes running at once all pointing to different mounted devices feels like the most natural way to approach this.

Your host operating system that’s running these commands on will take care of the task scheduling to try and optimize the resource usage and manage the simultaneous flashing.

Thanks Bryce, this is the unit we are testing based on our Debian based SolarNodeOS - I’m looking for setups that can do as you say - use dd to burn those images to multiple CM4 devices simultaneously. the Raspberry Pi Comput Module 4 IO Board is one way to do this certainly but does anyone know of carrier boards with 4G that will also let you burn the image onto the CM4 over USB? trying to reduce the steps of attaching the CM4s to the boards and then to the carrier board. or maybe there are service companies that will burn a set of CM4 boards or assemble full enclosures…
SolarNode Reference Design_ Industrial 8_20240226.pdf (1.3 MB)

Hi @John266303 - have you followed waveshare’s image writing guide? It details how to upload an image to the CM4 while it’s mounted in the Wireless Base

ok! very cool Michael, no I did not know you could do this directly on the Waveshare device, am going to try this right now. I have used a Windows program wtih the Raspberry Pi Compute Module IO Board to write images but there should be a way to use Linux to do the write as well?

1 Like

The instructions are for Windows and the Rpiboot_setup tool is precompiled for Windows (.exe)
I can’t see anything mentioned in the article about an equivalent tool for Linux :confused:

There should be something, but it doesn’t look like there is :person_shrugging: anyhow, hopefully this is a step in the right direction. It may just put a dependence on Windows in your production workflow.

Best of luck, let us know how you go!

I am reading here:


and it does look like a Linux box that can see a device that maps to the serial port with the Compute Module 4 IO Board hosting the CM4 can do this…wonder if the Waveshare CM4-IO-Wireless-base hosting a CM4 comes up as a device on Linux then it should be a dd command - will let you know

1 Like

On Windows using rpiboot.exe, I can see the CM4 file partition device as a D: drive and likely can flash it directly, just giving Ubuntu a try @Michael

1 Like

Great! Sounds pretty promising :smiley:

How to flash Raspberry Pi OS/ 64-bit Ubuntu OS or Other OS to eMMC | Seeed Studio Wiki these instructions seem to bring up the filesystem on the CM4 on a Debian 12 desktop like a USB device - as long as I have the boot toggle switch on the Waveshare CM4-IO-WIRELESS-BASE set to ON and the USB C port connected to the Debian desktop via a USB-A to USB-C cable in my case

1 Like

@Michael with the following commands on a Debian 12 Intel 64-bit desktop I was able to mount the 8GB eMMC media of the CM4 mounted on a CM4-IO-WIRELESS-BASE carrier board:

desktopuser@debian12desktop:~$ sudo apt install git pkg-config make gcc libusb-1.0-0-dev
[sudo] password for desktopuser: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
git is already the newest version (1:2.39.2-1.1).
pkg-config is already the newest version (1.8.1-1).
pkg-config set to manually installed.
make is already the newest version (4.3-4.1).
make set to manually installed.
gcc is already the newest version (4:12.2.0-3).
gcc set to manually installed.
The following packages were automatically installed and are no longer required:
  linux-headers-6.1.0-16-amd64 linux-headers-6.1.0-16-common linux-image-6.1.0-16-amd64
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
The following NEW packages will be installed:
  libusb-1.0-0-dev libusb-1.0-doc
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 276 kB of archives.
After this operation, 1,953 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian bookworm/main amd64 libusb-1.0-0-dev amd64 2:1.0.26-1 [83.3 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 libusb-1.0-doc all 2:1.0.26-1 [193 kB]
Fetched 276 kB in 5s (51.8 kB/s)        
Selecting previously unselected package libusb-1.0-0-dev:amd64.
(Reading database ... 462802 files and directories currently installed.)
Preparing to unpack .../libusb-1.0-0-dev_2%3a1.0.26-1_amd64.deb ...
Unpacking libusb-1.0-0-dev:amd64 (2:1.0.26-1) ...
Selecting previously unselected package libusb-1.0-doc.
Preparing to unpack .../libusb-1.0-doc_2%3a1.0.26-1_all.deb ...
Unpacking libusb-1.0-doc (2:1.0.26-1) ...
Setting up libusb-1.0-doc (2:1.0.26-1) ...
Setting up libusb-1.0-0-dev:amd64 (2:1.0.26-1) ...
desktopuser@debian12desktop:~$ git clone --depth=1 https://github.com/raspberrypi/usbboot
Cloning into 'usbboot'...
remote: Enumerating objects: 111, done.
remote: Counting objects: 100% (111/111), done.
remote: Compressing objects: 100% (90/90), done.
remote: Total 111 (delta 10), reused 67 (delta 3), pack-reused 0
Receiving objects: 100% (111/111), 151.34 MiB | 15.27 MiB/s, done.
Resolving deltas: 100% (10/10), done.
desktopuser@debian12desktop:~$ cd usbboot
desktopuser@debian12desktop:~/usbboot$ make
cc -Wall -Wextra -g -o bin2c bin2c.c
./bin2c msd/bootcode.bin msd/bootcode.h
./bin2c msd/start.elf msd/start.h
./bin2c msd/bootcode4.bin msd/bootcode4.h
./bin2c msd/start4.elf msd/start4.h
cc -Wall -Wextra -g -o rpiboot main.c bootfiles.c `pkg-config --cflags --libs libusb-1.0` -DGIT_VER="\"6eead47a\"" -DPKG_VER="\"20221215~105525\""
desktopuser@debian12desktop:~/usbboot$ sudo ./rpiboot
RPIBOOT: build-date Feb 27 2024 version 20221215~105525 6eead47a
Waiting for BCM2835/6/7/2711/2712...
Loading embedded: bootcode4.bin
Sending bootcode.bin
Successful read 4 bytes 
Waiting for BCM2835/6/7/2711/2712...
Loading embedded: bootcode4.bin
Second stage boot server
Cannot open file config.txt
Cannot open file pieeprom.sig
Loading embedded: start4.elf
File read: start4.elf
Cannot open file fixup4.dat
Second stage boot server done

and then I was able to write our latest Debian-based OS to this unit:

root@debian12desktop:/home/desktopuser# xz -cd /media/desktopuser/2TBDISK2/Documents/SolarNetwork/RPi/solarnodeos-deb12-raspi-2GB-20231222.img.xz |dd of=/dev/sdc bs=2M
0+158240 records in
0+158240 records out
2004877312 bytes (2.0 GB, 1.9 GiB) copied, 390.021 s, 5.1 MB/s
root@debian12desktop:/home/desktopuser# sync
root@debian12desktop:/home/desktopuser# blockdev --rereadpt /dev/sdc
root@debian12desktop:/home/desktopuser# e2fsck -f /dev/sdc2
e2fsck 1.47.0 (5-Feb-2023)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
SOLARNODE: 19006/89408 files (0.3% non-contiguous), 228378/357376 blocks

and by switching the boot toggle switch on the unit to OFF and power cycling the USB C connection and plugging in an ethernet cable for my LAN I could see that it booted up fine and I could SSH in!


Result! How good :slight_smile: I hope this helps streamline your production. Thanks for taking the time to document your experience. The CM4 is a bit esoteric, especially the CM4 and Wireless Base combo – I’m sure future users will feel more confident being able to reference your experience.

Best of luck with the project :smiley:

thanks @Michael ! just a question, do you you know if there is any waveshare or other board that can host the Orange Pi CM4?

Unsure @John266303 - after light research i can see orangepi often has compatibility issues with many tools made for RPi so it would require a bit of a deeper dive.