xm530: autoload the SD card driver at boot - #2315
Conversation
PR Summary by QodoAutoload the XM530 SD card driver at boot
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding |
openipc-ai
left a comment
There was a problem hiding this comment.
The new module check can't fail, so it doesn't guard what it's meant to.
br-ext-chip-xiongmai/board/xm530/xm530.generic.config carries CONFIG_MMC_SD=m, and OpenIPC/linux xiongmai-xm530 has obj-$(CONFIG_MMC_SD) += sdio0_sd.o in drivers/mmc/host/Makefile. This PR's own xm530_lite run builds and installs it:
LD [M] drivers/mmc/host/sdio0_sd.ko
INSTALL drivers/mmc/host/sdio0_sd.ko
So the image holds two modules called sdio0_sd.ko — that one under kernel/drivers/mmc/host/, and the vendor blob the package installs to xiongmai/. check_module does find "$TARGET_DIR/lib/modules" -name "$ko", which matches the kernel-built copy regardless of whether xiongmai-osdrv-xm530 shipped its own. If the package's INSTALL_TARGET_CMDS ever stopped installing it, the check would still print OK — exactly the #2032-class regression the script exists to catch.
Scoping the match by path fixes it without disturbing the wireguard entry:
- if find "$TARGET_DIR/lib/modules" -name "$ko" | grep -q .; then
+ if find "$TARGET_DIR/lib/modules" -path "*/$ko" | grep -q .; then
…
-check_module BR2_PACKAGE_XIONGMAI_OSDRV_XM530 sdio0_sd.ko
+check_module BR2_PACKAGE_XIONGMAI_OSDRV_XM530 xiongmai/sdio0_sd.kowireguard.ko still matches as */wireguard.ko.
Worth knowing which of the two actually loads, since it isn't the in-tree source: with both present, depmod (kmod 34.2) writes only xiongmai/sdio0_sd.ko: into modules.dep — the external directory wins over kernel/, it still wins when modules.order names the kernel path, and it isn't alphabetical. So modprobe sdio0_sd loads the vendor blob and the kernel-built copy is shadowed dead weight.
Two smaller things while you're pushing, since touching late-post-build-hooks.list re-runs the full board matrix each time:
- The description implies SD works out of the box, but the driver loads with
detect=0, sosdio0_powerup()leaves GPIO49 (sdio0_detect) unmuxed andneed_detect/need_pollare both 0. A card present at boot enumerates, as your evidence shows; one inserted afterwards has no detect path. Worth saying hot-plug is out of scope —/etc/modulesdoes take arguments (sdio0_sd detect=1) if it shouldn't be. - Have you been able to try this on a second XM530 board, ideally one without a card slot?
sdio0_powerup()muxes GPIO43-48 and 51-52 to SDIO and drives GPIO50 output-low unconditionally, and this makes that a default on every xm530/xm550 image. If those pads are free on all XM530 designs that's fine, but it'd be good to have it stated.
Everything else looks right to me — the hook is idempotent, the late-post-build-hooks.list placement genuinely does run after the overlay copy, and S35modules → S38mdev orders correctly (mdev sets the hotplug handler before mdev -s, so the coldplug can't race the card).
The vendor Arasan SDHC driver (module sdio0_sd) ships in the image but is never loaded: /etc/modules only lists vfat and exfat, so S35modules never modprobes it and /dev/mmcblk0 does not appear even with a card in the slot. mdev's automount helper and majestic's record path both expect /dev/mmcblk0p1. Append the module to /etc/modules from a late post-build hook keyed on BR2_PACKAGE_XIONGMAI_OSDRV_XM530, since general/overlay/etc/modules is shared by every SoC and must stay board-agnostic. Also assert the .ko lands in the image in check_target_modules.sh. Tested on XM530AI (IPC-RB-BLK530AI-0235P-AB0 V1.03) with a 128GB FAT32 card: before, the card is invisible to the kernel; after, mmc0 detects it and mdev mounts it at /mnt/mmcblk0p1.
Update the module check script to expect sdio0_sd.ko under the xiongmai/ subdirectory, matching the actual installation layout. Add comments to the post-build hook clarifying that the driver uses detect=0 by default, so hot-plug insertion is not detected—only cards present at boot are enumerated.
734600c to
b15e467
Compare
Problem
On XM530 boards the vendor SD card driver (Arasan SDHC, kernel module
sdio0_sd) ships in the image but is never loaded:general/overlay/etc/modulesonly lists
vfatandexfat, soS35modulesnever modprobes it. With a card inthe slot the kernel shows no mmc controller and no
/dev/mmcblk0; mdev'sautomount helper (
/lib/mdev/automount.sh) and majestic's record path(
/mnt/mmcblk0p1/%F) both expect the card at/dev/mmcblk0p1, so SD storage isdead out of the box.
The module entry is appended to
/etc/modulesby a late post-build hook keyed onBR2_PACKAGE_XIONGMAI_OSDRV_XM530(xm530 and xm550 defconfigs), becausegeneral/overlay/etc/modulesis shared by every SoC and must stay board-agnostic.check_target_modules.shadditionally assertssdio0_sd.kolands in the imagewhenever the package is selected.
Hardware tested on
XM530AI (marking 30WX1), board IPC-RB-BLK530AI-0235P-AB0 V1.03, "anbiux-A8B-3mp",
128GB FAT32 (SDXC) card.
Evidence
Before — card inserted, kernel has no idea it exists:
After (this patch, verified across a reboot):
Note: the kernel only supports vfat for the card (exfat is not built in and has
no module in this tree), so the card must be FAT32; this patch does not change
that.
Scope
general/package/all-patches/linux/(those go to OpenIPC/linux)general/overlay/or in a sharedload_<vendor>script hardcodes a value specific to my boardLD_PRELOAD, and no binaries that cannot be rebuilt from source