Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
From: Michael Sander <msander@appliedlogix.com>
To: linux-mtd@lists.infradead.org
Subject: Unable to lock flash
Date: Mon, 20 Jul 2020 17:08:37 -0400
Message-ID: <CAOM0yYSnUERV38T0D_Z=Um6XvWMV4M4SreCj2=J0wXHCvmrzyg@mail.gmail.com> (raw)

I am seeing the following failure:

root@localhost:~#  flash_unlock -i /dev/mtd0
flash_unlock: error!: could not check lock status device: /dev/mtd0

              error 95 (Operation not supported)

I can read and write the flash without any problems.

The kernel version is: 4.14.0-xilinx-v2018.3
I am using Petalinux on a Xilinx Zynq 7000 family SOC

dmesg is not showing any kernel errors associated with the call.

The MTD version is:
root@localhost:~# flash_unlock -V
flash_unlock (mtd-utils) 2.0.0

Looking at the source, it appears that the "95" error is from the
library call to the driver, and in the driver I see:

int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
    if (!mtd->_is_locked)
        return -EOPNOTSUPP;
    if (ofs < 0 || ofs >= mtd->size || len > mtd->size - ofs)
        return -EINVAL;
    if (!len)
        return 0;
    return mtd->_is_locked(mtd, ofs, len);
}
EXPORT_SYMBOL_GPL(mtd_is_locked);

So the driver appears to think the locking functionality is not supported.

The flash chip is a MT25QL128ABA8E12-1SIT which appears to support locking.

The device tree is as follows

&qspi {
        #address-cells = <1>;
        #size-cells = <0>;
        flash0: flash@0 {
                compatible = "n25q512a","micron,m25p80";
                reg = <0x0>;
                #address-cells = <1>;
                #size-cells = <1>;
                spi-max-frequency = <50000000>;
                /delete-node/ partition@qspi-fsbl-uboot;
                /delete-node/ partition@qspi-linux;
                /delete-node/ partition@qspi-device-tree;
                /delete-node/ partition@qspi-rootfs;
                /delete-node/ partition@qspi-bitstream;
                partition@0x00000000 {
                        label = "fs-boot";
                        reg = <0x00000000 0x00120000>;
                };
                partition@0x00120000 {
                        label = "fs-bootenv";
                        reg = <0x00120000 0x00020000>;
                };
                partition@0x00140000 {
                        label = "fs-kernel";
                        reg = <0x00140000 0x00d00000>;
                };
                partition@0x00e40000 {
                        label = "boot";
                        reg = <0x00e40000 0x00120000>;
                };
                partition@0x00f60000 {
                        label = "bootenv";
                        reg = <0x00f60000 0x00020000>;
                };
                partition@0x00f80000 {
                        label = "envshare";
                        reg = <0x00f80000 0x00010000>;
                };
                partition@0x00f90000 {
                        label = "spare";
                        reg = <0x00f90000 0x00070000>;
                };
        };
};

And mtdinfo is as follows, apologies, we have a few partitions set up.

root@localhost:~# mtdinfo -a
Count of MTD devices:           7
Present MTD devices:            mtd0, mtd1, mtd2, mtd3, mtd4, mtd5, mtd6
Sysfs interface supported:      yes

mtd0
Name:                           fs-boot
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          18 (1179648 bytes, 1.1 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:                           fs-bootenv
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          2 (131072 bytes, 128.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:                           fs-kernel
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          208 (13631488 bytes, 13.0 MiB)
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:                           boot
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          18 (1179648 bytes, 1.1 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:                           bootenv
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          2 (131072 bytes, 128.0 KiB)
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:                           envshare
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

mtd6
Name:                           spare
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          7 (458752 bytes, 448.0 KiB)
Minimum input/output unit size: 1 byte
Sub-page size:                  1 byte
Character device major/minor:   90:12
Bad blocks are allowed:         false
Device is writable:             true

thanks,
-- 
Michael Sander
www.appliedlogix.com

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOM0yYSnUERV38T0D_Z=Um6XvWMV4M4SreCj2=J0wXHCvmrzyg@mail.gmail.com' \
    --to=msander@appliedlogix.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org
	public-inbox-index linux-mtd

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git