dtbファイルを使用してカーネルを起動する

3461 ワード

QEMUでvexpress-a 15で3.10を実行する.28コアの時、bootを始めた直後に止まりました
$ ./qemu-2.0.0/arm-softmmu/qemu-system-arm   -M vexpress-a15  -kernel ../linux-3.10.28/arch/arm/boot/zImage -serial stdio --append "console=ttyAMA0" -S -s
audio: Could not init `oss' audio driver
Uncompressing Linux... done, booting the kernel.
debugモードを使用すると、カーネルhangの場所がわかります.
__loop_delay () at arch/arm/lib/delay-loop.S:46
46			subs	r0, r0, #1
(gdb) where
#0  __loop_delay () at arch/arm/lib/delay-loop.S:46
#1  0x803adfe4 in panic (
    fmt=0x804533a0 "vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.
You may need a device tree blob or a different kernel to boot on this board.
") at kernel/panic.c:181 #2 0x804d4204 in v2m_populate_ct_desc () at arch/arm/mach-vexpress/v2m.c:322 #3 v2m_map_io () at arch/arm/mach-vexpress/v2m.c:331 #4 0x804d31a0 in devicemaps_init (mdesc=0x804ed1a0 <__mach_desc_vexpress>) at arch/arm/mm/mmu.c:1248 #5 paging_init (mdesc=mdesc@entry=0x804ed1a0 <__mach_desc_vexpress>) at arch/arm/mm/mmu.c:1310 #6 0x804cff5c in setup_arch ( cmdline_p=cmdline_p@entry=0x804fffcc ) at arch/arm/kernel/setup.c:790 #7 0x804cd824 in start_kernel () at init/main.c:502 #8 0x80008074 in stext () at arch/arm/kernel/head.S:139

対応コード:
308 static void __init v2m_populate_ct_desc(void)
309 {
310     int i;
311     u32 current_tile_id;
312 
313     ct_desc = NULL;
314     current_tile_id = vexpress_get_procid(VEXPRESS_SITE_MASTER)
315                 & V2M_CT_ID_MASK;
316 
317     for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i)
318         if (ct_descs[i]->id == current_tile_id)
319             ct_desc = ct_descs[i];
320 
321     if (!ct_desc)
322         panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.
" 323 "You may need a device tree blob or a different kernel to boot on this board.
", 324 current_tile_id)
; 325 } 326

ヒントに従って、dtb方式でbootを使用することができます.
$ ./qemu-2.0.0/arm-softmmu/qemu-system-arm   -M vexpress-a15  -kernel ../linux-3.10.28/arch/arm/boot/zImage -serial stdio --append "console=ttyAMA0" -dtb ../linux-3.10.28/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dtb 
audio: Could not init `oss' audio driver
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Linux version 3.10.28 (charles@taotao) (gcc version 4.9.1 (GCC) ) #1 SMP Thu Sep 18 08:37:20 KST 2014
CPU: ARMv7 Processor [412fc0f1] revision 1 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
Machine: ARM-Versatile Express, model: V2P-CA15_CA7
Memory policy: ECC disabled, Data cache writealloc
これで大丈夫です.
dtbファイルはdtsファイルからコンパイルすることができる.
$ ARCH=arm CROSS_COMPILE=arm-v7a15-linux-gnueabi-  make vexpress-v2p-ca15_a7.dtb 
  CC      scripts/mod/devicetable-offsets.s
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTLD  scripts/mod/modpost
make[1]: `arch/arm/boot/dts/vexpress-v2p-ca15_a7.dtb' is up to date.

References:
http://www.cnblogs.com/coryxie/archive/2013/09/19/3329462.html