当分区为只读时,如何从Linux修改u-boot环境

时间:2019-12-20 20:58:57

标签: linux-kernel arm embedded-linux u-boot disk-partitioning

我需要在嵌入式Linux设备上修改一些u-boot env。

起初,我试图擦除分区:

root@ECU:# ./flash_erase /dev/mtd2 0 0
flash_erase: error!: /dev/mtd2
             error 13 (Permission denied)

mtd2是包含我的u-boot env的分区。但是,如下所示它是不可写的:

root@ECU:# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00020000 00020000 "vf-bcb"
mtd1: 00160000 00020000 "u-boot"
mtd2: 00080000 00020000 "u-boot-env"
mtd3: 00800000 00020000 "kernel-ubi"
mtd4: 01000000 00020000 "rootfs-ubi"
mtd5: 06600000 00020000 "userfs-ubi"

root@ECU:# ./mtd_debug info /dev/mtd2
mtd.type = MTD_NANDFLASH
mtd.flags =
mtd.size = 524288 (512K)
mtd.erasesize = 131072 (128K)
mtd.writesize = 2048 (2K)
mtd.oobsize = 64
regions = 0

我知道一个常见的解决方案是引导到u-boot并修改分区。但是,由于各种原因(无串行端口,无网络),我无法进入设备的u-boot。我当前的u-boot env如下:

Colibri VFxx # printenv
autostart=no
baudrate=115200
bootcmd=run ubiboot; run nfsboot
bootdelay=3
console=ttymxc0
defargs=vmalloc=64M usb_high_speed=1
ethact=FEC
ethaddr=00:14:2d:65:ec:15
fileaddr=80010000
filesize=6cb
gatewayip=172.24.172.1
ipaddr=172.24.172.200
loadaddr=0x80010000
memargs=mem=128M
mmcargs=root=/dev/mmcblk0p2 rw,noatime rootwait
mtddevname=vf-bcb
mtddevnum=0
mtdids=nand0=fsl_nfc
mtdparts=mtdparts=fsl_nfc:128k(vf-bcb)ro,1408k(u-boot)ro,512k(u-boot-env)ro,8m(kernel-ubi),16m(rootfs-ubi),-(userfs-ubi)
netmask=255.255.255.0
partition=nand0,0
serverip=172.24.172.99
setup=setenv setupargs fec_mac=${ethaddr} no_console_suspend=1 console=tty1 console=ttymxc0,${baudrate}n8 ${memargs}
stderr=serial
stdin=serial
stdout=serial
ubiargs=ip=off ubi.mtd=rootfs-ubi root=ubi0:rootfs ro rootfstype=ubifs
ubiboot=run setup; setenv bootargs ${defargs} ${mtdparts} ${setupargs} ${ubiargs} ${vidargs}; echo Booting from NAND...; ubi part kernel-ubi && ubi read ${loadaddr} kernel && bootm
ver=U-Boot 2014.04 (May 24 2014 - 01:16:51)
vidargs=video=dcufb:640x480-16@60

有什么办法可以忽略Linux中的只读标志,并修改/擦除/重写/ dev / mtd2分区吗?

最好的问候

0 个答案:

没有答案