2013年9月29日 星期日

arm gdb trace u-boot to start_kernel on i.mx6

1.
In Eclipse right click project
Debug As -> Debug Configurations -> GDB Hardware Debugging

2.
click Startup tab
uncheck the all items on startup page
add those lines under [Halt] box but do not check [Halt]
add-symbol-file /root/project_board/free_imx/out/matrix_io/uboot/u-boot 0x4FF04000
start debugging and trace code
(ps: in u-boot os keyin [bdinfo] show relocaddr = 0x4FF04000)

3.
file /root/project_board/free_imx/myandroid/bootable/bootloader/uboot-imx/arch/arm/lib/bootm.c
in function boot_jump_linux(bootm_headers_t *images, int flag)
//break at
kernel_entry = (void (*)(int, int, uint))images->ep;
run step over to next line
[Expressions] window show kernel_entry is 0x14008000

4.
Press [Terminate] to stop debug

5.
click Startup tab
uncheck the all items on startup page
add those lines under [Halt] box but do not check [Halt]
add-symbol-file /root/project_board/free_imx/out/matrix_io/kernel/arch/arm/boot/compressed/vmlinux 0x14008000
continue to debug and trace code

6.
#output_data is kernel code but only binary not include address info
file /root/project_board/free_imx/myandroid/kernel_imx/arch/arm/boot/compressed/misc.c
break at
ret = do_decompress(input_data, input_data_end - input_data, output_data, error);
check output_data
memory show: 7e7904eb 00900fe1

#confirm here
cd /root/project_board/free_imx/imx6_M601_210/out/matrix_io/kernel/arch/arm/boot
/root/project_board/free_imx/myandroid/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-objdump -D -b binary -marm ./image
show:
0:    eb04797e     bl    0x11e600
4:    e10f9000     mrs    r9, CPSR

7.
file /root/project_board/free_imx/myandroid/kernel_imx/arch/arm/boot/compressed/head.S
//break at
__enter_kernel:
mov r0, #0 @ must be 0
ARM( mov pc, r4 ) @ call kernel
[Registers] window show r4 = 0x10008000

8.
Press [Terminate] to stop debug

9.
/mnt/projects/imx6_M601_210/myandroid/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-objdump -h /mnt/projects/imx6_M601_210/out/matrix_io/kernel/vmlinux | grep .text
show:
0 .head.text    0000026c  80008000  80008000  00001000  2**2
1 .text              00c34bcc   80100000  80100000  00002000  2**6
16 .init.text     00099c10  812002e0   812002e0  010222e0  2**5
17 .exit.text    00006ecc   81299ef0   81299ef0  010bbef0  2**2

80008000 t .head.text   --->need
80100000 t .text            --->need

0x80008000 change to 0x10008000
0x80100000 change to 0x10100000

10.
click Startup tab
uncheck the all items on startup page
add those lines under [Halt] box but do not check [Halt]
add-symbol-file /root/project_board/free_imx/out/matrix_io/kernel/vmlinux 0x10100000 -s .head.text 0x10008000
continue to debug and trace code

11.
file /root/project_board/free_imx/myandroid/kernel_imx/arch/arm/kernel/head.S
//break at
ENTRY(__turn_mmu_on)


...
mov    pc, r3
[Registers] window show r3 = 0x813852bc

12.
Press [Terminate] to stop debug

13.
click Startup tab
uncheck the all items on startup page
add those lines under [Halt] box but do not check [Halt]
add-symbol-file /root/project_board/free_imx/out/matrix_io/kernel/vmlinux
[Disassembly] window find 0x813852bc at __mmap_switched of head-common.S
continue to debug and trace code

14.
file /root/project_board/free_imx/myandroid/kernel_imx/arch/arm/kernel/head-common.S
//break at
__mmap_switched:



b    start_kernel
//then go to start_kernel(void) of ~/.../kernel_imx/init/main.c

Demo photo:
https://picasaweb.google.com/106185541018774360364/IMx6#6251472029385486178

沒有留言:

張貼留言