ubuntu16.04 qemu arm u-boot模拟

版权声明:本文为博主原创文章,未经博主允许不得转载。博主出没群号331983270, 104504347 https://blog.csdn.net/viewsky11/article/details/80337326

安装交叉编译器

$ 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
=> 
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页