qemu-system-aarch64 来调试大端内核时,遇到以下几个问题,记录以下:
1、使用linux-4.9.84、linux-4.4.97内核
2、打入rt补丁。
3、配置CONFIG_BIG_ENDIAN,大端内核。
4、选择PREEMPT_LL时qemu可以启动。
5、选择PREEMPT_RT_FULL时,不能启动。
6、发现选择PREEMPT_RT_FULL时,伙伴系统只能选择CONFIG_SLUB。
7、当选择PREEMPT_LL + CONFIG_SLUB也不能启动。
8、当选择PREEMPT_LL + CONFIG_SLAB可以启动。
qemu-2.11版本,BIG_ENDIAN+PREEMPT_LL+CONFIG_SLUB,启动到如下就卡主了。
-bash-4.2$ ./qemu.sh
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.9.84-rt62-g6cc9d78 ([email protected]) (gcc version 6.2.0 20161103 ZTE Embsys-TSP Vtest (GCC) ) #119 SMP PREEMPT Mon Aug 27 18:58:51 CST 2018
[ 0.000000] Boot CPU: AArch64 Processor [410fd034]
[ 0.000000] earlycon: pl11 at MMIO 0x0000000009000000 (options '')
[ 0.000000] bootconsole [pl11] enabled
[ 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 19 pages/cpu @ffffffc03ffd9000 s38552 r8192 d31080 u77824
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: enabling workaround for ARM erratum 845719
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 258048
[ 0.000000] Kernel command line: rw console=ttyAMA0,115200 earlycon
[ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
[ 0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
[ 0.000000] Memory: 923224K/1048576K available (4094K kernel code, 226K rwdata, 940K rodata, 320K init, 270K bss, 125352K reserved, 0K cma-reserved)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] modules : 0xffffff8000000000 - 0xffffff8008000000 ( 128 MB)
[ 0.000000] vmalloc : 0xffffff8008000000 - 0xffffffbebfff0000 ( 250 GB)
[ 0.000000] .text : 0xffffff8008080000 - 0xffffff8008480000 ( 4096 KB)
[ 0.000000] .rodata : 0xffffff8008480000 - 0xffffff8008570000 ( 960 KB)
[ 0.000000] .init : 0xffffff8008570000 - 0xffffff80085c0000 ( 320 KB)
[ 0.000000] .data : 0xffffff80085c0000 - 0xffffff80085f8808 ( 227 KB)
[ 0.000000] .bss : 0xffffff80085f8808 - 0xffffff800863c0e4 ( 271 KB)
[ 0.000000] fixed : 0xffffffbefe7fd000 - 0xffffffbefec00000 ( 4108 KB)
[ 0.000000] PCI I/O : 0xffffffbefee00000 - 0xffffffbeffe00000 ( 16 MB)
[ 0.000000] vmemmap : 0xffffffbf00000000 - 0xffffffc000000000 ( 4 GB maximum)
[ 0.000000] 0xffffffbf00000000 - 0xffffffbf01000000 ( 16 MB actual)
[ 0.000000] memory : 0xffffffc000000000 - 0xffffffc040000000 ( 1024 MB)
启动过程其他问题:
1、挂载根文件系统失败,log如下:
[ 4.454439] Key type dns_resolver registered
[ 4.461131] registered taskstats version 1
[ 4.475201] hctosys: unable to open rtc device (rtc0)
[ 4.482318] uart-pl011 9000000.pl011: no DMA platform data
[ 4.486156] RAMDISK: gzip image found at block 0
[ 33.106435] EXT4-fs (ram0): couldn't mount as ext3 due to feature incompatibilities
[ 33.144973] EXT4-fs (ram0): mounted filesystem with ordered data mode. Opts: (null)
[ 33.145759] VFS: Mounted root (ext4 filesystem) on device 1:0.
[ 33.200246] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[ 33.200731] Please append a correct "root=" boot option; here are the available partitions:
[ 33.201442] 0100 10000000 ram0 (driver?)
[ 33.201987] 0101 10000000 ram1 (driver?)
[ 33.202276] 0102 10000000 ram2 (driver?)
[ 33.202582] 0103 10000000 ram3 (driver?)
[ 33.202893] 0104 10000000 ram4 (driver?)
[ 33.207627] 0105 10000000 ram5 (driver?)
[ 33.208033] 0106 10000000 ram6 (driver?)
[ 33.208313] 0107 10000000 ram7 (driver?)
[ 33.208636] 0108 10000000 ram8 (driver?)
[ 33.208933] 0109 10000000 ram9 (driver?)
[ 33.209222] 010a 10000000 ram10 (driver?)
[ 33.209521] 010b 10000000 ram11 (driver?)
[ 33.209812] 010c 10000000 ram12 (driver?)
[ 33.210097] 010d 10000000 ram13 (driver?)
[ 33.210384] 010e 10000000 ram14 (driver?)
[ 33.210694] 010f 10000000 ram15 (driver?)
[ 33.211279] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
解决方法:
bootargs添加:
/home/yuchen/work/open_source/qemu/qemu-2.11.0/bin/qemu-system-aarch64 -M virt -m 2048 -nographic -append "root=/dev/ram0 rw console=ttyAMA0,115200 earlycon" -cpu cortex-a53 -initrd /home/yuchen/work/023-cgel6x-mcs2.0/linux-4.9/ramdisk.img -kernel arch/arm64/boot/Image
2、挂载根文件系统失败2,log如下:
[ 3.442554] uart-pl011 9000000.pl011: no DMA platform data
[ 3.446453] RAMDISK: gzip image found at block 0
[ 9.662506] RAMDISK: incomplete write (2648 != 32768)
[ 9.662968] write error
[ 12.772657] EXT4-fs (ram0): couldn't mount as ext3 due to feature incompatibilities
[ 12.775751] EXT4-fs (ram0): bad geometry: block count 458752 exceeds size of device (131072 blocks)
[ 12.781907] EXT2-fs (ram0): error: couldn't mount because of unsupported optional features (2c0)
[ 12.789182] EXT4-fs (ram0): couldn't mount as ext3 due to feature incompatibilities
[ 12.790246] EXT4-fs (ram0): bad geometry: block count 458752 exceeds size of device (131072 blocks)
[ 12.791289] EXT2-fs (ram0): error: couldn't mount because of unsupported optional features (2c0)
[ 12.797082] List of all partitions:
[ 12.797576] 0100 131072 ram0 (driver?)
[ 12.798153] 0101 131072 ram1 (driver?)
[ 12.798432] 0102 131072 ram2 (driver?)
[ 12.798710] 0103 131072 ram3 (driver?)
[ 12.799003] 0104 131072 ram4 (driver?)
[ 12.799296] 0105 131072 ram5 (driver?)
[ 12.799569] 0106 131072 ram6 (driver?)
[ 12.799845] 0107 131072 ram7 (driver?)
[ 12.800114] 0108 131072 ram8 (driver?)
[ 12.800394] 0109 131072 ram9 (driver?)
[ 12.800664] 010a 131072 ram10 (driver?)
[ 12.805388] 010b 131072 ram11 (driver?)
[ 12.805661] 010c 131072 ram12 (driver?)
[ 12.805941] 010d 131072 ram13 (driver?)
[ 12.806240] 010e 131072 ram14 (driver?)
[ 12.806505] 010f 131072 ram15 (driver?)
[ 12.806847] No filesystem could mount root, tried: ext3 ext4 ext2 vfat fuseblk
[ 12.807647] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
[ 12.807894] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.4.97-rt110-EMBSYS-CGEL-6.1.R2.B1 #5
解决方法:
(1)检查内核配置:
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=131072 ---需要设置的足够大,需大于ramdisk镜像大小(单位kbytes)
(2)如果修改了CONFIG_BLK_DEV_RAM_SIZE仍无效,在尝试下bootargs添加ramdisk_size。
/home/yuchen/work/open_source/qemu/qemu-2.11.0/bin/qemu-system-aarch64 -M virt -m 2048 -nographic -append "root=/dev/ram0 rw console=ttyAMA0,115200 earlycon ramdisk_size=10000000" -cpu cortex-a53 -initrd /home/yuchen/work/023-cgel6x-mcs2.0/linux-4.9/ramdisk.img -kernel arch/arm64/boot/Image