基于aarch64分析kernel源码 一:环境搭建

news2024/11/17 9:55:25

一、测试环境

功能工具
操作系统ubuntu 22.04
编译工具gcc-12-aarch64-linux-gnu
调试工具gdb-multiarch
模拟器qemu 6.2.0
busyboxbusybox-1.36.1
kernellinux-6.4.1
编辑器vscode

二、编译器

1、查找ubuntu仓库中aarch64编译器

lq@lq-virtual-machine:~/my$ apt-cache search aarch64 | grep gcc
gcc-11-aarch64-linux-gnu - GNU C compiler (cross compiler for arm64 architecture)
gcc-11-aarch64-linux-gnu-base - GCC,GNU 编译器套装(基本软件包)
gcc-aarch64-linux-gnu - GNU C compiler for the arm64 architecture
gcc-10-aarch64-linux-gnu - GNU C compiler (cross compiler for arm64 architecture)
gcc-10-aarch64-linux-gnu-base - GCC,GNU 编译器套装(基本软件包)
gcc-12-aarch64-linux-gnu - GNU C compiler (cross compiler for arm64 architecture)
gcc-12-aarch64-linux-gnu-base - GCC,GNU 编译器套装(基本软件包)
gcc-9-aarch64-linux-gnu - GNU C compiler (cross compiler for arm64 architecture)
gcc-9-aarch64-linux-gnu-base - GCC,GNU 编译器套装(基本软件包)
gccgo-10-aarch64-linux-gnu - GNU Go compiler
gccgo-11-aarch64-linux-gnu - GNU Go compiler
gccgo-12-aarch64-linux-gnu - GNU Go compiler
gccgo-9-aarch64-linux-gnu - GNU Go compiler
gccgo-aarch64-linux-gnu - Go compiler (based on GCC) for the arm64 architecture
gcc-10-plugin-dev-aarch64-linux-gnu - Files for GNU GCC plugin development.
gcc-11-plugin-dev-aarch64-linux-gnu - Files for GNU GCC plugin development.
gcc-12-plugin-dev-aarch64-linux-gnu - Files for GNU GCC plugin development.
gcc-9-plugin-dev-aarch64-linux-gnu - Files for GNU GCC plugin development.
lq@lq-virtual-machine:~/my$ 

2、安装gcc

apt-get install gcc-12-aarch64-linux-gnu
lq@lq-virtual-machine:~$ aarch64-linux-gnu-
aarch64-linux-gnu-addr2line      aarch64-linux-gnu-gcc-12         aarch64-linux-gnu-gprof          aarch64-linux-gnu-objdump
aarch64-linux-gnu-ar             aarch64-linux-gnu-gcc-ar-12      aarch64-linux-gnu-ld             aarch64-linux-gnu-ranlib
aarch64-linux-gnu-as             aarch64-linux-gnu-gcc-nm-12      aarch64-linux-gnu-ld.bfd         aarch64-linux-gnu-readelf
aarch64-linux-gnu-c++filt        aarch64-linux-gnu-gcc-ranlib-12  aarch64-linux-gnu-ld.gold        aarch64-linux-gnu-size
aarch64-linux-gnu-cpp-12         aarch64-linux-gnu-gcov-12        aarch64-linux-gnu-lto-dump-12    aarch64-linux-gnu-strings
aarch64-linux-gnu-dwp            aarch64-linux-gnu-gcov-dump-12   aarch64-linux-gnu-nm             aarch64-linux-gnu-strip
aarch64-linux-gnu-elfedit        aarch64-linux-gnu-gcov-tool-12   aarch64-linux-gnu-objcopy        
lq@lq-virtual-machine:~$ 

修改gcc名字

sudo mv /usr/bin/aarch64-linux-gnu-gcc-12 /usr/bin/aarch64-linux-gnu-gcc

三、调试器

sudo apt-get install gdb-multiarch
lq@lq-virtual-machine:~/my$ gdb
gdb            gdb-add-index  gdb-multiarch  gdbtui         gdbus          
lq@lq-virtual-machine:~/my$

四、qemu

