Skip to content

Instantly share code, notes, and snippets.

@hathach
Last active October 22, 2021 15:35
Show Gist options
  • Select an option

  • Save hathach/64143ee906dd1f870d217092ba208e91 to your computer and use it in GitHub Desktop.

Select an option

Save hathach/64143ee906dd1f870d217092ba208e91 to your computer and use it in GitHub Desktop.
CM4 netboot

We will need an LAN cable to CM4 and PC running tftpd-hpa for netbooting. Basically we will need to

  1. Modify bootloader of CM4 to set TFTP_IP to our PC
  2. Flash the new config
  3. Install tftpd and change directory to our boot folder

1. Modify CM4 bootloader config

full doc can be found here https://www.raspberrypi.com/documentation/computers/compute-module.html#compute-module-4-bootloader . here is the summary

  • git clone https://github.com/raspberrypi/usbboot.git
  • then go into newly cloned usbboot folder and run make to compile.
  • then go to recovery folder to edit boot.conf to include TFTP_IP to your PC local IP, BOOT_UART=1 is nice to eanble as well. Here is mine
[all]
BOOT_UART=1
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0

# Try  SD -> Network ->  Loop
BOOT_ORDER=0xf21

# Set to 0 to prevent bootloader updates from USB/Network boot
# For remote units EEPROM hardware write protection should be used.
ENABLE_SELF_UPDATE=1

TFTP_IP=192.168.0.117
  • run ./update-pieeprom.sh which is helper script to generate binary and signature for bootloader config

2. Flash the CM4 bootloader config

  • Insert Jumpber to one that says Fit Jumper to disable eMMC Boot as shown in the picture image
  • plug usb micro usb cable from CM4IO to your pc and power on the cm4, it will boot as usb device with HID interface.
  • from usbboot folder run sudo ./rpiboot -d recover, it will then flash the new boot config to the board.
  • Then you are done with the CM4, remove the jumper, remove SD card, plug your LAN cable.

3. Install and Setup TFTP Server

Note this is for ubuntu 20.04, your PC can be different. Detailed install can be found here https://linuxhint.com/install_tftp_server_ubuntu/

  • sudo apt install tftpd-hpa
  • then edit its config sudo nano /etc/default/tftpd-hpa to change the TFTP_DIRECTORY to your preferred folder that hold all the boot files for CM4 (all the files in boot partition in SD card).
  • restart server with sudo systemctl restart tftpd-hpa. You could test the server using client from tft-hpa

You are all set, plug the LAN to CM4 without SD card, then it should try to boot with SD, then fall back to network. Just make sure kernel8.img is copied to your tft server directory when compiling.

TIPs: CM4 does not have power button, use an AC extension cord with on/off button to quickly cycle power on/off to test it out (not sure if this could cause any electrical issue with cpu).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment