关键词: U-boot, VersatilePB, ARM, Linux, Qemu, vexpress-a9

环境介绍:

  • Win7 64 + Vmware 15 + ubuntu18.04 64
  • u-boot 版本:u-boot-2012.04.01
  • Linux kernel版本:linux-5.3.0
  • busybox版本:1.32.0
  • 交叉编译工具链:arm-linux-gnueabihf-
  • qemu版本:2.11.1

概述:

目标:基于Qemu虚拟vexpress-a9单板,完整虚拟单板启动全过程,利用网络引导的方式启动Linux内核:uboot引导+加载linux内核+加载文件系统,最终进入命令行界面。具体方法是:开启Qemu的网络支持功能,启动u-boot,设置u-boot的环境变量,u-boot采用tftp的方式将uImage格式的Linux内核下载到内存地址0x60003000处进行引导,最后加载bosybox文件系统,显示命令行提示符。

命令:

sudo qemu-system-arm -M vexpress-a9 -m 512M -nographic -kernel u-boot -net nic -net tap -sd ~/a9rootfs.ext3

具体步骤:

需要加上sudo apt install ifupdown来开启ifupdowm,否则直接修改interface无效

sudo apt-get install uml-utilities bridge-utils

修改 /etc/network/interfaces 文件,最后需要重启计算机,使新的 /etc/network/interfaces 配置文件生效

#source /etc/network/interfaces.d/*# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopbackauto ens33
iface ens33 inet manualauto tap0
iface tap0 inet manualauto br0
iface br0 inet static
#之前上网时采用静态IP,所以这里依然使用此address 192.168.0.111
# 将之前上网的ip地址分配给网桥。network 192.168.0.0netmask 255.255.255.0broadcast 192.168.0.255gateway 192.168.0.1bridge_ports ens33 tap0
# 为网桥添加两个接口,分别是enp3s0(之前默认的上网网口)和tap0bridge_stp offbridge_fd 0bridge_maxwait 0dns-nameservers 114.114.114.114

使用qemu-ifup脚本,权限755 sudo chmod 755 qemu-ifup

#! /bin/sh
# Script to bring a network (tap) device for qemu up.
# The idea is to add the tap device to the same bridge
# as we have default routing to.# in order to be able to find brctl
PATH=$PATH:/sbin:/usr/sbinswitch=br0
interface=ens33
if [ -n "$1" ]; thenswitch_exit=`sudo ifconfig -a | grep $switch`interface_switch=`sudo brctl show | grep $interface`if [ "$switch_exit" = "" ] ; thensudo brctl addbr $switchfiif [ "$interface_switch" = "" ] ; thensudo ifconfig $interface 0.0.0.0 promisc upsudo brctl addif $switch $interfacefisudo ifconfig $1 0.0.0.0 promisc upsudo brctl addif $switch $1sudo dhclient $switch
elseecho "Error: no interface specified"exit
fi

使用qemu-ifdown脚本,权限755 sudo chmod 755 qemu-ifdown

#! /bin/sh
echo sudo brctl delif br0 $1
sudo brctl delif br0 $1echo sudo tunctl -d $1
sudo tunctl -d $1echo brctl show
brctl show

2、配置u-boot
修改单板配置文件:include/configs/ca9x4_ct_vxp.h

vim include/configs/ca9x4_ct_vxp.h// netmask
#define CONFIG_IPADDR           192.168.0.119
#define CONFIG_NETMASK          255.255.255.0
#define CONFIG_SERVERIP         192.168.0.111
#修改启动命令为
/* Basic environment settings */
#define CONFIG_BOOTCOMMAND "run bootflash; tftp 0x60003000 uImage; tftp 0x60500000 dtb; setenv bootargs 'root=/dev/mmcblk0 console=ttyAMA0'; bootm 0x60003000 - 0x60500000"

说明:
这里我把ipaddr等设置为了192.168.0.119,这个网址设置要跟br0的网址(192.168.0.111)在同一个网段