sudo apt-get install qemu-system
lq@lq-virtual-machine:~$ qemu-
qemu-img                    qemu-system-arm             qemu-system-mips            qemu-system-ppc64le         qemu-system-sparc64
qemu-io                     qemu-system-avr             qemu-system-mips64          qemu-system-riscv32         qemu-system-tricore
qemu-make-debian-root       qemu-system-cris            qemu-system-mips64el        qemu-system-riscv64         qemu-system-x86_64
qemu-nbd                    qemu-system-hppa            qemu-system-mipsel          qemu-system-rx              qemu-system-x86_64-microvm
qemu-pr-helper              qemu-system-i386            qemu-system-nios2           qemu-system-s390x           qemu-system-x86_64-spice
qemu-storage-daemon         qemu-system-m68k            qemu-system-or1k            qemu-system-sh4             qemu-system-xtensa
qemu-system-aarch64         qemu-system-microblaze      qemu-system-ppc             qemu-system-sh4eb           qemu-system-xtensaeb
qemu-system-alpha           qemu-system-microblazeel    qemu-system-ppc64           qemu-system-sparc           
lq@lq-virtual-machine:~$ qemu-
lq@lq-virtual-machine:~$ qemu-system-aarch64 --version
QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.11)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
lq@lq-virtual-machine:~$ 

五、busybox

1、源码

lq@lq-virtual-machine:~/my$ ls
busybox-1.36.1  busybox-1.36.1.tar.bz2
lq@lq-virtual-machine:~/my$ 

2、配置busybox

make menuconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

3、编译

make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

4、安装

make install ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

详细内容见:qemu搭建arm嵌入式linux开发环境_qemu 搭建 嵌入式开发环境_lqonlylove的博客-CSDN博客

六、kernel

1、源码

lq@lq-virtual-machine:~/my$ ls
linux-6.4.1  linux-6.4.1.tar.xz
lq@lq-virtual-machine:~/my$ 

2、安装依赖包

sudo apt-get install make gcc flex bison libncurses-dev libssl-dev

3、配置kernel

make defconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

4、配置内核

make menuconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

使用initramfs根文件系统

-> General setup
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
	(/home/lq/my/rootfs) Initramfs source file (s)

5、编译

make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1

6、生成调试compile_commands.json

./scripts/clang-tools/gen_compile_commands.py

7、清空工程

make distclean ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

七、qemu启动kernel测试

