Can openocd read call stack and local variable correct on i.mx6?Help

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

Can openocd read call stack and local variable correct on i.mx6?Help

1,633 Views
fatalfeel
Contributor V

//debug source section

static void pl2303_gpio_set(struct gpio_chip *chip, unsigned offset, int value)

{

  struct pl2303_gpio *gpio = to_pl2303_gpio(chip);

  struct pl2303_gpio_desc *desc;

  mutex_lock(&gpio->lock);

  desc = gpio->descs + offset;

  if (value) //--->break here

  gpio->data[desc->value_offset] |= desc->value_mask;

  else

  gpio->data[desc->value_offset] &= ~desc->value_mask;

  pl2303_vendor_write(desc->value_ctrl, gpio->data[desc->value_offset], gpio->serial);

  mutex_unlock(&gpio->lock);

}

////////////////////////////////////////openocd

/root/project_board/free_imx/myandroid/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-gdb

(gdb) target remote localhost:3333

(gdb) symbol-file /root/project_board/free_imx/out/matrix_io/kernel/vmlinux

(gdb) mon halt

(gdb) break /root/project_board/free_imx/myandroid/kernel_imx/drivers/usb/serial/pl2303.c:297

(gdb) continue

Breakpoint 1, pl2303_gpio_set (chip=0x800719bc, offset=3159793204, value=-2114730436)

  at /root/project_board/free_imx/myandroid/kernel_imx/drivers/usb/serial/pl2303.c:297

297 if (value)

(gdb) p value

$7 = -2114730436

Breakpoint 1, pl2303_vendor_write (value=65535, index=65535, serial=0x0)

  at /root/project_board/free_imx/myandroid/kernel_imx/drivers/usb/serial/pl2303.c:218

218 return res;

(gdb) p &index

$1 = (__u16 *) 0xbccb9d9c

(gdb) p &value

$2 = (__u16 *) 0xbccb9d9e

(gdb) p &res

$3 = (int *) 0xbccb9dac

Picasa Web Albums - Jesse Stone - i.mx6 -A

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

(gdb) target remote /dev/ttyUSB0

Remote debugging using /dev/ttyUSB0

kgdb_breakpoint ()

  at /root/project_board/free_imx/myandroid/kernel_imx/kernel/debug/debug_core.c:1025

1025 arch_kgdb_breakpoint();

(gdb) break /root/project_board/free_imx/myandroid/kernel_imx/drivers/usb/serial/pl2303.c:297

Breakpoint 1 at 0x8075bfd0: file /root/project_board/free_imx/myandroid/kernel_imx/drivers/usb/serial/pl2303.c, line 297.

(gdb) continue

Continuing.

Breakpoint 1, pl2303_gpio_set (chip=0xbc5e99e4, offset=0, value=0)

  at /root/project_board/free_imx/myandroid/kernel_imx/drivers/usb/serial/pl2303.c:297

(gdb) p value

$1 = 0

Breakpoint 1, pl2303_vendor_write (value=1, index=48, serial=0xbc5d7980)

  at /root/project_board/free_imx/myandroid/kernel_imx/drivers/usb/serial/pl2303.c:218

218 return res;

(gdb) p &index

$10 = (__u16 *) 0xbccb9d9c

(gdb) p &value

$11 = (__u16 *) 0xbccb9d9e

(gdb) p &res

$12 = (int *) 0xbccb9dac
Picasa Web Albums - Jesse Stone - i.mx6  -B
//////////////////////////////////////////////////////////////////////////////////////////////////

value = 0 is correct on kgdb

openocd and kgdb symbol address are the same

openocd global variable is good, only local variable is wrong. can fixed it?

and call stack jsut can see 2 or 3 layer.

kgdb can read all struct variable and call stacks

can make openocd like kgdb?

bug similar as this but not sure~~~how to fix openocd

https://code.google.com/p/go/issues/detail?id=8256

/////////////////////////////////////////////

here is a way debug openocd with eclipse

c/c++ application: /root/openocd-0.9.0/src/openocd

arguments: -f /opt/openocd/share/openocd/scripts/interface/ftdi/dp_busblaster.cfg -f /opt/openocd/share/openocd/scripts/target/imx6.cfg

Picasa Web Albums - Jesse Stone - i.mx6- C
//////////////////////////////////////

i compare global and local variable in openocd

