Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is how to create a single file project in Eclipse.

  1. Download the Yocto toolchain from the Emcraft website.

  2. Install the toolchain to your development host. The toolchain can be installed to an arbitrary directory:

    Code Block
    $ sh ./meta-toolchain-qt5-openstlinux-weston-stm32mp1-som-x86_64-toolchain-2.4-snapshot.sh
  3. Activate the cross-build environment:

    Code Block
    $ source /opt/st/stm32mp1-som/2.4-snapshot/environment-setup-cortexa7hf-neon-
    vfpv4-openstlinux_weston-linux-gnueabi
    $ unset CCACHE_PATH
  4. Select a workspace directory (an arbitrary directory, different from the directory where your source file is located):

    image-20240123-114533.pngImage Modified
  5. Create an empty project, open File -> New -> C/C++ Project, select C Managed Build, enter the name of the project, for example, c-example, and click Next.

    image-20240123-114636.pngImage Modified
  6. On the next screen you will be prompted to select configurations. Leave all the defaults and click Next to proceed.

  7. On the next screen, enter arm-openstlinux_weston-linux-gnueabi- as a Cross compiler prefix and /opt/st/stm32mp1-som/2.4-snapshot/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi/ as a Cross compiler path:

    image-20240123-114728.pngImage Modified
  8. Click Finish.

  9. Add your source file (see attached for an example) to the project, open File -> Import, select File System:

    image-20240123-114758.pngImage Modified
  10. Click Next, and, using Browse, navigate to the directory with your source file. Select the directory in the left window, this will add its content to the project:

    image-20240123-114826.pngImage Modified
  11. Click Finish.

Creating Build Configuration and Building the Project

Now, we need to instruct Eclipse on how to build the project for the STM32MP1 Cortex A7 target.

  1. Right-click on the just created project and select Properties. Navigate to C/C++ Build->Settings.

  2. In the Tool Settings tab on the right, select Include paths:

    image-20240123-114858.pngImage Modified
  3. If needed, click on the + button and enter an include path.

  4. Navigate to Miscellaneous and add --sysroot=/opt/st/stm32mp1-som/2.4-snapshot/sysroots/cortexa7hf-neon-vfpv4-openstlinux_weston-linux-gnueabi -marm -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 to Other flags.

    image-20240123-114939.pngImage Modified
  5. In the same window, navigate to Cross GCC Linker -> Library search path:

    image-20240123-115000.pngImage Modified
  6. If needed, click on the + button and enter a library search path.

  7. Navigate to Miscellaneous and add --sysroot=/opt/st/stm32mp1-som/2.4-snapshot/sysroots/cortexa7hf-neon-vfpv4-openstlinux_weston-linux-gnueabi -marm -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 to Other flags:

    image-20240123-115040.pngImage Modified
  8. Repeat the configuration steps above for the Release configuration.

  9. To build the project, press Ctrl-B.

Debugging the Project on the Target

Now, we need to add Debug Configuration to the Eclipse project:

  1. Open Run -> Debug Configurations:

    image-20240123-115116.pngImage Modified
  2. Create a new configuration in C/C++ Remote Application by clicking + in the upper left part of the dialogue; select Project and C/C++ Application:

    image-20240123-115152.pngImage Modified
  3. Create a new Connection by clicking New and choosing SSH connection type; click OK:

    image-20240123-115235.pngImage Modified
  4. Edit properties of the new connection: specify the Host IP address, the User (root) and the Password based authentication (leave the Password empty); click Finish:

    image-20240123-115256.pngImage Modified
  5. In the Main tab, specify Remote Absolute File Path for C/C++ Application and click Apply:

    image-20240123-115328.pngImage Modified
  6. Now, switch to the Debugger tab, change gdb to arm-openstlinux_weston-linux-gnueabi-gdb and click Apply:

    image-20240123-115403.pngImage Modified
  7. On the Linux development host, create the c-example/.gdbinit GDB command file in your workspace and add the set set sysroot /opt/st/stm32mp1-som/2.4-snapshot/sysroots/cortexa7hf-neon-vfpv4-openstlinux_weston-linux-gnueabi command command to it:

    Code Block
    echo "set set sysroot /opt/st/stm32mp1-som/2.4-snapshot/sysroots/cortexa7hf-neon-
    vfpv4-openstlinux_weston-linux-gnueabi command"
     > /home/sasha_d/eclipse-workspace/c-example/.gdbinit
  8. Click Debug. You will be asked to switch to the Debug Perspective window, accept it:

    image-20240123-115431.pngImage Modified
  9. Eclipse will automatically deploy your application on the target and run gdbserver on it using the SSH protocol.

  10. 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-20240123-115451.pngImage Modified