qemu 之 uboot、linux 启动

目录

  • 编译
  • uboot、kernel 编译
  • 启动
  • 从 uboot 中引导启动 linux
  • 参考

本文主要说明 arm64qemu 上的相关启动。

编译

使用的是 qemu-8.1.1 版本,编译命令如下:

../configure --cc=/usr/local/bin/gcc --prefix=/home/XXX/qemu_out --enable-virtfs --enable-slirp --target-list=aarch64-softmmu

--target-list 可选如下

  --target-list=LIST       set target list (default: build all)
                           Available targets: aarch64-softmmu alpha-softmmu 
                           arm-softmmu avr-softmmu cris-softmmu hppa-softmmu 
                           i386-softmmu loongarch64-softmmu m68k-softmmu 
                           microblaze-softmmu microblazeel-softmmu mips-softmmu 
                           mips64-softmmu mips64el-softmmu mipsel-softmmu 
                           nios2-softmmu or1k-softmmu ppc-softmmu ppc64-softmmu 
                           riscv32-softmmu riscv64-softmmu rx-softmmu 
                           s390x-softmmu sh4-softmmu sh4eb-softmmu 
                           sparc-softmmu sparc64-softmmu tricore-softmmu 
                           x86_64-softmmu xtensa-softmmu xtensaeb-softmmu 
                           aarch64-linux-user aarch64_be-linux-user 
                           alpha-linux-user arm-linux-user armeb-linux-user 
                           cris-linux-user hexagon-linux-user hppa-linux-user 
                           i386-linux-user loongarch64-linux-user 
                           m68k-linux-user microblaze-linux-user 
                           microblazeel-linux-user mips-linux-user 
                           mips64-linux-user mips64el-linux-user 
                           mipsel-linux-user mipsn32-linux-user 
                           mipsn32el-linux-user nios2-linux-user 
                           or1k-linux-user ppc-linux-user ppc64-linux-user 
                           ppc64le-linux-user riscv32-linux-user 
                           riscv64-linux-user s390x-linux-user sh4-linux-user 
                           sh4eb-linux-user sparc-linux-user 
                           sparc32plus-linux-user sparc64-linux-user 
                           x86_64-linux-user xtensa-linux-user 
                           xtensaeb-linux-user

uboot、kernel 编译

  • uboot 编译,需要使用 qemu_arm64_defconfig,使用其他真实板子的可能会起不来
make CROSS_COMPILE=aarch64-linux-gnu- qemu_arm64_defconfig
make  CROSS_COMPILE=aarch64-linux-gnu- -j4

编译后可以使用 u-bootu-boot.bin 文件

  • linux 编译使用命令,使用默认的 defconfig
make ARCH=arm64  CROSS_COMPILE=aarch64-linux-gnu- defconfig
make ARCH=arm64  CROSS_COMPILE=aarch64-linux-gnu- menuconfig
make ARCH=arm64  CROSS_COMPILE=aarch64-linux-gnu- -j4

启动

运行前,可先搭建一个网桥,并设置ip,用于网络连接:

sudo brctl addbr br0
sudo ifconfig br0 192.168.2.46

qemu-ifup 文件内容:

#!/bin/sh

echo sudo tunctl -u $(id -un) -t $1
sudo tunctl -u $(id -un) -t $1
echo sudo ifconfig $1 0.0.0.0 promisc up
sudo ifconfig $1 0.0.0.0 promisc up
echo sudo brctl addif br0 $1
sudo brctl addif br0 $1
echo brctl showbrctl show

qemu-ifdown 文件内容:

#!/bin/sh

echo sudo brctl delif br0 $1
sudo brctl delif br0 $1
echo sudo tunctl -d $1
sudo tunctl -d $1
echo brctl show
sudo brctl show

  • uboot 启动使用命令:
sudo ./qemu-system-aarch64 \
	-machine virt -cpu cortex-a76 -m size=1G \
	-kernel  ./qemu_test/u-boot \
	-nographic \
	-nic tap,script=./qemu_test/qemu-ifup,downscript=./qemu_test/qemu-ifdown

