2013年9月29日 星期日

arm-eabi-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.
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

7.
Press [Terminate] to stop debug

8.
use command [arm-eabi-nm]
/root/project_board/free_imx/myandroid/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-nm -a /root/project_board/free_imx/out/matrix_io/kernel/vmlinux | grep .text
813db454 t .exit.text
80008000 t .head.text   --->need
81385260 t .init.text
800081c0 t .text           --->need
80c90344 t .text.head
0x800081c0 change to 0x100081c0 for .text
0x80008000 change to 0x10008000 for .head.text

9.
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 0x100081c0 -s .head.text 0x10008000
continue to debug and trace code

10.
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

11.
Press [Terminate] to stop debug

12.
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

13.
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

沒有留言:

張貼留言