feat: wait up to 10s for a late MONTAUKROOT, retry USB enumeration after a port reset, recover halted EP0/bulk endpoints, MSC card reader settle

This commit is contained in:
daniel committed 2026-10-25 17:57:20 +01:00
1 parent ffee9002a6
commit 93d8becce3
14 files changed
+340 -57

No files matched your search

+23 -2
View File
@@ -11,6 +11,8 @@
#include <Fs/Fat32.hpp>
#include <Fs/Ext2.hpp>
#include <Fs/FsProbe.hpp>
#include <Drivers/Init.hpp>
#include <Timekeeping/Timer.hpp>
namespace Fs {
@@ -18,6 +20,12 @@ namespace Fs {
constexpr const char* RootLabel = "MONTAUKROOT";
// How long a boot without a ramdisk waits for the root partition to
// appear. A USB root (a stick, or a card reader still bringing its
// card up) can register after the boot scan; until then nothing would
// provide 0:/os/init.elf.
constexpr uint64_t RootWaitMs = 10000;
bool StringsEqual(const char* lhs, const char* rhs) {
if (lhs == nullptr || rhs == nullptr) return false;
@@ -126,8 +134,21 @@ namespace Fs {
Fat32::RegisterProbe();
Ext2::RegisterProbe();
if (!hasRamdisk && FsProbe::MountRootByLabel(RootLabel) < 0) {
Kt::KernelLogStream(Kt::WARNING, "Fs")
<< "No ramdisk and no " << RootLabel << " partition; using the first one found";
Kt::KernelLogStream(Kt::INFO, "Fs")
<< "Waiting for the " << RootLabel << " partition";
// A device that registers now gets its root partition mounted by
// FsProbe::MountPartitionsForBlockDevice, which knows the label.
// Counted in BusyWaitMs steps, which are bounded even without a tick.
for (uint64_t waited = 0; !Vfs::IsDriveRegistered(0) && waited < RootWaitMs; waited += 10) {
Drivers::ServiceStorageHotplug();
Timekeeping::BusyWaitMs(10);
}
if (!Vfs::IsDriveRegistered(0)) {
Kt::KernelLogStream(Kt::WARNING, "Fs")
<< "No ramdisk and no " << RootLabel << " partition; using the first one found";
}
}
FsProbe::MountPartitions(hasRamdisk ? 1 : 0);
}