有关博客:《Arm-Linux 移植 mtd-utils 1.x》、《mtd-utils 的 使用


背景:

  作为一项技术储备,可用于增强系统可维护性。

要求:

  要求主板以mtd作为分区管理,要求使用者清楚分区各部分应该存放什么内容

  注:

  笔者的uboot启动参数:

    bootargs 'mem=1024M console=ttyAMA0,115200 ubi.mtd=3 root=ubi0:ubifs rootflags=sync rootfstype=ubifs rw mtdparts=hinand:1M(u-boot),4M(kernel),1M(logo.jpg),250M(rootfs.img)'

  对应的表格如图所示:

含义
文件名
下载内存
nand
size
MTD
分区
bootloader
u-boot
0x41000000
0x0
0x80000
0
1m
uboot_env
CONFIG_ENV_OFFSET 
-
0x080000
0x40000
-
 
内核
kernel
0x42000000
0x100000
0x400000
1
4m
开机画面
logo.jpg
0x43000000
0x500000
0x80000
2
1m
视频输出
-vobuf-
0x43800000
-
-
-
 
文件系统
rootfs.img
0x42000000
0x600000
0xfa00000
3
250m

内核中有关的信息:

/ # cat /proc/mtd
dev:    size   erasesize  name
mtd0:   "u-boot"
mtd1:   "kernel"
mtd2:   "logo.jpg"
mtd3: 0fa00000  "rootfs.img"

烧写

升级内核脚本:(没有任何限制)

##
#    Copyright By Schips, All Rights Reserved
#    https://gitee.com/schips/
#    File Name:  update_kernel.sh
#    Created  :  Thu  Dec  :: PM CST
##
#!/bin/sh
MTD=/dev/mtd1
# $ as the name of kernel , will be "kernel" as default.

if [ "$1" == "" ];then
        KERNEL=kernel
else
        KERNEL=$
fi

if [ -f ${KERNEL} ];then
         ./flash_erase  ${MTD}
         ./nandwrite -p ${MTD} ${KERNEL}
else
        echo "[$KERNEL] not found"
        exit
fi

升级文件系统脚本:

(建议是将有关的工具在额外额外挂载点中执行以下脚本,例如额外挂载的U盘路径下)

##
#    Copyright By Schips, All Rights Reserved
#    https://gitee.com/schips/
#    File Name:  update_fs.sh
#    Created  :  Thu  Dec  :: PM CST
##
#!/bin/sh
MTD=/dev/mtd3
# $ as the name of img, will be "rootfs.img" as default.

if [ "$1" == "" ];then
        FSIMG=rootfs.img
else
        FSIMG=$
fi

if [ -f ${FSIMG} ];then
         ./flash_erase  ${MTD}
         ./nandwrite -p ${MTD} ${FSIMG}
else
        echo "[$FSIMG] not found"
        exit
fi
05-11 22:38