配置 setenv ipaddr 192.168.2.48 后,网络即可使用。
在这里插入图片描述
这里uboot 需要运行出现 BOOTP broadcast 1 后,才会有网络设备,启动时没有,这个没具体深究。应该是前面没添加网络设备,后面初始化了。

  • linux 启动使用命令:
sudo ./qemu-system-aarch64 \
    -machine virt \
	-nographic \
	-m size=1024M \
	-cpu cortex-a76 \
	-smp 4 \
	-kernel ./qemu_test/Image \
	-initrd ./qemu_test/uramdisk.image.gz \
	--append "root=/dev/ram0 rw init=/linuxrc console=ttyAMA0,115200" \
	-nic tap,script=./qemu_test/qemu-ifup \
	-hdb ./qemu_test/sd.ext4

qemu 的串口使用的是 ttyAMA0,配置后可直接打印,要使用 root=/dev/ram0 的方式,需要再内核添加几个配置,打开 CONFIG_BLK_DEV_RAM ,不然启动后会报错。

CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=2
CONFIG_BLK_DEV_RAM_SIZE=65536

上面命令中, -hda/-hdb 是使用文件作为硬盘镜像
sd.ext4 是加载一个 vda 的 image,会在系统中生产一个 /dev/vda 的设备

在这里插入图片描述

以下命令生成一个硬盘镜像为 ext4 格式:

dd if=/dev/zero of=sd.ext4 bs=1024 count=65536
sudo mke2fs -t ext4 -F sd.ext4 -L "sd.ext4" -b 1024 -m 0 -I 256

以下为进入 linux 后的打印

