功能 | 工具 |
---|---|
操作系统 | ubuntu 22.04 |
编译工具 | gcc-12-aarch64-linux-gnu |
调试工具 | gdb-multiarch |
模拟器 | qemu 6.2.0 |
busybox | busybox-1.36.1 |
kernel | linux-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$
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:~$
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博客
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-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 <[email protected]>
[ 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
~ #
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 是编译不过的
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
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
}
]
}
]
}