{"record":{"id":"e6d521a4830d6b2d","repo":"rust-embedded/rust-raspberrypi-OS-tutorials","slug":"error-initializing-bsp-driver-subsystem","errorCode":null,"errorMessage":"Error initializing BSP driver subsystem: {}","messagePattern":"Error initializing BSP driver subsystem: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"20_timer_callbacks/kernel/src/main.rs","lineNumber":40,"sourceCode":"/// When this code runs, virtual memory is already enabled.\n///\n/// # Safety\n///\n/// - Only a single core must be active and running this function.\n/// - Printing will not work until the respective driver's MMIO is remapped.\n#[no_mangle]\nunsafe fn kernel_init() -> ! {\n    exception::handling_init();\n    memory::init();\n\n    // Initialize the timer subsystem.\n    if let Err(x) = time::init() {\n        panic!(\"Error initializing timer subsystem: {}\", x);\n    }\n\n    // Initialize the BSP driver subsystem.\n    if let Err(x) = bsp::driver::init() {\n        panic!(\"Error initializing BSP driver subsystem: {}\", x);\n    }\n\n    // Initialize all device drivers.\n    driver::driver_manager().init_drivers_and_irqs();\n\n    bsp::memory::mmu::kernel_add_mapping_records_for_precomputed();\n\n    // Unmask interrupts on the boot CPU core.\n    exception::asynchronous::local_irq_unmask();\n\n    // Announce conclusion of the kernel_init() phase.\n    state::state_manager().transition_to_single_core_main();\n\n    // Transition from unsafe to safe.\n    kernel_main()\n}\n\n/// The main function running after the early init.","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials/blob/644474cc09f755249f9c55d99a5d1e07a2562fc7/20_timer_callbacks/kernel/src/main.rs#L22-L58","documentation":"kernel_init() panics with \"Error initializing BSP driver subsystem: {}\" when bsp::driver::init() returns Err. This initialization registers the BSP's device and IRQ managers; the kernel refuses to continue without them. The '{}' carries the BSP's underlying error string.","triggerScenarios":"bsp::driver::init() returns Err — e.g. its internal driver/IRQ manager construction or registration failed, or a board-specific check (hardware revision, MMIO region) rejected the platform.","commonSituations":"Booting on a board revision not supported by the selected BSP; a misconfigured BSP feature/const (wrong board, wrong peripheral base) causing driver init to bail; running a QEMU machine that doesn't emulate the expected peripherals.","solutions":["Inspect the wrapped '{}' message for the exact BSP error and fix that root cause first.","Build for the BSP matching your hardware (correct RUST_TARGET_BSP / board model).","Verify board revision detection (e.g. RPi GPIO/mailbox check) matches the actual machine.","Use a QEMU machine type that emulates the BSP's peripherals (e.g. -M raspi3 for rpi3 builds)."],"exampleFix":"// before: BSP mismatch\n// built for bsp=rpi4, executed on raspi3 -> bsp::driver::init() errors\n// after: build the BSP for the running board\nRUST_TARGET_BSP=rpi3 make; qemu-system-aarch64 -M raspi3 -kernel kernel8.elf","handlingStrategy":"fallback","validationCode":"// Verify board/BSP pairing before boot scripts launch the kernel\n// shell: check machine model matches RUST_TARGET_BSP\nqemu-system-aarch64 -M ? | grep -q raspi3 || echo \"wrong machine\"","typeGuard":null,"tryCatchPattern":"// Log the BSP error before panicking\nif let Err(x) = bsp::driver::init() {\n    sys_println!(\"BSP driver init failed: {}\", x);\n    panic!(\"Error initializing BSP driver subsystem: {}\", x);\n}","preventionTips":["Keep RUST_TARGET_BSP and your run command (QEMU -M / real board) in sync via a Makefile target.","Log the underlying BSP error string before panicking.","Add a hardware/revision sanity check early in the BSP init."],"tags":["kernel","bsp","drivers","boot","panic"],"backgroundTag":"module-init-failed","analyzedSha":"644474cc09f755249f9c55d99a5d1e07a2562fc7","analyzedAt":"2026-09-06T09:25:56.584Z","contentChangedAt":"2026-09-06T09:25:56.584Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}