Questions on RTEMS GDB stub over a serial line

Ian Jiang ianjiang.cn at gmail.com
Wed Nov 28 03:06:44 UTC 2007


Thanks for your help. I am able debug the hello-world now.
I would like to paste the final souce codes here to give a straightforward answer.


--------------
On 2007-11-28 00:46:37 Till Straumann <strauman at slac.stanford.edu> wrote:
Re: Questions on RTEMS GDB stub over a serial line

>Ian Jiang wrote:
>> Hi rtems-usersall!
>>
>> I am establishing a remote debug enviroment of RTEMS in a VMware workstation. I am using Till Straumann's GDB Agent for RTEMS. I referred http://www.slac.stanford.edu/~strauman/rtems/gdb/ but I am not clear enough about how to setup a session between the host and the target using a serial port.
>>
>> Questions
>> =========

>> 3) Why no debugging symbols found in the hello.exe although flag -g was used?
>>   
>Has been answered already; you want to use 'hello.nxe'.
hello.elf was used in fact.

(gdb) file o-optimize/hello.elf
Reading symbols from /home/ian/src/examples-4.7.1/hello4gdb/o-optimize/hello.elf...done.
No registers.


Another Question:
=================
Why tty_drv.h not installed?
This header file was needed when TTY1_DRIVER_TABLE_ENTRY is used. But it did not exist under my RTEMS_MAKEFILE_PATH=/home/ian/rtems/rtems_debug-4.7.1/i386-rtems4.7/pc386. I just created a symbol link:
ian at IanVM-1:~/rtems/rtems_debug-4.7.1/i386-rtems4.7/pc386/lib/include> ll tty_drv.h
lrwxrwxrwx 1 ian users 69 2007-11-28 06:46 tty_drv.h -> /home/ian/src/rtems-4.7.1/c/src/lib/libbsp/i386/shared/comm/tty_drv.h
However, I am wondering why tty_drv.h not installed to the RTEMS_MAKEFILE_PATH.


>
>HTH
>-- Till
>
>(PS: could you get the network driver working? I still have to look
>at the binaries you sent -- just haven't found the time yet, sorry)
Not yet. I had no idea what to do. But I would to have a try after I entablish this remote debug enviroment. Thank you all the same.



--------------------------------------------------------
ian at IanVM-1:~/src/examples-4.7.1/hello4gdb> cat test.c
/*
 *      Simple test program -- simplified version of sample test hello.
 */

#define TEST_INIT
#include <tmacros.h>

#include <bsp.h>

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <string.h>

#include <rtems/rtems_bsdnet.h>
#include <rtems-gdb-stub.h>
#include <bsp/bspExt.h>

#include "networkconfig.h"

#define TASK_PRIORITY_APP 4

void printdir(char *dir_name)
{
        struct dirent *d;
        DIR *dir;

        if (dir_name == NULL) {
                printf("NULL dir name\n");
                return;
        }

        dir = opendir(dir_name);
        if (dir == NULL) {
                printf("open dir %s failed:%s\n", dir_name, strerror(errno));
                return;
        }

        printf("List of dir %s:\n", dir_name);
        printf( "%-20s %8s %8s %8s %4s\n",
                 "name", "      inode", " offset", "reclen", " type" );
        d = readdir(dir);

        while (d) {
                printf( "%-20s %8d %8d %6di\n",
                         d->d_name, (int)d->d_ino, (int)d->d_off, d->d_reclen);
                d = readdir(dir);
        }

        return;
}


rtems_task
app_task (rtems_task_argument ignored)
{
        rtems_status_code ret;

        printf("Task App Enter\n");


        rtems_gdb_start(0, "/dev/ttyS1");

        rtems_gdb_breakpoint();

        printf( "\n\n*** HELLO WORLD TEST ***\n" );
        printf( "Hello World\n" );
        printf( "*** END OF HELLO WORLD TEST ***\n" );

        /* delete myself and exit */
        printf("Task App Exit\n");
        ret = rtems_task_delete(RTEMS_SELF);
        directive_failed(ret, "Delete task App");
}

rtems_task Init(
        rtems_task_argument ignored
)
{
        rtems_name app_name;
        rtems_id app_id;
        rtems_status_code ret;

        printdir("/");
        printdir("/dev/");

        /* create and start application task */
        app_name = rtems_build_name('a', 'p', 'p', '0');
        ret = rtems_task_create(app_name,
                        TASK_PRIORITY_APP,
                        RTEMS_MINIMUM_STACK_SIZE,
                        RTEMS_DEFAULT_MODES,
                        RTEMS_DEFAULT_ATTRIBUTES,
                        &app_id);
        directive_failed(ret, "Create task App");

        ret = rtems_task_start(app_id, app_task, 0);
        directive_failed(ret, "Start task App");

        /* delete myself and exit */
        ret = rtems_task_delete(RTEMS_SELF);
        directive_failed(ret, "Delete task Init");
}

/* configuration information */

#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_MAXIMUM_TASKS 4
#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)

#include <tty_drv.h>
#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
#ifdef CONFIGURE_INIT
rtems_driver_address_table Device_drivers[5] = {
        CONSOLE_DRIVER_TABLE_ENTRY,
        CLOCK_DRIVER_TABLE_ENTRY,
        TTY1_DRIVER_TABLE_ENTRY,
        {NULL, NULL, NULL, NULL, NULL, NULL},
        {NULL, NULL, NULL, NULL, NULL, NULL}
};
#endif

#define CONFIGURE_INIT

#include <rtems/confdefs.h>

/* end of file */



>> ian at IanVM-1:~/src/examples-4.7.1/hello4gdb> cat Makefile
>> --------------------------------------------------------
>> #
>> #  $Id: Makefile,v 1.4 1998/08/21 13:26:05 joel Exp $
>> #
>>
>> SAMPLE=hello
>> PGM=${ARCH}/$(SAMPLE).exe
>>
>> MANAGERS=all
>>
>> # C source names, if any, go here -- minus the .c
>> C_PIECES= test
>> C_FILES=$(C_PIECES:%=%.c)
>> C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
>>
>> H_FILES=
>>
>> DOCTYPES=
>> DOCS=$(DOCTYPES:%=$(SAMPLE).%)
>>
>> SRCS=$(DOCS) $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
>> OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
>>
>> PRINT_SRCS=$(DOCS)
>>
>> PGM=${ARCH}/$(SAMPLE).exe
>>
>> include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
>> include $(RTEMS_CUSTOM)
>> include $(PROJECT_ROOT)/make/leaf.cfg
>>
>> #
>> # (OPTIONAL) Add local stuff here using +=
>> #
>>
>> DEFINES  +=
>> CPPFLAGS +=
>> CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000
>> CFLAGS_OPTIMIZE_V   +=
>> CFLAGS_DEBUG_V   += -v -qrtems_debug
>>
>> CFLAGS_LD += -g
>>
>>
>> CFLAGS   += -fno-strict-aliasing -O
>> CFLAGS   += -I${RTEMS_MAKEFILE_PATH}/include
>> CFLAGS   += -I/home/ian/src/examples-4.7.1/test_includes
>> CFLAGS   += -g
>> CFLAGS   += -Wall
>>
>> #OP_SYS_LDFLAGS = -g
>>
>> LD_PATHS  += -L${RTEMS_MAKEFILE_PATH}/lib
>> #LD_LIBS   += -lif_le -lbsdport -lbspExt
>> LD_LIBS   += -lrtems-gdb-stub -lif_le -lbsdport -lbspExt
>> #LD_LIBS   += -lrtems-gdb-stub
>> LIBS   +=  -lrtemsall -lc
>>
>> #
>> # Add your list of files to delete here.  The config files
>> #  already know how to delete some stuff, so you may want
>> #  to just run 'make clean' first to see what gets missed.
>> #  'make clobber' already includes 'make clean'
>> #
>>
>> CLEAN_ADDITIONS +=
>> CLOBBER_ADDITIONS +=
>>
>> all:    ${ARCH} $(SRCS) $(PGM)
>>
>> ${PGM}: $(OBJS) $(LINK_FILES)
>>         $(make-exe)
>>
>> # Install the program(s), appending _g or _p as appropriate.
>> # for include files, just use $(INSTALL)
>> install:  all
>>         $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
>>
>>
>> ian at IanVM-1:~/src/examples-4.7.1/hello4gdb> cat networkconfig.h
>> ---------------------------------------------------------------
>> /*
>>  * Network configuration
>>  *
>>  ************************************************************
>>  * EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION     *
>>  * BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
>>  ************************************************************
>>  *
>>  *  $Id: networkconfig.h,v 1.8 2001/08/31 18:11:43 joel Exp $
>>  */
>>
>> #ifndef _RTEMS_NETWORKCONFIG_H_
>> #define _RTEMS_NETWORKCONFIG_H_
>>
>> //#define USE_QEMU
>>
>>
>> /*
>>  *  The following will normally be set by the BSP if it supports
>>  *  a single network device driver.  In the event, it supports
>>  *  multiple network device drivers, then the user's default
>>  *  network device driver will have to be selected by a BSP
>>  *  specific mechanism.
>>  */
>>
>> #ifdef RTEMS_BSP_NETWORK_DRIVER_NAME
>> #undef RTEMS_BSP_NETWORK_DRIVER_NAME
>> #endif
>> #ifdef USE_QEMU
>> #define RTEMS_BSP_NETWORK_DRIVER_NAME BSP_NE2000_NETWORK_DRIVER_NAME
>> #else
>> #define RTEMS_BSP_NETWORK_DRIVER_NAME "le1"
>> #endif
>>
>>
>>
>> #ifdef RTEMS_BSP_NETWORK_DRIVER_ATTACH
>> #undef RTEMS_BSP_NETWORK_DRIVER_ATTACH
>> #endif
>>
>> #ifdef USE_QEMU
>> #define RTEMS_BSP_NETWORK_DRIVER_ATTACH BSP_NE2000_NETWORK_DRIVER_ATTACH
>> #else
>> #define RTEMS_BSP_NETWORK_DRIVER_ATTACH libbsdport_netdriver_attach
>> #endif
>>
>> #include <rtems/pci.h>
>> #include <rtems/irq.h>
>>
>> #ifndef USE_QEMU
>> #include <bsp/libbsdport_api.h>
>> extern driver_t libbsdport_le_pci_driver;
>>
>> driver_t *libbsdport_netdriver_table[] = {
>>         &libbsdport_le_pci_driver,
>>         /* other drivers here or upstream of 'le' if they support
>>         * the same hardware but are preferred.
>>         */
>>         0
>> };
>> #endif
>>
>> /* #define RTEMS_USE_BOOTP */
>>
>> #include <bsp.h>
>>
>> /*
>>  * Define RTEMS_SET_ETHERNET_ADDRESS if you want to specify the
>>  * Ethernet address here.  If RTEMS_SET_ETHERNET_ADDRESS is not
>>  * defined the driver will choose an address.
>>  */
>> #ifndef USE_QEMU
>> #define RTEMS_SET_ETHERNET_ADDRESS
>> #endif
>> #if (defined (RTEMS_SET_ETHERNET_ADDRESS))
>> /* static char ethernet_address[6] = { 0x08, 0x00, 0x3e, 0x12, 0x28, 0xb1 }; */
>> static char ethernet_address[6] = { 0x00, 0x80, 0x7F, 0x22, 0x61, 0x77 };
>>
>> #endif
>>
>> #ifdef RTEMS_USE_LOOPBACK
>> /*
>>  * Loopback interface
>>  */
>> extern void rtems_bsdnet_loopattach();
>> static struct rtems_bsdnet_ifconfig loopback_config = {
>>         "lo0",                          /* name */
>>         rtems_bsdnet_loopattach,        /* attach function */
>>
>>         NULL,                           /* link to next interface */
>>
>>         "127.0.0.1",                    /* IP address */
>>         "255.0.0.0",                    /* IP net mask */
>> };
>> #endif
>>
>>
>> /*
>>  * Default network interface
>>  */
>> static struct rtems_bsdnet_ifconfig netdriver_config = {
>>         RTEMS_BSP_NETWORK_DRIVER_NAME,          /* name */
>>         RTEMS_BSP_NETWORK_DRIVER_ATTACH,        /* attach function */
>>
>>
>> #ifdef RTEMS_USE_LOOPBACK
>>         &loopback_config,               /* link to next interface */
>> #else
>>         NULL,                           /* No more interfaces */
>> #endif
>>
>> #if (defined (RTEMS_USE_BOOTP))
>>         NULL,                           /* BOOTP supplies IP address */
>>         NULL,                           /* BOOTP supplies IP net mask */
>> #else
>>         //"XXX.YYY.ZZZ.XYZ",            /* IP address */
>>
>> #ifdef USE_QEMU
>>         "192.168.10.230",               /* IP address */
>> #else
>>         "192.168.1.230",                /* IP address */
>> #endif
>>
>>         "255.255.255.0",                /* IP net mask */
>> #endif /* !RTEMS_USE_BOOTP */
>>
>> #if (defined (RTEMS_SET_ETHERNET_ADDRESS))
>>         ethernet_address,               /* Ethernet hardware address */
>> #else
>>         NULL,                           /* Driver supplies hardware address */
>> #endif
>>
>>
>> #ifndef USE_QEMU
>>         0                               /* Use default driver parameters */
>> #else
>>         0,                              /* Use default driver parameters */
>>         0,
>>         0,
>>         0,
>>
>>         0x300,
>>         9,
>>         0
>> #endif
>> };
>>
>> /*
>>  * Network configuration
>>  */
>> struct rtems_bsdnet_config rtems_bsdnet_config = {
>>         &netdriver_config,
>>
>> #if (defined (RTEMS_USE_BOOTP))
>>         rtems_bsdnet_do_bootp,
>> #else
>>         NULL,
>> #endif
>>
>>         0,                      /* Default network task priority */
>>         0,                      /* Default mbuf capacity */
>>         0,                      /* Default mbuf cluster capacity */
>>
>> #if (!defined (RTEMS_USE_BOOTP))
>>         "IanVM-N0",             /* Host name */
>>         "nodomain.com",         /* Domain name */
>>         "192.168.1.254",        /* Gateway */
>>         "192.168.1.241",        /* Log host */
>>         {"192.168.1.106" },     /* Name server(s) */
>>         {"192.168.1.241" },     /* NTP server(s) */
>>
>>         /*
>>          *  A real example -- DO NOT USE THIS YOURSELF!!!
>>          */
>>
>> #if 0
>>         "dy4",                  /* Host name */
>>         "NOT_oarcorp.com",      /* Domain name */
>>         "192.168.1.2",          /* Gateway */
>>         "192.168.1.2",          /* Log host */
>>         {"192.168.1.2" },       /* Name server(s) */
>>         {"192.168.1.2" },       /* NTP server(s) */
>> #endif
>> #endif /* !RTEMS_USE_BOOTP */
>>
>> };
>>
>> /*
>>  * For TFTP test application
>>  */
>> #if (defined (RTEMS_USE_BOOTP))
>> #define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST"
>> #define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE"
>> #else
>> #define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ"
>> #define RTEMS_TFTP_TEST_FILE_NAME "tftptest"
>> #endif
>>
>> #endif /* _RTEMS_NETWORKCONFIG_H_ */
>>
>>
>>
>>
>>
>>
>>  				
>> --------------
>> Ian Jiang
>> ianjiang.cn at gmail.com
>> 2007-11-27 20:09:23
>>
>> _______________________________________________
>> rtems-users mailing list
>> rtems-users at rtems.com
>> http://rtems.rtems.org/mailman/listinfo/rtems-users
>>   
>
>
 				
				
--------------
Ian Jiang
ianjiang.cn at gmail.com
2007-11-28 10:32:15




More information about the users mailing list