ubuntu16.04 qemu arm u-bootシミュレーション

12139 ワード

クロスコンパイラのインストール

$ 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ソースファイルをダウンロード: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
=>