3

我希望找到一种方法来从 uBoots 命令提示符增加 RAM 中的值。

简而言之,我设备上的地址 0xc4000000 是我需要增加的临时变量

想法?

  • 我可以将值放入环境变量并在那里添加吗?
  • 有什么技巧可以用来增加它吗?
4

1 回答 1

10

您可以使用 U-Boot 命令setexpr
,它接受目标、变量 1、操作和变量 2。

U-Boot> setexpr count ${count} + 1

但是,在某些旧版本的 U-Boot 中,不包含此命令。如果是这种情况,您可能需要重新编译更新的 U-Boot。

如果你不能这样做并且你仍然绝望,你可以编写嵌套的“if”语句来增加你的数字作为一个字符串。如果您需要将其存储以备后用,请定期将其保存到非易失性存储器(NAND 或 EEPROM)中。如果您这样做,则以十六进制计数,您必须将您的字符串与“f”、“1f”、“2f”等进行比较,具体取决于您需要计算多高。

这是一个可以工作的基本代码:

setenv ones "."
setenv tens "."
setenv hundreds "."
setenv thousands "."
setenv full ".++++++++++"
setenv doCountOnes 'if test ${ones} = ${full}; then setenv ones ".";setenv tens ${tens}+ ; else setenv ones ${ones}+; fi'
setenv doCountTens 'if test ${tens} = ${full}; then setenv tens ".";setenv hundreds ${hundreds}+ ; fi'
setenv doCountHundreds 'if test ${hundreds} = ${full}; then setenv hundreds ".";setenv thousands ${thousands}+ ; fi'
setenv printCount 'echo;echo **********************************************;echo ${thousands} Thousand ${hundreds} Hundred ${tens} Ten and ${ones};echo **********************************************'
setenv doCount 'run doCountOnes; run doCountTens; run doCountHundreds'
setenv mainLoop 'run yourTestHere; run doCount; run printCount'

要运行此脚本类型:

run mainLoop
于 2014-12-10T23:14:31.203 回答