3、配置Linux Kernel
要用u-boot引导,需要把Kernel编译成uImage格式:(LOADADDR和uboot的启动加载位置一致)
make uImage LOADADDR=0x60003000
编译生成的uImage在 ~/linux-4.9.218/arch/arm/boot下,将uImage拷贝到/tftpboot目录下

测试结果:

book@100ask:~/sss/u-boot-2012.04.01$ sudo qemu-system-arm -M vexpress-a9 -m 512M -nographic -kernel u-boot -net nic -net tap -sd ~/a9rootfs.ext3 
[sudo] password for book: 
device tap0 is already a member of a bridge; can't enslave it to bridge br0.
cmp: EOF on /tmp/tmp.3EuLhKWRJw which is empty
WARNING: Image format was not specified for '/home/book/a9rootfs.ext3' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument

U-Boot 2012.04.01 (Jul 08 2020 - 16:42:35)

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 
Wrong Image Format for bootm command
ERROR: can't get kernel image!
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
Using smc911x-0 device
TFTP from server 192.168.0.111; our IP address is 192.168.0.119
Filename 'uImage'.
Load address: 0x60003000
Loading: #################################################################
     #################################################################
     #################################################################
     ###############################################
done
Bytes transferred = 3552440 (3634b8 hex)
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
Using smc911x-0 device
TFTP from server 192.168.0.111; our IP address is 192.168.0.119
Filename 'dtb'.
Load address: 0x60500000
Loading: ##
done
Bytes transferred = 14708 (3974 hex)
## Booting kernel from Legacy Image at 60003000 ...
   Image Name:   Linux-4.9.218
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3552376 Bytes = 3.4 MiB
   Load Address: 60003000
   Entry Point:  60003000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 60500000
   Booting using the fdt blob at 0x60500000
   XIP Kernel Image ... OK
OK
   Loading Device Tree to 7feea000, end 7fef0973 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.9.218 (book@100ask) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #1 SMP Tue Jul 7 19:16:33 CST 2020
CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
OF: fdt:Machine model: V2P-CA9
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
percpu: Embedded 12 pages/cpu s19148 r8192 d21812 u49152
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: root=/dev/mmcblk0 console=ttyAMA0
log_buf_len individual max cpu contribution: 4096 bytes
log_buf_len total cpu_extra contributions: 12288 bytes
log_buf_len min size: 16384 bytes
log_buf_len: 32768 bytes
early log buf free: 15016(91%)
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 510948K/524288K available (5120K kernel code, 170K rwdata, 1208K rodata, 1024K init, 150K bss, 13340K reserved, 0K cma-reserved)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xa0800000 - 0xff800000   (1520 MB)
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
    modules : 0x7f000000 - 0x80000000   (  16 MB)
      .text : 0x80008000 - 0x80600000   (6112 kB)
      .init : 0x80800000 - 0x80900000   (1024 kB)
      .data : 0x80900000 - 0x8092a980   ( 171 kB)
       .bss : 0x8092c000 - 0x80951bf0   ( 151 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
Hierarchical RCU implementation.
    Build-time adjustment of leaf fanout to 32.
    RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4
NR_IRQS:16 nr_irqs:16 16
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating disabled, standby mode disabled
L2C-310 cache controller enabled, 8 ways, 128 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
smp_twd: clock not found -2
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
Failed to initialize '/smb@04000000/motherboard/iofpga@7,00000000/timer@12000': -22
Console: colour dummy device 80x30
Calibrating local timer... 91.44MHz.
Calibrating delay loop... 434.99 BogoMIPS (lpj=2174976)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: Spectre v2: using BPIALL workaround
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x60100000 - 0x60100058
Brought up 1 CPUs
SMP: Total of 1 processors activated (434.99 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 1024 (order: 4, 65536 bytes)
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
OF: amba_device_add() failed (-19) for /memory-controller@100e0000
OF: amba_device_add() failed (-19) for /memory-controller@100e1000
OF: amba_device_add() failed (-19) for /watchdog@100e5000
10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 35, base_baud = 0) is a PL011 rev1
console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 36, base_baud = 0) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 37, base_baud = 0) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 38, base_baud = 0) is a PL011 rev1
OF: amba_device_add() failed (-19) for /smb@04000000/motherboard/iofpga@7,00000000/wdt@0f000
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm,sp804
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 1 counters available
workingset: timestamp_bits=30 max_order=17 bucket_order=0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
io scheduler noop registered (default)
clcd-pl11x 10020000.clcd: PL111 designer 41 rev2 at 0x10020000
clcd-pl11x 10020000.clcd: /clcd@10020000 hardware, 1024x768@59 display
Console: switching to colour frame buffer device 128x48
clcd-pl11x 1001f000.clcd: PL111 designer 41 rev2 at 0x1001f000
clcd-pl11x 1001f000.clcd: /smb@04000000/motherboard/iofpga@7,00000000/clcd@1f000 hardware, 640x480@59 display
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(0): "40000000.flash"
(1): "40000000.flash"
into device "40000000.flash"
libphy: Fixed MDIO Bus: probed
libphy: smsc911x-mdio: probed
smsc911x 4e000000.ethernet eth0: MAC Address: 52:54:00:12:34:56
isp1760 4f000000.usb: bus width: 32, oc: digital
isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
isp1760 4f000000.usb: Scratch test failed.
isp1760 4f000000.usb: can't setup: -19
isp1760 4f000000.usb: USB bus 1 deregistered
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
rtc-pl031 10017000.rtc: rtc core: registered pl031 as rtc0
mmci-pl18x 10005000.mmci: Got CD GPIO
mmci-pl18x 10005000.mmci: Got WP GPIO
mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 31,32 (pio)
mmc0: new SD card at address 4567
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
input: AT Raw Set 2 keyboard as /devices/platform/smb@04000000/smb@04000000:motherboard/smb@04000000:motherboard:iofpga@7,00000000/10006000.kmi/serio0/input/input0
mmcblk0: mmc0:4567 QEMU! 64.0 MiB 
aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 30
aaci-pl041 10004000.aaci: FIFO 512 entries
oprofile: using arm/armv7-ca9
NET: Registered protocol family 17
9pnet: Installing 9P2000 support
Registering SWP/SWPB emulation handler
rtc-pl031 10017000.rtc: setting system clock to 2020-07-09 02:58:11 UTC (1594263491)
ALSA device list:
  #0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 30
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/smb@04000000/smb@04000000:motherboard/smb@04000000:motherboard:iofpga@7,00000000/10007000.kmi/serio1/input/input2
EXT4-fs (mmcblk0): mounting ext3 file system using the ext4 subsystem
random: fast init done
EXT4-fs (mmcblk0): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext3 filesystem) readonly on device 179:0.
Freeing unused kernel memory: 1024K
random: crng init done

Please press Enter to activate this console. 
/ #

主机环境:Ubuntu 18.04虚拟机,目标机器:QEMU模拟vexpress-a9

工具链设置为:
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=$PATH:/home/ToolChain/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin

