有关博客:《Arm-Linux 移植 mtd-utils 1.x》
背景:
作为一项技术储备,可用于增强系统可维护性。
要求:
要求主板以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 |
升级内核脚本:
## # Copyright By Schips, All Rights Reserved # https://gitee.com/schips/ # File Name: update_kernel.sh # Created : Thu 05 Dec 2019 05:18:03 PM CST ## #!/bin/sh MTD=/dev/mtd1 # $1 as the name of kernel , will be "kernel" as default. if [ "$1" == "" ];then KERNEL=kernel else KERNEL=$1 fi if [ -f ${KERNEL} ];then ./flash_erase ${MTD} 0 32 ./nandwrite -p ${MTD} ${KERNEL} else echo "[$KERNEL] not found" exit 1 fi
升级文件系统脚本:
(建议是在额外额外挂载点中执行以下脚本)
## # Copyright By Schips, All Rights Reserved # https://gitee.com/schips/ # File Name: update_fs.sh # Created : Thu 05 Dec 2019 05:20:13 PM CST ## #!/bin/sh MTD=/dev/mtd3 # $1 as the name of FSIMG , will be "FSIMG" as default. if [ "$1" == "" ];then FSIMG=rootfs.img else FSIMG=$1 fi if [ -f ${FSIMG} ];then ./flash_erase ${MTD} 0 2000 ./nandwrite -p ${MTD} ${FSIMG} else echo "[$FSIMG] not found" exit 1 fi