static int gdb_read_memory_packet(struct connection *connection, char const *packet, int packet_size)

...

...

...

...

into cortex_a_read_phys_memory

get value is wrong on local variable

any idea for me?

Labels (3)
0 Kudos
9 Replies

1,120 Views
fatalfeel
Contributor V

openocd debug linux kernel on i.mx6

https://www.youtube.com/watch?v=8K1qY3St06k

openocd debug u-boot on i.mx6

https://www.youtube.com/watch?v=2L1vr_LA8Nc

0 Kudos

1,120 Views
fatalfeel
Contributor V

Tools for Art and Microcomputers: Debugging on the Cortex-A8, System Components


For configuring systems at start up, such as setting memory controller parameters, clocks and PLL registers, memory access through the AHB access port is good. This should also work well for writing to flash memories.

For debugging code running on the MPU, the APB and access through the MPU core probably should be used, since this method avoids problems with virtual to physical address translations and also helps avoid cache coherency problems.

0 Kudos

1,120 Views
fatalfeel
Contributor V

use  Advanced Highperformance Bus can not read local address value

but use Advanced Peripheral Bus can read local address value

0 Kudos

1,120 Views
fatalfeel
Contributor V

/root/openocd-0.9.0/src/target/cortex_a.c

modify

armv7a->memory_ap_available = true;

to

armv7a->memory_ap_available = false;

watch local variable of address value is correct.... still have local variable wrong

0 Kudos

1,120 Views
fatalfeel
Contributor V

static int cortex_a_read_memory(struct target *target,

                                                            uint32_t address,

                                                            uint32_t size,

                                                            uint32_t count,

                                                            uint8_t *buffer)

{

    int mmu_enabled = 0;

    //uint32_t virt, phys;

    int retval;

    struct armv7a_common*    armv7a    = target_to_armv7a(target);

    //struct adiv5_dap*                swjdp        = armv7a->arm.dap;

    //uint8_t apsel = swjdp->apsel;

    /* cortex_a handles unaligned memory access */

    LOG_DEBUG("Reading memory at address 0x%" PRIx32 "; size %" PRId32 "; count %" PRId32, address, size, count);

    /* determine if MMU was enabled on target stop */

    if (!armv7a->is_armv7r)

    {

        retval = cortex_a_mmu(target, &mmu_enabled);

        if (retval != ERROR_OK)

            return retval;

    }

     /////when I mark this section the local pointer variable is correct, but local variable is wrong too

     ////

     ////  

    /*if (armv7a->memory_ap_available && (apsel == armv7a->memory_ap))

    {

        if (mmu_enabled)

        {

            virt = address;

            retval = cortex_a_virt2phys(target, virt, &phys);

            if (retval != ERROR_OK)

                return retval;

            LOG_DEBUG("Reading at virtual address. Translating v:0x%" PRIx32 " to r:0x%" PRIx32,     virt, phys);

            address = phys;

        }

        retval = cortex_a_read_phys_memory(target, address, size, count, buffer);

    }

    else*/

    {

        if (mmu_enabled)

        {

            retval = cortex_a_check_address(target, address);

            if (retval != ERROR_OK)

                return retval;

            /* enable MMU as we could have disabled it for phys access */

            retval = cortex_a_mmu_modify(target, 1);

            if (retval != ERROR_OK)

                return retval;

        }

        retval = cortex_a_read_apb_ab_memory(target, address, size, count, buffer);

    }

    return retval;

}

0 Kudos

1,120 Views
fatalfeel
Contributor V

I write local variable 0x03, address=0x4ccd7d86, buffer={0x03, 0x00}

retval = cortex_a_write_phys_memory(target, address, size, count, buffer);

then Read local variable, address= 0x4ccd7d86

retval = cortex_a_read_phys_memory(target, address, size, count, buffer);

buffer = {0x03,0x00}

the value is 0x03 is ok~~~

get local variable still wrong

0 Kudos

1,120 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

That is something that is related to the openOCD features. I suggest you to ask in the openOCD forum

Forum « Open On-Chip Debugger

There should not be a problem with the imx6q, J-Link, DStream tools are capable to get the call stack and local variables from the device.

Best Regards,

Alejandro

0 Kudos

1,120 Views
fatalfeel
Contributor V

tks Already asked, no response yet~~~~

0 Kudos