qemu 之 uboot、linux 启动

news2024/11/17 11:52:59

目录

  • 编译
  • 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

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

网络原理-UDP/TCP详解

一. UDP协议 UDP协议端格式 由上图可以看出&#xff0c;一个UDP报文最大长度就是65535. • 16位长度&#xff0c;表示整个数据报&#xff08;UDP首部UDP数据&#xff09;的最大长度&#xff08;注意&#xff0c;这里的16位UDP长度只是一个标识这个数据报长度的字段&#xff0…

[Android]修改应用包名、名称、版本号、Icon以及环境判断和打包

1.修改包名 在Android Studio中更改项目的包名涉及几个步骤&#xff1a; 打开项目结构: 在Android Studio中&#xff0c;确保您处于Android视图模式&#xff08;在左侧面板顶部有一个下拉菜单可以选择&#xff09;。 重命名包名: 在项目视图中&#xff0c;找到您的包名&…

Linux如何修改主机名(hostname)(亲测可用)

文章目录 背景Linux如何修改主机名&#xff08;hostname&#xff09;方法方法1. 使用 hostnamectl 命令示例 2. 编辑 /etc/hostname 文件注意事项 背景 我创建虚拟机的时候没设置主机名&#xff0c;现在显示localhost&#xff0c;有点尴尬&#x1f605;&#xff1a; 需要重新设…

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

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

单链表按位序与指定结点 删除

按位序删除(带头结点) #define NULL 0 #include<stdlib.h>typedef struct LNode {int data;struct LNode* next; }LNode, * LinkList;//按位序删除&#xff08;带头结点&#xff09; bool ListInsert(LinkList& L, int i, int& e) {if (i < 1)return false;L…

【Java 进阶篇】JQuery DOM操作:轻松驾驭网页内容的魔法

在前端开发的舞台上&#xff0c;DOM&#xff08;文档对象模型&#xff09;是我们与网页内容互动的关键。而JQuery作为一个轻量级的JavaScript库&#xff0c;为我们提供了便捷而强大的DOM操作工具。在本篇博客中&#xff0c;我们将深入探讨JQuery的DOM内容操作&#xff0c;揭开这…

基于Matlab+ AlexNet神经网络的动物识别系统

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介 二、功能三、系统四. 总结 一项目简介 基于Matlab和AlexNet神经网络的动物识别系统可以用于自然图像识别等场景&#xff0c;以下是一个基本的介绍设计步骤…

ARM64 linux并发与同步之内存屏障

1.2 内存屏障 1.2.1 概念理解 原理部分比较苦涩难懂&#xff0c;我们先不过多详细介绍这部分的由来和经过&#xff0c;接下来着重讲解什么用途和实现&#xff1b; ARM64架构中提供了3条内存屏障指令。 数据存储屏障(Data Memory Barrier, DMB)指令。数据同步屏障(Data Synch…

Thinkphp8 - 连接多个数据库

// 数据库连接配置信息connections > [mysql > [// 数据库类型type > mysql,// 服务器地址hostname > 127.0.0.1,// 数据库名database > thinkphp,// 用户名username > env(DB_USER, root),// 密码password >…

Yolo自制detect训练

Install 把代码拉下来 GitHub - ultralytics/yolov5 at v5.0 然后 pip install -r requirements.txt 安装完了,运行一下detect.py即可 结果会保存在对应的目录下 Intro ├── data:主要是存放一些超参数的配置文件(这些文件(yaml文件)是用来配置训练集和测试集还有验…

clouldcompare工具使用

文章目录 1.界面1.1 布局1.3 视觉显示方向1.4 放大镜1.5 建立旋转中心2.快速入门2.1 剪裁2.2 多点云拼接 1.界面 1.1 布局 参考&#xff1a;https://blog.csdn.net/lovely_yoshino/article/details/129595201 1.3 视觉显示方向 1.4 放大镜 1.5 建立旋转中心 2.快速入门 2.1 …

腾讯域名优惠卷领取

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

UE地形系统材质混合实现和Shader生成分析(UE5 5.2)

前言 随着电脑和手机硬件性能越来越高&#xff0c;游戏越来越追求大世界&#xff0c;而大世界非常核心的一环是地形系统&#xff0c;地形系统两大构成因素&#xff1a;高度和多材质混合&#xff0c;此篇文章介绍下UE4/UE5 地形的材质混合方案----基于WeightMap混合。 材质层 …

每日一题(LeetCode)----数组--长度最小的子数组

每日一题(LeetCode)----数组–长度最小的子数组 1.题目&#xff08; 209.长度最小的子数组&#xff09; 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 连续子数组 [numsl, numsl1, ..., numsr-1, numsr] &…

敏捷开发是什么?敏捷开发流程是怎么样的?

1. 什么是敏捷开发&#xff1f; 敏捷开发是一种迭代、增量式的软件开发方法&#xff0c;旨在通过灵活、协作和快速响应变化的方式&#xff0c;提高开发团队的效率和产品的质量。相较于传统的瀑布式开发模型&#xff0c;敏捷开发更加注重用户需求的响应和团队协作&#xff0…

elastic-job 完结篇

一 elastic-job 1.1 案例场景分析 1.设置4个分片&#xff0c;10秒执行一次。 分片弹性扩容缩容机制测试&#xff1a; 测试1&#xff1a;测试窗口1不关闭&#xff0c;再次运行main方法查看控制台日志&#xff0c;注意修改application.properties中的 server.port&#xf…

7.运算符

目录 一.算数运算符 1、算术运算符 2、比较运算符 1、等号()用来判断数字、字符串和表达式是否相等。 2、安全等于运算符(<>) 3、不等于运算符(<>或者!) 4、小于或等于运算符(<) 5、小于运算符(<) 6、IS NULL(IS NULL)&#xff0c;IS NOT NULL 运算…

删除杀软回调 bypass EDR 研究

01 — 杀软或EDR内核回调简介 Windows x64 系统中&#xff0c;由于 PatchGuard 的限制&#xff0c;杀软或EDR正常情况下&#xff0c;几乎不能通过 hook 的方式&#xff0c;完成其对恶意软件的监控和查杀。那怎么办呢&#xff1f;别急&#xff0c;微软为我们提供了其他的方法&a…

2352 智能社区医院管理系统JSP【程序源码+文档+调试运行】

摘要 本文介绍了一个智能社区医院管理系统的设计和实现。该系统包括管理员、护工和医生三种用户&#xff0c;具有社区资料管理、药品管理、挂号管理和系统管理等功能。通过数据库设计和界面设计&#xff0c;实现了用户友好的操作体验和数据管理。经过测试和优化&#xff0c;系…

CentOS7、CentOS8 如何修改ip信息(修改网络信息)(无图形界面)(亲测可用)

文章目录 CentOS 7方法一&#xff1a;使用 nmcli 命令方法二&#xff1a;编辑配置文件&#xff08;我的CentOS7是使用这种方法&#xff0c;亲测可用&#xff09; CentOS 8方法一&#xff1a;使用 nmcli 命令方法二&#xff1a;编辑配置文件 在 CentOS 系统中&#xff0c;如果你…