使用QEMU模拟启动uboot

这篇具有很好参考价值的文章主要介绍了使用QEMU模拟启动uboot。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

uboot的相关知识,可以参考:uboot基本概念。

一、环境配置

WSL: ubutu20.04
模拟开发板:vexpress-a9
uboot版本:u-boot-2023.10

二、安装QEMU

  • 2.1、安装
    sudo apt install qemu
    
  • 2.2、查看支持哪些开发板
    qemu-system-arm -M help
    
    结果如下:
    Supported machines are:
    akita                Sharp SL-C1000 (Akita) PDA (PXA270)
    ast2500-evb          Aspeed AST2500 EVB (ARM1176)
    ast2600-evb          Aspeed AST2600 EVB (Cortex A7)
    borzoi               Sharp SL-C3100 (Borzoi) PDA (PXA270)
    canon-a1100          Canon PowerShot A1100 IS
    cheetah              Palm Tungsten|E aka. Cheetah PDA (OMAP310)
    collie               Sharp SL-5500 (Collie) PDA (SA-1110)
    connex               Gumstix Connex (PXA255)
    cubieboard           cubietech cubieboard (Cortex-A8)
    emcraft-sf2          SmartFusion2 SOM kit from Emcraft (M2S010)
    highbank             Calxeda Highbank (ECX-1000)
    imx25-pdk            ARM i.MX25 PDK board (ARM926)
    integratorcp         ARM Integrator/CP (ARM926EJ-S)
    kzm                  ARM KZM Emulation Baseboard (ARM1136)
    lm3s6965evb          Stellaris LM3S6965EVB
    lm3s811evb           Stellaris LM3S811EVB
    mainstone            Mainstone II (PXA27x)
    mcimx6ul-evk         Freescale i.MX6UL Evaluation Kit (Cortex A7)
    mcimx7d-sabre        Freescale i.MX7 DUAL SABRE (Cortex A7)
    microbit             BBC micro:bit
    midway               Calxeda Midway (ECX-2000)
    mps2-an385           ARM MPS2 with AN385 FPGA image for Cortex-M3
    mps2-an505           ARM MPS2 with AN505 FPGA image for Cortex-M33
    mps2-an511           ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3
    mps2-an521           ARM MPS2 with AN521 FPGA image for dual Cortex-M33
    musca-a              ARM Musca-A board (dual Cortex-M33)
    musca-b1             ARM Musca-B1 board (dual Cortex-M33)
    musicpal             Marvell 88w8618 / MusicPal (ARM926EJ-S)
    n800                 Nokia N800 tablet aka. RX-34 (OMAP2420)
    n810                 Nokia N810 tablet aka. RX-44 (OMAP2420)
    netduino2            Netduino 2 Machine
    none                 empty machine
    nuri                 Samsung NURI board (Exynos4210)
    palmetto-bmc         OpenPOWER Palmetto BMC (ARM926EJ-S)
    raspi2               Raspberry Pi 2
    realview-eb          ARM RealView Emulation Baseboard (ARM926EJ-S)
    realview-eb-mpcore   ARM RealView Emulation Baseboard (ARM11MPCore)
    realview-pb-a8       ARM RealView Platform Baseboard for Cortex-A8
    realview-pbx-a9      ARM RealView Platform Baseboard Explore for Cortex-A9
    romulus-bmc          OpenPOWER Romulus BMC (ARM1176)
    sabrelite            Freescale i.MX6 Quad SABRE Lite Board (Cortex A9)
    smdkc210             Samsung SMDKC210 board (Exynos4210)
    spitz                Sharp SL-C3000 (Spitz) PDA (PXA270)
    swift-bmc            OpenPOWER Swift BMC (ARM1176)
    sx1                  Siemens SX1 (OMAP310) V2
    sx1-v1               Siemens SX1 (OMAP310) V1
    terrier              Sharp SL-C3200 (Terrier) PDA (PXA270)
    tosa                 Sharp SL-6000 (Tosa) PDA (PXA255)
    verdex               Gumstix Verdex (PXA270)
    versatileab          ARM Versatile/AB (ARM926EJ-S)
    versatilepb          ARM Versatile/PB (ARM926EJ-S)
    vexpress-a15         ARM Versatile Express for Cortex-A15
    vexpress-a9          ARM Versatile Express for Cortex-A9
    virt-2.10            QEMU 2.10 ARM Virtual Machine
    virt-2.11            QEMU 2.11 ARM Virtual Machine
    virt-2.12            QEMU 2.12 ARM Virtual Machine
    virt-2.6             QEMU 2.6 ARM Virtual Machine
    virt-2.7             QEMU 2.7 ARM Virtual Machine
    virt-2.8             QEMU 2.8 ARM Virtual Machine
    virt-2.9             QEMU 2.9 ARM Virtual Machine
    virt-3.0             QEMU 3.0 ARM Virtual Machine
    virt-3.1             QEMU 3.1 ARM Virtual Machine
    virt-4.0             QEMU 4.0 ARM Virtual Machine
    virt-4.1             QEMU 4.1 ARM Virtual Machine
    virt                 QEMU 4.2 ARM Virtual Machine (alias of virt-4.2)
    virt-4.2             QEMU 4.2 ARM Virtual Machine
    witherspoon-bmc      OpenPOWER Witherspoon BMC (ARM1176)
    xilinx-zynq-a9       Xilinx Zynq Platform Baseboard for Cortex-A9
    z2                   Zipit Z2 (PXA27x)
    