qemu-system-aarch64 -m 512M -smp 1 -cpu cortex-a57 -machine virt -kernel arch/arm64/boot/Image -append "rdinit=/linuxrc nokaslr console=ttyAMA0 loglevel=8" -nographic
lq@lq-virtual-machine:~/my/linux-6.4.1$ qemu-system-aarch64 -m 512M -smp 1 -cpu cortex-a57 -machine virt -kernel arch/arm64/boot/Image -append "rdinit=/linuxrc nokaslr console=ttyAMA0 loglevel=8" -nographic
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x411fd070]
[    0.000000] Linux version 6.4.1 (lq@lq-virtual-machine) (aarch64-linux-gnu-gcc (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1 SMP PREEMPT Fri Jul  7 20:27:10 CST 2023
[    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-0x000000005fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x5fef39c0-0x5fef5fff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x000000005fffffff]
[    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-0x000000005fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000005fffffff]
[    0.000000] cma: Reserved 32 MiB at 0x000000005d600000
[    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 22 pages/cpu s50216 r8192 d31704 u90112
[    0.000000] pcpu-alloc: s50216 r8192 d31704 u90112 alloc=22*4096
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Detected PIPT I-cache on CPU0
[    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: detected: Spectre-BHB
[    0.000000] CPU features: detected: ARM erratum 834220
[    0.000000] CPU features: detected: ARM erratum 1742098
[    0.000000] CPU features: detected: ARM erratum 832075
[    0.000000] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[    0.000000] alternatives: applying boot alternatives
[    0.000000] Kernel command line: rdinit=/linuxrc nokaslr console=ttyAMA0 loglevel=8
[    0.000000] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.000000] Fallback order for Node 0: 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129024
[    0.000000] Policy zone: DMA
[    0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[    0.000000] Memory: 439288K/524288K available (16320K kernel code, 4152K rwdata, 10156K rodata, 9664K init, 611K bss, 52232K reserved, 32768K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, 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=1.
[    0.000000] 	Trampoline variant of Tasks RCU enabled.
[    0.000000] 	Tracing 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=1
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] Root IRQ handler: gic_handle_irq
[    0.000000] GICv2m: range[mem 0x08020000-0x08020fff], SPI[80:143]
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] arch_timer: cp15 timer(s) running at 62.50MHz (virt).
[    0.000000] clocksource: arch_sys_counter: mask: 0x1ffffffffffffff max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns
[    0.000079] sched_clock: 57 bits at 63MHz, resolution 16ns, wraps every 4398046511096ns
[    0.008089] Console: colour dummy device 80x25
[    0.010162] Calibrating delay loop (skipped), value calculated using timer frequency.. 125.00 BogoMIPS (lpj=250000)
[    0.010313] pid_max: default: 32768 minimum: 301
[    0.011648] LSM: initializing lsm=capability,integrity
[    0.013800] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.013843] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.041455] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.048207] cblist_init_generic: Setting adjustable number of callback queues.
[    0.048341] cblist_init_generic: Setting shift to 0 and lim to 1.
[    0.048589] cblist_init_generic: Setting shift to 0 and lim to 1.
[    0.050070] rcu: Hierarchical SRCU implementation.
[    0.050113] rcu: 	Max phase no-delay instances is 1000.
[    0.055051] EFI services will not be available.
[    0.055617] smp: Bringing up secondary CPUs ...
[    0.055707] smp: Brought up 1 node, 1 CPU
[    0.055731] SMP: Total of 1 processors activated.
[    0.055816] CPU features: detected: 32-bit EL0 Support
[    0.055837] CPU features: detected: 32-bit EL1 Support
[    0.055936] CPU features: detected: CRC32 instructions
[    0.058609] CPU: All CPU(s) started at EL1
[    0.058833] alternatives: applying system-wide alternatives
[    0.080249] devtmpfs: initialized
[    0.094066] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.094231] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.098547] pinctrl core: initialized pinctrl subsystem
[    0.105366] DMI not present or invalid.
[    0.118927] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.129287] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.129812] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    0.130044] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.130298] audit: initializing netlink subsys (disabled)
[    0.136597] thermal_sys: Registered thermal governor 'step_wise'
[    0.136651] thermal_sys: Registered thermal governor 'power_allocator'
[    0.137418] audit: type=2000 audit(0.096:1): state=initialized audit_enabled=0 res=1
[    0.137903] cpuidle: using governor menu
[    0.139027] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[    0.139445] ASID allocator initialised with 65536 entries
[    0.145639] Serial: AMBA PL011 UART driver
[    0.181150] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 13, base_baud = 0) is a PL011 rev1
[    0.182343] printk: console [ttyAMA0] enabled
[    0.217833] KASLR disabled on command line
[    0.222731] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
[    0.223042] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
[    0.223396] HugeTLB: registered 32.0 MiB page size, pre-allocated 0 pages
[    0.223538] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
[    0.223680] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[    0.223816] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[    0.223956] HugeTLB: registered 64.0 KiB page size, pre-allocated 0 pages
[    0.224089] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
[    0.233622] ACPI: Interpreter disabled.
[    0.240998] iommu: Default domain type: Translated 
[    0.241186] iommu: DMA domain TLB invalidation policy: strict mode 
[    0.242673] SCSI subsystem initialized
[    0.243677] libata version 3.00 loaded.
[    0.245466] usbcore: registered new interface driver usbfs
[    0.245866] usbcore: registered new interface driver hub
[    0.246239] usbcore: registered new device driver usb
[    0.248953] pps_core: LinuxPPS API ver. 1 registered
[    0.249364] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.249696] PTP clock support registered
[    0.250468] EDAC MC: Ver: 3.0.0
[    0.252567] scmi_core: SCMI protocol bus registered
[    0.255614] FPGA manager framework
[    0.256578] Advanced Linux Sound Architecture Driver Initialized.
[    0.267545] vgaarb: loaded
[    0.270817] clocksource: Switched to clocksource arch_sys_counter
[    0.272203] VFS: Disk quotas dquot_6.6.0
[    0.273777] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.276259] pnp: PnP ACPI: disabled
[    0.293770] NET: Registered PF_INET protocol family
[    0.295434] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.300424] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.300802] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.301044] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.301347] TCP bind hash table entries: 4096 (order: 5, 131072 bytes, linear)
[    0.301677] TCP: Hash tables configured (established 4096 bind 4096)
[    0.302906] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.303852] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.305295] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.308103] RPC: Registered named UNIX socket transport module.
[    0.308385] RPC: Registered udp transport module.
[    0.308614] RPC: Registered tcp transport module.
[    0.308753] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.309025] PCI: CLS 0 bytes, default 64
[    0.315722] kvm [1]: HYP mode not available
[    0.319499] Initialise system trusted keyrings
[    0.327785] workingset: timestamp_bits=42 max_order=17 bucket_order=0
[    0.329835] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.332880] NFS: Registering the id_resolver key type
[    0.333541] Key type id_resolver registered
[    0.333666] Key type id_legacy registered
[    0.334089] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.334320] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.339395] 9p: Installing v9fs 9p2000 file system support
[    0.382159] Key type asymmetric registered
[    0.382345] Asymmetric key parser 'x509' registered
[    0.387228] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[    0.387588] io scheduler mq-deadline registered
[    0.387755] io scheduler kyber registered
[    0.388223] io scheduler bfq registered
[    0.444165] pl061_gpio 9030000.pl061: PL061 GPIO chip registered
[    0.459730] pci-host-generic 4010000000.pcie: host bridge /pcie@10000000 ranges:
[    0.460568] pci-host-generic 4010000000.pcie:       IO 0x003eff0000..0x003effffff -> 0x0000000000
[    0.461322] pci-host-generic 4010000000.pcie:      MEM 0x0010000000..0x003efeffff -> 0x0010000000
[    0.461865] pci-host-generic 4010000000.pcie:      MEM 0x8000000000..0xffffffffff -> 0x8000000000
[    0.467301] pci-host-generic 4010000000.pcie: Memory resource size exceeds max for 32 bits
[    0.468126] pci-host-generic 4010000000.pcie: ECAM at [mem 0x4010000000-0x401fffffff] for [bus 00-ff]
[    0.469567] pci-host-generic 4010000000.pcie: PCI host bridge to bus 0000:00
[    0.470505] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.470805] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.471120] pci_bus 0000:00: root bus resource [mem 0x10000000-0x3efeffff]
[    0.475455] pci_bus 0000:00: root bus resource [mem 0x8000000000-0xffffffffff]
[    0.477179] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.485352] pci 0000:00:01.0: [1af4:1000] type 00 class 0x020000
[    0.485765] pci 0000:00:01.0: reg 0x10: [io  0x0000-0x001f]
[    0.485955] pci 0000:00:01.0: reg 0x14: [mem 0x00000000-0x00000fff]
[    0.486183] pci 0000:00:01.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[    0.486460] pci 0000:00:01.0: reg 0x30: [mem 0x00000000-0x0007ffff pref]
[    0.494070] pci 0000:00:01.0: BAR 6: assigned [mem 0x10000000-0x1007ffff pref]
[    0.494483] pci 0000:00:01.0: BAR 4: assigned [mem 0x8000000000-0x8000003fff 64bit pref]
[    0.499494] pci 0000:00:01.0: BAR 1: assigned [mem 0x10080000-0x10080fff]
[    0.499696] pci 0000:00:01.0: BAR 0: assigned [io  0x1000-0x101f]
[    0.508478] EINJ: ACPI disabled.
[    0.564143] virtio-pci 0000:00:01.0: enabling device (0000 -> 0003)
[    0.581477] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.590155] SuperH (H)SCI(F) driver initialized
[    0.591851] msm_serial: driver initialized
[    0.616480] loop: module loaded
[    0.619135] megasas: 07.725.01.00-rc1
[    0.625843] physmap-flash 0.flash: physmap platform flash device: [mem 0x00000000-0x03ffffff]
[    0.627549] 0.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
[    0.628322] Intel/Sharp Extended Query Table at 0x0031
[    0.629207] Using buffer write method
[    0.629659] erase region 0: offset=0x0,size=0x40000,blocks=256
[    0.630148] physmap-flash 0.flash: physmap platform flash device: [mem 0x04000000-0x07ffffff]
[    0.631212] 0.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
[    0.632018] Intel/Sharp Extended Query Table at 0x0031
[    0.632695] Using buffer write method
[    0.632958] erase region 0: offset=0x0,size=0x40000,blocks=256
[    0.633285] Concatenating MTD devices:
[    0.633453] (0): "0.flash"
[    0.633547] (1): "0.flash"
[    0.633642] into device "0.flash"
[    0.710539] tun: Universal TUN/TAP device driver, 1.6
[    0.726684] thunder_xcv, ver 1.0
[    0.726908] thunder_bgx, ver 1.0
[    0.727092] nicpf, ver 1.0
[    0.730657] hns3: Hisilicon Ethernet Network Driver for Hip08 Family - version
[    0.730847] hns3: Copyright (c) 2017 Huawei Corporation.
[    0.731589] hclge is initializing
[    0.731858] e1000: Intel(R) PRO/1000 Network Driver
[    0.731990] e1000: Copyright (c) 1999-2006 Intel Corporation.
[    0.732354] e1000e: Intel(R) PRO/1000 Network Driver
[    0.732507] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.732948] igb: Intel(R) Gigabit Ethernet Network Driver
[    0.733262] igb: Copyright (c) 2007-2014 Intel Corporation.
[    0.733630] igbvf: Intel(R) Gigabit Virtual Function Network Driver
[    0.733947] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[    0.735501] sky2: driver version 1.30
[    0.739228] VFIO - User Level meta-driver version: 0.3
[    0.748527] usbcore: registered new interface driver usb-storage
[    0.758766] rtc-pl031 9010000.pl031: registered as rtc0
[    0.759599] rtc-pl031 9010000.pl031: setting system clock to 2023-07-07T13:06:58 UTC (1688735218)
[    0.761887] i2c_dev: i2c /dev entries driver
[    0.775124] ghes_edac: GHES probing device list is empty
[    0.779132] sdhci: Secure Digital Host Controller Interface driver
[    0.779765] sdhci: Copyright(c) Pierre Ossman
[    0.781837] Synopsys Designware Multimedia Card Interface Driver
[    0.784684] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.789872] ledtrig-cpu: registered to indicate activity on CPUs
[    0.796499] usbcore: registered new interface driver usbhid
[    0.796674] usbhid: USB HID core driver
[    0.806292] hw perfevents: enabled with armv8_pmuv3 PMU driver, 5 counters available
[    0.821681] NET: Registered PF_PACKET protocol family
[    0.823051] 9pnet: Installing 9P2000 support
[    0.824048] Key type dns_resolver registered
[    0.851693] registered taskstats version 1
[    0.852845] Loading compiled-in X.509 certificates
[    0.878615] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    0.889489] clk: Disabling unused clocks
[    0.889880] ALSA device list:
[    0.890020]   No soundcards found.
[    0.894309] uart-pl011 9000000.pl011: no DMA platform data
[    0.964396] Freeing unused kernel memory: 9664K
[    0.965502] Run /linuxrc as init process
[    0.965651]   with arguments:
[    0.965738]     /linuxrc
[    0.965814]   with environment:
[    0.966001]     HOME=/
[    0.966092]     TERM=linux

