U-boot, Qemu and baremetal

1.2k views Asked by At

I was reading this:
https://balau82.wordpress.com/2010/03/10/u-boot-for-arm-on-qemu/

Context:

Baremtal programming

Foreword:

  • OSX El Capitan, Qemu 2.2.1, U-boot 2016-07
  • We cannot use the uboot.bin (no proper load and crash. Not to mention no Uboot prompt). I think it is OK for older uboot version though.
  • I created a baremetal assembly program that executes just fine in qemu alone (set the registers to some values and the qemu monitor confirmed those values)
  • It fails to be executed when I mix it with UBoot
  • I need uboot to test UART, have a proper DRAM and so on. I don't want to write a new bootloader for those partly undocumented stuffs.

The process:

  • QEMU + baremetal application (Makefile below):

    prepimg:
        ~/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-as -g comm.ml -o comm.o
        ~/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-ld -T test.ld comm.o -o test.elf
        ~/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-objcopy -O binary test.elf test.bin
    mkimg:
        mkimage -A arm -C none -T kernel -O linux -d test.bin -a 0x0010000 -e 0x0010000 test.uimg
    launch_test:
        qemu-system-arm -m 128M -M vexpress-a9 -nographic -monitor telnet:127.0.0.1:1234,server,nowait -kernel test.uimg
    

It works. Code is executed at the correct address (r15 proves it).

  • QEMU + baremetal + U-boot

    prepimg:
        ~/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-as -g comm.ml -o comm.o
        ~/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-ld -T test.ld comm.o -o test.elf
        ~/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-objcopy -O binary test.elf test.bin
    mkimg:
        mkimage -A arm -C none -T kernel -O linux -d test.bin -a 0x0010000 -e 0x0010000 test.uimg
    
    cat_them:
        cat u-boot-2016.07/u-boot test.uimg > u-boot-2016.07/flash.bin
    
    launch_qemu:
        qemu-system-arm -m 128M -M vexpress-a9 -nographic -monitor telnet:127.0.0.1:1234,server,nowait -kernel u-boot-2016.07/flash.bin
    

Then, I get:

Wrong Image Format for bootm command
ERROR: can't get kernel image!

Trials:

  • I tried to modify the entry point and load address of my code to 0x80008000, 0x8000 but still the same thing.
  • I spent hours trying to display different regions of the memory (with the u-boot md tool), looking for my code, no luck.

I don't know what is going on.

1

There are 1 answers

0
Larry On

Finally,

I d/l my file via tftp and got the job done.