Red Hat Docs  >  Manuals  >  EDK Manuals  > 

Contents

Previous

Next


Developing for Embedded Systems

The following documentation shows how to create a project with the Embedded DevKit. Before beginning, your host system must be configured for the target in order to work with the tutorial; see Setting Up for Embedded Work if you have not already. Build your project for a native host system, and then for an embedded target board by creating the project file's database table, containing all the project-specific files, symbols, and references to other database files. After creating the project file's database table, develop it into an executable, creating build rules, then compiling and debugging.

To start, see Tutorial for Embedded Development.

Tutorial for Embedded Development

The following tutorial describes how to create a project for embedded work with a target board (examples use the x 86 board). You will change the build rules from working with a host system to work instead with the embedded target. You set up the directories, services and files that your application uses for the host so that the target environment matches your application's filesystem requirements.

In the following tutorial, you will build the httpd-demo for your native and your embedded target. The httpd-demo is a web server-based calendar. When you complete this tutorial, it will be running on your board; you can then connect to it from a web browser.

Creating the Build Rules for the Project

  1. Create the httpd-demo project file before creating build rules for a native project.

    mkdir ~/demos
    cd ~/demos
    cp -R /opt/redhat/edk-000221/examples/httpd-demo .

    Follow the same instructions as with Creating a New Project and Working with a New Project.

  2. From the Symbol Browser, select Tools -> Build Settings to start the Build Settings dialog.

    Build Settings dialog for creating a native project

  3. Enter x86_native as the name of the native build project.
  4. Click Create. The Edit Target dialog opens (Edit Target dialog).

    Edit Target dialog

     

  5. In the Build Directory field, click on the "..." button and select the directory in which you will store the object files and the executable.
  6. Select Executable in the Target Type field.
  7. Select GNUPro (native) in the Tool Chain field.

    See the results in Providing data for Build Directory, Target Type, and Tool Chain fields for the Edit Target dialog fields.

    Providing data for Build Directory, Target Type, and Tool Chain fields

  8. Select all the files on the left hand side of the Edit Target dialog by clicking on the first file and shift-clicking on the last file.
  9. Click Add Files to copy the files to the Target Files list (Project files added to a project).

    Project files added to a project

     

  10. Click the Build Rules tab (Modifying rules for how the project builds).

    Modifying rules for how the project builds

  11. Double click on the line containing the rules that you want to modify (C type, in the example). The Build Rule Settings dialog appears (Selecting Debug method).

    Selecting Debug method

  12. Select Standard Debug from the Debug dropdown menu.
  13. Click the Defines tab to define a macro (Defines tab).

    Defines tab

  14. Enter _GNU_SOURCE in the text entry field (Adding a macro).

    Adding a macro

  15. Click the New button to create the definition. Click OK to close the Build Rule Settings dialog.
  16. Click the Link Rules tab of the Edit Target dialog (Link Rules tab).

    Link Rules tab

  17. Enter -static in the Link flags field.
  18. Click Debug from the Debug/Execute Settings buttons (see Results of modifying Link flags field for results).

    Results of modifying Link flags field

  19. Click OK to close the Edit Target dialog.
  20. Click Done to close the dialog.

You have now created the build target. Now you must compile the program.

Build the Native Application

  1. Select Tools -> Build from the Symbol Browser in Source-Navigator. The Build dialog opens.
  2. In Build Targets, select x86_native from the target list. Click Start (Compiling the x86_native application).

    Compiling the x86_native application

  3. x86_native compiles without errors.
  4. Click Debug to open the Insight visual debugger for debugging the demo on the host machine. See Insight's Help menu or Working with Insight, the Debugger Interface for more information about debugging.
  5. Use a web browser and connect to http://localhost:8080; you should see the calendar.

Working with an Embedded Target

Now that you have created the host demo project, you will create the build target using similar steps to download the project to the x 86 target board.

IMPORTANT!

The PowerPC MBX target board's configuration has different settings.

For more information on the windows, dialog boxes, menus, buttons, and other features and functions of Source-Navigator, see its Help menu.

Setting Up a Target Configuration

