【问题标题】:raspberry u-boot load image and run image from sd cardraspberry u-boot 从 sd 卡加载镜像并运行镜像
【发布时间】:2014-12-28 13:05:19
【问题描述】:

我已经在 Raspberry PI 上编译并安装了来自 https://github.com/gonzoua/u-boot-pi/tree/rpi 的 u-boot。效果很好。它可以正常启动并且效果很好(请参阅http://arrizza.org/wiki/index.php/RPI_U-boot)。我可以使用可执行文件的 s-rec 版本加载示例应用程序。

现在我想创建一个映像,将其放在 sd 卡上(u-boot 映像所在的同一 sd 卡),然后加载并执行该映像。这和s-rec的流程是一样的:通过s-rec加载图片,然后使用“go”来执行,但不是通过串口加载,而是从sd卡中取出图片。

我尝试过使用:

load mmc 0 0x0100000 hello_world.bin

然后

go 0x0100000

加载正常:

U-Boot> fatload mmc 0 0x01000000 hello_world.bin
reading hello_world.bin
594 bytes read in 27222 ms (0 Bytes/s)
U-Boot> go 0x01000000
## Starting application at 0x01000000 ...

但 rPI 会自动重启。

  • 我也尝试过 fatload,结果相同

  • 我尝试使用 ./imagetool-uncompressed.py 创建图像,然后使用 load 或 fatload 进行操作,但没有任何乐趣

  • 我试过用 bootm 加载/fatload 还是不行

还有什么可以尝试的吗?

约翰

更新:@microMolvi 指出我使用了错误的地址。我重新运行它:

U-Boot> load mmc 0 0x01001000 hello_world.bin 
reading hello_world.bin
594 bytes read in 27200 ms (0 Bytes/s)
U-Boot> go 0x01001000
## Starting application at 0x01001000 ...
<snip>about 100 garbage characters<snip>
<I pressed Enter here>
## Application terminated, rc = 0x0
U-Boot> 

这是 printenv 的输出:

U-Boot> printenv
arch=arm
baudrate=115200
board=rpi_b
board_name=rpi_b
bootargs=dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x4e82105a smsc95xx.macaddr=B8:27:EB:82:10:5A sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
bootcmd=if mmc rescan ${mmcdev}; then if run loadbootenv; then run importbootenv; fi; if run loadbootscript; then run bootscript; fi; fi
bootenv=uEnv.txt
bootscript=echo Running bootscript from mmc${mmcdev} ...; source ${loadaddr}
cpu=arm1176
filesize=0x252
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
loadaddr=0x00200000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr
mmcdev=0
soc=bcm2835
stderr=serial,lcd
stdin=serial
stdout=serial,lcd
usbethaddr=B8:27:EB:82:10:5A
vendor=raspberrypi

Environment size: 1092/16380 bytes
U-Boot> 

【问题讨论】:

  • 嗨,John,0x0100000 不等于 0x01000000 :) 你能提供U-Boot&gt;printenv的输出吗
  • 更新见上文。我从您的回复中假设它应该可以正常工作!?
  • 顺便说一句,我也尝试过:load mmc 0 $loadaddr hello_world.bin,然后是go $loadaddr,最后我也尝试加载 hello_world.srec。这只是重置 rPI。
  • 不,我不确定程序,只是发现了错字:D 我过去在 arm11mpcore 板上遇到过同样的问题,但无法解决。我将尝试您在下面发布的解决方案,希望它也适用于我:)

标签: raspberry-pi u-boot


【解决方案1】:

好的,看来您不能随便在任何地方加载 bin 文件。

这是我所做的: 1)我重新加载了s-rec版本

U-Boot> loads
## Ready for S-Record download ...

## First Load Addr = 0x0C100000
## Last  Load Addr = 0x0C100251
## Total Size      = 0x00000252 = 594 Bytes
## Start Addr      = 0x0C100000
U-Boot> 

注意“起始地址”,它是 0x0C10-00000

2) 我重置了 rPI,然后在 0x0C10-0000 处加载了 bin

U-Boot> load mmc 0 0x0C100000 hello_world.bin
reading hello_world.bin
594 bytes read in 15644 ms (0 Bytes/s)

3) 并从同一个地址运行它:

U-Boot> go 0x0C100000
## Starting application at 0x0C100000 ...
Example expects ABI version 6
Actual U-Boot ABI version 6
Hello World
argc = 1
argv[0] = "0x0C100000"
argv[1] = "<NULL>"
Hit any key to exit ... 

## Application terminated, rc = 0x0
U-Boot> 

我不确定默认地址 0x0C10-0000 来自哪里,所以目前我还不知道如何在编译/链接期间更改它,但它记录在这里:

u-boot-pi-rpi/doc/README.standalone

这表示基于 ARM 的板(如 rPI)已加载并从 0x0C10-0000 开始: 应用程序的默认加载和启动地址如下:

                    Load address    Start address
    x86             0x00040000      0x00040000
    PowerPC         0x00040000      0x00040004
    ARM             0x0c100000      0x0c100000
    MIPS            0x80200000      0x80200000
    Blackfin        0x00001000      0x00001000
    NDS32           0x00300000      0x00300000
    Nios II         0x02000000      0x02000000

【讨论】:

    【解决方案2】:

    在arch/arm/config.mk中有:

    CONFIG_STANDALONE_LOAD_ADDR = 0xc100000
    

    在文件examples/standalone/.hello_world.cmd中

    cmd_examples/standalone/hello_world := arm-linux-gnueabi-ld.bfd   -g -Ttext 0xc100000 -o examples/standalone/hello_world -e hello_world examples/standalone/hello_world.o examples/standalone/libstubs.o -L /usr/lib/gcc-cross/arm-linux-gnueabi/4.7 -lgcc
    

    这里的 -Ttext 是 0xc100000。这意味着 hello_world 入口地址是 0xc100000。所以hello.bin必须加载到内存地址0xc100000。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-04
      • 2022-10-15
      • 2019-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-05
      相关资源
      最近更新 更多