Phytec中国的wiki
support@phytec.cn
热线:0755-61802110-803
Ubi fastmap是ubi的一个可配置属性, 这个属性是通过内核的CONFIG_MTD_UBI_FASTMAP这个配置来使能的,
使能ubi fastmap之后, 就会在ubi内部新建一个分卷来存储fastmap的数据.
使能ubi fastmap后, 当执行一次ubiattach之后, 会把ubi各个分卷的扫描信息存储在ubi fastmap的分卷上,
下一次再执行ubiattach后, 就可以使用fastmap分卷上的信息, 不用再扫描整个ubi分区,
所以在使用fastmap可以减少ubi flash的扫描时间,
在我们系统上使用ubifastmap功能后会比不使用ubifastmap启动快3~4s.
更多ubi fastmap信息参考官方文档介绍:
http://www.linux-mtd.infradead.org/doc/ubi.html#L_fastmap
BAREBOX中使能fastmap功能
barebox中ubi fastmap特性介绍:
https://www.barebox.org/doc/latest/user/ubi.html
在kernel中是配置了CONFIG_MTD_UBI_FASTMAP的配置后, 启动kernel后就会生成一个ubi fastmap的内部分卷,
在新建ubi fastmap内部分卷之后, 需要在barebox中使用ubiformat格式化整个nand0.root分区, 然后在attach整个ubi分区ubi fastmap才能起作用.
MX6核心板版本 | 出厂测试时BSP版本 | CONFIG_MTD_UBI_FASTMAP |
---|---|---|
老SOM | PD16 | n |
新SOM | PD18 | y |
在MX6的BSP中, PD16的版本是不使能CONFIG_MTD_UBI_FASTMAP配置的, 所以老版本的SOM出厂后如果要使能ubi fastmap功能的话,
需要先更新一遍PD18的镜像, 然后启动进入系统后, 此时ubi内部会新建一个ubi fastmap的分卷,
然后再重启进入barebox, 使用ubiformat格式化nand0.root分区, 然后在重新烧写ubi分区的镜像后就可以使能fastmap的功能.
而新SOM在出厂时是使用PD18的镜像测试的, 此时ubi内部已经有ubi fastmap的分卷, 出厂后直接烧写PD18版本的镜像就可以使能ubi fastmap的功能.
MX6 PD18.1.2 Ubi Fastmap测试
使能ubi fastmap的情况
barebox ubiattach的log:
booting 'nand' ubi0: attached by fastmap ubi0: fastmap pool size: 256 ubi0: fastmap WL pool size: 128 ubi0: registering /dev/nand0.root.ubi ubi0: registering kernel as /dev/nand0.root.ubi.kernel ubi0: registering oftree as /dev/nand0.root.ubi.oftree ubi0: registering root as /dev/nand0.root.ubi.root ubi0: attached mtd0 (name "nand0.root", size 1007 MiB) to ubi0 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: 8052, bad PEBs: 4, corrupted PEBs: 0 ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128 ubi0: max/mean erase counter: 180/106, WL threshold: 65536, image sequence number: 21814 ubi0: available PEBs: 0, total reserved PEBs: 8052, PEBs reserved for bad PEB handling: 156
kernel中ubi attach的log:
[ 4.250283] ubi0: default fastmap pool size: 256 [ 4.254988] ubi0: default fastmap WL pool size: 128 [ 4.259924] ubi0: attaching mtd2 [ 4.493051] ubi0: attached by fastmap [ 4.496727] ubi0: fastmap pool size: 256 [ 4.500654] ubi0: fastmap WL pool size: 128 [ 4.519748] ubi0: attached mtd2 (name "root", size 1007 MiB) [ 4.525497] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes [ 4.532395] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048 [ 4.539186] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096 [ 4.546179] ubi0: good PEBs: 8052, bad PEBs: 4, corrupted PEBs: 0 [ 4.552290] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128 [ 4.559530] ubi0: max/mean erase counter: 180/106, WL threshold: 4096, image sequence number: 21814 [ 4.568592] ubi0: available PEBs: 0, total reserved PEBs: 8052, PEBs reserved for bad PEB handling: 156 [ 4.578032] ubi0: background thread "ubi_bgt0d" started, PID 135
从kernel log中看出ubiattach时大概花了0.2s.
系统启动时间:
root@phyboard-mira-imx6-3:~# systemd-analyze Startup finished in 4.920s (kernel) + 3.869s (userspace) = 8.790s
上电到phytec-qtdemo启动时间约为18.45s
不使能ubi fastmap的情况
barebox ubiattach的log:
booting 'nand' ubi0: scanning is finished ubi0 warning: print_rsvd_warning: cannot reserve enough PEBs for bad PEB handling, reserved 60, need 156 ubi0: registering /dev/nand0.root.ubi ubi0: registering kernel as /dev/nand0.root.ubi.kernel ubi0: registering oftree as /dev/nand0.root.ubi.oftree ubi0: registering root as /dev/nand0.root.ubi.root ubi0: attached mtd0 (name "nand0.root", size 1007 MiB) to ubi0 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: 8052, bad PEBs: 4, corrupted PEBs: 0 ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128 ubi0: max/mean erase counter: 178/105, WL threshold: 65536, image sequence number: 5862 ubi0: available PEBs: 0, total reserved PEBs: 8052, PEBs reserved for bad PEB handling: 60
kernel中ubi attach的log:
[ 4.252653] ubi0: default fastmap pool size: 256 [ 4.257276] ubi0: default fastmap WL pool size: 128 [ 4.262200] ubi0: attaching mtd2 [ 4.750678] random: crng init done [ 7.099309] ubi0: scanning is finished [ 7.114345] ubi0 warning: ubi_eba_init: cannot reserve enough PEBs for bad PEB handling, reserved 60, need 156 [ 7.128042] ubi0: attached mtd2 (name "root", size 1007 MiB) [ 7.133753] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes [ 7.140635] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048 [ 7.147473] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096 [ 7.154460] ubi0: good PEBs: 8052, bad PEBs: 4, corrupted PEBs: 0 [ 7.160575] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128 [ 7.167822] ubi0: max/mean erase counter: 178/105, WL threshold: 4096, image sequence number: 5862 [ 7.176817] ubi0: available PEBs: 0, total reserved PEBs: 8052, PEBs reserved for bad PEB handling: 60 [ 7.186169] ubi0: background thread "ubi_bgt0d" started, PID 135
从kernel log中看出ubiattach时大概花了2.8s.
系统启动时间:
root@phyboard-mira-imx6-3:~# systemd-analyze Startup finished in 7.504s (kernel) + 3.785s (userspace) = 11.290s
上电到phytec-qtdemo启动时间约为22.22s.