How to correlate/bind specific usb hardware to /dev/sd* in u-boot?

Since udev is not present in OpenWrt I am looking for a way to to correlate/bind specific usb hardware to a specific /dev/sd* (not via fstab).

https://openwrt.org/docs/guide-user/base-system/hotplug

2 Likes

hot/coldplug comes into play once the kernel starts loading.

How about a way in u-boot? (just edited the topic to better reflect)

The device names are a kernel construct. U-Boot is long gone at the point the drivers load and device names are generated.

2 Likes

Describe why exactly you would want that?

There are up to three USB drives connected to the router at boot time and the router to be booted from one of those three

WARNING: risky business....

in this case... a relavent uboot bootcmd which scans each /dev/sdX ( to uboot they are usb 0:1, usb 0:2 etc ) for either loadable files, a flagfile or a bootcmd.txt / boot.scr is the way it is done...

they would also then have to inform the kernel of the "abstracted" /dev/sdX ... ( better to use UUID or similar )... in the form of a modified bootarg option....

this is how i'm doing it... expanding to more usb drives is easy... you'd have to pass UUID or similar differently....

Of note: Below its important to realise that booty.txt replaces the built-in bootcmd. The whole process hinges on that... Not the only way to do it... but it is one way to ensure that you dont mess with the on device boot process....

booty.txt ( you would have seperate ones on each drive with different wrtbootdev device labels etc. )

bootdelay=3
wrt_init=/sbin/init
wrt_root_delay=7
wrt_console=ttyMSM0,115200n8 
wrtbootdev=/dev/sda3
serverip=192.168.1.7
wrtgo=usb start; ext2load usb 0:1 $kload kernel; run wrtbootarg; bootm $kload
bootcmd=run wrtgo

some relavent uboot vars

wrtbootarg=setenv bootargs console=$wrt_console initrd=initrd=$loadaddr_rootfs init=$wrt_init root=$wrtbootdev rootwait

checkusb=usb start; if ext2load usb 0:1 ${uload} booty.txt; then echo Importing USB booty.txt && env import -t ${uload} ${filesize} && run bootcmd; fi

wrtgo=usb start; ext2load usb 0:1 $kload kernel; run wrtbootarg; bootm $kload

bootcmd=run checkusb; run bootcmdorg; run bootresc

DO NOT SAVEENV until the whole thing is tested many times with and without the drive present!

FYI: there is also this "alpha" live-oem-without-serial-or-fw_printenv injection script... obviously specific to me.... but shows parsing, and saving specific values....

https://raw.githubusercontent.com/wulfy23/rt2600ac/master/synowrt/base-files/custom/bin/wrtbootgen

3 Likes

reckon UUID is the best and safest bet

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.