mtd0 device is missing in /sys/class/mtd

Manojkiran Eda manojkiran.eda at gmail.com
Thu Dec 28 08:38:51 PST 2023


Hi All,

I was as beginner in linux device driver development, and recently I was working on a device driver for espi protocol and was stuck with a problem.

I have an mtd device driver through which one could access the NOR flash connected to the other end of  espi bus. The driver seems to have probed successfully , I see an entry for my mtd device in /proc/mtd but , I dont see an entry for my mtd device in the /sys/class/mtd.

Here are few logs of interest :

root at mybox:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 04000000 00001000 "aspeed-espi-flash” <<<<<—— This is my mtd device
mtd1: 04000000 00010000 "bmc"
mtd2: 000e0000 00010000 "u-boot"
mtd3: 00020000 00010000 "u-boot-env"
mtd4: 00900000 00010000 "kernel"
mtd5: 02000000 00010000 "rofs"
mtd6: 01600000 00010000 "rwfs"
mtd7: 04000000 00010000 "alt-bmc"
mtd8: 000e0000 00010000 "alt-u-boot"
mtd9: 00020000 00010000 "alt-u-boot-env"
mtd10: 00900000 00010000 "alt-kernel"
mtd11: 02000000 00010000 "alt-rofs"
mtd12: 01600000 00010000 "alt-rwfs”


root at mybox:/sys/class/mtd# ls
mtd1     mtd10ro  mtd11ro  mtd12ro  mtd2     mtd3     mtd4     mtd5     mtd6     mtd7     mtd8     mtd9
mtd10    mtd11    mtd12    mtd1ro   mtd2ro   mtd3ro   mtd4ro   mtd5ro   mtd6ro   mtd7ro   mtd8ro   mtd9ro

I was expecting mtd0 to be present in the /sys/class/mtd, but its not there.

Looking at dmesg:

root at mybox:/sys/class/mtd# dmesg | grep -ie mtd -A5 -ie espi
[    0.685006] Entered the aspeed_espi_ctrl_probe function
[    0.690990] device matched :  1
[    0.699225] espi alloc started
[    0.704726] espi read from device tree, flash size :  67108864
[    0.712416] espi flash enabled
[    0.716572] espi flash channel is ready
[    0.720940] espi flash allocation completed
[    0.725259] aspeed-espi-ctrl 1e6ee000.espi-ctrl: module loaded
--
[    0.962764] 5 fixed-partitions partitions found on MTD device bmc
[    0.969675] Creating 5 MTD partitions on "bmc":
[    0.974776] 0x000000000000-0x0000000e0000 : "u-boot"
[    0.981982] 0x0000000e0000-0x000000100000 : "u-boot-env"
[    0.989557] 0x000000100000-0x000000a00000 : "kernel"
[    0.996772] 0x000000a00000-0x000002a00000 : "rofs"
[    1.003759] 0x000002a00000-0x000004000000 : "rwfs"
--
[    1.048304] 5 fixed-partitions partitions found on MTD device alt-bmc
[    1.055563] Creating 5 MTD partitions on "alt-bmc":
[    1.061096] 0x000000000000-0x0000000e0000 : "alt-u-boot"
[    1.068672] 0x0000000e0000-0x000000100000 : "alt-u-boot-env"
[    1.076607] 0x000000100000-0x000000a00000 : "alt-kernel"
[    1.084211] 0x000000a00000-0x000002a00000 : "alt-rofs"
[    1.091594] 0x000002a00000-0x000004000000 : "alt-rwfs”

and the mtd devices listed in /sys/class/mtd from mtd1 through mtd12 are basically from the partitions list above.

root at mybox:/sys/class/mtd# for dir in *; do cat $dir/name; done
bmc
alt-kernel
alt-rofs
alt-rwfs
u-boot
u-boot-env
kernel
rofs
rwfs
alt-bmc
alt-u-boot
alt-u-boot-env

Does anyone know what could be the possible reason for the problem ? Any hints/help would be appreciated.

Thanks,
Manoj




More information about the linux-mtd mailing list