$ sudo ./qemu-system-aarch64     -machine virt -nographic -m size=1024M -cpu cortex-a76 -smp 4 -kernel ./qemu_test/Image -initrd ./qemu_test/uramdisk.image.gz --append "root=/dev/ram0 rw init=/linuxrc console=ttyAMA0,115200" -nic tap,script=./qemu_test/qemu-ifup -hdb ./qemu_test/sd.ext4 
WARNING: Image format was not specified for 'xxxxx/sd.ext4' 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.
sudo tunctl -u root -t tap0
TUNSETIFF: Device or resource busy
sudo ifconfig tap0 0.0.0.0 promisc up
sudo brctl addif br0 tap0
brctl showbrctl show
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x414fd0b1]
[    0.000000] Linux version 5.10.191-179793-g991fea0035ae (xx@Debian) (aarch64-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0, GNU ld (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 2.32.0.20190321) #14 SMP PREEMPT Fri Oct 20 15:50:33 CST 2023
[    0.000000] random: crng init done
[    0.000000] Machine model: linux,dummy-virt
[    0.000000] efi: UEFI not found.
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x7fdf4b00-0x7fdf6fff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000007fffffff]
[    0.000000] cma: Reserved 32 MiB at 0x000000007c000000
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] percpu: Embedded 23 pages/cpu s56664 r8192 d29352 u94208
[    0.000000] Detected PIPT I-cache on CPU0
[    0.000000] CPU features: kernel page table isolation forced ON by KASLR
[    0.000000] CPU features: detected: Kernel page table isolation (KPTI)
[    0.000000] CPU features: detected: Hardware dirty bit management
[    0.000000] CPU features: detected: Spectre-v4
[    0.000000] CPU features: detected: Spectre-BHB
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 258048
[    0.000000] Policy zone: DMA
[    0.000000] Kernel command line: root=/dev/ram0 rw init=/linuxrc console=ttyAMA0,115200
[    0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 959592K/1048576K available (14272K kernel code, 2808K rwdata, 7652K rodata, 5952K init, 514K bss, 56216K reserved, 32768K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu: 	RCU event tracing is enabled.
[    0.000000] rcu: 	RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=4.
[    0.000000] 	Trampoline variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv2m: range[mem 0x08020000-0x08020fff], SPI[80:143]
[    0.000000] arch_timer: cp15 timer(s) running at 62.50MHz (virt).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns
[    0.000117] sched_clock: 56 bits at 62MHz, resolution 16ns, wraps every 4398046511096ns
[    0.005552] Console: colour dummy device 80x25
[    0.007038] Calibrating delay loop (skipped), value calculated using timer frequency.. 125.00 BogoMIPS (lpj=250000)
[    0.007137] pid_max: default: 32768 minimum: 301
[    0.007813] LSM: Security Framework initializing
[    0.008568] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.008597] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.028389] /cpus/cpu-map: empty cluster
[    0.033608] rcu: Hierarchical SRCU implementation.
[    0.036353] EFI services will not be available.
[    0.037171] smp: Bringing up secondary CPUs ...
[    0.039141] Detected PIPT I-cache on CPU1
[    0.039798] CPU1: Booted secondary processor 0x0000000001 [0x414fd0b1]
[    0.042908] Detected PIPT I-cache on CPU2
[    0.043011] CPU2: Booted secondary processor 0x0000000002 [0x414fd0b1]
[    0.043968] Detected PIPT I-cache on CPU3
[    0.044150] CPU3: Booted secondary processor 0x0000000003 [0x414fd0b1]
[    0.044501] smp: Brought up 1 node, 4 CPUs
[    0.044540] SMP: Total of 4 processors activated.
[    0.044566] CPU features: detected: Privileged Access Never
[    0.044573] CPU features: detected: LSE atomic instructions
[    0.044578] CPU features: detected: User Access Override
[    0.044612] CPU features: detected: 32-bit EL0 Support
[    0.044632] CPU features: detected: Common not Private translations
[    0.044637] CPU features: detected: RAS Extension Support
[    0.044651] CPU features: detected: Data cache clean to the PoU not required for I/D coherence
[    0.044664] CPU features: detected: CRC32 instructions
[    0.044669] CPU features: detected: Speculative Store Bypassing Safe (SSBS)
[    0.312924] CPU: All CPU(s) started at EL1
[    0.323069] alternatives: patching kernel code
[    0.360408] devtmpfs: initialized
[    0.374577] KASLR enabled
[    0.376195] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.376558] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.380334] pinctrl core: initialized pinctrl subsystem
[    0.388973] DMI not present or invalid.
[    0.394993] NET: Registered protocol family 16
[    0.407147] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.407417] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    0.407580] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.407761] audit: initializing netlink subsys (disabled)
[    0.409582] audit: type=2000 audit(0.244:1): state=initialized audit_enabled=0 res=1
[    0.412381] thermal_sys: Registered thermal governor 'step_wise'
[    0.412431] thermal_sys: Registered thermal governor 'power_allocator'
[    0.413393] cpuidle: using governor menu
[    0.414265] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[    0.415432] ASID allocator initialised with 32768 entries
[    0.418028] Serial: AMBA PL011 UART driver
[    0.446808] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 47, base_baud = 0) is a PL011 rev1
[    0.472591] printk: console [ttyAMA0] enabled
[    0.502877] HugeTLB registered 1.00 GiB page size, pre-allocated 0 pages
[    0.504599] HugeTLB registered 32.0 MiB page size, pre-allocated 0 pages
[    0.504756] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    0.504867] HugeTLB registered 64.0 KiB page size, pre-allocated 0 pages
[    0.517397] cryptd: max_cpu_qlen set to 1000
[    0.527777] ACPI: Interpreter disabled.
[    0.530844] iommu: Default domain type: Translated 
[    0.531731] vgaarb: loaded
[    0.532894] SCSI subsystem initialized
[    0.534925] usbcore: registered new interface driver usbfs
[    0.535225] usbcore: registered new interface driver hub
[    0.536509] usbcore: registered new device driver usb
[    0.537506] pps_core: LinuxPPS API ver. 1 registered
[    0.537680] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.537935] PTP clock support registered
[    0.538401] EDAC MC: Ver: 3.0.0
[    0.545081] FPGA manager framework
[    0.545758] Advanced Linux Sound Architecture Driver Initialized.
[    0.574672] clocksource: Switched to clocksource arch_sys_counter
[    0.576069] VFS: Disk quotas dquot_6.6.0
[    0.576416] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.577790] pnp: PnP ACPI: disabled
[    0.605497] NET: Registered protocol family 2
[    0.606605] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.611132] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear)
[    0.611390] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.611599] TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear)
[    0.611839] TCP: Hash tables configured (established 8192 bind 8192)
[    0.612755] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.613202] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.615045] NET: Registered protocol family 1
[    0.618759] RPC: Registered named UNIX socket transport module.
[    0.618971] RPC: Registered udp transport module.
[    0.619098] RPC: Registered tcp transport module.
[    0.619236] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.619459] PCI: CLS 0 bytes, default 64
[    0.622088] Trying to unpack rootfs image as initramfs...
[    0.626104] rootfs image is not initramfs (no cpio magic); looks like an initrd
[    0.643230] Freeing initrd memory: 3444K
[    0.652017] hw perfevents: enabled with armv8_pmuv3 PMU driver, 7 counters available
[    0.652537] kvm [1]: HYP mode not available
[    0.671261] Initialise system trusted keyrings
[    0.672625] workingset: timestamp_bits=42 max_order=18 bucket_order=0
[    0.680116] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.681880] NFS: Registering the id_resolver key type
[    0.682397] Key type id_resolver registered
[    0.682482] Key type id_legacy registered
[    0.683153] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.683319] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.684046] 9p: Installing v9fs 9p2000 file system support
[    0.698207] Key type asymmetric registered
[    0.698446] Asymmetric key parser 'x509' registered
[    0.698751] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[    0.699176] io scheduler mq-deadline registered
[    0.699361] io scheduler kyber registered
[    0.712000] pl061_gpio 9030000.pl061: PL061 GPIO chip registered
[    0.715376] pci-host-generic 4010000000.pcie: host bridge /pcie@10000000 ranges:
[    0.716352] pci-host-generic 4010000000.pcie:       IO 0x003eff0000..0x003effffff -> 0x0000000000
[    0.716978] pci-host-generic 4010000000.pcie:      MEM 0x0010000000..0x003efeffff -> 0x0010000000
[    0.717187] pci-host-generic 4010000000.pcie:      MEM 0x8000000000..0xffffffffff -> 0x8000000000
[    0.718132] pci-host-generic 4010000000.pcie: ECAM at [mem 0x4010000000-0x401fffffff] for [bus 00-ff]
[    0.719058] pci-host-generic 4010000000.pcie: PCI host bridge to bus 0000:00
[    0.719415] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.719625] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.719765] pci_bus 0000:00: root bus resource [mem 0x10000000-0x3efeffff]
[    0.719971] pci_bus 0000:00: root bus resource [mem 0x8000000000-0xffffffffff]
[    0.721058] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.723550] pci 0000:00:01.0: [1af4:1000] type 00 class 0x020000
[    0.723829] pci 0000:00:01.0: reg 0x10: [io  0x0000-0x001f]
[    0.724077] pci 0000:00:01.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[    0.724255] pci 0000:00:01.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
[    0.724644] pci 0000:00:02.0: [1af4:1001] type 00 class 0x010000
[    0.724778] pci 0000:00:02.0: reg 0x10: [io  0x0000-0x007f]
[    0.724898] pci 0000:00:02.0: reg 0x14: [mem 0x00000000-0x00000fff]
[    0.725120] pci 0000:00:02.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[    0.727038] pci 0000:00:01.0: BAR 6: assigned [mem 0x10000000-0x1003ffff pref]
[    0.727395] pci 0000:00:01.0: BAR 4: assigned [mem 0x8000000000-0x8000003fff 64bit pref]
[    0.727886] pci 0000:00:02.0: BAR 4: assigned [mem 0x8000004000-0x8000007fff 64bit pref]
[    0.728167] pci 0000:00:02.0: BAR 1: assigned [mem 0x10040000-0x10040fff]
[    0.728335] pci 0000:00:02.0: BAR 0: assigned [io  0x1000-0x107f]
[    0.728778] pci 0000:00:01.0: BAR 0: assigned [io  0x1080-0x109f]
[    0.732814] EINJ: ACPI disabled.
[    0.745831] virtio-pci 0000:00:01.0: enabling device (0000 -> 0003)
[    0.748370] virtio-pci 0000:00:02.0: enabling device (0000 -> 0003)
[    0.759932] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.763648] SuperH (H)SCI(F) driver initialized
[    0.764478] msm_serial: driver initialized
[    0.766846] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.779374] brd: module loaded
[    0.792193] loop: module loaded
[    0.806320] virtio_blk virtio1: [vda] 131072 512-byte logical blocks (67.1 MB/64.0 MiB)
[    0.809516] vda: detected capacity change from 0 to 67108864
[    0.820855] megasas: 07.714.04.00-rc1
[    0.826630] physmap-flash 0.flash: physmap platform flash device: [mem 0x00000000-0x03ffffff]
[    0.831215] 0.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
[    0.836564] Intel/Sharp Extended Query Table at 0x0031
[    0.839556] Using buffer write method
[    0.841466] physmap-flash 0.flash: physmap platform flash device: [mem 0x04000000-0x07ffffff]
[    0.845666] 0.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
[    0.849335] Intel/Sharp Extended Query Table at 0x0031
[    0.850796] Using buffer write method
[    0.851077] Concatenating MTD devices:
[    0.851173] (0): "0.flash"
[    0.851255] (1): "0.flash"
[    0.851311] into device "0.flash"
[    0.882157] tun: Universal TUN/TAP device driver, 1.6
[    0.894494] thunder_xcv, ver 1.0
[    0.894678] thunder_bgx, ver 1.0
[    0.894843] nicpf, ver 1.0
[    0.896562] hclge is initializing
[    0.896866] hns3: Hisilicon Ethernet Network Driver for Hip08 Family - version
[    0.897039] hns3: Copyright (c) 2017 Huawei Corporation.
[    0.897441] e1000: Intel(R) PRO/1000 Network Driver
[    0.898260] e1000: Copyright (c) 1999-2006 Intel Corporation.
[    0.898499] e1000e: Intel(R) PRO/1000 Network Driver
[    0.898580] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.898792] igb: Intel(R) Gigabit Ethernet Network Driver
[    0.898926] igb: Copyright (c) 2007-2014 Intel Corporation.
[    0.899109] igbvf: Intel(R) Gigabit Virtual Function Network Driver
[    0.899252] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[    0.899852] sky2: driver version 1.30
[    0.901519] VFIO - User Level meta-driver version: 0.3
[    0.911140] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.911425] ehci-pci: EHCI PCI platform driver
[    0.911703] ehci-platform: EHCI generic platform driver
[    0.912001] ehci-orion: EHCI orion driver
[    0.912240] ehci-exynos: EHCI Exynos driver
[    0.912492] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.912867] ohci-pci: OHCI PCI platform driver
[    0.913113] ohci-platform: OHCI generic platform driver
[    0.913394] ohci-exynos: OHCI Exynos driver
[    0.914692] usbcore: registered new interface driver usb-storage
[    0.923684] rtc-pl031 9010000.pl031: registered as rtc0
[    0.924952] rtc-pl031 9010000.pl031: setting system clock to 2023-10-24T11:37:04 UTC (1698147424)
[    0.926031] i2c /dev entries driver
[    0.933046] sdhci: Secure Digital Host Controller Interface driver
[    0.933244] sdhci: Copyright(c) Pierre Ossman
[    0.933893] Synopsys Designware Multimedia Card Interface Driver
[    0.935046] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.940663] ledtrig-cpu: registered to indicate activity on CPUs
[    0.942774] usbcore: registered new interface driver usbhid
[    0.942894] usbhid: USB HID core driver
[    0.949688] NET: Registered protocol family 17
[    0.950992] 9pnet: Installing 9P2000 support
[    0.951712] Key type dns_resolver registered
[    0.952975] registered taskstats version 1
[    0.953096] Loading compiled-in X.509 certificates
[    0.960069] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    0.964485] ALSA device list:
[    0.964642]   No soundcards found.
[    0.966645] uart-pl011 9000000.pl011: no DMA platform data
[    0.969213] RAMDISK: gzip image found at block 0
[    1.481594] EXT4-fs (ram0): mounted filesystem with ordered data mode. Opts: (null)
[    1.482353] VFS: Mounted root (ext4 filesystem) on device 1:0.
[    1.484921] devtmpfs: mounted
[    1.584812] Freeing unused kernel memory: 5952K
[    1.586579] Run /linuxrc as init process
Starting rcS...
++ Mounting filesystem
++ Setting up eth0
++ Setting up mdev
/etc/init.d/rcS: line 17: can't create /proc/sys/kernel/hotplug: nonexistent directory
++ Starting telnet daemon
++ Starting ftp daemon
rcS Complete
root@root:/# 

