Eclipse STM32Cube IDE setup - mipidisaster/miLibrary GitHub Wiki

This page will go over the steps to setup the STM32Cube/Eclipse IDE.

Note, the steps for STM32Cube installation will not be captured here (as assumed to be on Windows machine). However initial setup and installation of additional software will be covered.

Eclipse installation and supporting software

The following is an installation guide for Eclipse on a linux machine. The version stated in this wiki is "2020-06" as this aligns with the supported STM32CubeMax version (v6.2.1). Go to the following website https://www.eclipse.org/downloads/packages/release/2020-06/r, and install/download the 'C/C++ Developers' version. This should put a 'tar.gz' into your downloads area (or were ever you select to download it). Decide whether you want to install it for all users or only for the current user, by extracting the archive in a suitable location. The following steps will be putting this into the 'home' location of the current user:

Prior to installing Eclipse, suggest that you ensure that java is present on the machine: sudo apt install default-jdk

user@machine:~/Downloads$ ls eclipse*
eclipse-cpp-2020-06-R-linux-gtk-x86_64.tar.gz

user@machine:~/Downloads$ tar -xvf eclipse* -C ..
    -x = Extract files from an archive
    -v = Verbosely list files processed
    -f = use archive file (could use --file=ARCHIVE)
    -C = Change to directory (could use --directory=DIR)
        ".." means to put it up a level (i.e. /home/user/<here>)

user@machine:~/Downloads$ cd ~/eclipse
user@machine:~/eclipse$ ./eclipse &
    & = Will run the executable in the background (i.e. not within the current shell/terminal

Create Eclipse Icon (with shell enviornment loading)

Should now have a working installation of Eclipse. However, currently the only way to run this is via the terminal. Can create a eclipse.desktop file as follows:

user@machine:~/.local/share/applications$ more eclipse.desktop
  [Desktop Entry]
  Type = Application
  Exec = bash -i -c /home/user/eclipse/eclipse
  Name = ROS-Eclipse
  Icon = /home/user/eclipse/icon.xpm
  Terminal = False
  Categories = Development;IDE;C++;ROS;Java;Ant
  MimeType = text/x-c++src;text/x-c++hdr;text/x-xsrc;application/x-designer;

Obviously some of the above would need to modified to take into account the location of the Eclipse installation. The reason why the Exec states bash -i -c is because the website - http://wiki.ros.org/IDEs#Eclipse indicates that this will source the bashrc in which ROS will have been sourced already.

Eclipse extra(s)

Via the help/install new software..., install the following:

  • Programming Languages/Eclipse Java Delopment Tools (Work with '2020-06')
  • General Purpose Tools/Remote System Explorer (all of them) (work with '2020-06')
  • All terminals (work tiwh 'http://www.mihai-nita.net/eclipse')

As per note in https://wiki.ros.org/IDEs#Running_and_debugging_your_executables_within_Eclipse

  • ArbitraryLine (Eclipse Marketplace)
  • YAML Editor (Eclipse Marketplace)
  • Asciidoctor Editor (Eclipse Matketplace)

Cross-Compliation support

As it is likely that Eclipse will be installed onto a desktop computer (e.g. Intel x86), it will be unable to compile/understand code designed for an ARM processor (i.e. RaspberryPi). So cross-complication support will need to be provided. Based upon some testing, believe that the best way to support this is through the use of the Linaro Toolchain for Raspbian. Which can be downloaded from the RPi Foundation, steps are as follows (assumes git is already installed):

user@machine:~$ git clone https://github.com/raspberrypi/tools.git

With that everything needed to cross-compile is within the home folder 'tools'. However, you'll need to use the full filepath, unless it gets added to the .bashrc file in the home directory. The following will fix this:

user@machine:~$ tail -2 .bashrc
export PATH=$PATH:~tools/arm-bcm2708/gcc-linaro-linux-gnueabihf-raspbian-x64/bin
source /opt/ros/noetic/setup.bash

Can now make use of arm-linux-gnueabihf-gdb for debugging of ARM code.

Setup ssh key with external device

First generate a public key and private key on the local machine, using: ssh-keygen. I've normally selected the default parameters - however, believe that there are some things that can be done here to improve security. Ultimatley, this will generate a key within the .ssh folder on the local machine: a file called id_rsa.pub and id_rsa will be in the .ssh folder. This needs to be pushed to the remote device via:

user@machine:~$ ssh-copy-id username@remotedevice

Note, the id_rsa is the private keys, and id_rsa.pub is the public keys (hence why it is being pushed to the remote device).

As this will be likely the first time you are connecting with the remote device, linux will ask you to accept the finger print. Accept this. You should now be able to access the remote device without a password (as the SSH keys are exchanged in the background).

Remote Aliases

You can now put a config file into the local machine .ssh folder. Within this config file, you can give the remote device an alias (say make it easier to call the remote device via ssh). Additionally, can set 'strickhostkeychecking' to 'yes', which introduces an extra level of security; if the fingerprint changes to this remote device, it won't connect!

user@machine:~$ more .ssh/config
Host server1
   Hostname <remotedevice>
   Port <number>
   StrictHostKeyChecking yes
   User <username>

user@machine:~$ ssh server1

Have included the Port option if this is useful, haven't needed to use it for now. So can ignore.

Note, to delete all the created keys on the local machine, use ssh-add -D

ROS for remote depolyment update

As it is expected the remote device will be used for ROS, the system environment will need to be updated such that it looks at the ROS setup.bash file. This is done via updating the /etc/profile file.

File in etc are configuration files for the system (and other miscellaneous stuff). So after logining into the remote device (see steps ssh option above), you'll need to switch to the root user.

username@remotedevice:~$ sudo su
username@remotedevice:~$ echo "source/opt/ros/<distrubition>/setup.bash" >> /etc/profile

After this you don't need to reference the setup.bash within the user's .bashrc file.

ROS Eclipse

Should now have Eclipse setup with Java, Remote System Explorer, and Arbitrary lines. As well as a secure (ssh-key) link to the remote device. Can now start to create ROS packages whilst using the Eclipse setup.

Majority of the useful steps to follow on initial setup is already captured within the ROS wiki - http://wiki.ros.org/IDEs#Eclipse.

What will be captured here, is the steps that I have found/created to faciliate remote deployment of a ROS workspace/package (stored on the local machine) onto the remote device. As well as how it can be remotely debugged.

Housekeeping

When you first import the ROS project in Eclipse, you'll want to give the index sometime to sort out the files which are to be used. You'll also need to update the Project 'C/C++ Include Paths and Preprocessor Symbols' to look at the ROS installation location, which is typically: /opt/ros/<distribution>/include.

You'll also need to update this with any other libraries that your project may require.

Finally, within the milibrary repository, there are "my" prefered preferences for the Eclipse workspace. So suggest that you import these preferences, which should:

  • Link the CMakeLists.txt as xml files
  • Link any file ending with *.launch again as xml files
  • Syntax colour coding

Configure for Remote Deployment

Using the xml folder within the milibrary repository, the remoteDevice.xml file can be used to do remote deploy the build, along with Debugging/Releasing the code on the Remote device. This file can be run via External Tools selecting the Ant Build. Ensure that the Base Directory is pointing to the workspace build folder. Within the Targets tab, select the option you want to run i.e. 'Debug (remote)'. Prior to running, put a copy of `mi_remote.properties' into the workspace\build folder, and ensure it is configured for remote device, remote username, and local workspace location. You should now be able to deploy the build remotely, and a copy of the deployed code will be copied into the workspace.

Remote Debug

Within Run/Debug Configuration, create a new C/C++ Remote Application. Within this point the C/C++ Application to the file you want to debug - note, this will need to be the copied version from the remote deploy. Then in the bottom create a new connection to the remote device. Setup a SSH, and make use of Public key based authentication. Within the Remote Absolute File Path for C/C++ Application, you'll need to type in the location of the file within the remote device, i.e. /home/<username>/<ros_ws>/devel/lib/<package>.

You'll then need to configure the Debugger to make use of the Cross-Compliation debugger created above, i.e. GDB debugger: arm-linux-gnueabihf-gdb. Then within the Shared Libraries, navigate to the Cross-Compliation library: /home/<username>/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/lib. Need to also put in somthing within the Source tab to tell the debugger were the source files located on the remote device are located. This can be done by adding a Path Mapping to either:

  • Point to the local copy of the ROS workspace, update the Compliation path to the remote ROS workspace, and the Local file system path to the local ROS workspace.
  • Mount the remote device to the local machine, using sshfs, and then point to this location:

sudo sshfs -o allow_other,default_permissions,IdentityFile=<location of id_rsa file> <remote device:/> <local file to mount too>

This should allow for remote debug use.

⚠️ **GitHub.com Fallback** ⚠️