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

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

Change U-Boot Environment Variable in Linux

问题

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

在DTS中:

  1. nor@0,0 {
  2. #address-cells = <1>;
  3. #size-cells = <1>;
  4. compatible = "cfi-flash";
  5. reg=<0x0 0x0 0x1000000>;
  6. bank-width = <2>;
  7. device-width = <1>;
  8. partition@0 {
  9. /* This location must not be altered */
  10. /* 256KB for Vitesse 7385 Switch firmware */
  11. reg=<0x0 0x00040000>;
  12. label="NOR Vitesse-7385 Firmware";
  13. read-only;
  14. };
  15. partition@40000 {
  16. /* 256KB for DTB Image */
  17. reg=<0x00040000 0x00040000>;
  18. label = "NOR DTB Image";
  19. };
  20. partition@80000 {
  21. /* 3.5 MB for Linux Kernel Image */
  22. reg = <0x00080000 0x00380000>;
  23. label = "NOR Linux Kernel Image";
  24. };
  25. partition@400000 {
  26. /* 11MB for JFFS2 based Root file System */
  27. reg=<0x00400000 0x00b00000>;
  28. label = "NOR JFFS2 Root File System";
  29. };
  30. partition@f20000 {
  31. /* 8KB for u-boot Environment Variables */
  32. reg=<0x00f20000 0x00002000>;
  33. label = "NOR U-Boot Environment Variable";
  34. };
  35. partition@f40000 {
  36. /* This location must not be altered */
  37. /* 512KB for u-boot Bootloader Image */
  38. reg=<0x00f40000 0x000C0000>;
  39. label = "NOR U-Boot Image";
  40. };

};

在Linux中:

  1. mtd0: 00040000 00020000 "NOR Vitesse-7385 Firmware"
  2. mtd1: 00040000 00020000 "NOR DTB Image"
  3. mtd2: 00380000 00020000 "NOR Linux Kernel Image"
  4. mtd3: 00b00000 00020000 "NOR JFFS2 Root File System"
  5. mtd4: 00002000 00020000 "NOR U-Boot Environment Variable"
  6. 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:

  1. nor@0,0 {
  2. #address-cells = &lt;1&gt;;
  3. #size-cells = &lt;1&gt;;
  4. compatible = &quot;cfi-flash&quot;;
  5. reg=&lt;0x0 0x0 0x1000000&gt;;
  6. bank-width = &lt;2&gt;;
  7. device-width = &lt;1&gt;;
  8. partition@0 {
  9. /* This location must not be altered */
  10. /* 256KB for Vitesse 7385 Switch firmware */
  11. reg=&lt;0x0 0x00040000&gt;;
  12. label=&quot;NOR Vitesse-7385 Firmware&quot;;
  13. read-only;
  14. };
  15. partition@40000 {
  16. /* 256KB for DTB Image */
  17. reg=&lt;0x00040000 0x00040000&gt;;
  18. label = &quot;NOR DTB Image&quot;;
  19. };
  20. partition@80000 {
  21. /* 3.5 MB for Linux Kernel Image */
  22. reg = &lt;0x00080000 0x00380000&gt;;
  23. label = &quot;NOR Linux Kernel Image&quot;;
  24. };
  25. partition@400000 {
  26. /* 11MB for JFFS2 based Root file System */
  27. reg=&lt;0x00400000 0x00b00000&gt;;
  28. label = &quot;NOR JFFS2 Root File System&quot;;
  29. };
  30. partition@f20000 {
  31. /* 8KB for u-boot Environment Variables */
  32. reg=&lt;0x00f20000 0x00002000&gt;;
  33. label = &quot;NOR U-Boot Environment Variable&quot;;
  34. };
  35. partition@f40000 {
  36. /* This location must not be altered */
  37. /* 512KB for u-boot Bootloader Image */
  38. reg=&lt;0x00f40000 0x000C0000&gt;;
  39. label = &quot;NOR U-Boot Image&quot;;
  40. };

};

In Linux:

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

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

答案1

得分: 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.
英文:
  1. 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:

确定