【问题标题】:uboot a hello world kerneluboot 一个 hello world 内核
【发布时间】:2018-04-04 20:13:24
【问题描述】:

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

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

编译好了

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-

hello world 项目看起来像

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

还有汇编

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

创建单个二进制文件:

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

计算出的 uboot 二进制大小

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 但它说

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

有什么建议吗?

【问题讨论】:

    标签: qemu bootloader u-boot


    【解决方案1】:

    尝试使用相同构建映像的 go 命令 (go 0x218F20) 或使用 bootm 参考[1](5.12.3.处理器缓存注意事项),mkimage命令好像出错了。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-24
      • 1970-01-01
      • 2021-09-25
      • 2018-12-09
      相关资源
      最近更新 更多