Tux
Communication
Mailing lists
Documentation
User Manual
Target board info.
Target chip info.
Support
Linux support
Bugzilla
Downloads
STLinux
Updates
Search
Google


The web
stlinux.com
Using STWorkbench with STLinux
Building and debugging a userspace application
ST Logo
Previous   Contents   Next

Overview

This describes how to create projects to automatically manage builds and how to debug applications using STWorkbench as a remote debugger.

STLinux applications have no intrinsic links to specific target boards, therefore this is applicable to any supported board. However, the following host and target features must be available.

  • The Linux kernel must be booting and running on the target board.
  • When building for an ST40, sh4-linux-gcc and sh4-linux-gdb must be accessable through the host's path.
  • When building for an ST200, st231-linux-gcc and st231-linux-gdb must be accessable through the host's path.
  • gdbserver must be present on the target filesystem.
  • The root user must be able to log in to the target using SSH with an empty password or without being prompted for a password. This is the default, provided the root user has remotely logged in at least once previously.

Creating and building the project

  1. Click File > New > Project.... The New Project window appears.

  2. Select C > C Project from the Wizards tree/list and click Next. The C Project dialog appears.

  3. Enter 'HelloWorld' into the Project name text box

  4. Select Executable from the Project types list

  5. Select ST40 Linux GCC from the Toolchain list.

  6. Click Finish. This bypasses the final page of the wizard but the default values are correct. If an alert appears to confirm a perspective switch, click Yes.

  7. Select HelloWorld from the STWorkbench C/C++ Projects view.

  8. Click File > New > File. The New File window appears.

  9. Enter 'hello.c' into the File name text box and click Finish.

  10. Copy the following into the editor.

    #include <stdio.h> int main() {     int i;     for (i=0; i<25; i++) {         printf("Hello world\n");     }     return 0; }

  11. Select File > Save.

  12. Select Project > Build Project. The application is built.

    If the console output is not displayed automatically, select HelloWorld from the STWorkbench Navigator window.

To explore further, try the following.

  • Add extra source files to your project. These are automatically included in subsequent builds.
  • Introduce warnings or errors into your code. STWorkbench highlights them in the editor and maintains a list of issues in its Problems window.
  • Examine C/C++ Build from Project > Properties. This allows you to switch between Debug and Release builds as well as tweaking other C compiler and linker arguments.

Debugging the project

  1. Select HelloWorld from the STWorkbench Navigator window.

  2. Click Run > Debug.... The Create, manage, and run configurations window appears.

  3. Screenshot of the Debug configuration dialog

  4. From the Configurations list, select STLinux Target Application and click New. A HelloWorld configuration is automatically created from the selected project.

  5. In the Debug window, select the Debugger tab.

  6. Check that ST40 Linux GDB Debugger or ST200 Linux GDB Debugger is selected in the Debugger list.

  7. Enter the name or IP address of the target board into the Target name or IP address text box.

  8. Click Debug. The application is copied to the target and executed, and the debugger stops at a breakpoint on main(). If an alert is displayed to confirm a perspective switch, choose Yes.

  9. Click Run > Step Over twice. The value of i, shown in the STWorkbench Variables window becomes 0.

  10. Click Run > Step Over again. Hello world appears in the STWorkbench Console window.

    Note: The Console window shows the console output of multiple processes. Switch between them using the terminal icon at the top right of the Console window.

  11. Click Run > Resume. The program runs to completion and is marked <terminated> in the STWorkbench Debug window.

To explore further, try the following.

  • Add extra functions to allow you to become familiar with the stack traces in the STWorkbench Debug window.
  • Use pthread_create() to spawn new threads to help understand the concept of multiple threads in the STWorkbench Debug window.
  • Supplement this introduction with tutorials from the generic C/C++ Development User Guide.
Previous   Contents   Next
Valid HTML 4.01! Last updated: 14th December 2007
© Copyright STMicroelectronics Limited, 2005
Printer