从 uboot 中引导启动 linux

这里需要用到设备树,可在 linux 启动命令 -machine 中添加:

-machine virt,dumpdtb=./qemu_test/qemu_arm64.dtb

以下为命令:(删除 -hdb 项

 sudo ./qemu-system-aarch64 \
    -machine virt,dumpdtb=./qemu_test/qemu_arm64.dtb \
	-nographic \
	-m size=1024M \
	-cpu cortex-a76 \
	-smp 4 \
	-kernel ./qemu_test/Image \
	-initrd ./qemu_test/uramdisk.image.gz \
	--append "root=/dev/ram0 rw init=/linuxrc console=ttyAMA0,115200" \
	-nic tap,script=./qemu_test/qemu-ifup

这里需要注意下, uboot 启动的 DRAM 大小(-m 参数)需要与 linux 中的一致,不然起不来

而后在 uboot 中,就可使用 tftpboot 加载所需要的文件

setenv ipaddr 192.168.2.48 && setenv serverip 192.168.2.46&&tftpboot ${kernel_addr_r} Image1&&tftpboot ${ramdisk_addr_r} uramdisk.image.gz&&tftpboot ${fdt_addr} qemu_arm64.dtb&&setenv bootargs "root=/dev/ram0 rw  init=/linuxrc  console=ttyAMA0,115200"&&booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr}

