在Linux中更改U-Boot环境变量

huangapple go评论84阅读模式
英文:

Change U-Boot Environment Variable in Linux

问题

我想通过fw_setenv命令在Linux中更改u-boot环境变量。当我尝试使用fw_printenv打印环境变量时,没有错误或警告,它正常工作。但是,当我尝试更改这些变量时,我收到错误消息:"无法打开/dev/mtd4:权限被拒绝"。以下是我的设置:

在DTS中:

nor@0,0 {
	#address-cells = <1>;
	#size-cells = <1>;
	compatible = "cfi-flash";
	reg=<0x0 0x0 0x1000000>;
	bank-width = <2>;
	device-width = <1>;

	partition@0 {
		/* This location must not be altered  */
		/* 256KB for Vitesse 7385 Switch firmware */
		reg=<0x0 0x00040000>;
		label="NOR Vitesse-7385 Firmware";
		read-only;
	};

	partition@40000 {
		/* 256KB for DTB Image */
		reg=<0x00040000 0x00040000>;
		label = "NOR DTB Image";
	};

	partition@80000 {
		/* 3.5 MB for Linux Kernel Image */
		reg = <0x00080000 0x00380000>;
		label = "NOR Linux Kernel Image";
	};

	partition@400000 {
		/* 11MB for JFFS2 based Root file System */
		reg=<0x00400000 0x00b00000>;
		label = "NOR JFFS2 Root File System";
	};

	partition@f20000 {
		/* 8KB for u-boot Environment Variables */
		reg=<0x00f20000 0x00002000>;
		label = "NOR U-Boot Environment Variable";
	};

	partition@f40000 {
		/* This location must not be altered  */
		/* 512KB for u-boot Bootloader Image */
		reg=<0x00f40000 0x000C0000>;
		label = "NOR U-Boot Image";
	};

};

在Linux中:

mtd0: 00040000 00020000 "NOR Vitesse-7385 Firmware"
mtd1: 00040000 00020000 "NOR DTB Image"
mtd2: 00380000 00020000 "NOR Linux Kernel Image"
mtd3: 00b00000 00020000 "NOR JFFS2 Root File System"
mtd4: 00002000 00020000 "NOR U-Boot Environment Variable"
mtd5: 000c0000 00020000 "NOR U-Boot Image"

这些配置有什么问题?
感谢帮助。

英文:

I want to change u-boot environment variables in Linux via fw_setenv command. When i try to print environment variables via fw_printenv there is no error or warning, it works fine. However, when I try to change these variables I got an error: "Can't open /dev/mtd4: Permission denied". Here my settings:

In DTS:

nor@0,0 {
	#address-cells = &lt;1&gt;;
	#size-cells = &lt;1&gt;;
	compatible = &quot;cfi-flash&quot;;
	reg=&lt;0x0 0x0 0x1000000&gt;;
	bank-width = &lt;2&gt;;
	device-width = &lt;1&gt;;

	partition@0 {
		/* This location must not be altered  */
		/* 256KB for Vitesse 7385 Switch firmware */
		reg=&lt;0x0 0x00040000&gt;;
		label=&quot;NOR Vitesse-7385 Firmware&quot;;
		read-only;
	};

	partition@40000 {
		/* 256KB for DTB Image */
		reg=&lt;0x00040000 0x00040000&gt;;
		label = &quot;NOR DTB Image&quot;;
	};

	partition@80000 {
		/* 3.5 MB for Linux Kernel Image */
		reg = &lt;0x00080000 0x00380000&gt;;
		label = &quot;NOR Linux Kernel Image&quot;;
	};

	partition@400000 {
		/* 11MB for JFFS2 based Root file System */
		reg=&lt;0x00400000 0x00b00000&gt;;
		label = &quot;NOR JFFS2 Root File System&quot;;
	};

	partition@f20000 {
		/* 8KB for u-boot Environment Variables */
		reg=&lt;0x00f20000 0x00002000&gt;;
		label = &quot;NOR U-Boot Environment Variable&quot;;
	};

	partition@f40000 {
		/* This location must not be altered  */
		/* 512KB for u-boot Bootloader Image */
		reg=&lt;0x00f40000 0x000C0000&gt;;
		label = &quot;NOR U-Boot Image&quot;;
	};

};

In Linux:

mtd0: 00040000 00020000 &quot;NOR Vitesse-7385 Firmware&quot;
mtd1: 00040000 00020000 &quot;NOR DTB Image&quot;
mtd2: 00380000 00020000 &quot;NOR Linux Kernel Image&quot;
mtd3: 00b00000 00020000 &quot;NOR JFFS2 Root File System&quot;
mtd4: 00002000 00020000 &quot;NOR U-Boot Environment Variable&quot;
mtd5: 000c0000 00020000 &quot;NOR U-Boot Image&quot;

What is wrong in these configurations?
Thanks for the help..

答案1

得分: 1

Partition size is 8 kb but flash erasesize is 128 kb. Partition must start and end on erase/write block boundary to be writeable.
英文:
mtd4: 00002000 00020000 &quot;NOR U-Boot Environment Variable&quot;

Partition size is 8 kb but flash erasesize is 128 kb. Partition must start and end on erase/write block boundary to be writeable.

huangapple
  • 本文由 发表于 2023年7月31日 20:51:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76803815.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定