* mtdpart add/del usage
@ 2019-09-27 13:21 Mauro Condarelli
2019-09-27 14:31 ` Richard Weinberger
0 siblings, 1 reply; 5+ messages in thread
From: Mauro Condarelli @ 2019-09-27 13:21 UTC (permalink / raw)
To: linux-mtd
I have been unable to find detailed usage information for mtdpart (and
my attempts have met failure).
I need to us it because I have a huge number of devices in the field
that I need to repartition without any chance to recall them all for
hardware reflashing.
Old partition scheme is defined by:
m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "gd25q128";
reg = <0 0>;
linux,modalias = "m25p80", "gd25q128";
spi-max-frequency = <10000000>;
m25p,chunked-io = <32>;
partition@0 {
label = "u-boot";
reg = <0x0 0x40000>;
};
partition@40000 {
label = "u-boot-env";
reg = <0x40000 0x10000>;
};
partition@50000 {
label = "kernel";
reg = <0x50000 0x230000>;
};
partition@280000 {
label = "initrd";
reg = <0x280000 0x170000>;
};
partition@3f0000 {
label = "scripts";
reg = <0x3f0000 0x10000>;
};
partition@400000 {
label = "filesystem";
reg = <0x400000 0xbf0000>;
};
partition@ff0000 {
label = "firmware";
reg = <0xff0000 0x010000>;
};
};
while the desired "new format" is something like (exact sizes not fixed
yet):
m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "gd25q128";
reg = <0 0>;
linux,modalias = "m25p80", "gd25q128";
spi-max-frequency = <10000000>;
m25p,chunked-io = <32>;
partition@0 {
label = "u-boot";
reg = <0x0 0x40000>;
};
partition@40000 {
label = "u-boot-env";
reg = <0x40000 0x10000>;
};
partition@50000 {
label = "kernel";
reg = <0x50000 0x550000>;
};
partition@5a0000 {
label = "filesystem";
reg = <0x5a0000 0xa50000>;
};
partition@ff0000 {
label = "firmware";
reg = <0xff0000 0x010000>;
};
};
Plan was: boot old system, change (temporarily, in memory) mtd
partitions (delete mtd{2..5}, create mtd{2..3}), write new kernel and
rootfs and reboot.
Problem is I seem unable to effectively use mtdpart at all (this is in
"new stile" kernel, but it's the same in "old"):
/ # mtdinfo
Count of MTD devices: 6
Present MTD devices: mtd0, mtd1, mtd2, mtd3, mtd4, mtd5
Sysfs interface supported: yes
/ # mtdinfo -a
Count of MTD devices: 6
Present MTD devices: mtd0, mtd1, mtd2, mtd3, mtd4, mtd5
Sysfs interface supported: yes
mtd0
Name: spi0.0
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 256 (16777216 bytes, 16.0 MiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:0
Bad blocks are allowed: false
Device is writable: true
mtd1
Name: u-boot
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 4 (262144 bytes, 256.0 KiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:2
Bad blocks are allowed: false
Device is writable: true
mtd2
Name: u-boot-env
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 1 (65536 bytes, 64.0 KiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:4
Bad blocks are allowed: false
Device is writable: true
mtd3
Name: kernel
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 85 (5570560 bytes, 5.3 MiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:6
Bad blocks are allowed: false
Device is writable: true
mtd4
Name: filesystem
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 165 (10813440 bytes, 10.3 MiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:8
Bad blocks are allowed: false
Device is writable: true
mtd5
Name: firmware
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 1 (65536 bytes, 64.0 KiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:10
Bad blocks are allowed: false
Device is writable: true
/ # mtdpart del /dev/mtd3 3
mtdpart: error!: Failed to issue BLKPG ioctl
error 22 (Invalid argument)
/ # mtdpart del /dev/mtd3 4
mtdpart: error!: Failed to issue BLKPG ioctl
error 22 (Invalid argument)
/ # mtdpart del /dev/mtd3 2
mtdpart: error!: Failed to issue BLKPG ioctl
error 22 (Invalid argument)
/ # mtdpart del /dev/mtd 3
mtdpart: error!: Cannot open /dev/mtd
error 2 (No such file or directory)
/ # ls -la /dev/mt*
crw------- 1 root root 90, 0 Jan 1 00:00 /dev/mtd0
crw------- 1 root root 90, 1 Jan 1 00:00 /dev/mtd0ro
crw------- 1 root root 90, 2 Jan 1 00:00 /dev/mtd1
crw------- 1 root root 90, 3 Jan 1 00:00 /dev/mtd1ro
crw------- 1 root root 90, 4 Jan 1 00:00 /dev/mtd2
crw------- 1 root root 90, 5 Jan 1 00:00 /dev/mtd2ro
crw------- 1 root root 90, 6 Jan 1 00:00 /dev/mtd3
crw------- 1 root root 90, 7 Jan 1 00:00 /dev/mtd3ro
crw------- 1 root root 90, 8 Jan 1 00:00 /dev/mtd4
crw------- 1 root root 90, 9 Jan 1 00:00 /dev/mtd4ro
crw------- 1 root root 90, 10 Jan 1 00:00 /dev/mtd5
crw------- 1 root root 90, 11 Jan 1 00:00 /dev/mtd5ro
brw------- 1 root root 31, 0 Jan 1 00:00 /dev/mtdblock0
brw------- 1 root root 31, 1 Jan 1 00:00 /dev/mtdblock1
brw------- 1 root root 31, 2 Jan 1 00:00 /dev/mtdblock2
brw------- 1 root root 31, 3 Jan 1 00:00 /dev/mtdblock3
brw------- 1 root root 31, 4 Jan 1 00:00 /dev/mtdblock4
brw------- 1 root root 31, 5 Jan 1 00:00 /dev/mtdblock5
/ #
I also have (in my build environment):
mcon@cinderella:~/vocore/Buildroot-2$ grep MTD
input/configs/vocore2_kernel_defconfig
CONFIG_MTD=y
CONFIG_MTD_CMDLINE_PARTS=y
CONFIG_MTD_BLOCK=y
CONFIG_MTD_PARTITIONED_MASTER=y
CONFIG_MTD_CFI=y
CONFIG_MTD_PHYSMAP=y
CONFIG_MTD_PHYSMAP_OF=y
CONFIG_MTD_M25P80=y
CONFIG_MTD_SPI_NOR=y
# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
Can someone point me in the right direction, please?
Thanks in Advance
Mauro
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mtdpart add/del usage
2019-09-27 13:21 mtdpart add/del usage Mauro Condarelli
@ 2019-09-27 14:31 ` Richard Weinberger
2019-09-27 15:29 ` Mauro Condarelli
2019-09-28 16:07 ` Mauro Condarelli
0 siblings, 2 replies; 5+ messages in thread
From: Richard Weinberger @ 2019-09-27 14:31 UTC (permalink / raw)
To: Mauro Condarelli; +Cc: linux-mtd
On Fri, Sep 27, 2019 at 3:21 PM Mauro Condarelli <mc5686@mclink.it> wrote:
> / # mtdpart del /dev/mtd3 3
> mtdpart: error!: Failed to issue BLKPG ioctl
> error 22 (Invalid argument)
> / # mtdpart del /dev/mtd3 4
> mtdpart: error!: Failed to issue BLKPG ioctl
> error 22 (Invalid argument)
> / # mtdpart del /dev/mtd3 2
> mtdpart: error!: Failed to issue BLKPG ioctl
> error 22 (Invalid argument)
Is /dev/mtd3 really the master partition?
IIRC you can only apply such changes on the mtd master
partition.
--
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mtdpart add/del usage
2019-09-27 14:31 ` Richard Weinberger
@ 2019-09-27 15:29 ` Mauro Condarelli
2019-09-28 16:07 ` Mauro Condarelli
1 sibling, 0 replies; 5+ messages in thread
From: Mauro Condarelli @ 2019-09-27 15:29 UTC (permalink / raw)
To: Richard Weinberger; +Cc: linux-mtd
On 9/27/19 4:31 PM, Richard Weinberger wrote:
> On Fri, Sep 27, 2019 at 3:21 PM Mauro Condarelli <mc5686@mclink.it> wrote:
>> / # mtdpart del /dev/mtd3 3
>> mtdpart: error!: Failed to issue BLKPG ioctl
>> error 22 (Invalid argument)
>> / # mtdpart del /dev/mtd3 4
>> mtdpart: error!: Failed to issue BLKPG ioctl
>> error 22 (Invalid argument)
>> / # mtdpart del /dev/mtd3 2
>> mtdpart: error!: Failed to issue BLKPG ioctl
>> error 22 (Invalid argument)
> Is /dev/mtd3 really the master partition?
No, it is definitely not.
It is the partition I wish to delete.
> IIRC you can only apply such changes on the mtd master
> partition.
That makes sense but, in spite of having "CONFIG_MTD_PARTITIONED_MASTER=y",
I see no "mtd master partition".
...
Please forget about that.
After a couple of reboots I actually have:
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 01000000 00010000 "spi0.0"
mtd1: 00040000 00010000 "u-boot"
mtd2: 00010000 00010000 "u-boot-env"
mtd3: 00550000 00010000 "kernel"
mtd4: 00a50000 00010000 "filesystem"
mtd5: 00010000 00010000 "firmware"
and:
mtdpart del /dev/mtd0 3
works as expected.
I am unsure why I was unable to see the master device before, it *seems*
changing
just CONFIG_MTD_PARTITIONED_MASTER did not trigger right recompilation.
After a full kernel recompile I see it.
Sorry for the noise and
THANKS! for the help.
Mauro
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mtdpart add/del usage
2019-09-27 14:31 ` Richard Weinberger
2019-09-27 15:29 ` Mauro Condarelli
@ 2019-09-28 16:07 ` Mauro Condarelli
2019-09-28 22:48 ` Richard Weinberger
1 sibling, 1 reply; 5+ messages in thread
From: Mauro Condarelli @ 2019-09-28 16:07 UTC (permalink / raw)
To: linux-mtd
On 9/27/19 4:31 PM, Richard Weinberger wrote:
> On Fri, Sep 27, 2019 at 3:21 PM Mauro Condarelli <mc5686@mclink.it> wrote:
>> / # mtdpart del /dev/mtd3 3
>> mtdpart: error!: Failed to issue BLKPG ioctl
>> error 22 (Invalid argument)
> Is /dev/mtd3 really the master partition?
No.
It is not.
On a recent kernel I managed to have this work (using
"CONFIG_MTD_PARTITIONED_MASTER=y").
> IIRC you can only apply such changes on the mtd master
> partition.
Is it possible to retrieve (or re-create) the master device in an older
kernel (3.18)?
It does not have MTD_PARTITIONED_MASTER config option.
I know it won't be able to del/add partitions, but being able to write
to the whole,
unpartitioned device would be *very* useful nonetheless.
Thanks in advance
Mauro Condarelli
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mtdpart add/del usage
2019-09-28 16:07 ` Mauro Condarelli
@ 2019-09-28 22:48 ` Richard Weinberger
0 siblings, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2019-09-28 22:48 UTC (permalink / raw)
To: Mauro Condarelli; +Cc: linux-mtd
On Sat, Sep 28, 2019 at 6:08 PM Mauro Condarelli <mc5686@mclink.it> wrote:
> Is it possible to retrieve (or re-create) the master device in an older
> kernel (3.18)?
> It does not have MTD_PARTITIONED_MASTER config option.
You can backport the feature, it should be hard.
> I know it won't be able to del/add partitions, but being able to write
> to the whole,
> unpartitioned device would be *very* useful nonetheless.
MTD partitions are allowed to be overlapping. So you can create
a partition schema which contains one part over all others.
--
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-28 22:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 13:21 mtdpart add/del usage Mauro Condarelli
2019-09-27 14:31 ` Richard Weinberger
2019-09-27 15:29 ` Mauro Condarelli
2019-09-28 16:07 ` Mauro Condarelli
2019-09-28 22:48 ` Richard Weinberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).