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

Penk Chen
Penk Chen
Dec 11, 2016 · 2 min read

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

Written by

Penk Chen

Keep on rockin' in the free world

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade