当前位置:   article > 正文

linux下擦出flash4K命令,在Linux/U-Boot里为QSPI Flash使用UBIF

qspi flash zynqmp 测速

测试工具版本:PetaLinux 2018.2

测试单板: ZCU106

UBIFS是更强壮的FLash文件系统。很多嵌入式系统都使用了UBIFS。

Xilinx PetaLinux 2018.2也支持UBIFS。只需要在Linux/U-Boot里添加相关配置选项,就能为QSPI Flash创建UBIFS。

第1步,为Linux Kernel添加UBIFS配置选项。

需要注意的是,需要去掉SPI_NOR_USE_4K_SECTORS。

CONFIG_MTD_UBI=y

CONFIG_MTD_UBI_WL_THRESHOLD=4096

CONFIG_MTD_UBI_BEB_LIMIT=20

# CONFIG_MTD_UBI_FASTMAP is not set

# CONFIG_MTD_UBI_GLUEBI is not set

# CONFIG_MTD_UBI_BLOCK is not set

CONFIG_UBIFS_FS=y

# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set

CONFIG_UBIFS_FS_LZO=y

CONFIG_UBIFS_FS_ZLIB=y

CONFIG_UBIFS_ATIME_SUPPORT=y

# CONFIG_UBIFS_FS_ENCRYPTION is not set

CONFIG_UBIFS_FS_SECURITY=y

CONFIG_CRYPTO_DEFLATE=y

CONFIG_CRYPTO_LZO=y

# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set

第2步,为U-Boot添加UBIFS配置选项。

CONFIG_CMD_MTDPARTS=y

CONFIG_MTDIDS_DEFAULT=""

CONFIG_MTDPARTS_DEFAULT=""

CONFIG_CMD_MTDPARTS_SPREAD=y

CONFIG_CMD_UBI=y

CONFIG_CMD_UBIFS=y

CONFIG_MTD=y

# CONFIG_CFI_FLASH is not set

# CONFIG_ALTERA_QSPI is not set

CONFIG_MTD_UBI=y

CONFIG_MTD_UBI_WL_THRESHOLD=4096

CONFIG_MTD_UBI_BEB_LIMIT=20

# CONFIG_MTD_UBI_FASTMAP is not set

CONFIG_RBTREE=y

CONFIG_LZO=y

第3步,根据单板需要,定义Flash分区。

启动后,在Linux里可以通过命令 cat /proc/mtd检查。

root@zcu106_vcu_trd:/qspi_fs# cat /proc/mtd

dev: size erasesize name

mtd0: 01e00000 00020000 "boot"

mtd1: 00040000 00020000 "bootenv"

mtd2: 00c00000 00020000 "kernel"

mtd3: 055c0000 00020000 "spare"

第4步,在Linux里创建和挂载UBIFS分区。

如果是第一次启动,在Linux里创建和挂载UBIFS分区。

mkdir -p /qspi_fs

ubiformat /dev/mtd3

ubiattach /dev/ubi_ctrl -m 3

ubimkvol /dev/ubi0 -N qspi_ubi0 -m

mount -t ubifs ubi0:qspi_ubi0 /qspi_fs

如果不是第一次启动,直接在Linux里挂载UBIFS分区。

ubiattach /dev/ubi_ctrl -m 3

mount -t ubifs ubi0:qspi_ubi0 /qspi_fs

第5步,创建分区后,在U-Boot里使用UBIFS。

sf probe 0 50000000 0

setenv partition "nor0,3" # Activate mtd3.

setenv mtdids "nor0=spi0.0"

setenv mtdparts "mtdparts=spi0.0:30m(boot),256k(bootenv),12m(kernel),87808k(spare)"

mtdparts

ubi part spare # Select mtd3.

mtd

ubifsmount ubi0:qspi_ubi0

ubifsls

ubifsload 0x2000000 qspi_fs_ready__do_not_remove.bin.md5

更详细的在U-Boot里使用UBIFS的记录。

ZynqMP> sf probe 0 50000000 0

SF: Detected n25q512a with page size 512 Bytes, erase size 128 KiB, total 128 MiB

ZynqMP> setenv partition "nor0,3"

ZynqMP> setenv mtdids "nor0=spi0.0"

ZynqMP> setenv mtdparts "mtdparts=spi0.0:30m(boot),256k(bootenv),12m(kernel),87808k(spare)"

ZynqMP> mtdparts

device nor0 , # parts = 4

#: name size offset mask_flags

0: boot 0x01e00000 0x00000000 0

1: bootenv 0x00040000 0x01e00000 0

2: kernel 0x00c00000 0x01e40000 0

3: spare 0x055c0000 0x02a40000 0

active partition: nor0,3 - (spare) 0x055c0000 @ 0x02a40000

defaults:

mtdids :

mtdparts:

ZynqMP> ubi part spare

ubi0: attaching mtd2

ubi0: scanning is finished

ubi0: attached mtd2 (name "mtd=3", size 85 MiB)

ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 130944 bytes

ubi0: min./max. I/O unit sizes: 1/512, sub-page size 1

ubi0: VID header offset: 64 (aligned 64), data offset: 128

ubi0: good PEBs: 686, bad PEBs: 0, corrupted PEBs: 0

ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128

ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 1968612066

ubi0: available PEBs: 0, total reserved PEBs: 686, PEBs reserved for bad PEB handling: 0

ZynqMP> ubifsmount ubi0:qspi_ubi0

UBIFS assert failed in ubifs_change_lp at 540

UBIFS assert failed in ubifs_release_lprops at 278

UBIFS assert failed in ubifs_change_lp at 540

UBIFS assert failed in ubifs_release_lprops at 278

UBIFS assert failed in ubifs_change_lp at 540

UBIFS assert failed in ubifs_release_lprops at 278

UBIFS assert failed in ubifs_change_lp at 540

UBIFS assert failed in ubifs_release_lprops at 278

ZynqMP> ubifsls

1024 Fri Feb 01 09:57:29 2019 qspi_fs_ready__do_not_remove.bin

76 Fri Feb 01 09:57:29 2019 qspi_fs_ready__do_not_remove.bin.md5

ZynqMP> ubifsload 0x2000000 qspi_fs_ready__do_not_remove.bin.md5

Loading file 'qspi_fs_ready__do_not_remove.bin.md5' to addr 0x02000000...

Done

ZynqMP> md 0x2000000

02000000: 63336432 36336334 35333664 33316537 2d3c4c36d6357e13

02000010: 65636164 31303032 61626234 62393632 dace20014bba269b

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/185497
推荐阅读
相关标签
  

闽ICP备14008679号