raspberry u-boot load image and run image from sd card
Solution 1
Ok, it looks like you can't just load the bin files just anywhere.
Here's what I did: 1) I reloaded the s-rec version
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>
Note the "Start Addr", it's 0x0C10-00000
2) I reset the rPI and then loaded the bin at 0x0C10-0000
U-Boot> load mmc 0 0x0C100000 hello_world.bin
reading hello_world.bin
594 bytes read in 15644 ms (0 Bytes/s)
3) and run it from the same addr:
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>
I'm not sure where the default address 0x0C10-0000 comes from, so at this point I don't know how to change it during the compilation/link yet, but it is documented here:
u-boot-pi-rpi/doc/README.standalone
This says that ARM based boards like the rPI are loaded and started at 0x0C10-0000: The default load and start addresses of the applications are as follows:
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
Solution 2
In arch/arm/config.mk there is:
CONFIG_STANDALONE_LOAD_ADDR = 0xc100000
In file 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
Here the -Ttext is 0xc100000. That means hello_world entry address is 0xc100000. So the hello.bin must be loaded to memory address 0xc100000.
JohnA
Updated on June 27, 2022Comments
-
JohnA about 2 years
I have compiled and installed u-boot from https://github.com/gonzoua/u-boot-pi/tree/rpi on the Raspberry PI. Works great. It boots fine and works great (see http://arrizza.org/wiki/index.php/RPI_U-boot). I can load the example apps using the s-rec version of the executable.
Now I'd like to create an image, put it on the sd card (the same sd card the u-boot image is on) and then load and execute that image. That is the same as the s-rec process: load the image via s-rec and then use "go" to execute, but instead of loading across the serial port just get the image off the sd card.
I have tried using:
load mmc 0 0x0100000 hello_world.bin
and then
go 0x0100000
it loads ok:
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 ...
but the rPI self-reboots.
I also tried fatload with the same results
I tried creating an image using ./imagetool-uncompressed.py and then using load or fatload and go but no joy
I tried load/fatload with bootm and still no go
Anything else available for me to try?
John
Update: @microMolvi pointed out I used the wrong address. I re-ran it:
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>
And here's the output of 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>