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


Ignore:
Timestamp:
Nov 20, 2008, 3:17:07 PM (11 years ago)
Author:
Robert
Comment:

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, ...

Legend:

Unmodified
Added
Removed
Modified
  • Developer/Eclipse/Plugin

    v1 v1  
     1= RTEMS Eclipse Plug-in =
     2
     3= Introduction =
     4
     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
     11
     12= Current Capabilities =
     13
     14Here is a list of its main features:
     15
     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
     18#Cross-compilation
     19#Post-build infrastructure with implementation of boot image generation
     20#Remote GDB integration (via serial GDB stub)
     21= Limitations =
     22
     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 =
     27
     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 http://java.sun.com/javase/downloads/index.jsp. My JDK version is 1.5.0_10. You can check the version using "java -version".
     35= Eclipse, CDT and RTEMS Plug-in Installation =
     36
     37
     38Note:
     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.
     42
     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 =
     46
     47
     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.
     49
     50  RTEMS_TOOLSET=i386-rtems4.9-ar, i386-rtems4.9-as, i386-rtems4.9-gcc, i386-rtems4.9-g++
     51
     52 *  RTEMS_BSP_DEFINED_SYMBOLS holds BSP defined symbols determined by configuration.
     53
     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:
     55
     56  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
     57
     58 *  RTEMS_INSTALL_BSP_DIR holds directory of the installed BSP
     59
     60  RTEMS_INSTALL_BSP_DIR=C:\opt\rtems_install\i386-rtems4.9\pc686
     61
     62 *  RTEMS_INSTALL_DIR holds the install directory of built BSP (i.e., the --prefix in configure)
     63
     64  RTEMS_INSTALL_DIR=C:\opt\rtems_install
     65
     66 *  RTEMS_TARGET_CPU_GCC_LIB_DIR holds the GCC lib directory for target CPU
     67
     68  RTEMS_TARGET_CPU_GCC_LIB_DIR=C:\opt\rtems-4.9\lib\gcc\i386-rtems4.9\4.3.2\mpentiumpro
     69
     70 *  RTEMS_TOOL_DIR holds the directory of toolset
     71
     72  RTEMS_TOOL_DIR=C:\opt\rtems-4.9
     73
     74 *  RTEMS_TARGET_TOOL_DIR holds the directory of target toolset
     75
     76  RTEMS_TARGET_TOOL_DIR=C:\opt\rtems-4.9\i386-rtems4.9
     77
     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 =
     80
     81There 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.
     82
     83#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".
     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 =
     89
     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 =
     93
     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., http://download.eclipse.org/tools/cdt/releases/ganymede) from: http://www.eclipse.org/cdt/downloads.php
     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 =
     100
     101#Close Eclipse if it's running.
     102#Download the zip file RtemsEclipsePlug-in.zip from ftp://ftp.rtems.com/pub/rtems/RtemsEclipsePlugin.zip.
     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 =
     108
     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 =
     115
     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:
     122{{{
     123/*
     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 */
     131
     132#define CONFIGURE_INIT
     133
     134#include <stdio.h>
     135#include <stdlib.h>
     136
     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 */
     142
     143#include <rtems.h>
     144#include <rtems/shell.h>
     145
     146// BSP specific include
     147#include <bsp.h>
     148#include <bsp/uart.h>
     149#include <bsp/tty_drv.h>
     150
     151
     152extern rtems_task Init(rtems_task_argument argument);
     153
     154#define CONFIGURE_APPLICATION_EXTRA_DRIVERS  TTY1_DRIVER_TABLE_ENTRY
     155
     156#ifdef RTEMS_BSP_HAS_IDE_DRIVER
     157#include <libchip/ata.h> /* for ata driver prototype */
     158#include <libchip/ide_ctrl.h> /* for general ide driver prototype */
     159#endif
     160
     161#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     162#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     163#ifdef RTEMS_BSP_HAS_IDE_DRIVER
     164#define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
     165#endif
     166#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
     167#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
     168
     169/*
     170 * these values are higher than needed...
     171 */
     172#define CONFIGURE_MAXIMUM_TASKS             20
     173#define CONFIGURE_MAXIMUM_SEMAPHORES        20
     174#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES    20
     175#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
     176#define STACK_CHECKER_ON
     177#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     178
     179#define CONFIGURE_EXTRA_TASK_STACKS         (6 * RTEMS_MINIMUM_STACK_SIZE)
     180
     181#define CONFIGURE_MALLOC_STATISTICS
     182
     183
     184#include <rtems/confdefs.h>
     185
     186
     187#define CONFIGURE_SHELL_COMMANDS_INIT
     188#define CONFIGURE_SHELL_COMMANDS_ALL
     189
     190#include <rtems/shellconfig.h>
     191
     192extern int BSPConsolePort;
     193
     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;
     200
     201/*
     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   //}
     218
     219   // Initialize GDB stub itself
     220   set_debug_traps();
     221
     222   // Initialize GDB break in capability
     223   // It has to be called after set_debug_traps
     224   i386_stub_glue_init_breakin();
     225
     226   // Put breakpoint in
     227   breakpoint();
     228}
     229
     230void testIO(char *devName) {
     231  char buffer[256];
     232
     233  #ifdef TEST_COM1
     234    printf("*** Simple COM1 Test (9600 8N1) ***\n");
     235  #else
     236    printf("*** Simple Remote Debug Test ***\n");
     237  #endif
     238
     239  int fd = open(devName, O_RDWR | O_NOCTTY | _FNDELAY);
     240
     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  }
     245
     246  numBytes = read(fd, buffer, 255);
     247  if (numBytes < 0) {
     248    printf("\nFailed to read from %s!\n", devName);
     249
     250  } else {
     251    buffer[numBytes] = 0; // terminate
     252    printf(buffer);
     253  }
     254
     255  close(fd);
     256 }
     257
     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  );
     268}
     269
     270rtems_task Init(rtems_task_argument ignored) {
     271#ifdef TEST_COM1
     272  char devName[] = "/dev/ttyS1";
     273#else
     274  char devName[] = "/dev/console";
     275
     276  setupRemoteGDB();
     277#endif
     278
     279  testIO(devName);
     280
     281  startShell();
     282
     283  exit( 0 );
     284}
     285}}}
     286
     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 =
     289
     290
     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  =
     298
     299
     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 mkiso.sh.
     302{{{
     303#! /bin/sh
     304
     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
     306
     307}}}
     308
     309Note: Might be able to combine the above 2 steps into one.
     310= Remote GDB Integration =
     311
     312
     313Note: as shown below, Zylin CDT plug-in is not needed.
     314
     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]]