目录
- 编译
- uboot、kernel 编译
- 启动
- 从 uboot 中引导启动 linux
- 注
- 参考
本文主要说明
arm64
在
qemu
上的相关启动。
编译
使用的是 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-boot
或 u-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