Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

This application note describes how to use Eclipse for building and debugging applications for Emcraft Cortex-M BSPs.

1. Installing Eclipse IDE

Download and install a Linux version of the Eclipse IDE to the Linux host.

The latest version of Eclipse IDE for C/C++ Developers can be found here:

https://www.eclipse.org/downloads/eclipse-packages/

2. Creating a Project in Eclipse

Perform the following steps to create a single file project in Eclipse.

  1. Start Eclipse and select a workspace directory, different from the directory where your source file is located.

  2. To create an empty project, open File -> New -> C/C++ Project, select ะก Managed Build and click Next.

    image-20240620-104405.png
  3. In C Project window enter the name of the project, for example, c-example, select Empty Project -> Cross GCC and click Finish.

    image-20240620-104619.png
  4. On this step you are prompted to choose build configurations. Click Next to proceed with the default settings.

  5. In the Cross GCC Command window, enter arm-buildroot-uclinuxfdpiceabi- in the Cross compiler prefix box and
    /usr/local/arm-buildroot-uclinuxfdpiceabi_sdk-buildroot/bin in Cross compiler path, click Finish.

    image-20240620-105026.png
  6. To add the source file to the project, open File -> Import. In the Import window select General -> File System, click Next.

    image-20240620-105501.png
  7. Navigate to the directory where the source file is located (/home/sasha/work in the example below). Select the directory in the left window.

    image-20240620-105742.png
  8. Click Finish to complete.

3. Building the Project

To build the project, press Ctrl-B.

4. Debugging the Project on the Target

On the host filesystem, the executable binaries are located in the Debug subfolder of the Eclipse workspace directory:

% $ ls -1 eclipse-workspace/c-example/Debug/
app.d
app.o
c-example
makefile
sources.mk
subdir.mk
$

In the directory above, c-example is the binary for Cortex-M target.

For remote debugging, you need to copy the c-example binary to the target. This can be done in several ways:

  • Using scp or sftp to copy the binary to the target;

  • Using NFS share configured on the host and mounting this share from the target.

  1. Copy the binaries to the directory exported via NFS

4.1. Using NFS Share

This application note shows how to use NFS share to copy the binary to the target.

For example, the Eclipse workspace directory, /srv/homes/eclipse-workspace/ is exported as NFS share. Let's modify the Linux project to auto-mount this directory via NFS.

  1. Add the following lines to etc/rc:

    % cd projects/rootfs
    % vi etc/rc
    ...
    sleep 2
    mount -o nolock 192.168.0.103:/srv/homes/eclipse-workspace/ /mnt/nfs
    ...
  2. Rebuild the project.

  3. After loading the project to the target, the Eclipse workspace directory is mounted as /mnt/nfs:

    / # df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    192.168.0.103:/srv/homes/eclipse-workspace/
                         488645632 124968960 338781184  27% /mnt/nfs
    / # ls -la /mnt/nfs/c-example/Debug/
    drwxrwxr-x    2 1005     1005          4096 Jun 11  2024 .
    drwxrwxr-x    4 1005     1005          4096 Jun 11  2024 ..
    -rw-rw-r--    1 1005     1005            16 Jun 11  2024 app.d
    -rw-rw-r--    1 1005     1005         52048 Jun 11  2024 app.o
    -rwxrwxr-x    1 1005     1005         41680 Jun 11  2024 c-example
    -rw-rw-r--    1 1005     1005          1360 Jun 11  2024 makefile
    -rw-rw-r--    1 1005     1005           402 Jun 11  2024 sources.mk
    -rw-rw-r--    1 1005     1005           752 Jun 11  2024 subdir.mk
    / #

4.2. Adding Debug Configuration to the Project

Perform the following steps to add a debug configuration to the Eclipse project:

  1. Open Run -> Debug Configurations -> C/C++ Remote Applications:

    image-20240620-110120.png
  2. Create a new configuration in C/C++ Remote Application by clicking + in the upper left part of the dialogue:

    image-20240620-110337.png
  3. In the Main tab, click Select other... to change Using GDB Automatic Remote Debugging Launcher.

  4. In the Select Preferred Launcher dialog, select Manual Remote Debugging Launcher and click OK.

    image-20240620-110457.png
  5. In the Debug Configuration window, switch to the Debugger tab and change GDB debugger to the full path to arm-buildroot-uclinuxfdpiceabi-gdb. Click Apply.

    image-20240620-110617.png
  6. Select the Connection tab and enter an IP address of you target and gdbserver connection port number. Click Apply.

    image-20240620-110706.png

DO NOT click Debug.

4.3. Debugging on the Target

To start debugging on the target, in the target console window, start gdbserver with the application using the port number specified at Step 6 above:

/ # gdbserver :1234 /mnt/nfs/c-example/Debug/c-example
Process /mnt/nfs/c-example/Debug/c-example created; pid = 134
Listening on port 1234

Return to the Eclipse window and click Debug. Accept an invitation to to switch to the Debug Perspective window.

image-20240620-094513.png

When started under remote debugger, the program automatically stops at the main() function.

Now you can execute you program with steps, put breakpoints, and examine variables:

image-20240620-094454.png

  • No labels