Reputation: 93
I have embedded system with some MTD devices and added one more MTD device (SPI flash). This new device now is mtd0 and number for all previous MTD devices are +1. How can I assign MTD device number for this new driver to keep numbers of previous MTD devices unchanged ?
Before:
# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "u-boot"
...
After:
# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00001000 "spi-nor-flash"
mtd1: 00100000 00020000 "u-boot"
...
I want to achieve:
# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "u-boot"
...
mtd5: 00100000 00001000 "spi-nor-flash"
Upvotes: 0
Views: 1972
Reputation: 93
Possible workaround: make SPI flash driver as loadable module and load it after system booting:
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00800000 00020000 "u-boot"
...
mtd4: 0c8c0000 00020000 "ubipart"
/ # insmod m25p80.ko
[ 365.735184] m25p80 spi0.0: n25q256a (32768 Kbytes)
[ 365.739903] 1 ofpart partitions found on MTD device spi0.0
[ 365.745396] Creating 1 MTD partitions on "spi0.0":
[ 365.750133] 0x000000000000-0x000000800000 : "spi-flash"
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00800000 00020000 "u-boot"
...
mtd4: 0c8c0000 00020000 "ubipart"
mtd5: 00800000 00001000 "spi-flash"
Upvotes: 0
Reputation: 181
You may specify MTD partition numbers in the device tree source file (or in the board .c file if your kernel doesn't use DTB). You need something like this:
&spi0{
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
/* DO is MOSI, D1 is MISO */
/*ti,pindir-d0-out-d1-in = <0>;*/
m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "st,m25pe80";
reg = <0>;
spi-max-frequency = <1000000>;
/*m25p,fast-read;*/
partition@12 {
label = "spi-nor-spl1";
reg = <0x0 0x20000>; /* 128k */
};
};
};
(example taken from here) for SPI flash and other devices with MTD partitions.
Upvotes: 1
Reputation: 2858
I suggest to have a look at this article https://wiki.archlinux.org/index.php/persistent_block_device_naming . Udev can help you name block devices without relying on the order the devices are discovered.
Upvotes: 1