Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Timing issues with USB attached storage
john%ziaspace.com@localhost (John Klos) writes:
>I run NetBSD on a number of Raspberry Pis with USB attached storage. For
>spinning rust, there's "boot_delay" in config.txt, but now I'm running in
>to another issue.
>If I have a USB keyboard attached to this Pi with a Suptronics X820, it
>boots just fine. If I remove the keyboard, the SATA SSD doesn't attach
>until the kernel is already trying to mount root, so I get the error
>message seen here:
This here is a patch that waits some time for a specified root
device to appear. Was necessary to make an RPI2 use the root from USB
(it still needs to fetch firmware and kernel from SD-card).
Index: kern_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_subr.c,v
retrieving revision 1.230
diff -p -u -r1.230 kern_subr.c
--- kern_subr.c 19 Mar 2022 13:51:35 -0000 1.230
+++ kern_subr.c 15 Jan 2023 08:22:39 -0000
@@ -174,6 +174,13 @@ uint64_t booted_nblks;
char *bootspec;
/*
+ * Time to wait for a specified boot device to appear.
+ */
+#ifndef ROOT_WAITTIME
+#define ROOT_WAITTIME 20
+#endif
+
+/*
* Use partition letters if it's a disk class but not a wedge or flash.
* XXX Check for wedge/flash is kinda gross.
*/
@@ -185,6 +192,7 @@ char *bootspec;
void
setroot(device_t bootdv, int bootpartition)
{
+ time_t waitend;
/*
* Let bootcode augment "rootspec", ensure that
@@ -241,14 +249,19 @@ setroot(device_t bootdv, int bootpartiti
/*
* loop until a root device is specified
*/
+ waitend = time_uptime + ROOT_WAITTIME;
do {
if (boothowto & RB_ASKNAME)
setroot_ask(bootdv, bootpartition);
- else
+ else {
setroot_root(bootdv, bootpartition);
-
- if (root_device == NULL)
- boothowto |= RB_ASKNAME;
+ if (root_device == NULL) {
+ if (time_uptime < waitend) {
+ kpause("root", false, hz, NULL);
+ } else
+ boothowto |= RB_ASKNAME;
+ }
+ }
} while (root_device == NULL);
}
Home |
Main Index |
Thread Index |
Old Index