嵌入式Linux运行过程中动态更新cramfs分区。

 一直想解决在嵌入式linux运行的时候,动态更新cramfs,今天用mtd_debug实现了对kernel和rootfs的运行时更新。

同时还使用了dd以及nandwrite,发现dd对一个文件是可以的,但是写入另一文件后,内核启动的过程中出现了ECC的kernel panic。

而使用nandwrite则一次都不能成功。

--=================================================-- 1. OK /root/mtd_utils # ./mtd_debug write /dev/mtdblock/1 0x0 1218604 zImage Copied 1218604 bytes from zImage to address 0x00000000 in flash

./mtd_debug write /dev/mtdblock/2 0x0 2404352 ./rootfs.my.cramfs # ok ./mtd_debug write /dev/mtdblock/2 0x0  2416640 rootfs080626.cramfs # ok ./mtd_debug write /dev/mtd/2 0x0  2416640 rootfs080626.cramfs # write ok, run ok!

注意mtd_debug的长度参数,要<=文件的长度,才会写入到mtd中,否则会给出如下提示并退出: file_to_flash: fread, size 0x1297f5, n 0x1297f5 fread(): Success

--=================================================-- 2. 参数错误 /root/mtd_utils # ./mtd_debug write /dev/mtd/1 0x0 1218604 zImage MTD_open MTD_write nand_write_ecc: Attempt to write not page aligned data fileMTD_close _to_flash: write, size 0x12982c, n 0x12982c write(): Invalid argument

--=================================================-- 3. dd 有的时候可以,有的时候不能运行,可能跟cramfs的内容有关系 dd if=rootfs.my.cramfs of=/dev/mtdblock/2 # OK dd if=rootfs.my.cramfs of=/dev/mtd/2 (writing '/dev/mtd/2': Invalid argument) dd if=rootfs080626.cramfs of=/dev/mtdblock/2 # ecc error

--=================================================-- 4. nandwrite 不行 ./nandwrite /dev/mtd/2 ./rootfs.my.cramfs # Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0) ./nandwrite /dev/mtd/2  ./rootfs080626.cramfs # failed, can not mount ./nandwrite /dev/mtdblock/2 ./rootfs080626.cramfs # MEMGETINFO: Inappropriate ioctl for device

 

你可能感兴趣的:(c,linux,File,Flash,嵌入式)