在这里插入图片描述
在这里插入图片描述

要进入文件系统,需要修改 inittab 文件里的串口,否则无法输入命令

ttyAMA0::respawn:-/bin/ash

这里定义的 ttyAMA0 串口能直接进入系统,不用输入密码,暂不明白原因

参考

https://blog.51cto.com/u_15072780/3818667
https://hlyani.github.io/notes/openstack/qemu_make.html
https://www.zhaixue.cc/qemu/qemu-u-boot.html
https://zhuanlan.zhihu.com/p/547338158

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/137031.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Three.js——基于原生WebGL封装运行的三维引擎

文章目录 前言一、什么是WebGL&#xff1f;二、Three.js 特性 前言 Three.js中文官网 Three.js是基于原生WebGL封装运行的三维引擎&#xff0c;在所有WebGL引擎中&#xff0c;Three.js是国内文资料最多、使用最广泛的三维引擎。既然Threejs是一款WebGL三维引擎&#xff0c;那么…

RAG相关内容介绍

本文记录在查找RAG相关内容时所整合的一些资料与内容&#xff0c;还有一个组会报告的PPT 文章目录 定义LLM的知识更新难题 RAG是什么&#xff1f;-“开卷考试”RAG原理与技术RAG技术细节一、数据索引• 数据提取• 分块&#xff08;Chunking&#xff09;分块方式确定应用程序的…

