QEMU仿真aarch64处理器运⾏Linuxkernel
编译ARM64仿真器QEMU
下载qemu源码
$ wget /qemu-6.0.
解压tar包
$ tar xvf qemu-6.0.
配置qemu
$ cd qemu-6.0.
$ ./configure --prefix=~/opt/qemu --target-list="arm-softmmu aarch64-softmmu i386-softmmu x86_64-softmmu arm-linux-user aarch64-linux-user i386-linu x-user x86_64-linux-user riscv64-softmmu" --enable-sdl --enable-debug
编译qemu
$ make -j8
安装qemu
$ make install
编译Linux内核
下载Linux kernel源码
$ wget /pub/linux/kernel/v5.x/linux-5.13.
解压Linux kernel源码tar包
$ tar xvf linux-5.13.
配置Linux kernel
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- defconfig
编译Linux kernel
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image -j8
busybox安装制作根⽂件系统
基于busybox制作根⽂件系统
下载busybox源码
$ wget busybox/downloads/busybox-1.33.1.tar.bz2
解压busybox源码tar包
$ tar jxvf busybox-1.33.1.tar.bz2
配置busybox
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- menuconfig
其中如下配置项要选上
编译busybox源码
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu-
安usybox
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- install
执⾏如下脚本内容,制作基于编译的busybox的根⽂件系统
rm -rfv rootfs
mkdir rootfs
#mkdir -p rootfs/lib
#copy dynamic library for rootfs, because we compile the busybox dynamically
#cp -pvf /usr/aarch64-linux-gnu/lib/* rootfs/lib
#cp -rpvf /opt/arm64/toolchain/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/lib/* rootfs/lib cp -rfv busybox-1.33.1/_install/* rootfs/
cd rootfs
mkdir dev etc proc
cd dev
#create the communication console
sudo mknod console c 51
sudo mknod null c 13
sudo mknod tty1 c 41
sudo mknod tty2 c 42
sudo mknod tty3 c 43
sudo mknod tty4 c 44
cd../etc
echo"::sysinit:/etc/init.d/rcS"> inittab
echo"::respawn:-/bin/sh">> inittab
echo"::askfirst:-/bin/sh">> inittab
echo"::ctrlaltdel:/bin/umount -a -r ">> inittab
mkdir init.d
cd init.d
echo"#!/bin/sh"> rcS
echo"mount -t proc proc /proc">> rcS
chmod +x ./rcS
cd../..
#find . | cpio -o -H newc > rootfs.cpio
#gzip -c rootfs.cpio > ../
find.| cpio -o -H newc |gzip -c >../
基于QEMU运⾏Linux kernel
执⾏如下命令运⾏Linux kernel
qemu-system-aarch64 \
-machine virt,virtualization=true,gic-version=3\
-nographic \
-m size=1024M \
-cpu cortex-a72 \
-smp 4\
-kernel linux-5.13.8/arch/arm64/boot/Image \
-
initrd busybox-1.33.1/ \
--append "console=ttyAMA0 rdinit=/linuxrc"
执⾏结果如下
[0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083]
[0.000000] Linux version 5.13.8 (wxer@wxer-PC)(aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) 10.2.1 20201103, GNU ld (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16))2.35.1.20201028)#1 SMP PREEMPT Sat Aug 7 19:05: 03 CST 2021
[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 0x7fdf4c00-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 0x000000007cc00000
[0.000000] psci: probing for conduit method from DT.
[0.000000] psci: PSCIv0.2 detected in firmware.
[0.000000] psci: Using standard PSCI v0.2 function IDs
[0.000000] psci: Trusted OS migration not required
[0.000000] percpu: Embedded 23 pages/cpu s56920 r8192 d29096 u94208
[0.000000] Detected PIPT I-cache on CPU0
[0.000000] CPU features: detected: GIC system register CPU interface
[0.000000] CPU features: detected: Spectre-v2
[0.000000] CPU features: detected: Spectre-v3a
[0.000000] CPU features: detected: Spectre-v4
[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: ARM errata 1165522, 1319367, or 1530923
[0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 258048
[0.000000] Policy zone: DMA
[0.000000] Kernel command line: console=ttyAMA0 rdinit=/linuxrc
[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: 960556K/1048576K available (15040K kernel code, 3038K rwdata, 7972K rodata, 6080K init, 500K bss, 55252K 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] GICv3: GIC: Using split EOI/Deactivate mode
[0.000000] GICv3: 224 SPIs implemented
[0.000000] GICv3: 0 Extended SPIs implemented
[0.000000] GICv3: Distributor has no Range Selector support
[0.000000] Root IRQ handler: gic_handle_irq
[0.000000] GICv3: 16 PPIs implemented
[0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000080a0000
[0.000000] random: get_random_bytes called from start_kernel+0x33c/0x528 with crng_init=0
[0.000000] arch_timer: cp15 timer(s) running at 62.50MHz (phys).
[0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns [0.000450] sched_clock: 56 bits at 62MHz, resolution 16ns, wraps every 4398046511096ns
[0.040101] Console: colour dummy device 80x25
[0.056038] Calibrating delay loop (skipped), value calculated using timer frequency..125.00 BogoMIPS (lpj=250000) [0.056766] pid_max: default: 32768 minimum: 301
[0.064225] LSM: Security Framework initializing
[0.070758] Mount-cache hash table entries: 2048(order: 2, 16384 bytes, linear)
[0.071044] Mountpoint-cache hash table entries: 2048(order: 2, 16384 bytes, linear)
[0.282766] rcu: Hierarchical SRCU implementation.
[0.327626] EFI services will not be available.
[0.334913] smp: Bringing up secondary CPUs ...
[0.351930] Detected PIPT I-cache on CPU1
[0.355194] GICv3: CPU1: found redistributor 1 region 0:0x00000000080c0000
[0.356265] CPU1: Booted secondary processor 0x0000000001 [0x410fd083]
[0.379016] Detected PIPT I-cache on CPU2
[0.379426] GICv3: CPU2: found redistributor 2 region 0:0x00000000080e0000
[0.379955] CPU2: Booted secondary processor 0x0000000002 [0x410fd083]
[0.390380] Detected PIPT I-cache on CPU3
[0.390798] GICv3: CPU3: found redistributor 3 region 0:0x0000000008100000
[0.391325] CPU3: Booted secondary processor 0x0000000003 [0x410fd083]
[0.394859] smp: Brought up 1 node, 4 CPUs
[0.395376] SMP: Total of 4 processors activated.
[0.395649] CPU features: detected: 32-bit EL0 Support
[0.395761] CPU features: detected: 32-bit EL1 Support
[0.396216] CPU features: detected: CRC32 instructions
[0.683570] CPU: All CPU(s) started at EL2
[0.686043] alternatives: patching kernel code
[0.777761] devtmpfs: initialized
[0.852671] KASLR enabled
[0.860514] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[0.861342] futex hash table entries: 1024(order: 4, 65536 bytes, linear)
[0.891588] pinctrl core: initialized pinctrl subsystem
[0.961147] DMI not present or invalid.
[  1.011108] NET: Registered protocol family 16
[  1.090254] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[  1.094684] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[  1.097778] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[  1.099477] audit: initializing netlink subsys (disabled)
[  1.110092] audit: type=2000 audit(1.000:1): state=initialized audit_enabled=0res=1
[  1.144168] thermal_sys: Registered thermal governor 'step_wise'
[  1.144487] thermal_sys: Registered thermal governor 'power_allocator'
[  1.149150] cpuidle: using governor menu
[  1.155518] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[  1.159551] ASID allocator initialised with 32768 entries
[  1.199593] Serial: AMBA PL011 UART driver
[  1.557598]9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq =48, base_baud =0) is a PL011 rev1
[  1.603511] printk: console [ttyAMA0] enabled
[  1.881030] HugeTLB registered 1.00 GiB page size, pre-allocated 0 pages
[  1.881755] HugeTLB registered 32.0 MiB page size, pre-allocated 0 pages
[  1.882482] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[  1.883002] HugeTLB registered 64.0 KiB page size, pre-allocated 0 pages
[  1.941526] cryptd: max_cpu_qlen set to 1000
[  2.010906] ACPI: Interpreter disabled.
[  2.059036] iommu: Default domain type: Translated
[  2.065907] vgaarb: loaded
[  2.076064] SCSI subsystem initialized
[  2.090593] usbcore: registered new interface driver usbfs
[  2.093097] usbcore: registered new interface driver hub
[  2.094479] usbcore: registered new device driver usb
[  2.114261] pps_core: LinuxPPS API ver. 1 registered
[  2.114812] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[  2.115926] PTP clock support registered
[  2.120032] EDAC MC: Ver: 3.0.0
[  2.158848] FPGA manager framework
[  2.164359] Advanced Linux Sound Architecture Driver Initialized.
[  2.236227] clocksource: Switched to clocksource arch_sys_counter
[  2.252339] VFS: Disk quotas dquot_6.6.0
[  2.253868] VFS: Dquot-cache hash table entries: 512(order 0, 4096 bytes)
[  2.264071] pnp: PnP ACPI: disabled
[  2.412967] NET: Registered protocol family 2
[  2.420270] IP idents hash table entries: 16384(order: 5, 131072 bytes, linear)
[  2.449357] tcp_listen_portaddr_hash hash table entries: 512(order: 1, 8192 bytes, linear)
[  2.450495] TCP established hash table entries: 8192(order: 4, 65536 bytes, linear)
[  2.452174] TCP bind hash table entries: 8192(order: 5, 131072 bytes, linear)
[  2.453413] TCP: Hash tables configured (established 8192bind8192)
[  2.463177] UDP hash table entries: 512(order: 2, 16384 bytes, linear)
[  2.464775] UDP-Lite hash table entries: 512(order: 2, 16384 bytes, linear)
[  2.476331] NET: Registered protocol family 1
[  2.494090] RPC: Registered named UNIX socket transport module.
[  2.495148] RPC: Registered udp transport module.
[  2.495635] RPC: Registered tcp transport module.
[  2.496014] RPC: Registered tcp NFSv4.1 backchannel transport module.
[  2.496994] PCI: CLS 0 bytes, default 64
[  2.522399]
[  2.528429] hw perfevents: enabled with armv8_pmuv3 PMU driver, 5 counters available
[  2.533230] kvm [1]: IPA Size Limit: 44 bits
[  2.576787] kvm [1]: GICv3: no GICV resource entry
[  2.578298] kvm [1]: disabling GICv2 emulation
[  2.579854] kvm [1]: GIC system register CPU interface enabled
[  2.583364] kvm [1]: vgic interrupt IRQ9
[  2.628611] kvm [1]: Hyp mode initialized successfully
[  2.723999] Initialise system trusted keyrings
[  2.737268] workingset: timestamp_bits=42max_order=18bucket_order=0
[  2.879685] squashfs: version 4.0(2009/01/31) Phillip Lougher
[  2.898165] NFS: Registering the id_resolver key type
[  2.900842] Key type id_resolver registered
[  2.901427] Key type id_legacy registered
[  2.905210] nfs4filelayout_init: NFSv4 File Layout
[  2.906105] nfs4flexfilelayout_init: NFSv4 Flexfile Layout
[  2.911816] 9p: Installing v9fs 9p2000 file system support
[  2.967171] Freeing initrd memory: 1080K
[  2.972997] Key type asymmetric registered
[  2.973858] Asymmetric key parser 'x509' registered
[  2.975877] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[  2.976966] io scheduler mq-deadline registered
[  2.977710] io scheduler kyber registered
[  3.167082] pl061_gpio 9030000.pl061: PL061 GPIO chip registered
[  3.213453] pci-host-generic 4010000000.pcie: host bridge /pcie@10000000 ranges:
[  3.219095] pci-host-generic 4010000000.pcie:      IO 0x003eff0000..0x003effffff -> 0x0000000000 [  3.222607] pci-host-generic 4010000000.pcie:      MEM 0x0010000000..0x003efeffff -> 0x0010000000 [  3.223755] pci-host-generic 4010000000.pcie:      MEM 0x8000000000..0xffffffffff -> 0x8000000000 [  3.227547] pci-host-generic 4010000000.pcie: Memory resource size exceeds max for32 bits
[  3.231149] pci-host-generic 4010000000.pcie: ECAM at [mem 0x4010000000-0x401fffffff]for[bus 00-ff] [  3.240557] pci-host-generic 4010000000.pcie: PCI host bridge to bus 0000:00
[  3.242029] pci_bus 0000:00: root bus resource [bus 00-ff]
[  3.243096] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[  3.243908] pci_bus 0000:00: root bus resource [mem 0x10000000-0x3efeffff]
[  3.244507] pci_bus 0000:00: root bus resource [mem 0x8000000000-0xffffffffff]
[  3.253104] pci 0000:00:00.0: [1b36:0008]type 00 class 0x060000
[  3.277592] pci 0000:00:01.0: [1af4:1000]type 00 class 0x020000
[  3.279678] pci 0000:00:01.0: reg 0x10: [io  0x0000-0x001f]
[  3.280721] pci 0000:00:01.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[  3.281809] pci 0000:00:01.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
[  3.304458] pci 0000:00:01.0: BAR 6: assigned [mem 0x10000000-0x1003ffff pref]
[  3.306907] pci 0000:00:01.0: BAR 4: assigned [mem 0x8000000000-0x8000003fff 64bit pref]
[  3.308308] pci 0000:00:01.0: BAR 0: assigned [io  0x1000-0x101f]
[  3.352299] EINJ: ACPI disabled.
[  3.615108] virtio-pci 0000:00:01.0: enabling device (0000 -> 0003)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。