基于Qemu虚拟vexpress-a9开发板,实现完整系统启动(uboot+kernel+rootfs)相关推荐

  1. 基于Qemu搭建imx6l模拟开发板环境+添加驱动+驱动测试

    一.Qemu镜像下载 准备环境 vmware ubuntu18.04 git工具 下载镜像文件 root@ubuntu:/home/mf/Desktop# git clone https://e.co ...

  2. QEMU 模拟Arm A9开发板

    一.在Deepin 中编译Qemu4, 1.下载Qemu4源码 wget https://download.qemu.org/qemu-4.0.0.tar.xz 2.解压缩 tar xvJf qemu ...

  3. 基于QEMU的ARM Cortex-A9开发板Vexpress-ca9的Linux内核的编译和运行

    宿主机:Ubuntu16.04 x64(Linux内核4.4.0) 交叉编译工具链:gcc-arm-linux-gnueabi arm-linux-gcc:4.4.3 QEMU:2.5.0 Linux ...

  4. STM32下载程序至SRAM——基于正点原子精英STM32F103ZET6开发板

    STM32下载程序至SRAM--基于正点原子精英STM32F103ZET6开发板 如题,由于STM32的FLASH烧写寿命在1万次左右,对于本人这样的改一行代码都想下载到开发板中测试的强迫症患者,真是 ...

  5. c语言模拟32u4单片机,一种基于Atmega32u4的教学型Arduino开发板的制作方法

    本实用新型涉及一种教学型Arduino开发板,具体是基于Atmega32u4芯片的教学型Arduino开发板. 背景技术: 近些年来,互联网和物联网高速发展,在推动社会生产力快速发展的同时,也对我们的 ...

  6. 基于TI AM335x创龙开发板U-Boot编译

    分享一下基于广州创龙TL335x-IDK开发板的U-Boot编译.希望能帮助上你. 板子特点如下:  基于 TI AM335x ARM Cortex-A8 CPU,主频可高达 1GHz,运算能力可高 ...

  7. PAJ7620手势传感器快速应用- -基于涂鸦CBU模组开发板

    PAJ7620手势传感器快速驱动- -基于涂鸦CBU模组开发板 正在,或是想要开发物联网小产品的你是否会觉得一些常用的控制需要繁琐地掏出手机会让你的产品体验不佳?添加实体按键又显得太 low ?不妨来 ...

  8. 《S5PV210三星原厂开发板使用说明+完整原理图》

    呵呵,本人手机的arm开发板的资料,希望对大家有帮助 以后ARM开发板的专栏里面会有我对市场上一些比较流行的开发板的一些评价和对于初学者使用开发板的一些建议,请敬请期待... <S5PV210三 ...

  9. qemu图形界面linux,QEMU 简单几步搭建一个虚拟的ARM开发板

    1.安装QEMU 先在Ubuntu中安装QEMU sudo apt-get install qemu 1 安装几个QEMU需要的软件包: sudo apt-get install zlib1g-dev ...

最新文章

  1. AAAI 2021 顶会论文开源,OCR方向最火开源项目已超1万 star!
  2. macbook可以装linux,怎样给老旧的 MacBook 安装 Linux
  3. python 调用linux命令-python3调用linux命令——Subprocess
  4. 对大学 IT 专业教育的反馈
  5. 浙江大学计算机学院1702班,测控1702:传道授业解惑 此间师者真情
  6. java await signal_【Java并发008】原理层面:ReentrantLock中 await()、signal()/signalAll()全解析...
  7. 5s突然一直信号无服务器,手机突然没信号了怎么回事?
  8. List特有迭代器--ListIterator的特殊功能
  9. 个人作业-软件产品案例分析
  10. 我遇到的JPA中事务回滚的问题
  11. lua数据结构php,Lua数据结构
  12. 《暗黑破坏神2》关于d2loader的使用说明
  13. 软件能力成熟度模型CMM
  14. OpenCV python
  15. 修复pd16虚拟机在big sur 的usb无法使用和无法联网问题!
  16. 操作系统春招面试复习之:进程管理
  17. CNN中的Inductive bias(归纳偏置)
  18. 如何修改知乎绑定的手机号(2021)
  19. 「Nginx」什么是代理
  20. 另类解决android中用三星手机拍的照片存储后旋转问题。

热门文章

  1. 基于MFC的OpenDDS发布订阅例子(PubSubDemo)
  2. 掌阅标签功能能否自定义名字?
  3. unity 两种粒子系统
  4. 常用短链接生成工具推荐
  5. flask+gunicorn部署
  6. 2021-2027全球与中国射频屏蔽窗市场现状及未来发展趋势
  7. 开发日志:浏览器宽度大于400px,td的宽度按百分比自适应,小于400px时,宽度为指定的值
  8. Unity3d vector3.forward和transform.forward的区别!
  9. Win10下系统自带的各种监测工具
  10. Linux/Mac实现下alias重命名命令永久生效