生成烧录文件之提取Env分区的内容

我之前有一篇文章,以Xeltex烧录器为例,讲述如何生成烧录文件。其中,输入部分除了auImage.bin, u-boot.bin等,还需要env_ecc.bin。这是带有ecc信息的Env分区的数据。最近为Huangpu-Mico的烧录提取了一次,把方法列举如下:

PC端的操作:
//把要烧录的rootfs_cramfs.stb225-nand.bin解到某个目录,如hello
sudo mount -o loop -t cramfs rootfs_cramfs.stb225-nand.bin mnt/
sudo cp -a mnt/ hello

//改变inittab,使得启动后进入command line模式
cd hello/
sudo vim etc/inittab //let enter command line after startup

//generate the new cramfs
mkcramfs . ../newcramfs.image

//burn it to nand
./reflash -j -u -d nand0 -s /dev/ttyUSB0 -f -n FS1 /home/qianjiang/tmp/newcramfs.image

启动STB:
//insert a usb to stb and mount it
root:# mount -t vfat /dev/sda1 mnt/

//dump data
root:# nanddump -b -f mnt/env.bin /dev/mtd2
ECC failed: 0
ECC corrected: 0
Number of bad blocks: 0
Number of bbt blocks: 0
Block size 16384, page size 512, OOB size 16
Dumping data starting at 0x00000000 and ending at 0x00080000...

//Check//当时为了确保方法没错进行检查
in STB u-boot: nand dump 0x120000
in PC: hexdump -n 528 env.bin

compare: it means env.bin has contain ecc data

//Test//测试方法是否正确
Write a program which will remove ecc data
./remove_oob ~/tmp/env.bin //generate output.bin without ecc
//512K is too large, 256K should be enough
dd of=env_noecc.bin if=output.bin bs=1024 count=256
//in u-boot, erase env
nand erase Env
//then env is broken, application can not be started
//now reflash Env to check
./reflash -j -y -d nand0 -s /dev/ttyUSB0  -a 0x120000  ~/projects/nand/remove_oob/env_noecc.bin  -r ~/tmp/image_0403_ethenet/files/u-boot.rescue.bin

//Done, cut env_ecc.bin from the original one, we only need 256K + ecc = 528 * 1024/2
dd of=huangpu_env.bin if=env.bin bs=528 count=512


你可能感兴趣的:(职场,休闲,nand,stb225)