目录
kernel配置
配置linux内核选上
1)Device Drivers —>Memory Technology Device (MTD) support —>UBI - Unsorted blockimages —>Enable UBI
2)File systems —>Miscellaneous filesystems —>UBIFS file system support
第二条的内核配置打印输出如下:
UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 1117
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "program"
UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
UBIFS (ubi0:0): FS size: 93073408 bytes (88 MiB, 733 LEBs), journal size 4698112 bytes (4 MiB, 37 LEBs)
UBIFS (ubi0:0): reserved for root: 4396086 bytes (4293 KiB)
UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 9CF794A9-B195-465A-BAA8-21DA249026D3, small LPT model
在此之前一直挂载不上,没有提示错误一直以为内核已经给配置好,少配置了第二项
######start app####
mount ubifs
ubi0: attaching mtd3
ubi0: scanning is finished
ubi0: attached mtd3 (name "app_filesystem", size 100 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 800, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 2, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 78507198
ubi0: available PEBs: 11, total reserved PEBs: 789, PEBs reserved for bad PEB handling: 40
ubi0: background thread "ubi_bgt0d" started, PID 1113
使用方法
1、config 文件中分区
2、ubiformat格式化 如: ubiformat /dev/mtd3
3、ubiattach 如:ubiattach /dev/ubi_ctrl -m 3
4、ubimkvol 在分区上创建卷
ubimkvol /dev/ubi0 -N program -s 94371840 >/dev/null 2>&1
ubimkvol /dev/ubi0 -N firstParmRegion -s 4194304 >/dev/null 2>&1
ubimkvol /dev/ubi0 -N secondParmRegion -s 2097152 >/dev/null 2>&1
ubimkvol /dev/ubi0 -N systemLog -s 4194304 >/dev/null 2>&1
5,挂载卷到文件系统中
mount -t ubifs ubi0:program /gongjiao/program >/dev/null 2>&1
mount -t ubifs ubi0:firstParmRegion /gongjiao/firstParm >/dev/null 2>&1
mount -t ubifs ubi0:secondParmRegion /gongjiao/secondParm >/dev/null 2>&1
mount -t ubifs ubi0:systemLog /gongjiao/systemLog >/dev/null 2>&1
#mount -t ubifs ubi0:systemLogo /gongjiao/systemLogo >/dev/null 2>&1
6、文件系统中直接对/proc/mtd操作
擦除: flash_eraseall /dev/mtd1
搬运数据 :nandwrite -p /dev/mtd1 /media/mmcblk0p1/update/uImage
存在问题以及解决方法
1、在系统运行时格式化,格式化前先ubidetach
~ # ubidetach --help
BusyBox v1.31.1 (2022-10-08 01:03:34 PDT) multi-call binary.
Usage: ubidetach -d UBI_NUM UBI_CTRL_DEV
Detach MTD device from UBI
-d UBI_NUM UBI device number
工具提示 ubidetach -d xxx xxx 这种方式使用是错误的,这个工具不是hisi提供的
2、将SDK中的ubidetach 移植到板子上
/mnt/sd0/ubi # ./ubidetach -h
ubidetach version 2.1.1 - tool to remove UBI devices (detach MTD devices from UBI)
Usage: ubidetach [<UBI control device node file name>]
[-d <UBI device number>] [-m <MTD device number>] [-p <path to device>]
[--devn=<UBI device number>] [--mtdn=<MTD device number>]
[--dev-path=<path to device>]
UBI control device defaults to /dev/ubi_ctrl if not supplied.
Example 1: ubidetach -p /dev/mtd0 - detach MTD device /dev/mtd0
Example 2: ubidetach -d 2 - delete UBI device 2 (ubi2)
Example 3: ubidetach -m 0 - detach MTD device 0 (mtd0)
-d, --devn=<UBI device number> UBI device number to delete
-p, --dev-path=<path to device> or alternatively, MTD device node path to detach
-m, --mtdn=<MTD device number> or alternatively, MTD device number to detach
-h, --help print help message
-V, --version print program version
/mnt/sd0/ubi # ./ubidetach -m 3
ubi0: detaching mtd3
ubidetach -h 使用与系统带的不一样,并且使用-m参数正常