How to Boot the Raspberry Pi 3 from USB with Ubuntu Core

Penk Chen
2 min readDec 11, 2016

--

Update 16 Dec:

Latest Pi3 gadget snap from edge channel (pi3–16.04–0.5 rev.10 at the time of writing) enabled the USB boot feature by default. Here’s how you do it:

Download these two files to your SD card’s boot directory:

Add program_usb_boot_mode=1 to config.txt and reboot Pi with that SD card.

Then just dd edge version’s Ubuntu Core image to the USB drive will do.

Original content:

Here’s a weekend hacking: I want to explore the idea of booting a Raspberry Pi with Ubuntu Core from USB drive, without creating my own custom Gadget snap or modify to the official image.

As you can imagine, technically speaking this isn’t booting directly from the USB drive. Unlike the USB boot mode method, the boot loader and configuration are still being loaded from the micro SD card, but after that, the entire kernel loading and partition mounting process jumps right onto the USB drive.

Turns out it’s quite easy: since the boot loader loads bootscript by default, we can justdd Ubuntu Core image to the USB drive; then add a file /boot/uboot/uEnv.txt on the micro SD card:

snap_core=core_584.snap
snap_kernel=pi2-kernel_24.snap
snappy_usb_boot=run loadfiles; setenv mmcroot "/dev/sda2 ${snappy_cmdline} snap_core=${snap_core} snap_kernel=${snap_kernel}"; run mmcargs; bootz ${loadaddr} ${initrd_addr}:${initrd_size} 0x02000000loadinitrd=load usb ${mmcdev}:${mmcpart} ${initrd_addr} ${snap_kernel}/${initrd_file}; setenv initrd_size ${filesize}
loadkernel=load usb ${mmcdev}:${mmcpart} ${loadaddr} ${snap_kernel}/${kernel_file}
uenvcmd=echo USB-BOOT; run usb_boot; run snappy_usb_boot

(You can download uEnv.txt from the gist)

If you compare these to the original content of uboot.env.in, you’ll see I simply change root partition to /dev/sda2; and replace load mmc with load usb.

Note that I’m using a newer version of Core image on the USB, so snap_core and snap_kernel file name needs to be set differently, if you have the same image on both SD card and USB drive, delete those two lines.

That’s it, plug in the micro SD card, USB drive and power, it boots right on:

Welcome to Ubuntu Core 16!

Needless to say, this is an unofficial and unsupported method, and hasn’t been tested against any of the tools or update mechanism of Ubuntu Core. If you want to go back to the normal booting method, just remove the uEnv.txt file will do. 🍻

--

--

Penk Chen

(自稱) 網紅工程師╱數位藝術家,現旅居東京。長大以後的夢想是開一家玩具店、賣自己做的玩具。