三、安装交叉编译链

sudo apt install arm-linux-gnueabi-gcc

注:此步非必须,也可自己从Arm GNU Toolchain下载,解压后添加到环境变量即可。

四、编译uboot

  • 4.1、解压
tar -vxjf u-boot-2023.10.tar.bz2
  • 4.2、编译
cd u-boot-2023.10/

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- vexpress_ca9x4_defconfig
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- -j`nproc`
  • 4.3、生成的u-boot.bin文件
    使用QEMU模拟启动uboot,uboot,uboot,qemu

五、使用qemu工具运行uboot

  • 5.1、启动uboot
qemu-system-arm -M vexpress-a9 -m 512M -kernel ./u-boot -nographic -no-reboot

运行结果如下:

U-Boot 2023.10 (Nov 02 2023 - 10:17:15 +0800)

DRAM:  512 MiB
WARNING: Caches not enabled
Core:  18 devices, 10 uclasses, devicetree: embed
Flash: 64 MiB
MMC:   mmci@5000: 0
Loading Environment from Flash... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@3,02000000
Hit any key to stop autoboot:  0
MMC Device 1 not found
no mmc device at slot 1
Card did not respond to voltage select! : -110
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
*** Warning: no boot file name; using '0A00020F.img'
Using ethernet@3,02000000 device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15
Filename '0A00020F.img'.
Load address: 0x60100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
smc911x: MAC 52:54:00:12:34:56
missing environment variable: pxefile_addr_r
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (0 ms)
Using ethernet@3,02000000 device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15
Filename 'boot.scr.uimg'.
Load address: 0x60100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (0 ms)
Using ethernet@3,02000000 device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15
Filename 'boot.scr.uimg'.
Load address: 0x60100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
smc911x: MAC 52:54:00:12:34:56
cp - memory copy

Usage:
cp [.b, .w, .l, .q] source target count
Wrong Image Format for bootm command
ERROR: can't get kernel image!
=>

说明uboot已经启动成功。

  • 5.2、在uboot中输入help,查看uboot中的支持的命令:
=>
=> help
?         - alias for 'help'
base      - print or set address offset
bdinfo    - print Board Info structure
blkcache  - block cache diagnostics and control
bootefi   - Boots an EFI payload from memory
bootelf   - Boot from an ELF image in memory
bootflow  - Boot flows
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
eficonfig - provide menu-driven UEFI variable maintenance interface
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 /)
fatmkdir  - create a directory
fatrm     - delete a file
fatsize   - determine a file's size
fatwrite  - write file into a dos filesystem
fdt       - flattened device tree utility commands
flinfo    - print FLASH memory information
fstype    - Look up a filesystem type
fstypes   - List supported filesystem types
go        - start application at address 'addr'
help      - print command description/usage
iminfo    - print header information for application image
ln        - Create a symbolic link
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)
net       - NET sub-system
nm        - memory modify (constant address)
panic     - Panic with optional message
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
To use IPv6 add -ipv6 parameter
random    - fill memory with random pattern
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  - load file via network using TFTP protocol
true      - do nothing, successfully
ubi       - ubi commands
ubifsload - load file from an UBIFS filesystem
ubifsls   - list files in a directory
ubifsmount- mount UBIFS volume
ubifsumount- unmount UBIFS volume
version   - print monitor, compiler and linker version
=>

六、使用gdb调试uboot

  • 6.1、输入如下启动命令:
qemu-system-arm -M vexpress-a9 -m 512M -kernel ./u-boot -nographic -no-reboot -S -s

其中:
-S 表示QEMU虚拟机会冻结CPU,直到远程的GDB输入相应的控制命令。
-s 表示在1234端口接收GDB调试连接。

  • 6.2、gdb调试
    重新打开一个终端,进入到u-boot文件的目录下,输入以下命令开始gdb调试:
cd u-boot-2023.10
gdb-multiarch --tui u-boot

如下:
使用QEMU模拟启动uboot,uboot,uboot,qemu

  • 6.3、开始调试
    在gdb中输入以下命令,开始调试:
(gdb) set architecture arm
(gdb) target remote localhost:1234

以上,设置架构为arm架构,通过远程端口1234连接QEMU虚拟机。如下图:
使用QEMU模拟启动uboot,uboot,uboot,qemu
上图显示,已经进入vectors.S文件中的_start程序入口。
接下来就可以单步跟踪调试了:
使用QEMU模拟启动uboot,uboot,uboot,qemu文章来源地址https://www.toymoban.com/news/detail-738978.html

