linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* 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

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).