[U-Boot] qemu and baremetal arm prog

For a Hello world uboot project I am using https://balau82.wordpress.com/2010/03/10/u-boot-for-arm-on-qemu/ tutorial.
I have used GNU ARM toolchain Downloaded Uboot source : u-boot-2017.09
Compiled it
make vexpress_ca9x4_defconfig ARCH=arm CROSS_COMPILE=../gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-
make all ARCH=arm CROSS_COMPILE=../gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-
And the hello world project looks like
**test.c**
volatile unsigned int * const UART0DR = (unsigned int *)0x101f1000; void print_uart0(const char *s) { while(*s != '\0') { /* Loop until end of string */ *UART0DR = (unsigned int)(*s); /* Transmit char */ s++; /* Next char */ } } void c_entry() { print_uart0("Hello world!\n"); }
**startup.s**
.global _Reset _Reset: LDR sp, =stack_top BL c_entry B .
**test.ld**
ENTRY(_Reset) SECTIONS { . = 0x100000; /*initial address*/ .startup . : { startup.o(.text) } .text : { *(.text) } .data : { *(.data) } .bss : { *(.bss COMMON) } . = ALIGN(8); . = . + 0x1000; /* 4kB of stack memory */ stack_top = .; }
**And the compilation**
../gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gcc -c -mcpu=arm926ej-s test.c -o test.o
../gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-as -mcpu=arm926ej-s startup.s -o startup.o
../gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-ld -T test.ld -Map=test.map test.o startup.o -o test.elf
../gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-objcopy -O binary test.elf test.bin
**Create Image :**
mkimage -A arm -C none -O linux -T kernel -d test.bin -a 0x00100000 -e 0x00100000 test.uimg
**Output :**
Image Name: Created: Mon Oct 23 20:58:01 2017 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 146 Bytes = 0.14 kB = 0.00 MB Load Address: 00100000 Entry Point: 00100000
**Create a single binary :**
cat ../u-boot-2017.09/u-boot test.uimg > flash.bin
**Calculated uboot binary size**
printf "bootm 0x%X\n" $(expr $(stat -c%s u-boot.bin) + 65536) bootm 0x218F20
**Then run :**
qemu-system-arm -M vexpress-a9 -kernel flash.bin -m 128M -nographic
Interrupted it and then run `bootm 0x218F20` But it says
Wrong Image Format for bootm command ERROR: can't get kernel image!
Any suggestion?
[1]: https://balau82.wordpress.com/2010/03/10/u-boot-for-arm-on-qemu

Dear Anupam,
In message CAEmaDyHtO=2+jZXLa=afZ6+oyxvndaRAbhfL-SSJhHV-kmzmyQ@mail.gmail.com you wrote:
printf "bootm 0x%X\n" $(expr $(stat -c%s u-boot.bin) + 65536) bootm 0x218F20
The value 0x218F20 printed here is the offset where your image starts relative to the begin of the U-Boot binary.
**Then run :**
qemu-system-arm -M vexpress-a9 -kernel flash.bin -m 128M -nographic
Interrupted it and then run `bootm 0x218F20` But it says
Wrong Image Format for bootm command ERROR: can't get kernel image!
This can only be correct if your U-Boot binary was loaded to address 0x0000, which probably is not correct.
Best regards,
Wolfgang Denk
participants (2)
-
Anupam Datta
-
Wolfgang Denk