This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Kernel debugging DM816x/C6A816x/AM389x EVM



I would like to debug kernel modules on the EVM.  I have found that KGDB is now part of the main kernel and can compile the kgdboc module in with the following settings . .config.

CONFIG_HAVE_ARCH_KGDB=y

CONFIG_KGDB=y

CONFIG_KGDB_SERIAL_CONSOLE=y

# CONFIG_KGDB_TESTS is not set

CONFIG_KGDB_KDB=y

CONFIG_KDB_KEYBOARD=y 

 

I am using ttyS0 as the console and as the kgdb debug port.

I configure kgdboc using 

echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc

I then trigger kgdb using 

echo g > /proc/sysrq-trigger 

I get this output which shows something happened

SysRq : DEBUG                                                                                                                                                                                                     

Unable to handle kernel NULL pointer dereference at virtual address 00000000                                                                                                                                      

pgd = cbd00000                                                                                                                                                                                                    

[00000000] *pgd=8cb9b031, *pte=00000000, *ppte=00000000                                                                                                                                                           

Internal error: Oops: 80000007 [#1]                                                                                                                                                                               

last sysfs file: /sys/module/kgdboc/parameters/kgdboc                                                                                                                                                             

KGDB: re-enter exception: ALL breakpoints killed                                                                                                                                                                  

---[ end trace c97b6aac639fbca9 ]---                                                                                                                                                                              

Then the shell restarts and I am not able to issue any kdb commands.

I have tried using kgdboe but the source is not in the SDK so I am unable to take that route.  Will it work if I get the source?

I have also attempted to use a JTag  debugger with openocd but there is not an openocd config file vaialble for this platform.

 

 

 

 

 

 

  • Hello,

    Can you specify which kernel version are you using?

    Post 2.6.36 kernels, the serial port driver used on OMAP/DM816x kernel is changed and the serial devices are named as ttyO0, ttyO1 ('O' as for OMAP serial console) and so on instead of ttySx.

    Can you try following if you are using newer kernel?

    echo ttyO0 > /sys/module/kgdboc/parameters/kgdboc

       Hemant

  • Hello  Hemant

    Thank your for your reply.

    My Linux version is

    Linux version 2.6.37 (gnewton@EY-UBDx86-WS02) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #13 Tue Sep 6 14:42:14 BST 2011            

    I tried 

    root@dm816x-evm:~# echo ttyO0 > /sys/module/kgdboc/parameters/kgdboc      

    and nothing happens -- no registration message.

    When I try ttyS0 I get this:-

    root@dm816x-evm:~# echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc                                                                                                                                              

    kgdb: Registered I/O driver kgdboc.      

     

    I am using /dev/ttyS0 as the console.

    The devices /dev/ttyO0 - /dev/ttyO2 do exist

    Anything else I can look at or try out?

    Thanks

    Graham

     

  • Graham,

    I guess this is because the OMAP UART driver is probably not supporting polling which is perhaps required by kgdboc.

    There are 2 options if you want to debug using serial console:

    Option 1) Switch to standard 8250 driver - but this is not easily possible as the omap serial driver is always selected by default and some Kconfig file modifications might be required to force this. Also, this driver may not have undergone extensive testing on OMAP kernel as the omap uart driver would have (since it is the default driver used on DM816x platforms and OMAP kernel)

    Option 2) Update omap serial driver to support polling.

    I have created following (***UNTESTED***) patch to do so:

    diff --git a/drivers/serial/omap-serial.c b/drivers/serial/omap-serial.c
    index bb578fc..9ff1802 100644
    --- a/drivers/serial/omap-serial.c
    +++ b/drivers/serial/omap-serial.c
    @@ -906,6 +906,19 @@ static inline void wait_for_xmitr(struct uart_omap_port *up)
            }
     }

    +#ifdef CONFIG_CONSOLE_POLL
    +static int serial_omap_console_getchar(struct uart_port *port)
    +{
    +       struct uart_omap_port *up = (struct uart_omap_port *)port;
    +       unsigned char lsr = serial_in(up, UART_LSR);
    +
    +       if (!(lsr & UART_LSR_DR))
    +               return NO_POLL_CHAR;
    +
    +       return serial_in(up, UART_RX);
    +}
    +#endif
    +
     static void serial_omap_console_putchar(struct uart_port *port, int ch)
     {
            struct uart_omap_port *up = (struct uart_omap_port *)port;
    @@ -1023,6 +1036,10 @@ static struct uart_ops serial_omap_pops = {
            .request_port   = serial_omap_request_port,
            .config_port    = serial_omap_config_port,
            .verify_port    = serial_omap_verify_port,
    +#ifdef CONFIG_CONSOLE_POLL
    +       .poll_get_char  = serial_omap_console_getchar,
    +       .poll_put_char  = serial_omap_console_putchar,
    +#endif
     };

     static struct uart_driver serial_omap_reg = {

    Please note:

    1) The above patch may not apply cleanly to your kernel and some manual merge may be necessary

    2) As mentioned, this is untested and just for reference and/or debug purpose

    3) The above patch may not be the correct solution and should just be used (for now) as a quick fix

     

       Hemant

  • Thanks for that.  I applied the suggested patch and it worked. The background information was also useful.