摊牌 了,我不藏了,上线了一年多的网站还是广而告之吧!

大家好&#xff0c;我是大明哥&#xff0c;一个专注「死磕 Java」系列文章创作的程序员。 本文已收录到我的小站&#xff1a;https://skjava.com。 从去年开始一直有小伙伴问我&#xff0c;大明哥&#xff0c;你的网站怎么打不开了&#xff1f;我只能苦涩地跟他说&#xff0c;没…

DevChat智能编程助手:小白也能轻松上手的开发利器

DevChat智能编程助手&#xff1a;小白也能轻松上手的开发利器 一、DevChat介绍1.1 DevChat简介1.2 DevChat特点1.3 DevChat官网 二、注册DevChat账号2.1 访问DevChat官网2.2 注册账号2.3 复制Access Key2.4 登录DevChat 三、安装DevChat3.1 打开VS Code软件3.2 安装DevChat3.3 …

(免费领源码)java#ssm#mysql在线学习平台85204-计算机毕业设计项目选题推荐

摘 要 随着科学技术的飞速发展&#xff0c;社会的方方面面、各行各业都在努力与现代的先进技术接轨&#xff0c;通过科技手段来提高自身的优势&#xff0c;在线学习平台当然也不能排除在外。在线学习平台是以实际运用为开发背景&#xff0c;运用软件工程原理和开发方法&#x…

