測試工具版本: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: minmax. 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
編輯:hfy
-
FlaSh
+關注
關注
10文章
1621瀏覽量
147754 -
嵌入式系統
+關注
關注
41文章
3567瀏覽量
129229 -
UBIFS
+關注
關注
0文章
5瀏覽量
6918
發布評論請先 登錄
相關推薦
評論