Please press Enter to activate this console. 
~ # ls
bin      etc      linuxrc  proc     sbin     tmp
dev      lib      mnt      root     sys      usr
~ # 

八、qemu调试kernel环境搭建

1、内核配置

make menuconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

关闭地址随机化

Kernel Features ---->
    [ ] Randomize the address of the kernel image

关闭编译器优化

# 在主 Makefile 中修改 KBUILD_CFLAGS

# 修改前:
KBUILD_CFLAGS += -O2

# 注意:kernel 使用 O0 或 O1 是编译不过的

2、GDB调试

1、启动qemu

qemu-system-aarch64 -m 512M -smp 1 -cpu cortex-a57 -machine virt -kernel arch/arm64/boot/Image -append "rdinit=/linuxrc nokaslr console=ttyAMA0 loglevel=8" -nographic -s -S

2、使用gdb调试kernel

$ cd linux-6.4.1
$ gdb-multiarch vmlinux
(gdb) target remote localhost:1234
(gdb) b start_kernel
(gdb) c
(gdb) layout src

3、使用vscode搭建调试环境

1、launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/lq/my/linux-6.4.1/vmlinux", // 指定vmlinux路径
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",	// 指定gdb-multiarch路径
            "miDebuggerServerAddress": "localhost:1234",	// gdb 连接
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

