用Qemu模拟vexpress-a9

配置buildroot

下载buildroot

$ cd buildroot-xxxx.xx
$ make menuconfig

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

添加post-image.sh文件

$vim buildroot-xxxx.xx/board/qemu/arm-vexpress/post-image.sh

添加以下内容:

#!/bin/sh
# post-image.sh for CircuitCo BeagleBone and TI am335x-evm
# 2014, Marcin Jabrzyk <[email protected]>
# 2016, Lothar Felten <[email protected]>

BOARD_DIR="$(dirname $0)"

cp board/qemu/arm-vexpress/uEnv.txt $BINARIES_DIR/uEnv.txt

# the 4.1 kernel does not provide a dtb for beaglebone green, so we
# use a different genimage config if am335x-bonegreen.dtb is not
# built:

GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"

GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"

rm -rf "${GENIMAGE_TMP}"

genimage \
    --rootpath "${TARGET_DIR}" \
    --tmppath "${GENIMAGE_TMP}" \
    --inputpath "${BINARIES_DIR}" \
    --outputpath "${BINARIES_DIR}" \
    --config "${GENIMAGE_CFG}"

添加uEnv.txt文件

$vim buildroot-xxxx.xx/board/qemu/arm-vexpress/uEnv.txt

添加以下内容:

bootpart=0:1
devtype=mmc
bootdir=
bootfile=zImage
bootpartition=mmcblk0p2
set_bootargs=setenv bootargs console=ttyAMA0 init=/linuxrc root=/dev/${bootpartition} rw rootwait earlyparintk
uenvcmd=run set_bootargs;run loadimage;run loadfdt;printenv bootargs;bootz ${loadaddr} - ${fdtaddr}

修改uboot

在第一次编译buildroot前buildroot-xxxx.xx/output/build/uboot-xxxx.xx不存在,可以先拷贝uboot-xxxx.xx源码到buildroot-xxxx.xx/output/build/目录

$ vim buildroot-xxxx.xx/output/build/uboot-xxxx.xx/include/configs/vexpress_ca9x4.h

修改文件为以下内容:

/*
 * (C) Copyright 2011 Linaro
 * Ryan Harkin, <[email protected]>
 *
 * Configuration for Versatile Express. Parts were derived from other ARM
 *   configurations.
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#ifndef __VEXPRESS_CA9X4_H
#define __VEXPRESS_CA9X4_H

#define CONFIG_VEXPRESS_ORIGINAL_MEMORY_MAP
#include "vexpress_common.h"

#undef CONFIG_EXTRA_ENV_SETTINGS
#define CONFIG_EXTRA_ENV_SETTINGS \
	CONFIG_PLATFORM_ENV_SETTINGS \
	"bootpart=0:1\0" \
	"bootdir=\0" \
	"devtype=mmc\0"\
	"bootfile=zImage\0" \
	"bootpartition=mmcblk0p2\0"\
	"console=ttyAMA0,38400n8\0" \
	"fdtfile=vexpress-v2p-ca9.dtb\0 " \
    "loadaddr=0x60003000\0"\
    "fdtaddr=0x65000000\0"\
	"mmcdev=0\0" \
	"mmcrootfstype=ext4 rootwait\0" \
	"finduuid=part uuid mmc ${bootpart} uuid\0" \
	"bootenvfile=uEnv.txt\0" \
    "loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr\0" \
	"bootscript=echo Running bootscript from mmc${mmcdev} ...; " \
		"source ${loadaddr}\0" \
	"importbootenv=echo Importing environment from mmc${mmcdev} ...; " \
		"env import -t ${loadaddr} ${filesize}\0" \
	"loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}\0" \
	"loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \
	"loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
	"envboot=mmc dev ${mmcdev}; " \
		"if mmc rescan; then " \
			"echo SD/MMC found on device ${mmcdev};" \
			"if run loadbootscript; then " \
				"run bootscript;" \
			"else " \
				"if run loadbootenv; then " \
					"echo Loaded env from ${bootenvfile};" \
					"run importbootenv;" \
				"fi;" \
				"if test -n $uenvcmd; then " \
					"echo Running uenvcmd ...;" \
					"run uenvcmd;" \
				"fi;" \
			"fi;" \
		"fi;\0" \
	BOOTENV

#endif /* VEXPRESS_CA9X4_H */

编译buildroot

$ cd buildroot-xxxx.xx
$ make

qemu运行vexpress

编译完成后output/images目录会有u-boot、zImage 、vexpress-v2p-ca9.dtb、sdcard.img文件

uboot启动:

$ cd buildroot-xxxx.xx/output/images
$ qemu-system-arm -M vexpress-a9 -m 512M -kernel u-boot -sd sdcard.img -nographic

kernel启动:

$ cd buildroot-xxxx.xx/output/images
$ qemu-system-arm -M vexpress-a9 -m 512M -kernel zImage -dtb vexpress-v2p-ca9.dtb -sd sdcard.img -nographic -append "init=/linuxrc root=/dev/mmcblk0p2 rw rootwait earlyparintk console=ttyAMA0"

猜你喜欢

转载自blog.csdn.net/kingwan560/article/details/84138946