In message: [linux-yocto] [linux-yocto v5.10/standard/sdkv5.10/xlnx-soc][PATCH 0/7] mtd: spi-nor: fix flash lock/unlock issue on 19/10/2021 [email protected] wrote:
> From: Quanyang Wang <[email protected]> > > Hi Bruce & Michal, > > Would you please help review and merge these patches to the branch: > > linux-yocto v5.10/standard/sdkv5.10/xlnx-soc > > This series fix the flash lock/unlock issue at zcu102/zc706/zc702 board. > > The patch "mtd: spi-nor: swp: fix unlock lower area failure" has been > sent to mainline and is still in maintainer's queue and waiting for > handle. > https://lkml.org/lkml/2021/7/22/505 > It's a long time and I decide to send it to linux-yocto regardless of > mainline and then kick off the test on flash lock/unlock for WRLinux > at xilinx boards. > > As below is the testlog at zcu102 board after applying this patch > series. For now, flash lock/unlock can work well at zcu102/zc702, > but there are some issues at zc706 since the BP bit of the flashes > (s25fl128s1 x 2) is in CR register not SR register and now there is > no support at mainline code for this. > > The series changes much at spi-nor core code by reverting 2 SDK patches > and rearrange the spi-nor flash partitions. I only do some test at zcu102 > and zc702 boards. It may break the flashes at other xilinx boards. > > Before applying these patches: > root@xilinx-zynqmp:~# flash_lock -l /dev/mtd0 0 1 > root@xilinx-zynqmp:~# /wqy/get_mtd_lock.sh mtd0 > mtd0 locks from 0x0 to 0x100000 in total 0x8 blocks > > After applying these patches: > root@xilinx-zynqmp:/# flash_lock -l /dev/mtd0 0 1 > root@xilinx-zynqmp:/# /wqy/get_mtd_lock.sh mtd0 > mtd0 locks from 0x0 to 0x20000 in total 0x1 blocks > root@xilinx-zynqmp:/# flash_erase /dev/mtd0 0 1 > Erasing 128 Kibyte @ 0 -- 0 % complete spi-nor spi0.0: Erase operation > failed. > spi-nor spi0.0: Attempted to modify a protected sector. > libmtd: error!: MEMERASE64 ioctl failed for eraseblock 0 (mtd0) > error 5 (Input/output error) > flash_erase: error!: /dev/mtd0: MTD Erase failure > error 5 (Input/output error) > Erasing 128 Kibyte @ 0 -- 100 % complete > root@xilinx-zynqmp:/# flash_erase /dev/mtd0 0x20000 1 > Erasing 128 Kibyte @ 20000 -- 100 % complete > root@xilinx-zynqmp:/# flash_lock -l /dev/mtd0 0x20000 7 > root@xilinx-zynqmp:/# /wqy/get_mtd_lock.sh mtd0 > mtd0 locks from 0x0 to 0x100000 in total 0x8 blocks > root@xilinx-zynqmp:/# flash_lock -u /dev/mtd0 0 0x8 > root@xilinx-zynqmp:/# /wqy/get_mtd_lock.sh mtd0 > mtd0 locks from 0x0 to 0x0 in total 0x0 blocks > root@xilinx-zynqmp:/# flash_erase /dev/mtd0 0x20000 1 > Erasing 128 Kibyte @ 20000 -- 100 % complete > > > root@xilinx-zynqmp:/# flash_lock -l /dev/mtd3 0x77e0000 1 > root@xilinx-zynqmp:/# /wqy/get_mtd_lock.sh mtd3 > mtd3 locks from 0x77e0000 to 0x7800000 in total 0x1 blocks > root@xilinx-zynqmp:/# flash_erase /dev/mtd3 0x77e0000 1 > Erasing 128 Kibyte @ 77e0000 -- 0 % complete spi-nor spi0.0: Erase operation > failed. > spi-nor spi0.0: Attempted to modify a protected sector. > libmtd: error!: MEMERASE64 ioctl failed for eraseblock 959 (mtd3) > error 5 (Input/output error) > flash_erase: error!: /dev/mtd3: MTD Erase failure > error 5 (Input/output error) > Erasing 128 Kibyte @ 77e0000 -- 100 % complete > root@xilinx-zynqmp:/# flash_erase /dev/mtd3 0x77c0000 1 > Erasing 128 Kibyte @ 77c0000 -- 100 % complete > root@xilinx-zynqmp:/# flash_lock /dev/mtd3 0x7000000 0x40 > root@xilinx-zynqmp:/# /wqy/get_mtd_lock.sh mtd3 > > mtd3 locks from 0x7000000 to 0x7800000 in total 0x40 blocks > root@xilinx-zynqmp:/# flash_lock -u /dev/mtd3 0x70000000 0x40 > flash_lock: error!: 0x70000000 is beyond device size 0x7800000 > root@xilinx-zynqmp:/# flash_lock -u /dev/mtd3 0x7000000 0x40 > root@xilinx-zynqmp:/# /wqy/get_mtd_lock.sh mtd3 > > mtd3 locks from 0x0 to 0x0 in total 0x0 blocks > root@xilinx-zynqmp:/# flash_erase /dev/mtd3 0x7000000 0x40 > Erasing 128 Kibyte @ 77e0000 -- 100 % complete > > The script get_mtd_lock.sh can help print how many blocks are locked: > =========================== > #!/bin/bash > > mtd_size=$((16#`cat /proc/mtd | grep $1 | awk '{print $2}'`)) > erase_size=$((16#`cat /proc/mtd | grep $1 | awk '{print $3}'`)) > mtd_lock_start=0 > mtd_lock_end=0 > step_start=0 > start_found=0 > > while [ $step_start -lt $mtd_size ]; do > result="`flash_lock -i /dev/$1 $step_start 1 | grep "Lock status: > locked"`" > if [ ${#result} -gt 0 ]; then > if [ $start_found -eq 0 ]; then > mtd_lock_start=$step_start > start_found=1 > fi > mtd_lock_end=$(($step_start+$erase_size)) > fi > step_start=$(($step_start+$erase_size)) > done > > > printf "$1 locks from 0x%x to 0x%x in total 0x%x blocks\n" $mtd_lock_start > $mtd_lock_end $((($mtd_lock_end-$mtd_lock_start)/$erase_size)) > =========================== Thanks for all the details! This is good enough for the linux-yocto support, I'll watch upstream and otherwise adjust to feedback. But it will be nice to have this in tree, so it will be available and get some extra testing. Bruce > > > Quanyang Wang (7): > mtd: spi-nor: swp: fix unlock lower area failure > mtd: spi-nor: add appropriate BP flags for mt25qu512a > arm64: zynqmp: adjust flash size for zcu102 rev1.0 board > arm64: zynqmp: adjust qspi flash partition > mtd: spi-nor: delete dual mode handling in spi_nor_lock/unlock > Revert "mtd: spi-nor: Set proper block protection bits for Winbond > flashes" > Revert "mtd: spi-nor: Update flash lock/unlock feature" > > .../boot/dts/xilinx/zynqmp-zcu102-rev1.0.dts | 9 + > .../boot/dts/xilinx/zynqmp-zcu102-revA.dts | 14 +- > drivers/mtd/spi-nor/core.c | 185 +++--------------- > drivers/mtd/spi-nor/core.h | 6 +- > drivers/mtd/spi-nor/micron-st.c | 3 +- > drivers/mtd/spi-nor/winbond.c | 5 +- > include/linux/mtd/spi-nor.h | 3 +- > 7 files changed, 45 insertions(+), 180 deletions(-) > > > -- > 2.25.1 >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#10557): https://lists.yoctoproject.org/g/linux-yocto/message/10557 Mute This Topic: https://lists.yoctoproject.org/mt/86435173/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
