Boot Raspberry Pi 4 with USB drives plugged in. reddit / freebsd ---------------------------------------------------------------------- o0xh · 2023-04-04 14:49 # SOLVED In order to boot FreeBSD, with 2 USB devices attached, the following process worked for me and should work for you: 1. Write the image to an SD card as usual, boot with a serial cable attached. 2. Interrupt the boot process, and enter the U-boot menu and type: > usb stop; boot > > (then press Enter) 3. Once FreeBSD boots up, configure networking and install the u-boot- tools package 4. Create a file called `/boot/msdos/boot.cmd` with the following contents: ``` usb stop ``` 4. Run the following command to compile `boot.cmd` ``` mkimage -C none -A arm -T script -d /boot/msdos/boot.cmd /boot/msdos/boot.scr ``` 5. You can now boot with multiple USB devices attached. 6. Alternatively, if you want to just drop `boot.scr` onto the root of the FAT partition of your SD card you can get it here: https://paste.c-net.org/FamineVenom You're also going to want to add `vfs.root_mount_always_wait=1` to `/boot/loader.conf` if these drives are part of a zpool. --- # Problem Is there some trick to getting FreeBSD 13.1 to boot on the Pi 4 with two USB flash drives plugged in? I wrote the 13.1 PI image to an SD card, booted it up, formatted two USB drives and rebooted and it will not boot with both USB drives plugged in, but work fine without any plugged in or one plugged in at boot time (I can plug them in after boot, and they work fine as well.) Update, serial console output: ``` U-Boot 2021.07 (May 12 2022 - 07:00:33 +0000) DRAM: 3.9 GiB RPI 4 Model B (0xc03114) MMC: mmc@7e300000: 3, emmc2@7e340000: 0 Loading Environment from FAT... In: serial Out: vidconsole Err: vidconsole Net: eth0: ethernet@7d580000 PCIe BRCM: link up, 5.0 Gbps x1 (SSC) starting USB... Bus xhci_pci: Register 5000420 NbrPorts 5 Starting the controller USB XHCI 1.00 scanning bus xhci_pci for devices... 4 USB Device(s) found scanning usb for storage devices... 2 Storage Device(s) found Hit any key to stop autoboot: 0 switch to partitions #0, OK mmc0 is current device Scanning mmc 0:1... libfdt fdt_check_header(): FDT_ERR_BADMAGIC Scanning disk mmc@7e300000.blk... Disk mmc@7e300000.blk not ready Scanning disk emmc2@7e340000.blk... ** Unrecognized filesystem type ** Scanning disk usb_mass_storage.lun0... ** Unrecognized filesystem type ** Scanning disk usb_mass_storage.lun0... ERROR: failure to add disk device usb_mass_storage.lun0, r = 20 ``` dmesg after booting and plugging in drives: ``` da0 at umass-sim0 bus 0 scbus0 target 0 lun 0 da0: Removable Direct Access SPC-4 SCSI device da0: Serial Number 0401af2d1bf39f943d64313d1b383f39ebdee64aebdf02d7d372291d55d9 da0: 400.000MB/s transfers da0: 58680MB (120176640 512 byte sectors) da0: quirks=0x2 usb_msc_auto_quirk: UQ_MSC_NO_GETMAXLUN set for USB mass storage device USB SanDisk 3.2Gen1 (0x0781:0x5583) usb_msc_auto_quirk: UQ_MSC_NO_PREVENT_ALLOW set for USB mass storage device USB SanDisk 3.2Gen1 (0x0781:0x5583) usb_msc_auto_quirk: UQ_MSC_NO_SYNC_CACHE set for USB mass storage device USB SanDisk 3.2Gen1 (0x0781:0x5583) ugen0.4: at usbus0 umass1 on uhub0 umass1: on usbus0 umass1: SCSI over Bulk-Only; quirks = 0xc100 umass1:1:1: Attached to scbus1 da1 at umass-sim1 bus 1 scbus1 target 0 lun 0 da1: Removable Direct Access SPC-4 SCSI device da1: Serial Number 0401b4fa3d03aaf47263ea6c0d011914bcad225674711bf0bfaa52c01137 da1: 400.000MB/s transfers da1: 58674MB (120164352 512 byte sectors) da1: quirks=0x2 ``` ---------------------------------------------------------------------- o0xh · 2023-04-05 00:31 This sounds like my problem: [https://bugs.freebsd.org/bugzilla/show\_ bug.cgi?id=256441](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=2 56441) > With 0 or 1 USB storage devices inserted, the system boots fine. With 2-4 USB storage devices inserted, the system will not boot. Looks like U-Boot is getting stuck in this situation and not able to read the second stage bootloader from the SD card mmc0 storage. ---------------------------------------------------------------------- o0xh · 2023-04-05 00:40 In case this helps anyone else out this [workaround](https://bugs.free bsd.org/bugzilla/show_bug.cgi?id=253983#c59) "works": > interrupt to get into the u-boot-prompt(e.g. by holding the TAB- key). > > type exactly following one-liner : > > usb stop; boot > > (then press Enter) But I'm not sure how to make that a permanent option in u-boot, if I find out, I'll share here. ---------------------------------------------------------------------- EstablishmentBig7956 · 2023-04-05 01:12 Sounds like it's getting confused so it just hangs up ---------------------------------------------------------------------- o0xh · 2023-04-05 01:52 Sounds about right, u-boot is getting _me_ confused. I found some suggestions on the FreeBSD forum that the u-boot environment variables can be managed by placing a `uEnv.txt` file on the FAT partition, though so far I've had no luck in getting that to change the variables shown through `printenv` in the u-boot menu. Through testing I've found that I can set: > editenv bootcmd > > usb stop; run distro_bootcmd but also can't seem to make that persist. `saveenv` also fails as mentioned here too: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263170 Honestly, the unused NUC on my shelf is looking pretty tempting at the moment I'd have been done with this project already instead of now looking at having to setup a FreeBSD machine to fiddle with u-boot packages. ---------------------------------------------------------------------- EstablishmentBig7956 · 2023-04-05 02:09 I don't really know anything about pi but whatever SD card you installed in on is probably the one it's always looking for to boot from. Adding more or putting it in a different SD card slot it can't find itself to boot. That's my logical deduction behind it