Use Source-Navigator's EDK Preferences dialog to specify EDK-specific parameters.

  1. Select File -> EDK Preferences from the Symbol Browser window.
  2. When the EDK Preferences dialog appears (Target tab fields), enter the <target-IP-address> from Network information in the Hostname field.
  3. Enter /tftpboot/<target-IP-address>/zImage in the Boot Image field (<target-IP-address> indicates the target's IP address that the DHCP server assigns, which you determined from Network information).

    Target tab fields

  4. Click the Filesystem tab (Sprecifying information for the Filesystem tab fields).

    Specifying information for the Filesystem tab fields

  5. Select NFS Root as the filesystem.

    Enter /tftpboot/<target-IP-address> in the Root Directory field (where you substitute <target-IP-address> for the value that you determined from Network information).

  6. Click the Kernel tab.
  7. Specifying information for the Modules section of the Kernel

  8. Specify the kernel in the Source Path dialog area.
    • The path to the x 86 kernel should be:
      ~/kernels/linux-2.2.14-5
    • The path to the PowerPC kernel should be:
      ~/kernels/linux-2.2.13

    Select Monolithic in the Modules section.

  1. Click OK to close the EDK Preferences dialog.

Creating an Embedded Target's Build Rules

  1. Now, create the embedded target build rules. Choose Tools -> Build Settings from the Symbol Browser in Source-Navigator to access the Build Settings dialog.
  2. Enter x86_embedded_linux as the name for the build application.

    IMPORTANT!

    The PowerPC MBX target board will use a different naming convention, such as mbx_embedded_linux for the build application.

    Click Create (Adding an embedded build rule). The Edit Target dialog opens.

    Adding an embedded build rule

     

  3. In the Build Directory field, click on the "..." button and select the directory in which you will store the object files and the executable.
  4. Select Executable in the Target Type field.
  5. Select GNUPro (Embedded x86 linux) in the Tool Chain field.
  6. Select all the files on the left hand side of the Edit Target dialog by clicking on the first file and shift-clicking on the last file.
  7. Click Add Files to copy the files to the Target Files list.
  8. Click the Build Rules tab.
  9. Double click on the line containing the rules that you want to modify (C type, in the example). The Build Rule Settings dialog appears.
  10. Select Standard Debug from the Debug dropdown menu.
  11. Click the Defines tab to define the macro.
  12. Enter _GNU_SOURCE in the text entry field (Defining the macro for the embedded target).

    Defining the macro for the embedded target

  13. Click the New button to create the definition.
  14. Click OK to close the Build Rule Settings.
  15. Click the Link Rules tab of the Edit Target dialog.

    Enter -static in the Link flags field.

    Click Debug from the Debug/Execute Settings buttons.

  1. Click OK to close the Edit Target dialog.
    Click Done to close Build Settings.

Build the Rules for an Embedded Project

Now, build the embedded target application.

  1. Select Tools -> Build. The Build dialog opens.
  2. In the Build Targets field, select x86_embedded_linux from the file list.
  3. Click Start (Choosing the embedded application to build).

    Choosing the embedded application to build

  4. x86_embedded_linux generates without errors.

Debug an Executable Application on a Target Board

With the embedded executable application built into a program, you can debug it on the embedded target board with Insight.

  1. Reboot the target board.
    • For the x86 board, insert the boot ROM floppy and power up the board.
    • For the MBX board, start Minicom, power up the board and type the following command at the EPPC-Bug prompt.
      pl 20 0
      The target board will get the boot image, the kernel will reboot, gdbserver will launch and the kernel's console window displays the message:
        Process /app created; pid=8
  2. gdbserver will then be waiting for GDB. Click the OK button from Project to debug.

    Insight launches, stopping at a breakpoint.

    For a native project, click the Run button. For an embedded project, click Run and then click the Continue button.

    For more details on debugging, see Working with Insight, the Debugger Interface.

WARNING!

Do not debug any applications in the background or else debugging will not work.

Run the Executable Application

  1. After you successfully debug the target board application, now set up the application as an executable on the host.
  2. Return to the Symbol Browser to select Tools -> Build Settings to start the Build Settings dialog.
  3. Double-click on x86_embedded_linux. The Edit Target dialog opens. Click the Link Rules tab of the Edit Target dialog (Changing the application).

    Changing the application

  4. Click Execute from the Debug/Execute Settings buttons.
  5. Click OK to close the Edit Target dialog.
  6. From the Symbol Browser, select Tools -> Build to start the Build Settings dialog. Select the x86_embedded_linux target application from the Build Targets drop-down list (Building the executable for the target board).

    Building the executable for the target board

    Click Start.
  7. Restart the target board. When you restart the target board, the application downloads to the target board using the TFTP services.
  8. Start your web browser and, in the location/address field, provide the target board's specific IP address followed by ":8080" (as the following example shows).
      http://192.168.1.100:8080
  9. See a calendar from a web page, running as the executable application from the target board, displaying on the host screen (Executable in a web browser).

    Executable in a web browser


Contents

Previous

Next