错误调试 1
保存uboot环境变量时出现下面的错误;
hisilicon # saveenv
Saving Environment to NAND...
Erasing Nand...
Warning: Erase size 0x00040000 smaller than one erase block 0x00100000
Erasing 0x00100000 instead
或者是:
hisilicon # saveenv
Saving Environment to NAND...
Erasing Nand...
MT29F16G08CBACA: MTD Erase failure: -22
Writing to Nand... done
错误分析:在写环境变量的时候,会把这个区的数据清空再写入,清空数据失败;
修改
这个值需要定义为当前存储器的block块大小的整数倍,不然会有上面的提升信息,需要擦除整个块数据。对于flash的分区也需要按块的最小单元的整数倍来分区。
在uboot/include/configs/hi3519v101_nand.h
/* env in flash instead of CFG_ENV_IS_NOWHERE */
#define CONFIG_ENV_OFFSET 0x800000 /* environment starts here */
#define CONFIG_ENV_NAND_ADDR (CONFIG_ENV_OFFSET)
#define CONFIG_ENV_SPI_ADDR (CONFIG_ENV_OFFSET)
#define CONFIG_CMD_SAVEENV
#define CONFIG_ENV_SIZE 0x100000 /*include ENV_HEADER_SIZE */
#define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE
#define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */
/* kernel parameter list phy addr */
#define CFG_BOOT_PARAMS (MEM_BASE_DDR+0x0100)
错误调试 2
hisilicon # nand erase 1000000 500000
NAND erase: device 0 offset 0x1000000, size 0x500000
Skipping bad block at
0x01000000
Skipping bad block at
0x01100000
Skipping bad block at
0x01200000
Skipping bad block at
0x01300000
Skipping bad block at
0x01400000
OK
解决:
nand scrub 命令 把出厂的坏块标示全部清除掉,有一定风险,建议只在测试环境下使用。可能还会减少nand flash 的写寿命。
在uboot命令中,输入 nand scrub 命令即可。
hisilicon # nand scrub
NAND scrub: device 0 whole chip
Warning: scrub option will erase all factory set bad blocks!
There is no reliable way to recover them.
Use this command only for testing purposes if you
are sure of what you are doing!
Really scrub this NAND flash? <y/N>
Erasing at 0x5100000 -- 4% complete.
MT29F16G08CBACA: MTD Erase failure: -5
Block at 0x05a00000 is marked bad block
MT29F16G08CBACA: MTD Erase failure: -5
Block at 0x05b00000 is marked bad block
Erasing at 0x7ff00000 -- 100% complete.
OK
测试:
hisilicon # nand erase 1000000 500000
NAND erase: device 0 offset 0x1000000, size 0x500000
Erasing at 0x1400000 -- 100% complete.
OK