2、测试
在这里插入图片描述

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

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

相关文章

零矩阵

暴力解法&#xff1a;先全部检索&#xff0c;定位0所在的位置&#xff0c; 记录到新的数组 数组的行列分别进行去重 数组中记录的行列赋值为零 如果直接修改&#xff0c;在行被修改之后&#xff0c;修改列时会因为行已经被修改产生影响 import org.junit.Test;import java.uti…

tensorboard命令行使用方法

第一步&#xff1a;进入虚拟环境 conda activate 虚拟环境名称 第二步&#xff1a; tensorboard --logdir绝对地址 第三步&#xff1a;在浏览器输入提供的网址

day03 重新学python——python函数

文章目录 一、python函数1.函数介绍2.函数的定义3.函数的参数4.函数的返回值5.函数的说明文档6.函数的嵌套调用7.变量的作用域8.综合案例 一、python函数 1.函数介绍 函数&#xff1a;即组织好的、课重复利用&#xff0c;用来实现特殊功能的代码段&#xff0c;这样可以提高代码…

生产者消费者

前言 生产者消费者模式属于一种经典的多线程协作的模式&#xff0c;弄清生产者消费者问题能够让我们对于多线程编程有更深刻的理解&#xff0c;下面&#xff0c;为大家分享一个生产者消费者的案例。 一、案例描述 这里以快递为例&#xff0c;假设有一个快递柜&#xff0c;用来…