Linux下C++调用python脚本实现LDAP协议通过TNLM认证连接到AD服务器

1.前言 首先要实现这个功能&#xff0c;必须先搞懂如何通过C调用python脚本文件最为关键&#xff0c;因为两者的环境不同。本质上是在 c 中启动了一个 python 解释器&#xff0c;由解释器对 python 相关的代码进行执行&#xff0c;执行完毕后释放资源。 2 模块功能 2.1python…

基于樽海鞘群算法优化概率神经网络PNN的分类预测 - 附代码

基于樽海鞘群算法优化概率神经网络PNN的分类预测 - 附代码 文章目录 基于樽海鞘群算法优化概率神经网络PNN的分类预测 - 附代码1.PNN网络概述2.变压器故障诊街系统相关背景2.1 模型建立 3.基于樽海鞘群优化的PNN网络5.测试结果6.参考文献7.Matlab代码 摘要&#xff1a;针对PNN神…

CnosDB 在最近新发布的 2.4.0 版本中增加对时空函数的支持。

CnosDB 在最近新发布的 2.4.0 版本中增加对时空函数的支持。 概述 时空函数是一种用于描述时空结构和演化的函数。它在物理学、数学和计算机科学等领域中都有广泛的应用。时空函数可以描述物体在时空中的位置、速度、加速度以及其他相关属性。 用法 CnosDB 将使用一种全新的…

基于蜉蝣算法优化概率神经网络PNN的分类预测 - 附代码

基于蜉蝣算法优化概率神经网络PNN的分类预测 - 附代码 文章目录 基于蜉蝣算法优化概率神经网络PNN的分类预测 - 附代码1.PNN网络概述2.变压器故障诊街系统相关背景2.1 模型建立 3.基于蜉蝣优化的PNN网络5.测试结果6.参考文献7.Matlab代码 摘要&#xff1a;针对PNN神经网络的光滑…

腾讯域名优惠卷领取

腾讯域名到到期了&#xff0c;听说申请此计划&#xff0c;可获得优惠卷&#xff0c;看到网上5年域名只需要10元&#xff0c;姑且试试看。 我的博客即将同步至腾讯云开发者社区&#xff0c;邀请大家一同入驻&#xff1a;https://cloud.tencent.com/developer/support-plan?in…

Vue3+NodeJS 接入文心一言, 发布一个 VSCode 大模型问答插件

