uboot一个hello world kernel

时间:2017-10-24 06:31:33

标签: qemu bootloader u-boot

对于Hello world uboot项目,我正在使用this教程。

我使用过GNU ARM工具链 下载的Uboot源:u-boot-2017.09

编译

var newHTML = ScratchPad.find('script')[0].src;
expect(newHTML).toBe(..

hello world项目看起来像

test.c的

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-

的Startup.s

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");
}

test.ld

.global _Reset
_Reset:
 LDR sp, =stack_top
 BL c_entry
 B .

编译

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 = .;
}

创建图片

../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

输出

mkimage -A arm -C none -O linux -T kernel -d test.bin -a 0x00100000 -e 0x00100000 test.uimg

创建一个二进制文件:

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

计算uboot二进制文件大小

cat ../u-boot-2017.09/u-boot test.uimg > flash.bin

然后运行:

printf "bootm 0x%X\n" $(expr $(stat -c%s u-boot.bin) + 65536)
bootm 0x218F20

中断它,然后运行qemu-system-arm -M vexpress-a9 -kernel flash.bin -m 128M -nographic 但它说

bootm 0x218F20

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

尝试使用相同构建映像的go命令(转到0x218F20)或使用bootm 参考[1](5.12.3。处理器缓存注意事项),mkimage命令似乎是错误的。

[1] https://www.denx.de/wiki/DULG/UBootStandalone

相关问题