Changes between Version 3 and Version 4 of Developer/Eclipse/Plugin


Ignore:
Timestamp:
Dec 22, 2008, 6:36:26 PM (11 years ago)
Author:
Sh
Comment:

Update for new plug-in.

Legend:

Unmodified
Added
Removed
Modified
  • Developer/Eclipse/Plugin

    v3 v4  
    22
    33
    4 {| border="0" cellpadding="5" cellspacing="0" align="right"
     4{| border="" cellpadding="5" cellspacing="0" align="right"
    55|-
    66! style="background:#efefef;" |
     
    88= Introduction =
    99
    10 This page describes how to setup and use RTEMS Eclipse Plug-in. This plug-in has most features of a full-fledged Eclipse/CDT IDE with ordinary GNU toolchain. After setup, except typing in project name and post build commands, with only mouse clicks, it can finish the whole process of:
    11  *  Generate skeleton code
    12  *  Compile
    13  *  Link
    14  *  Generate boot image and externally start up the system (in simulator)
    15  *  Setup break points, and hook GDB to the remote target
    16 
    17 = Current Capabilities =
    18 
    19 Here is a list of its main features:
    20 
    21 #Editing features come with Eclipse/CDT, such as  syntax error checking, refactoring, etc.
    22 #RTEMS specific template enabling auto-generation of skeleton code via new-project wizard
    23 #Cross-compilation
    24 #Post-build infrastructure with implementation of boot image generation
    25 #Remote GDB integration (via serial GDB stub)
    26 = Limitations =
    27 
    28 #Currently there is only one configuration to build executables, and no configuration to build libraries yet.
    29 #Due to hard and soft resource constraint, I only tested the plug-in against i386 target on Windows (and it's done with simulation). For other targets, I only verified that corresponding toolset could be invoked. Since Eclipse and the plug-in are written in Java, it's likely they would work in most host environments.
    30 #GDB with CEXP is not tried yet.
     10This page describes how to setup and use the RTEMS Eclipse Plug-in.  This plug-in extends [http://www.eclipse.org/cdt CDT] and most features of a full-fledged Eclipse/CDT IDE with an ordinary GNU toolchain are available (debugging is not yet tested).  Supported platforms are: Cygwin, MinGW, MacOS X and UNIX.  Every RTEMS target architecture and BSP that provides the standard Makefiles is supported.  This are at least the ones managed by the RTEMS repository from OAR.
    3111= Starting Point =
    3212
    33 It's assume that we start from the environment constructed by the end of
    34 ''[wiki:Developer/Simulators/VMWare Simulate Serial Communication Application]''.
    35 In other words, it assumes that
    36 #RTEMS MinGW toolset has been installed according to [wiki:TBR/UserManual/MinGW_Tools_for_Windows Windows Installers]
    37 #Build, boot and simulation (or real hardware) environment has been setup according to ''[wiki:Developer/VirtualMachines/VMWareSetup MinGW:Grub2:VMWare Development Environment Setup]''
    38 #Serial communication hardware has been proven to work with RTEMS. Refer to ''[wiki:Developer/Simulators/VMWare Simulate Serial Communication Application]''.
    39 #JDK with version at least 1.5 is installed. If not, download one from http://java.sun.com/javase/downloads/index.jsp. My JDK version is 1.5.0_10. You can check the version using "java -version".
    40 = Eclipse, CDT and RTEMS Plug-in Installation =
     13You should be able to build a simple Hello World application for your BSP with the standard Makefiles.
     14= Eclipse Installation =
    4115
     16The plug-in has been developed for the Gandymede release of Eclipse and CDT version 5.  Other releases may work but are not tested.  If you have not yet installed Eclipse simply choose the package [http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-cpp-ganymede-SR1-win32.zip Eclipse IDE for C/C++ Developers] or what ever you want from the [http://www.eclipse.org/downloads Eclipse download page].  An existing Eclipse installation needs a recent [http://www.eclipse.org/cdt CDT plug-in] (version 5 is recomended).  The ''Eclipse IDE for C/C++ Developers'' already contains all required plug-ins.
     17= Plug-In Installation =
    4218
    43 Note:
    44  *  For this plug-in development, I put RTEMS source code under C:/opt/src/rtems, my build directory is C:/opt/src/rtems/i386_build, and it's configured as the following:
    45  /opt/src/rtems/rtems-4.9.0/configure --target=i386-rtems4.9 --enable-rtemsbsp=pc686 --enable-cxx --enable-rdbg --prefix=/opt/rtems_install
    46  *  If desired, it's better to change baud rate now in c\src\lib\libbsp\i386\shared\comm\i386-stub-glue.c as the following, and build or rebuild. The reason is that when verbose option is enabled, GDB becomes slow with low baud rate.
     19You can install the plug-in via the standard Eclipse infrastucture.  Simply add http://www.rtems.com/ftp/pub/rtems/eclipse/updates to the software update sites ('''Help > Software Updates...''').
    4720
    48   /* BSP_uart_init(uart, 38400, CHR_8_BITS, 0, 0, 0); */
    49   BSP_uart_init(uart,   115200, CHR_8_BITS, 0, 0, 0);
    50 = Setup RTEMS Environment Variables =
     21<center>[[Image(repi-install.jpg)]]</center>
     22= Plug-In Setup =
    5123
     24After the plug-in installation you should setup the preferences ('''Window > Preferences''').
    5225
    53  *  RTEMS_TOOLSET holds set of GNU tool commands in the order of Archive, Assembler, C Compiler, C++ Compiler. It defaults to i386 target toolset if undefined, so you don't need define it if you build i386 target.
     26<center>[[Image(repi-setup.jpg)]]</center>
     27= Project Creation =
    5428
    55   RTEMS_TOOLSET=i386-rtems4.9-ar, i386-rtems4.9-as, i386-rtems4.9-gcc, i386-rtems4.9-g++
     29Switch to the ''C/C++ Perpective'' ('''Window > Open Perspective > Other...''').  You can now create a new ''C Project'' or ''C++ Project'' ('''File > New > C Project''' or '''File > New > C++ Project''') and follow the wizard.
    5630
    57  *  RTEMS_BSP_DEFINED_SYMBOLS holds BSP defined symbols determined by configuration.
    58 
    59 From DEFS of a generated Makefile like "i386_build\i386-rtems4.9\c\pc686\testsuites\samples\Makefile", extract all -DXYZ=1, remove "-D" and "=1", and then set the variable like the following:
    60 
    61   RTEMS_BSP_DEFINED_SYMBOLS=STDC_HEADERS, HAVE_SYS_TYPES_H, HAVE_SYS_STAT_H, HAVE_STDLIB_H, HAVE_STRING_H, HAVE_INTTYPES_H, HAVE_STDINT_H, HAVE_UNISTD_H, HAVE_CSTDIO, HAVE_CSTDLIB, HAVE_IOSTREAM
    62 
    63  *  RTEMS_INSTALL_BSP_DIR holds directory of the installed BSP
    64 
    65   RTEMS_INSTALL_BSP_DIR=C:\opt\rtems_install\i386-rtems4.9\pc686
    66 
    67  *  RTEMS_INSTALL_DIR holds the install directory of built BSP (i.e., the --prefix in configure)
    68 
    69   RTEMS_INSTALL_DIR=C:\opt\rtems_install
    70 
    71  *  RTEMS_TARGET_CPU_GCC_LIB_DIR holds the GCC lib directory for target CPU
    72 
    73   RTEMS_TARGET_CPU_GCC_LIB_DIR=C:\opt\rtems-4.9\lib\gcc\i386-rtems4.9\4.3.2\mpentiumpro
    74 
    75  *  RTEMS_TOOL_DIR holds the directory of toolset
    76 
    77   RTEMS_TOOL_DIR=C:\opt\rtems-4.9
    78 
    79  *  RTEMS_TARGET_TOOL_DIR holds the directory of target toolset
    80 
    81   RTEMS_TARGET_TOOL_DIR=C:\opt\rtems-4.9\i386-rtems4.9
    82 
    83 When the plug-in cannot construct bin, lib or include path, it'll be disabled, and won't show up, just like other toolchains won't show up when a RTEMS template is selected.
    84 = Install Eclipse =
    85 
    86 There are several ways to install Eclipse and CDT. Take a look of http://www.eclipse.org/downloads/packages/compare-packages. We need Eclipse and CDT of the simultaneous release no earlier than Ganymede SR1 release. One of the possible ways is described below.
    87 
    88 #Download "Eclipse for RCP/Plug-in Developers" from http://www.eclipse.org/downloads. The file name would look like "eclipse-rcp-ganymede-SR1-win32.zip".
    89 #Unzip it to a directory like c:/java. c:/java will be used in the rest of this document.
    90 #(Optional) Rename c:/java/eclipse to c:/java/eclipseCDT. c:/java/eclipseCDT will be used in the rest of this document.
    91 #(Optional) Create short-cut of c:/java/eclipseCDT/eclipse.exe on Windows desktop.
    92 #Create a directory (e.g., c:/java/CDT_workspace) for Eclipse workspace
    93 = Initial Eclipse Launch =
    94 
    95 #Double click on the above eclipse short-cut, and select the workspace created above (e.g., c:/java/CDT_workspace)
    96 #Go to workbench
    97 = Install or Update CDT =
    98 
    99 "Eclipse for RCP/Plug-in Developers" package does not come with CDT. "Eclipse IDE for C/C++ Developers" does not come with the debugger we need. Thus in all cases, this step is necessary.
    100 #In Eclipse, select menu "Help | Software Updates...", then select "Available Software", and click on "Add Site..."
    101 #Fill in "Location" field with CDT update URL (e.g., http://download.eclipse.org/tools/cdt/releases/ganymede) from: http://www.eclipse.org/cdt/downloads.php
    102 #Select all CDT features except any of XL C/C++ Compiler features, then click on "Install...", and follow instructions to finish the update. If you install XL C/C++ Compiler features, you might get annoying error or warning down the road.
    103 #After Eclipse restarts, verify that you have "Eclipse GDB Hardware Debugging Plug-in" installed by selecting menu "Help | About Eclipse Platform" and CLick on "Feature Details".
    104 = Install RTEMS Eclipse Plug-in =
    105 
    106 #Close Eclipse if it's running.
    107 #Download the zip file RtemsEclipsePlug-in.zip from http://www.rtems.org/ftp/pub/rtems/eclipse/RtemsEclipsePlugin-20081120.zip.
    108 #Install it in one of the following ways
    109 #*Unzip it into c:/java/eclipseCDT
    110 #*Unzip it into a temporary location, then copy org.rtems.cdt.toolchain_x.y.z.jar into c:/java/eclipseCDT/plug-ins.
    111 #Start Eclipse
    112 = Note about Updating Plug-in =
    113 
    114 When the time comes to update RTEMS plug-in, in order to workaround a caching issue in Eclipse, do the following:
    115 #Close Eclipse if it's running.
    116 #Delete RTEMS plug-in jar file from c:/java/eclipseCDT/plug-ins.
    117 #Start Eclipse, after it opens up, close it.
    118 #Follow the above steps to install the plug-in as a fresh new install.
    119 = Application Skeleton Code Auto-Generation =
    120 
    121 #Go to C/C++ perspective if it's in other perspective
    122 #Select menu File | New | C Project, type in project name "SerialRemoteDebug", then select "RTEMS Serial Remote Debug Project" template under "Executable", and the only applicable "RTEMS Toolchain" is automatically selected.[[BR]]<center>[[Image(IDE_New_Project.jpg)]]</center>[[BR]]
    123 #Click "Next", and you can fill information in the "Basic Settings" page or simply click on "Next".
    124 #Click on "Next", and then click on "Finish". By default, "Build Automatically" is turned on, and without any manual source code edit ting and manual configuration, the project is built automatically, and the executable is created.
    125 #Try menu "Project" | "Clean..." to clean and rebuild it.
    126 #From "Project Explorer", open src/SerialRemoteDebug.c. You can see it has been automatically based on the template.[[BR]]<center>[[Image(IDE_New_File_Bld.jpg)]]</center>[[BR]]Noticed the include paths which are made available through auto-discovery customization. They are necessary for features like indexing, syntax error checking, etc.  Here is the generated code:
    127 {{{
    128 /*
    129  *  File Name   : SerialRemoteDebug.c
    130  *  Author      : Your name here
    131  *  Version     : 1.0
    132  *  Description : A simple serial and shell test program if defined TEST_COM1;
    133  *                A serial remote debug test program otherwise
    134  *  Copyright   : Your copyright notice
    135  */
    136 
    137 #define CONFIGURE_INIT
    138 
    139 #include <stdio.h>
    140 #include <stdlib.h>
    141 
    142 #include <string.h>  /* String function definitions */
    143 #include <unistd.h>  /* UNIX standard function definitions */
    144 #include <fcntl.h>   /* File control definitions */
    145 #include <errno.h>   /* Error number definitions */
    146 #include <termios.h> /* POSIX terminal control definitions */
    147 
    148 #include <rtems.h>
    149 #include <rtems/shell.h>
    150 
    151 // BSP specific include
    152 #include <bsp.h>
    153 #include <bsp/uart.h>
    154 #include <bsp/tty_drv.h>
    155 
    156 
    157 extern rtems_task Init(rtems_task_argument argument);
    158 
    159 #define CONFIGURE_APPLICATION_EXTRA_DRIVERS  TTY1_DRIVER_TABLE_ENTRY
    160 
    161 #ifdef RTEMS_BSP_HAS_IDE_DRIVER
    162 #include <libchip/ata.h> /* for ata driver prototype */
    163 #include <libchip/ide_ctrl.h> /* for general ide driver prototype */
    164 #endif
    165 
    166 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
    167 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    168 #ifdef RTEMS_BSP_HAS_IDE_DRIVER
    169 #define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
    170 #endif
    171 #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
    172 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
    173 
    174 /*
    175  * these values are higher than needed...
    176  */
    177 #define CONFIGURE_MAXIMUM_TASKS             20
    178 #define CONFIGURE_MAXIMUM_SEMAPHORES        20
    179 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES    20
    180 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
    181 #define STACK_CHECKER_ON
    182 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    183 
    184 #define CONFIGURE_EXTRA_TASK_STACKS         (6 * RTEMS_MINIMUM_STACK_SIZE)
    185 
    186 #define CONFIGURE_MALLOC_STATISTICS
    187 
    188 
    189 #include <rtems/confdefs.h>
    190 
    191 
    192 #define CONFIGURE_SHELL_COMMANDS_INIT
    193 #define CONFIGURE_SHELL_COMMANDS_ALL
    194 
    195 #include <rtems/shellconfig.h>
    196 
    197 extern int BSPConsolePort;
    198 
    199 /* Temporarily worked around the issue with remote_debug in i386.
    200    "int     remote_debug;" is defined in m68k-stub.c, but only declared
    201    in i386-stub.c. Also except "remote_debug = !(remote_debug);", nowhere else
    202    value is assigned to remote_debug.
    203  */
    204 int remote_debug = 1;
    205 
    206 /*
    207  * Setup GDB as described in c\src\lib\libbsp\i386\shared\comm\GDB.HOWTO.
    208  *
    209  * Later found similar function: init_remote_gdb in
    210  * c\src\lib\libbsp\i386\shared\comm\gdb_glue.c. But it does not fit with the
    211  * following hardware configuration:
    212  *       there exist VGA console and COM1, but not COM2.
    213  */
    214 void setupRemoteGDB(void) {
    215    // Initialize GDB glue
    216    /*
    217    if(BSPConsolePort != BSP_UART_COM2) {
    218         // If com2 is not used as console use it for debugging
    219        i386_stub_glue_init(BSP_UART_COM2);
    220    } else { // Otherwise use com1  */
    221        i386_stub_glue_init(BSP_UART_COM1);
    222    //}
    223 
    224    // Initialize GDB stub itself
    225    set_debug_traps();
    226 
    227    // Initialize GDB break in capability
    228    // It has to be called after set_debug_traps
    229    i386_stub_glue_init_breakin();
    230 
    231    // Put breakpoint in
    232    breakpoint();
    233 }
    234 
    235 void testIO(char *devName) {
    236   char buffer[256];
    237 
    238   #ifdef TEST_COM1
    239     printf("*** Simple COM1 Test (9600 8N1) ***\n");
    240   #else
    241     printf("*** Simple Remote Debug Test ***\n");
    242   #endif
    243 
    244   int fd = open(devName, O_RDWR | O_NOCTTY | _FNDELAY);
    245 
    246   int numBytes = write(fd, "Hello, I'm waiting for input...\r\n", 33);
    247   if (numBytes < 0) {
    248     printf("\nFailed to write to %s!\n", devName);
    249   }
    250 
    251   numBytes = read(fd, buffer, 255);
    252   if (numBytes < 0) {
    253     printf("\nFailed to read from %s!\n", devName);
    254 
    255   } else {
    256     buffer[numBytes] = 0; // terminate
    257     printf(buffer);
    258   }
    259 
    260   close(fd);
    261  }
    262 
    263 void startShell(void) {
    264   printf("\n====== starting shell ======\n");
    265   rtems_shell_init(
    266     "SHLL",                          /* task_name */
    267     RTEMS_MINIMUM_STACK_SIZE * 4,    /* task_stacksize */
    268     100,                             /* task_priority */
    269     "/dev/console",                  /* devname */
    270     0,                               /* forever */
    271     1                                /* wait */
    272   );
    273 }
    274 
    275 rtems_task Init(rtems_task_argument ignored) {
    276 #ifdef TEST_COM1
    277   char devName[] = "/dev/ttyS1";
    278 #else
    279   char devName[] = "/dev/console";
    280 
    281   setupRemoteGDB();
    282 #endif
    283 
    284   testIO(devName);
    285 
    286   startShell();
    287 
    288   exit( 0 );
    289 }
    290 }}}
    291 
    292 6. Normal editing features like refactoring works (Right mouse click on a symbol | Refactor | Rename...).[[BR]]<center>[[Image(IDE_Refactor.jpg)]]</center>[[BR]]<center>[[Image(IDE_Refactor_Preview.jpg)]]</center>[[BR]]
    293 = RTEMS Specific Customization Features =
    294 
    295 
    296 #Predefined symbols, includes and library paths made available through auto-discovery customization [[BR]]<center>[[Image(IDE_Gen_Includes.jpg)]]</center>[[BR]] <center>[[Image(IDE_Gen_Symbols.jpg)]]</center>[[BR]]<center>[[Image(IDE_Gen_Lib_Paths.jpg)]]</center>[[BR]]
    297 #Default defined symbols for C/C++ compiler (previous ones are for general editing features)[[BR]]<center>[[Image(IDE_C_CPP_Symbols.jpg)]]</center>[[BR]]
    298 #Default miscellaneous compiler settings [[BR]]<center>[[Image(IDE_Compiler_Misc.jpg)]]</center>[[BR]]
    299 #Default shared libgcc linker setting [[BR]]<center>[[Image(IDE_Link_Shared.jpg)]]</center>[[BR]]
    300 #Default miscellaneous linker settings [[BR]]<center>[[Image(IDE_Linker_Misc.jpg)]]</center>[[BR]]
    301 #Default RTEMS specific manager-related relocation linker settings (corresponding to MANAGERS/MANAGERS_NOT_WANTED in Makefile)[[BR]]<center>[[Image(IDE_RTEMS_Specific.jpg)]]</center>[[BR]]
    302 = Post-build Infrastructure  =
    303 
    304 
    305 #Post-build step equivalent to "make install" [[BR]]<center>[[Image(IDE_Post_Build.jpg)]]</center>[[BR]]
    306 #Via menu "Run | External Tools | External Tools Configurations...", create and run an external tool to build boot image and possibly other actions like loading image onto hardware. Since we can start shell and run script, its functionality can be easily extended. [[BR]]<center>[[Image(IDE_Ext_Tool.jpg)]]</center>[[BR]]Here is content of mkiso.sh.
    307 {{{
    308 #! /bin/sh
    309 
    310 grub-mkrescue --overlay=/opt/rtems_install/i386-rtems4.9/pc686/lib/rtems-4.9 --overlay=/opt/rtems_install/grub_cfg /vm/pc686_rtems4.9.0.iso
    311 
    312 }}}
    313 
    314 Note: Might be able to combine the above 2 steps into one.
    315 = Remote GDB Integration =
    316 
    317 
    318 Note: as shown below, Zylin CDT plug-in is not needed.
    319 
    320 #Via menu "Run | Debug Configurations", create a "GDB Hardware Debugging" configuration, and fill in "Main" page as shown below.[[BR]]<center>[[Image(IDE_Dbg_Main.jpg)]]</center>[[BR]]
    321 #Fill in "Debugger" page exactly as shown below.[[BR]]<center>[[Image(IDE_Cfg_Debugger.jpg)]]</center>[[BR]]
    322 #Fill in "Startup" page as shown below. (For baud rate setting, refer to the note regarding baud rate in the installation section.) [[BR]]<center>[[Image(IDE_Dbg_Startup.jpg)]]</center>[[BR]]
    323 #Start the virtual machine (VM) in VMWare (or startup your real hardware), and execution breaks as shown below.[[BR]]<center>[[Image(IDE_VM_Break.jpg)]]</center>[[BR]]
    324 #Setup one or more break points in IDE, and start GDB from IDE. As shown below, if everything works correctly, your GDB on host machine should stop at your 1st break point, and you can evaluate variable values, step through code, etc. [[BR]][[BR]]Enjoy![[BR]]<center>[[Image(IDE_Debugging.jpg)]]</center>[[BR]]
     31<center>[[Image(repi-project.jpg)]]</center>