# Booting Raspberry Pi  3 from USB



## balanga (Aug 8, 2019)

Can I boot FreeBSD from a USB device on a RPi3 (I presume it wouldn't work on an RPi2...)?
Is it just a matter of copying the contents of the SD card to USB? If so can I just pop the card into a USB adapter?


----------



## SirDice (Aug 8, 2019)

Raspberry Pi Documentation - Raspberry Pi hardware
					

The official documentation for Raspberry Pi computers and microcontrollers



					www.raspberrypi.org


----------



## aragats (Aug 8, 2019)

As it's mentioned in the article on the link above, some USB drives won't work. My experience shows that most USB 2 drives work, and most USB 3 drives don't. Although I experimented with BBB, not RPi, but I found that there is a timeout constant in *u-boot* (in the USB device detection function), which is too small, so I increased it and recompiled *u-boot*, and now I'm able to use all my USB drives.


----------



## balanga (Aug 9, 2019)

SirDice said:


> Raspberry Pi Documentation - Raspberry Pi hardware
> 
> 
> The official documentation for Raspberry Pi computers and microcontrollers
> ...


It's not clear whether this applies to FreeBSD:-



> To enable the USB boot bit, the Raspberry Pi 3 needs to be booted from an SD card with a config option to enable USB boot mode.



Does that mean I need to set the config option in config.txt on the FAT partition?  Any specific keywords?

Is there any way I can identify which model FreeBSD thinks it is installed on?


----------



## 6502 (Aug 9, 2019)

There is OTP (one time programmable) flag which must be programmed and then RPi will try to boot from USB in addition to SD card (I guess USB is with higher priority).

Details:








						raspberrypi/documentation
					

Official documentation for the Raspberry Pi. Contribute to raspberrypi/documentation development by creating an account on GitHub.




					github.com


----------



## balanga (Aug 9, 2019)

The link provided mentions:- 





> *The following boot sequence applies to the BCM2837-based models of Raspberry Pi only. On all other models, the Pi will try SD card boot, followed by USB device mode boot.*



When I run `dmesg | grep 'bcm283'` I get:-


> bcm283x_dwcotg0: <DWC OTG 2.0 integrated USB controller (bcm283x)> mem 0x7e980000-0x7e98ffff,0x7e006000-0x7e006fff irq 46,47 on simplebus0
> usbus0 on bcm283x_dwcotg0
> bcm2835_cpufreq0: <CPU Frequency Control> on cpu0
> bcm2835_cpufreq0: ARM 600MHz, Core 250MHz, SDRAM 400MHz, Turbo OFF



It sounds to me like the GPIO boot mode OTP bits cannot be programmed on my model, but I should be able to boot using USB device boot mode, if I can figure how to set it, although it looks like I have an RPi model 3B v1.2 so it may well not boot from USB no matter what I  do.


----------



## aragats (Aug 10, 2019)

Also, you can always insert an SD card with *u-boot* script, which will order it to boot off the USB device.


----------



## balanga (Aug 10, 2019)

I learned how to boot from USB using Raspbian....

First check if usb-boot-mode has been set. If it has you will see:-

```
$ vcgencmd otp_dump | grep 17:
17:3020000a
```

If you get a different  result and then you will need to run:- `echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt`.

Once you have it set you just copy your SD card to USB stick using usb-boot .

How do I do the same on FreeBSD?


----------



## Vctrsnts (Aug 24, 2019)

balanga said:


> I learned how to boot from USB using Raspbian....
> 
> First check if usb-boot-mode has been set. If it has you will see:-
> 
> ...



Hello,

I have the same problem. For many years, I have been trying to do the same, to take advantage of 64bits, try to start FreeBSD with the minimum boot of SD and the rest of the system put it on an external hard drive, but it is impossible.

In my opinion, it is not possible, as FreeBSD and u-Boot works (although it may be wrong), because I have tested both the RPI1, RPI2 and now with the RPI3 and nowhere have I achieved it, instead with Raspbian, in 5 minutes I have already done it and that I have looked for information everywhere, I have asked in all the FreeBSD forums that I have been found and they told me in all, it cannot be done.

When you say


```
$ vcgencmd otp_dump | grep 17:
17: 3020000a
```

This file in FreeBSD does not exist and 
	
	



```
vcgencmd
```
 is an instruction only available in Raspbian.

Sorry if my words are very pessimistic.

Of course, I will follow this post, because I find it very interesting.


----------



## Vctrsnts (Aug 29, 2019)

Hello,

I have an RPI3 to which I have installed FreeBSD 12.0 Release on a USB (I discovered how to start FreeBSD from an external USB or HDD without the need for an SD).

When boot the system, the following message appears:


```
Mounting from ufs:/dev/ufs/rootfs failed with error 19
Loader variables:
vfs.root.mountfrom = ufs:/dev/ufs/rootfs
vfs.root.mountfrom.options = rw
mountroof>
```

And the system stops, but if I write `ufs:/dev/da0s2a` where is the system in the USB it starts without any problem and works correctly.

The problem was in the /etc/fstab file, change 
	
	



```
/dev/ufs/rootfs
```
 by 
	
	



```
/dev/da0s2a
```

When reboot the system, the same message reappears:


```
Mounting from ufs:/dev/da0s2a failed with error 19
Loader variables:
vfs.root.mountfrom = ufs:/dev/da0s2a
vfs.root.mountfrom.options = rw
mountroof>
```

And if I write the same command `ufs:/dev/da0s2a` the system starts correctly and again, without any problem.

This is where I have the doubt, how to solve this problem.

Thank you if you can help me.


----------



## Phishfry (Aug 29, 2019)

My first attempt would be to add more delay to allow the drive to come up.

/boot/loader.conf

```
vfs.mountroot.timeout="15"
```


----------



## Phishfry (Aug 30, 2019)

There is also a loader setting you could try to see if fstab is working right.
/boot/loader.conf

```
vfs.root.mountfrom="ufs:/dev/da0s2a"
```

I also foggily seem to remember that dtb's were only symbolic linked to boot partition from /boot/dtb/*.
So if you have built your own spin make sure you have the links.


----------



## teh_fink (Nov 3, 2019)

After reading your comments, I decided to give it a try, with:

FreeBSD-12.1-RC2-arm64-aarch64-RPI3.img.xz
32GB USB drive
Raspberry Pi 3 Model B Rev 1.2 with reprogrammed otp for usb booting
I copied the image to the drive from my mac: `sudo dd if=FreeBSD-12.1-RC2-arm64-aarch64-RPI3.img of=/dev/disk5 bs=2m`
With the freebsd USB drive inserted, the rpi boots to a rainbow screen. However, it can't get past u-boot, showing the following errors:


```
Net:   No ethernet found.
starting USB...
Bus usb@7e980000: scanning bus usb@7e980000 for devices...
    USB device not accepting new address (error=0)
4 USB Device(s) found
    scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:   0
MMC Device 0 not found
no mmc device at slot 0
Card did not respond to voltage select!

Device 0: unknown device
Waiting for Ethernet connection... unable to connect.
Missing environment variable: pxeuuid
Missing environment variable: bootfile
…
```


----------



## sagaracharya (Jun 25, 2020)

Are there any updates on this front? I want to use 13-CURRENT on RPI3 as a server and booting from hard disk via usb would help me a lot with storage size!


----------



## SirDice (Jun 25, 2020)

sagaracharya said:


> I want to use 13-CURRENT


Topics about unsupported FreeBSD versions

Stick to a -RELEASE version. Or, if you want to be more adventurous, use a -STABLE version.


----------



## aragats (Jun 25, 2020)

sagaracharya said:


> booting from hard disk via usb would help me a lot with storage size


What's wrong with booting it in regular way ― off an SD card and still use a USB hard disk for storage, if the purpose IS storage?


----------



## sagaracharya (Jun 25, 2020)

aragats said:


> What's wrong with booting it in regular way ― off an SD card and still use a USB hard disk for storage, if the purpose IS storage?


Nothing wrong. Just saves the sd card. And helps with minimalism



SirDice said:


> Topics about unsupported FreeBSD versions
> 
> Stick to a -RELEASE version. Or, if you want to be more adventurous, use a -STABLE version.


Sir, I did try 13-CURRENT of around 28th May and they work fine in my case. I was using the most recent snapshot. Although I must accept I was unable to mount my FLASH USB. Anyways, I read the above post, I'll switch to 12.1-STABLE. Please let me know if anyone has managed to run FBSD through USB.


----------



## trev (Jul 1, 2020)

See https://wiki.freebsd.org/arm/Raspberry Pi#Known_Issues.2Fhints


----------