目录 一&#xff1a;首先明确插件开发方式 二&#xff1a;新建一个Vscode 插件项目 1. 官网教程地址 2. 一步一步来创建 3. 分析目录结构以及运行插件 三&#xff1a;新建一个Vue3 项目&#xff0c;在侧边栏中展示&#xff0c;实现vscode插件 <> vue项目 双向消息传…

模型部署:量化中的Post-Training-Quantization(PTQ)和Quantization-Aware-Training(QAT)

模型部署&#xff1a;量化中的Post-Training-Quantization&#xff08;PTQ&#xff09;和Quantization-Aware-Training&#xff08;QAT&#xff09; 前言量化Post-Training-Quantization&#xff08;PTQ&#xff09;Quantization-Aware-Training&#xff08;QAT&#xff09; 参…

Python---字符串 lstrip()--删除字符串两边的空白字符、rstrip()--删除字符串左边的空白字符、strip()--删除字符串右边的空白字符

strip() 方法主要作用&#xff1a;删除字符串两边的空白字符&#xff08;如空格&#xff09; lstrip() 方法 left strip&#xff0c;作用&#xff1a;只删除字符串左边的空白字符 left 英 /left/ 左 rstrip() 方法 right strip&#xff0c;作用&#xff1a;只删除字符…

阿里云严重故障,影响阿里系、淘宝、饿了么、语雀等都崩了...

作者&#xff1a;JavaPub 编程学习一条龙&#xff1a;http://luxian.javapub.net.cn 就在一年一度的双十一剁手节火热进行时&#xff0c;阿里云服务出现了严重故障。 关键是前不久刚发生了语雀事件&#xff0c;不了解的朋友阅读这里 阿里语雀突发P0级事故&#xff0c;一度崩溃…

Vector - CANoe - Vector Hardware Manager基础介绍

经常使用CANoe的人都知道&#xff0c;我们之前使用配置VN系列硬件通道的时候使用的是Vector Hardware Config&#xff0c;非常的方便&#xff0c;不过在Vector Driver Setup驱动版本大于22.14后&#xff0c;为了更好的适用车载以太网相关的配置&#xff0c;以及各个配置之间继承…

【Qt之Model/View】编程

Model/View编程介绍 Qt包含一组使用模型/视图架构来管理数据和用户呈现的关系的视图类。此架构引入的功能分离使开发人员可以更灵活地自定义项的呈现方式&#xff0c;并提供标准的模型接口&#xff0c;以允许各种数据源与现有项视图一起使用。在本文档中&#xff0c;我们简要介…

Leetcode—20.有效的括号【简单】

2023每日刷题&#xff08;二十七&#xff09; Leetcode—20.有效的括号 C实现代码 class Solution { public:bool isValid(string s) {stack<char> arr;int len s.size();if(len 1) {return false;}for(int i 0; i < len; i) {if(s[i] ( || s[i] [ || s[i] {)…

HDMI之编码篇

概述 HDMI 2.0b(含)以下版本,采用3个Channel方式输出。传输又分为3三种周期,视频数据,数据岛以及控制周期。视频传输采用8/10编码。数据岛采用4/10编码(TERC4)。控制周期采用2/10。编码都拓展成了10bits。 上图中,Pixel component(e.g.B)->D[7:0]表示视频数据周期…

深入了解JVM和垃圾回收算法

1.什么是JVM&#xff1f; JVM是Java虚拟机&#xff08;Java Virtual Machine&#xff09;的缩写&#xff0c;是Java程序运行的核心组件。JVM是一个虚拟的计算机&#xff0c;它提供了一个独立的运行环境&#xff0c;可以在不同的操作系统上运行Java程序。 2.如何判断可回收垃圾…

Git Commit 之道:规范化 Commit Message 写作指南

1 commit message 规范 commit message格式都包括三部分&#xff1a;Header&#xff0c;Body和Footer <type>(<scope>): <subject><body><footer>Header是必需的&#xff0c;Body和Footer则可以省略 1.1 Header Type&#xff08;必需&#xf…