openocd debug u-boot to stext of kernel

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

openocd debug u-boot to stext of kernel

Jump to solution
1,096 Views
fatalfeel
Contributor V

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

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/kernel/head.o 0x80008000 -s .head.text 0x10008000

continue to debug and trace code

9.

file /root/project_board/free_imx/myandroid/kernel_imx/arch/arm/kernel/head.S

//break at

ENTRY(stext)

THUMB( adr r9, BSYM(1f) ) @ Kernel is always entered in ARM.

THUMB( bx r9 ) @ If this is a Thumb-2 kernel,

THUMB( .thumb ) @ switch to Thumb now.

THUMB(1: )

#ifdef CONFIG_ARM_VIRT_EXT

bl __hyp_stub_install

#endif

@ ensure svc mode and all interrupts masked

safe_svcmode_maskall r9

//done ~~~

demo:

Picasa Web Albums - Jesse Stone - i.mx6

Labels (3)
0 Kudos
1 Solution
784 Views
fatalfeel
Contributor V

Debugging Skill - How to debug from u-boot to start_kernel

Programming Guide: Openocd debug 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 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] windows 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:

adr r3, __mmap_switched_data

b start_kernel

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

View solution in original post

0 Kudos
1 Reply
785 Views
fatalfeel
Contributor V

Debugging Skill - How to debug from u-boot to start_kernel

Programming Guide: Openocd debug 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 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] windows 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:

adr r3, __mmap_switched_data

b start_kernel

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

0 Kudos