使用 mtd-utils 烧写Arm Linux 系统各个部分
使用 mtd-utils 烧写Arm Linux 系统各个部分
背景
作为一项技术储备,可用于增强系统可维护性。
要求
要求主板以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: 00100000 00020000 "u-boot"
mtd1: 00400000 00020000 "kernel"
mtd2: 00100000 00020000 "logo.jpg"
mtd3: 0fa00000 00020000 "rootfs.img"
烧写
升级内核脚本:(没有任何限制)
##
# 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
升级文件系统脚本:
(建议是将有关的工具在额外额外挂载点中执行以下脚本,例如额外挂载的U盘路径下)
##
# 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 img, will be "rootfs.img" 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
如果说我的文章对你有用,只不过是我站在巨人的肩膀上再继续努力罢了。
若在页首无特别声明,本篇文章由 Schips 经过整理后发布。
博客地址:https://www.cnblogs.com/schips/
若在页首无特别声明,本篇文章由 Schips 经过整理后发布。
博客地址:https://www.cnblogs.com/schips/