到了这里,关于使用QEMU模拟启动uboot的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • QEMU源码全解析 —— PCI设备模拟(6)

    接前一篇文章: 上一回讲到了pci_edu_realize函数中的pci_register_bar函数,本回对于其进行详细解析。 再次贴出pci_register_bar函数源码,在hw/pci/pci.c中,代码如下: (1)首先根据region_num找到PCIDevice-io_regions数组中对应的项。PCI设备的MMIO存放在PCIIORegion结构体中,结构体中保存了

    2024年01月16日
    浏览(28)
  • QEMU源码全解析 —— PCI设备模拟(7)

    接前一篇文章: 上一回讲解了pci_edu_realize函数中的pci_register_bar函数,本回开始对于edu设备的MMIO读写函数进行解析。 操作系统与PCI设备交互的主要方式是PIO和MMIO。MMIO虽然是一段内存,但是其没有EPT映射,在虚拟机访问设备的MMIO时,会产生VM Exit;KVM识别此MMIO访问并且将该访

    2024年01月22日
    浏览(27)
  • 【QEMU系统分析之启动篇(二十)】

    本文以 QEMU 8.2.2 为例,分析其作为系统仿真工具的启动过程,并为读者展示各种 QEMU 系统仿真的启动配置实例。 本文读者需要具备一定的 QEMU 系统仿真使用经验,并对 C 语言编程有一定了解。 QEMU 是一个通用且开源的机器模拟器和虚拟机。 其官方主页是:https://www.qemu.org/

    2024年04月27日
    浏览(24)
  • Linux 之搭建 arm 的 qemu 模拟器

    2024年02月03日
    浏览(35)
  • Ubuntu下运行QEMU模拟riscv64跑Debian

    1.安装QEMU 下载地址: https://www.qemu.org/download/ 建议选择稳定版本,下载后解压,然后make wget https://download.qemu.org/qemu-8.0.3.tar.xz tar xjvf qemu-8.0.3.tar.xz cd qemu-8.0.3 ./configure --enable-kvm --enable-virtfs make --enable-virtfs 用户虚拟机和宿主机之间共享文件 2.安装u-boot-qemu sudo apt install u-boot-qe

    2024年02月10日
    浏览(29)
  • kvm qemu虚拟机的创建和启动

    qemu-img create -f qcow2 win1021H1.qcow2 10G sudo qemu-system-x86_64 -enable-kvm -m 8G -smp 4 -boot once=d -cdrom ./iso/cn_windows_7_enterprise_with_sp1_x64_dvd_u_677685.iso -hda ./win7_x64.qcow2 -vnc :1 -usb -usbdevice tablet 如果没有指定-hda ./win7.qcow2,则在安装系统的时候没有磁盘,如下图片是增加了之后才有的磁盘 默认不

    2024年02月12日
    浏览(41)
  • 在Ubuntu上用Qemu模拟ARM版本的Fedora39

    Fedora Quick Docs Fedora Server Documentation Deploy an ARM64 Fedora VM on your PC: 3 steps Architectures/AArch64/Install with QEMU Virtualization – Getting Started Fedora on Raspberry Pi Architectures/ARM ARM Single Board Computer (SBC) Installation Creating a virtual machine using Fedora Server Edition disk image 8 Linux virsh subcommands for managing VM

    2024年03月27日
    浏览(33)
  • qemu启动镜像提示 VNC server running on ::1:5900

    1.启动iso qemu启动镜像之后出现以下提示VNC server running on ::1:5900 2.分析 虚拟机的环境是centos7.9然后再centos7.9上虚拟出一个xen cpu的centos7.9。以上提示是由于,没有多媒体库sdl导致(通过查找资料发现) 3.解决 1. 既然缺少SDL那么安装: 默认情况下,安装安装SDL就会知道安装SDL-

    2024年03月23日
    浏览(23)
  • 在x86下运行的Ubuntu系统上部署QEMU用于模拟RISC-V硬件系统

    下载地址: 建议选择stable版本,arch选择riscv64-lp64d,libc选择常用的glibc。 下载后解压,然后将bin目录加入PATH环境变量中。 下载地址: 建议选择稳定版本,下载后解压,然后make --enable-virtfs 用户虚拟机和宿主机之间共享文件 Linux内核下载地址: 选择稳定的版本,下载完后解

    2024年02月13日
    浏览(44)
  • 使用QEMU运行虚拟机

    1,get kernel source from here 2,将当前guest os的内核配置文件 /boot/config-5.10.0 拷贝至内核源码目录并命名为.config 3,执行命令“make rpm-pkg -j10” 将内核各个组件编译为RPM包 4,生成的RPM包位于“/root/rpmbuild/RPMS/aarch64/”: kernel-headers-5.10.0-1.aarch64.rpm, kernel-devel-5.10.0-1.aarch64.rpm, kernel-5

    2024年02月05日
    浏览(33)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包