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).


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.


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. )

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....


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.