文章目录
背景
固件分区没有使用原厂的分区方式,当前分区信息为:
烧录设备后,启动报错,userfs(data分区)挂载不上,log如下:
ubi1 error: vtbl_check: too large reserved_pebs 621, good PEBs 607
思路
报错log是指ubi分区的header读取的size,比falsh实际可用的size要大。
ubi0对应的rootfs分区可以正常挂载,并且uboot可以正常拉起kernel,说明uboot、kernel、rootfs分区配置正常。
ubi1对应userfs,其在uboot bootcmd中传递给kernel,并在kernel阶段对ubi1挂载,定位到大致范围,接下来分析具体问题
解决
ubi1 error: vtbl\_check: too large reserved\_pebs
此条log表示,从ubi分区的header读取的size,比falsh实际可用的size要大。
从dmesg中可以看到如下log:
0x000003100000-0x000008000000 : "userdata"
mtd: partition "userdata" extends beyond the end of device "sfc_nand" -- size truncated to 0x4c00000
0x8000000 => 128M
0x3100000 + 0x4c00000 => 125M,少了3M跑哪里了?
先定位该log位于:drivers/mtd/mtdpart.c::allocate_partition
其中struct mtd_info,即nand flash信息,追踪调用代码,可知:
allocate_partition
<- add_mtd_partitions
<- mtd_add_device_partitions
<- mtd_device_parse_register
<- module_drivers/drivers/mtd/devices/ingenic_sfc_V2/ingenic_sfc_nand.c::ingenic_sfc_nand_probe
ingenic_sfc_nand_probe(struct sfc_flash *flash)
struct sfc_flash.mtd 即上述的struct mtd_info
该接口中:
#ifndef CONFIG_INGENIC_SFCNAND_FMW
flash->mtd.size = nand_info->param.flashsize;
#else
flash->mtd.size = nand_info->param.flashsize - CONFIG_SN_FLASH_SIZE - CONFIG_MAC_FLASH_SIZE - CONFIG_LICENSE_FLASH_SIZE;
#endif
.config正好配置了CONFIG_INGENIC_SFCNAND_FMW,同时CONFIG_SN/MAC/LICENCE_FLASH_SIZE,一共3M,和前述对应上了。
CONFIG_INGENIC_SFCNAND_FMW为预留用于存放oem或产测固化信息。
至此,原因找到,在内核中将CONFIG_INGENIC_SFCNAND_FMW配置关闭即可。