蚂蚁链发布零知识证明技术架构 可满足数据“隐私保护”、“可验证”双要求

7 月 8 日&#xff0c;在 2023WAIC 全球区块链产业高峰论坛上&#xff0c;蚂蚁链宣布隐私协作平台 AntChain FAIR 进行全新架构升级&#xff0c;引入零知识证明&#xff08;ZKP&#xff09;为核心的可验证计算技术&#xff0c;从可信数据流转拓展到计算过程、数据属性以及身份的…

Vmware环境下的CentOS安装

CentOS7 下载安装 因为 centos 是安装在 VMware 上面的&#xff0c;所以需要提前安装 VMware centos 下载 网址&#xff1a;http://isoredirect.centos.org/centos/7/isos/x86_64/ 镜像源&#xff1a;http://centos.mirror.rafal.ca/7.9.2009/isos/x86_64/ 安装 centos 创建…

哪些软件分析工具需要使用到pdb符号文件?

目录 1、什么是pdb文件&#xff1f;pdb文件有哪些用途&#xff1f; 2、pdb文件的时间戳与pdb文件名称 3、常用软件分析工具有哪些&#xff1f; 4、使用Windbg调试器查看函数调用堆栈时需要加载pdb文件 4.1、给Windbg设置pdb文件路径 4.2、为什么要设置系统库pdb文件下载服…

深度剖析线上应用节点流量隔离技术

作者&#xff1a;谢文欣&#xff08;风敬&#xff09; 为什么要做流量隔离 源于一个 EDAS 客户遇到的棘手情况&#xff1a;他们线上的一个 Pod CPU 指标异常&#xff0c;为了进一步诊断问题&#xff0c;客户希望在不重建此 Pod 的情况下保留现场&#xff0c;但诊断期间流量还…

Element-UI 实现动态增加多个输入框并校验

