在linux中查找ubi信息

 root@phyboard-segin-imx6ul-6:~# ls /dev/ubi0_*
/dev/ubi0_0  /dev/ubi0_1  /dev/ubi0_2
root@phyboard-segin-imx6ul-6:~# ubinfo /dev/ubi0 
ubi0
Volumes count:                           3
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     4052 (514506752 bytes, 490.6 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       4
Count of reserved physical eraseblocks:  76
Current maximum erase counter value:     1
Minimum input/output unit size:          2048 bytes
Character device major/minor:            245:0
Present volumes:                         0, 1, 2
root@phyboard-segin-imx6ul-6:~# ubinfo /dev/ubi0_0
Volume ID:   0 (on ubi0)
Type:        static
Alignment:   1
Size:        67 LEBs (8507392 bytes, 8.1 MiB)
Data bytes:  6725712 bytes (6.4 MiB)
State:       OK
Name:        kernel
Character device major/minor: 245:1
root@phyboard-segin-imx6ul-6:~# ubinfo /dev/ubi0_1
Volume ID:   1 (on ubi0)
Type:        static
Alignment:   1
Size:        9 LEBs (1142784 bytes, 1.0 MiB)
Data bytes:  34242 bytes (33.4 KiB)
State:       OK
Name:        oftree
Character device major/minor: 245:2
root@phyboard-segin-imx6ul-6:~# ubinfo /dev/ubi0_2
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        3894 LEBs (494444544 bytes, 471.5 MiB)
State:       OK
Name:        root
Character device major/minor: 245:3

从以上ubi信息中看出来ubi0_0和ubi0_1对应kernel和oftree的分区.

如果是从sdcard启动后进入linux, 在文件系统中并没有ubi的设备, 需要先对nand的root分区做一下ubiattach才有ubi设备

root@phyboard-segin-imx6ul-6:~# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00400000 00020000 "barebox"
mtd1: 00100000 00020000 "barebox-environment"
mtd2: 1fb00000 00020000 "root"
root@phyboard-segin-imx6ul-6:~# ubiattach -p /dev/mtd2
[  214.003866] ubi0: attaching mtd2
[  214.027383] ubi0: "delete" compatible internal volume 2147479552:0 found, will remove it
[  215.096154] ubi0: scanning is finished
[  215.122919] ubi0: attached mtd2 (name "root", size 507 MiB)
[  215.128522] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[  215.175519] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[  215.182338] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[  215.206312] ubi0: good PEBs: 4052, bad PEBs: 4, corrupted PEBs: 0
[  215.212436] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
[  215.222317] ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 23797
[  215.231866] ubi0: available PEBs: 2, total reserved PEBs: 4050, PEBs reserved for bad PEB handling: 76
[  215.242257] ubi0: background thread "ubi_bgt0d" started, PID 191

更新kernel和oftree

在linux中使用ubiupdatevol来更新ubi中的镜像

root@phyboard-segin-imx6ul-6:~# ubiupdatevol /dev/ubi0_0 zImage-phyboard-segin-imx6ul-6.bin
root@phyboard-segin-imx6ul-6:~# ubiupdatevol /dev/ubi0_1 zImage-imx6ull-phytec-segin-ff-rdk-nand.dtb
  • No labels