The Idea here is to boot from SD card, load uboot and link/tag usb boot partition to continue boot the Pi. This is the only way in order to boot from external usb hard drive the pi.
first of all I gathered info from these sources:
[*]setting up U-Boot into SD:
https://blog.christophersmart.com/2016/ ... rm-boards/
1. I used VirtualBox in my Arch system and installed Fedora for my guest Os
2. I connected my usb/card reader and passed-through my Fedora guest
Partition the SD card
you don't need ext4 partition because you'll use that from USB!!
Assuming your card is at /dev/sdx (replace as necessary, check dmesg after plugging it in if you’re not sure).
Code: Select all
sudo umount /dev/sdx* # makes sure it's not mounted
sudo parted -s /dev/sdx \
mklabel msdos \
mkpart primary fat32 1M 30M
Code: Select all
sudo mkfs.vfat /dev/sdx1
Code: Select all
sudo mount /dev/sdx1 /mnt
Code: Select all
sudo dnf install \
gcc-arm-linux-gnu \
binutils-arm-linux-gnu \
uboot-tools
Code: Select all
cd "${HOME}"
git clone --depth 1 -b v2019.10 git://git.denx.de/u-boot.git
cd u-boot
# Run this for the Pi 2
Code: Select all
CROSS_COMPILE=arm-linux-gnu- make rpi_2_defconfig
Code: Select all
CROSS_COMPILE=arm-linux-gnu- make rpi_3_32b_defconfig
Code: Select all
CROSS_COMPILE=arm-linux-gnu- make -j$(nproc)
Code: Select all
sudo cp -iv u-boot.bin /mnt/kernel.img
Sadly, the Raspberry Pi cannot boot entirely on open source software, we need to get the proprietary files from Broadcom and place them on the SD card also.
Clone the Raspberry Pi Foundation’s GitHub repository.
Code: Select all
cd "${HOME}"
git clone --depth 1 https://github.com/raspberrypi/firmware
Code: Select all
sudo cp -iv firmware/boot/{bootcode.bin,fixup.dat,start.elf} /mnt/
Code: Select all
sync && sudo umount /mnt
Bootloader config
Next we need to make a bootloader file, boot.cmd, which tells U-Boot what to load and boot (the kernel, device tree and initramfs).
The bootargs line says to output the console to serial and to boot from the ramdisk. Variables are used for the memory locations of the kernel, dtb and initramfs.
Note that the root device is /dev/root which is required for the initramfs.
Code: Select all
cat > boot.cmd << EOF
# After modifying, run ./mkscr
#Set root partition to the second partition of boot device
setenv usb_pgood_delay 10000; #usb_pgood_delay initial value was 2000 and the usb search inside uboot was failing
setenv fdtfile bcm2709-rpi-2-b.dtb #load from sd card the dev tree
usb stop;
usb start;
usb dev 0;
setenv bootargs console=ttyS1,115200 console=tty0 root=/dev/sda2 rw rootwait rootdelay=30 smsc95xx.macaddr="${usbethadd>
if load usb 0:1 ${kernel_addr_r} /kernel7.img; then
if load usb 0:1 ${fdt_addr_r} /${fdtfile}; then
if load usb 0:1 ${ramdisk_addr_r} /initramfs-linux.img; then
setenv usb_pgood_delay 200; #reset the value here because the 1st usb search always fails
bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
else
setenv usb_pgood_delay 200; #reset the value here because the 1st usb search always fails
bootz ${kernel_addr_r} - ${fdt_addr_r};
fi;
fi;
fi
EOF
Code: Select all
sudo mkimage -C none -A arm -T script -d boot.cmd /mnt/boot.scr
Code: Select all
sudo umount /dev/sdx*
I used ArchLinuxArm and followed those instructions. make sure you put boot partition in the 1st place and root 2nd.
After Booting Arch Linux
finalizing Arch with this tutorial:
https://github.com/phortx/Raspberry-Pi-Setup-Guide
Final Words
this guide is for those who want pure usb bootable system from RPI that supports U-Boot and doesn't support usb from start... I was playing with my RPI2 and all I've ever wanted was to update my system and to minimize sd card corruption/degradation from the read/write jobs.
inside my boot.cmd file I linked some files from my USB boot partition that comes with Arch-Arm Image preinstalled
1. /kernel7.img
2. /${fdtfile}
3. /initramfs-linux.img
all 3 of them are located inside my usb boot partition
an image after booting rpi2:
