Changes between Initial Version and Version 1 of Developer/Eclipse/Plugin

Nov 20, 2008, 3:17:07 PM (11 years ago)

New page: ==Introduction== 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, ...


  • Developer/Eclipse/Plugin

    v1 v1  
     1= RTEMS Eclipse Plug-in =
     3= Introduction =
     5This 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:
     6 *  Generate skeleton code
     7 *  Compile
     8 *  Link
     9 *  Generate boot image and externally start up the system (in simulator)
     10 *  Setup break points, and hook GDB to the remote target
     12= Current Capabilities =
     14Here is a list of its main features:
     16#Editing features come with Eclipse/CDT, such as  syntax error checking, refactoring, etc.
     17#RTEMS specific template enabling auto-generation of skeleton code via new-project wizard
     19#Post-build infrastructure with implementation of boot image generation
     20#Remote GDB integration (via serial GDB stub)
     21= Limitations =
     23#Currently there is only one configuration to build executables, and no configuration to build libraries yet.
     24#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.
     25#GDB with CEXP is not tried yet.
     26= Starting Point =
     28It's assume that we start from the environment constructed by the end of
     29''[wiki:Developer/Simulators/VMWare Simulate Serial Communication Application]''.
     30In other words, it assumes that
     31#RTEMS MinGW toolset has been installed according to [wiki:TBR/UserManual/MinGW_Tools_for_Windows Windows Installers]
     32#Build, boot and simulation (or real hardware) environment has been setup according to ''[wiki:Developer/VirtualMachines/VMWareSetup MinGW:Grub2:VMWare Development Environment Setup]''
     33#Serial communication hardware has been proven to work with RTEMS. Refer to ''[wiki:Developer/Simulators/VMWare Simulate Serial Communication Application]''.
     34#JDK with version at least 1.5 is installed. If not, download one from My JDK version is 1.5.0_10. You can check the version using "java -version".
     35= Eclipse, CDT and RTEMS Plug-in Installation =
     39 *  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:
     40 /opt/src/rtems/rtems-4.9.0/configure --target=i386-rtems4.9 --enable-rtemsbsp=pc686 --enable-cxx --enable-rdbg --prefix=/opt/rtems_install
     41 *  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.
     43  /* BSP_uart_init(uart, 38400, CHR_8_BITS, 0, 0, 0); */
     44  BSP_uart_init(uart,   115200, CHR_8_BITS, 0, 0, 0);
     45= Setup RTEMS Environment Variables =
     48 *  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.
     50  RTEMS_TOOLSET=i386-rtems4.9-ar, i386-rtems4.9-as, i386-rtems4.9-gcc, i386-rtems4.9-g++
     52 *  RTEMS_BSP_DEFINED_SYMBOLS holds BSP defined symbols determined by configuration.
     54From 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:
     58 *  RTEMS_INSTALL_BSP_DIR holds directory of the installed BSP
     60  RTEMS_INSTALL_BSP_DIR=C:\opt\rtems_install\i386-rtems4.9\pc686
     62 *  RTEMS_INSTALL_DIR holds the install directory of built BSP (i.e., the --prefix in configure)
     64  RTEMS_INSTALL_DIR=C:\opt\rtems_install
     66 *  RTEMS_TARGET_CPU_GCC_LIB_DIR holds the GCC lib directory for target CPU
     68  RTEMS_TARGET_CPU_GCC_LIB_DIR=C:\opt\rtems-4.9\lib\gcc\i386-rtems4.9\4.3.2\mpentiumpro
     70 *  RTEMS_TOOL_DIR holds the directory of toolset
     72  RTEMS_TOOL_DIR=C:\opt\rtems-4.9
     74 *  RTEMS_TARGET_TOOL_DIR holds the directory of target toolset
     76  RTEMS_TARGET_TOOL_DIR=C:\opt\rtems-4.9\i386-rtems4.9
     78When 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.
     79= Install Eclipse =
     81There are several ways to install Eclipse and CDT. Take a look of We need Eclipse and CDT of the simultaneous release no earlier than Ganymede SR1 release. One of the possible ways is described below.
     83#Download "Eclipse for RCP/Plug-in Developers" from The file name would look like "".
     84#Unzip it to a directory like c:/java. c:/java will be used in the rest of this document.
     85#(Optional) Rename c:/java/eclipse to c:/java/eclipseCDT. c:/java/eclipseCDT will be used in the rest of this document.
     86#(Optional) Create short-cut of c:/java/eclipseCDT/eclipse.exe on Windows desktop.
     87#Create a directory (e.g., c:/java/CDT_workspace) for Eclipse workspace
     88= Initial Eclipse Launch =
     90#Double click on the above eclipse short-cut, and select the workspace created above (e.g., c:/java/CDT_workspace)
     91#Go to workbench
     92= Install or Update CDT =
     94"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.
     95#In Eclipse, select menu "Help | Software Updates...", then select "Available Software", and click on "Add Site..."
     96#Fill in "Location" field with CDT update URL (e.g., from:
     97#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.
     98#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".
     99= Install RTEMS Eclipse Plug-in =
     101#Close Eclipse if it's running.
     102#Download the zip file from
     103#Install it in one of the following ways
     104#*Unzip it into c:/java/eclipseCDT
     105#*Unzip it into a temporary location, then copy org.rtems.cdt.toolchain_x.y.z.jar into c:/java/eclipseCDT/plug-ins.
     106#Start Eclipse
     107= Note about Updating Plug-in =
     109When the time comes to update RTEMS plug-in, in order to workaround a caching issue in Eclipse, do the following:
     110#Close Eclipse if it's running.
     111#Delete RTEMS plug-in jar file from c:/java/eclipseCDT/plug-ins.
     112#Start Eclipse, after it opens up, close it.
     113#Follow the above steps to install the plug-in as a fresh new install.
     114= Application Skeleton Code Auto-Generation =
     116#Go to C/C++ perspective if it's in other perspective
     117#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]]
     118#Click "Next", and you can fill information in the "Basic Settings" page or simply click on "Next".
     119#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.
     120#Try menu "Project" | "Clean..." to clean and rebuild it.
     121#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:
     124 *  File Name   : SerialRemoteDebug.c
     125 *  Author      : Your name here
     126 *  Version     : 1.0
     127 *  Description : A simple serial and shell test program if defined TEST_COM1;
     128 *                A serial remote debug test program otherwise
     129 *  Copyright   : Your copyright notice
     130 */
     132#define CONFIGURE_INIT
     134#include <stdio.h>
     135#include <stdlib.h>
     137#include <string.h>  /* String function definitions */
     138#include <unistd.h>  /* UNIX standard function definitions */
     139#include <fcntl.h>   /* File control definitions */
     140#include <errno.h>   /* Error number definitions */
     141#include <termios.h> /* POSIX terminal control definitions */
     143#include <rtems.h>
     144#include <rtems/shell.h>
     146// BSP specific include
     147#include <bsp.h>
     148#include <bsp/uart.h>
     149#include <bsp/tty_drv.h>
     152extern rtems_task Init(rtems_task_argument argument);
     157#include <libchip/ata.h> /* for ata driver prototype */
     158#include <libchip/ide_ctrl.h> /* for general ide driver prototype */
     170 * these values are higher than needed...
     171 */
     172#define CONFIGURE_MAXIMUM_TASKS             20
     173#define CONFIGURE_MAXIMUM_SEMAPHORES        20
     176#define STACK_CHECKER_ON
     184#include <rtems/confdefs.h>
     190#include <rtems/shellconfig.h>
     192extern int BSPConsolePort;
     194/* Temporarily worked around the issue with remote_debug in i386.
     195   "int     remote_debug;" is defined in m68k-stub.c, but only declared
     196   in i386-stub.c. Also except "remote_debug = !(remote_debug);", nowhere else
     197   value is assigned to remote_debug.
     198 */
     199int remote_debug = 1;
     202 * Setup GDB as described in c\src\lib\libbsp\i386\shared\comm\GDB.HOWTO.
     203 *
     204 * Later found similar function: init_remote_gdb in
     205 * c\src\lib\libbsp\i386\shared\comm\gdb_glue.c. But it does not fit with the
     206 * following hardware configuration:
     207 *       there exist VGA console and COM1, but not COM2.
     208 */
     209void setupRemoteGDB(void) {
     210   // Initialize GDB glue
     211   /*
     212   if(BSPConsolePort != BSP_UART_COM2) {
     213        // If com2 is not used as console use it for debugging
     214       i386_stub_glue_init(BSP_UART_COM2);
     215   } else { // Otherwise use com1  */
     216       i386_stub_glue_init(BSP_UART_COM1);
     217   //}
     219   // Initialize GDB stub itself
     220   set_debug_traps();
     222   // Initialize GDB break in capability
     223   // It has to be called after set_debug_traps
     224   i386_stub_glue_init_breakin();
     226   // Put breakpoint in
     227   breakpoint();
     230void testIO(char *devName) {
     231  char buffer[256];
     233  #ifdef TEST_COM1
     234    printf("*** Simple COM1 Test (9600 8N1) ***\n");
     235  #else
     236    printf("*** Simple Remote Debug Test ***\n");
     237  #endif
     239  int fd = open(devName, O_RDWR | O_NOCTTY | _FNDELAY);
     241  int numBytes = write(fd, "Hello, I'm waiting for input...\r\n", 33);
     242  if (numBytes < 0) {
     243    printf("\nFailed to write to %s!\n", devName);
     244  }
     246  numBytes = read(fd, buffer, 255);
     247  if (numBytes < 0) {
     248    printf("\nFailed to read from %s!\n", devName);
     250  } else {
     251    buffer[numBytes] = 0; // terminate
     252    printf(buffer);
     253  }
     255  close(fd);
     256 }
     258void startShell(void) {
     259  printf("\n====== starting shell ======\n");
     260  rtems_shell_init(
     261    "SHLL",                          /* task_name */
     262    RTEMS_MINIMUM_STACK_SIZE * 4,    /* task_stacksize */
     263    100,                             /* task_priority */
     264    "/dev/console",                  /* devname */
     265    0,                               /* forever */
     266    1                                /* wait */
     267  );
     270rtems_task Init(rtems_task_argument ignored) {
     271#ifdef TEST_COM1
     272  char devName[] = "/dev/ttyS1";
     274  char devName[] = "/dev/console";
     276  setupRemoteGDB();
     279  testIO(devName);
     281  startShell();
     283  exit( 0 );
     2876. 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]]
     288= RTEMS Specific Customization Features =
     291#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]]
     292#Default defined symbols for C/C++ compiler (previous ones are for general editing features)[[BR]]<center>[[Image(IDE_C_CPP_Symbols.jpg)]]</center>[[BR]]
     293#Default miscellaneous compiler settings [[BR]]<center>[[Image(IDE_Compiler_Misc.jpg)]]</center>[[BR]]
     294#Default shared libgcc linker setting [[BR]]<center>[[Image(IDE_Link_Shared.jpg)]]</center>[[BR]]
     295#Default miscellaneous linker settings [[BR]]<center>[[Image(IDE_Linker_Misc.jpg)]]</center>[[BR]]
     296#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]]
     297= Post-build Infrastructure  =
     300#Post-build step equivalent to "make install" [[BR]]<center>[[Image(IDE_Post_Build.jpg)]]</center>[[BR]]
     301#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
     303#! /bin/sh
     305grub-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
     309Note: Might be able to combine the above 2 steps into one.
     310= Remote GDB Integration =
     313Note: as shown below, Zylin CDT plug-in is not needed.
     315#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]]
     316#Fill in "Debugger" page exactly as shown below.[[BR]]<center>[[Image(IDE_Cfg_Debugger.jpg)]]</center>[[BR]]
     317#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]]
     318#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]]
     319#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]]