ubuntu16.04 qemu arm u-boot模拟

安装交叉编译器

$ arm-linux-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gcc
COLLECT_LTO_WRAPPER=/usr/local/arm_linux_4.8/libexec/gcc/arm-nuvoton-linux-uclibceabi/4.8.4/lto-wrapper
Target: arm-nuvoton-linux-uclibceabi
Configured with: ../configure --prefix=/usr/local/arm_linux_4.8 --target=arm-nuvoton-linux-uclibceabi --enable-static --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --enable-target-optspace --disable-libsanitizer --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --with-float=soft --disable-decimal-float --with-abi=aapcs-linux --with-cpu=arm926ej-s --with-float=soft --with-mode=arm --enable-languages=c,c++ --enable-poison-system-directories --enable-shared --disable-libgomp --with-sysroot=/usr/local/arm_linux_4.8 --with-build-time-tools=/usr/local/arm_linux_4.8/arm-nuvoton-linux-uclibceabi/bin --enable-shared
Thread model: posix
gcc version 4.8.4 (GCC) 

获取u-boot源码

下载U-Boot源文件: http://ftp.denx.de/pub/u-boot/
这里下载的是 u-boot-2017.11.tar.bz2

编译u-boot

进入U-Boot 源文件目录,然后执行:

 cd u-boot-2017.11
 export ARCH=arm 
 export CROSS_COMPILE=arm-linux-
 make vexpress_ca9x4_defconfig
 make

编译完成后,如果目录下生成 u-boot 文件,则说明编译成功。

运行u-boot

使用命令:

qemu-system-arm -M vexpress-a9 -nographic -m 512M -kernel u-boot

执行情况如下:

pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument


U-Boot 2017.11 (May 16 2018 - 14:06:06 +0800)

DRAM:  512 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC:   MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0 
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
*** ERROR: `serverip' not set
smc911x: MAC 52:54:00:12:34:56
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
*** ERROR: `serverip' not set
smc911x: MAC 52:54:00:12:34:56
Wrong Image Format for bootm command
ERROR: can't get kernel image!
=> 

编译时网络没有设置serverip,也不能获取内核镜像,然后进入了u-boot命令行 ,列出命令行:

U-Boot 2017.11 (May 16 2018 - 14:06:06 +0800)

DRAM:  512 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC:   MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0 
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
*** ERROR: `serverip' not set
smc911x: MAC 52:54:00:12:34:56
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
*** ERROR: `serverip' not set
smc911x: MAC 52:54:00:12:34:56
Wrong Image Format for bootm command
ERROR: can't get kernel image!
=> help
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
bootefi - Boots an EFI payload from memory
bootelf - Boot from an ELF image in memory
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
bootvx  - Boot vxWorks from an ELF image
bootz   - boot Linux zImage image from memory
cmp     - memory compare
cp      - memory copy
crc32   - checksum calculation
dhcp    - boot image via network using DHCP/TFTP protocol
echo    - echo args to console
env     - environment handling commands
erase   - erase FLASH memory
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
ext4load- load binary file from a Ext4 filesystem
ext4ls  - list files in a directory (default /)
ext4size- determine a file's size
false   - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatsize - determine a file's size
fdt     - flattened device tree utility commands
flinfo  - print FLASH memory information
fstype  - Look up a filesystem type
go      - start application at address 'addr'
help    - print command description/usage
iminfo  - print header information for application image
load    - load binary file from a filesystem
loop    - infinite loop on address range
ls      - list files in a directory (default /)
md      - memory display
mii     - MII utility commands
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mw      - memory write (fill)
nm      - memory modify (constant address)
part    - disk partition related commands
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
pxe     - commands to get and boot from pxe files
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
save    - save file to a filesystem
saveenv - save environment variables to persistent storage
setenv  - set environment variables
showvar - print local hushshell variables
size    - determine a file's size
source  - run script from memory
sysboot - command to get and boot from syslinux files
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
version - print monitor, compiler and linker version
=> 

include/configs/vexpress_common.h修改如下:

/* Basic environment settings */
#define CONFIG_BOOTCOMMAND \
    "tftp 0x80001000 uImage; tftp 0x80500000 vexpress-v2p-cat9.dtb; \
     setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.42.130:/home/rootfs \ 
     init=/linuxrc ip=192.168.42.10 console=ttyAM0';  \
     bootm 0x80001000 - 0x80500000;"

#define CONFIG_IPADDR 192.168.42.10
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_SERVERIP 192.168.42.130

include/configs/vexpress_common.h中去掉:

#define CONFIG_EXTRA_ENV_SETTINGS \
        CONFIG_PLATFORM_ENV_SETTINGS \
                BOOTENV \
        "console=ttyAMA0,38400n8\0" \
        "dram=1024M\0" \
        "root=/dev/sda1 rw\0" \
        "mtd=armflash:1M@0x800000(uboot),7M@0x1000000(kernel)," \
            "24M@0x2000000(initrd)\0" \
        "flashargs=setenv bootargs root=${root} console=${console} " \
            "mem=${dram} mtdparts=${mtd} mmci.fmax=190000 " \
            "devtmpfs.mount=0  vmalloc=256M\0" \
        "bootflash=run flashargs; " \
            "cp ${ramdisk_addr} ${ramdisk_addr_r} ${maxramdisk}; " \
            "bootm ${kernel_addr} ${ramdisk_addr_r}\0"

则启动正常:

U-Boot 2017.11 (May 16 2018 - 14:35:31 +0800)

DRAM:  512 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC:   MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0 
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
Using smc911x-0 device
TFTP from server 192.168.42.130; our IP address is 192.168.42.10
Filename 'uImage'.
Load address: 0x80001000
Loading: *
ARP Retry count exceeded; starting again
smc911x: MAC 52:54:00:12:34:56
Wrong Image Format for bootm command
ERROR: can't get kernel image!

使用u-boot的print命令查看命令参数:

U-Boot 2017.11 (May 16 2018 - 14:35:31 +0800)

DRAM:  512 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC:   MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0 
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
Using smc911x-0 device
TFTP from server 192.168.42.130; our IP address is 192.168.42.10
Filename 'uImage'.
Load address: 0x80001000
Loading: *
ARP Retry count exceeded; starting again
smc911x: MAC 52:54:00:12:34:56
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
Using smc911x-0 device
TFTP from server 192.168.42.130; our IP address is 192.168.42.10
Filename 'vexpress-v2p-cat9.dtb'.
Load address: 0x80500000
Loading: *
ARP Retry count exceeded; starting again
smc911x: MAC 52:54:00:12:34:56
Wrong Image Format for bootm command
ERROR: can't get kernel image!
=> print
=> print
arch=arm
baudrate=38400
board=vexpress
board_name=vexpress
bootargs=root=/dev/nfs rw nfsroot=192.168.42.130:/home/rootfs      init=/linuxrc ip=192.168.42.10 console=ttyAM0,115200n8
bootcmd=tftp 0x80001000 uImage; tftp 0x80500000 vexpress-v2p-cat9.dtb;      setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.42.130:/home/rootfs      init=/linuxrc ip=192.168.42.10 console=ttyAM0';       bootm 0x80001000 - 0x80500000;
bootdelay=2
cpu=armv7
ethact=smc911x-0
ethaddr=52:54:00:12:34:56
ipaddr=192.168.42.10
netmask=255.255.255.0
serverip=192.168.42.130
stderr=serial
stdin=serial
stdout=serial
vendor=armltd

Environment size: 648/262140 bytes
=> 

串口波特率为: baudrate=38400
可以在configs/vexpress_ca9x4_defconfig文件做一下修改:

  CONFIG_BAUDRATE=115200
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,076评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,658评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,732评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,493评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,591评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,598评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,601评论 3 415
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,348评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,797评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,114评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,278评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,953评论 5 339
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,585评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,202评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,442评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,180评论 2 367
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,139评论 2 352

推荐阅读更多精彩内容