文章目录 前言实现通过按钮动态增加表单并验证必填实现动态多个输入框为行内模式&#xff0c;其它为行外模式 前言 在做复杂的动态表单&#xff0c;实现业务动态变动&#xff0c;比如有一条需要动态添加的el-form-item中包含了多个输入框&#xff0c;并实现表单验证&#xff0…

非线性激活函数

目录 理论介绍 常见的激活函数 A. sigmoid函数 B. tanh C.ReLu Leaky Relu 函数 Parametric ReLU (PReLU) Exponential Linear Unit (ELU) 实验结果及分析 理论介绍 在神经网络的计算中&#xff0c;无非就是矩阵相乘&#xff0c;输入的是线性&#xff0c;不论输出层有…

如何修复ssh漏洞进行版本升级

目录 一、ssh低版本漏洞信息 OpenSSH GSSAPI 处理远端代码执行漏洞 OpenSSH GSSAPI认证终止信息泄露漏洞 OpenSSH X连接会话劫持漏洞 二、升级ssh版本进行修复漏洞 第一步 安装Telnet服务 第二步 重启服务 第三步 安装依赖环境 第四步 备份ssh老版本文件 第五步 导入…

【JavaEE进阶】Spring 创建与使用

Spring 创建与使用 1&#xff0c;Spring项目的创建 使用Maven方式来创建一个Spring项目&#xff0c;创建Spring项目和Servlet类似&#xff0c;总共分为以下3步&#xff1a; 创建一个普通Maven项目添加 Spring 框架⽀持&#xff08;spring-context、spring-beans&#xff09;添…

UE特效案例 —— 魔法翅膀

一&#xff0c;环境配置 创建默认地形Landscape&#xff0c;如给地形上材质需确定比例&#xff1b;添加环境主光源DirectionalLight&#xff0c;设置相应的强度和颜色&#xff1b;PostProcessVolume设置曝光&#xff0c;设置Min/Max Brightness为1&#xff1b; 与关闭Game Sett…

【二分查找】35. 搜索插入位置

35. 搜索插入位置 解题思路 使用二分查找算法当找到元素之后直接返回位置即可当没找到元素&#xff0c;将该元素插入到left位置即可 class Solution {public int searchInsert(int[] nums, int target) {// 二分查找int left 0;int right nums.length - 1;while(left < …

数组扁平化flat方法的多种实现

flat() let arr [[1],[2, 3],[4, 5, 6, [7, 8, [9, 10, [11]]]],12 ];// 参数指要提取嵌套数组的结构深度&#xff0c;默认值为 1。 // Infinity 指递归嵌套的所有层级。 let flattedArr arr.flat(Infinity); console.log(flattedArr);执行效果&#xff1a; toString() 注意…

FreeRTOS ~(六)信号量 ~ (2/3)信号量解决互斥缺陷

前情提要 FreeRTOS ~&#xff08;四&#xff09;同步互斥与通信 ~ &#xff08;2/3&#xff09;互斥的缺陷 FreeRTOS ~&#xff08;五&#xff09;队列的常规使用 ~ &#xff08;2/5&#xff09;队列解决互斥缺陷 举例子说明&#xff1a;利用信号量解决前述的"互斥的缺陷&…

SQL Server数据库 -- 表的高级查询

文章目录 一、子查询 嵌套子查询相关子查询二、查询运算 并运算union交运算intersect差运算except三、函数的使用 if语句while语句case语句四、总结 前言 高级子查询是对查询更灵活的运用&#xff0c;学会了高级查询将对数据库使用有很大的帮助。 一、子查询 1、子查询简介 在…

MATLAB画等深度构造图

clc;clear;close all; data xlsread(J_UNCONFORMITY等深度.xlsx); x data(:,1) xmax max(x); xmin min(x); y data(:,2) ymax max(y); ymin min(y); z data(:,3); N 45…

天天刷题-->LeetCode(两数相加)

个人名片&#xff1a; &#x1f405;作者简介&#xff1a;一名大二在校生&#xff0c;热爱生活&#xff0c;爱好敲码&#xff01; \ &#x1f485;个人主页 &#x1f947;&#xff1a;holy-wangle ➡系列内容&#xff1a; &#x1f5bc;️ tkinter前端窗口界面创建与优化 &…