Tag Archives: eclipse

ESP32 – IDF Sdk with Eclipse

After configuring the IDF development environment in the previous article

ESP32 – IDF Sdk

let’s see now how to use Eclipse as IDE for code development. Instructions are available at the link

Eclipse Setup

Download the  C/C++ Eclipse  for Linux

Eclipse Download

Unpack the file and move it to /opt/

Run ecplise

Set the workspace for eclipse

eclipse-workspaceOnce the IDE is open, select File -> Import -> C / C ++ – -> Existing Code as Makefile Project

eclipse-importPress Next; on the next screen select the folder containing the Makefile of a sample project in the “Existing Code Location” field and choose CrossGcc as “Toolchain for indexer settings” as shown below

eclipse-import2Once the project is loaded, using the mouse right button on the project name, select the properties option

eclipse-project-propertiesUnder C / C ++ Build -> Envinronment add the variable

eclipse-batchAdd the IDF_PATH variable pointing to the downloaded IDF SDK in the same section

eclipse-idf-pathEdit the PATH variable and add the path to the bin folder of the cross compiler /home/sviluppo/Esp32/espressif/esp/xtensa-esp32-elf/bin

eclipse-pathAccess “C / C ++ General” -> “Preprocessor Include Paths”; choose the Providers tab and click on “CDT Cross GCC Built-in Compiler Settings”

eclipse-cross-cdtReplace $ {COMMAND}

eclipse-cross-cdt1with xtensa-esp32-elf-gcc

eclipse-cross-cdt2Choose now, always in the providers section,  “CDT GCC Build Output Parser”

eclipse-cross-cdt3and insert at the beginning of the “Compiler command pattern” xtensa-esp32-elf-

eclipse-cross-cdt4Save the configurations.

The project settings should always be made by make menuconfig in the unix shell. Access the shell and set the LED to be switched on/off  the value 2 as GPIO; this is because in our case the card is a doit whose design is illustrated in this document


Access to Example configuration

blink-configurationand set the gpio value to 2

blink-gpioSave the configuration. Go back to Eclipse and proceed with cleaning with

eclipse-clean-blinkand subsequent compilation with Project -> Build

eclipse-build-blinkTo run firmware flash from eclipse;, select the project and with the right button choose Build Targets -> Create …

eclipse-create-targetEnter flash as value in the target name field, leaving everything else as default

eclipse-create-target-flashAt this point we proceed to upload the image by double-clicking on the new flash item within the project targets

eclipse-run-flashThe settings to run the flash must be set with make menuconfig, as seen in the previous article

 

C Eclipse project reading temperature and humidity on Beaglebone

After the cross building and DHT11 sensor setup on Beaglebone Black

Remote debug on Beaglebone

Sensors on Beaglebone

Temperature and humidity reading on Beaglebone in python

now we show how to create a C project , using  the C source code available with the Adafruit library

Adafruit Python DHT Sensor Library

Using Eclipse, we create a project for the reading of our sensor. It calls the functions in the C code of the Adafruit library. These sources are imported into the Eclipse project

Dht sensor Projectand using the sample C code  dhtSensor.c,  which contains the main C program, we read the sensors by calling the funtions available in Adafruit C sources; the usage is  similar to what seen in Python.

Running

 it shows the help instructions

To read the DHT11 sensor on pin P8_11 we have to run

The output is the following

DHT sensor reading in CHere is the Eclipse C project

dhtSensor Eclipse project

Remote debug on Beaglebone

In the previous article we have prepared the environment with Eclipse for cross building for BeagleBone

Cross building for Beaglebone

Now we shall configure Eclipse and BeagleBone to debug the code directly on BeagleBone.

On BeagleBone install gdbserver

On the Debian system with Eclipse install gdb-multiarch

From Eclipse access to Run-> Debug Configurations

debug configurationsDouble-click C++  Remote Application to set parameters

Remote debugger configurationAt the next window, create a new ssh connection with the New button

New connectionEnter the parameters for the connection

Connection parametersSet the remote destination folder for the file  and execution management; with the browse button choose where to copy the files, and with the field “Commands to execute before application” will give execute permissions to the file

Remote foldersIn our case we create a folder esempi under /root on the  BeagleBone where to debug remotely

main debug settingsSet the multarch debugger in the Debugger Tab and other startup parameters and gdb command line settings

Debugger multiarch settingsSet the port of the remote debug server installed on BeagleBone in the Gdbserver Settings Tab

debug server settingsCreate .gdbinit files in the project folder with the command

touch debugTo start debugging run the configuration we set

debug runEclipse connects with BeagleBone and performs remote debugging  opening the Debug Perspective

debug perspective

Cross building for Beaglebone

In the article on the Debian environment we prepared the linux machine for the development of embedded systems

Debian development envinronment

In the article on building an image for the Orange PI PC we installed the cross build tools for armhf environment

Building Armbian for Orange PI PC

Starting from the clean image of the Debian envinronment we list the steps required to install the cross compiling environment. We log on Debian Desktop as sviluppo/ password.

As a preliminary step we install  the cross toolchains in Debian

https://wiki.debian.org/CrossToolchains

Create the file crosstools.list in the /etc/apt/sources.list.d folder

and add the line

Save the file and add the key of  the repository embedian.org

Install the following packages and add the armhf architecture

We install at this point the Eclipse IDE for Cpp downloading the IDE for Linux 64bit

Eclipse IDE

Unzip the eclipse package under / home /sviluppo.

Install the jre java

Add the line at the end of the file

Run the following commands

Run Eclipse from the eclipse folder to start the IDE

eclipseAs a first example we create a simple program in C for BeagleBone.

Create a new project in C, by inserting the following data

new projectSelect both configurations

project configurationEnter the cross compiler prefix and path

crosscompiler prefixPress Finish.
Add to the project a source file in C

C source fileInsert the following simple code

Proceed with the build by selecting the project with the right mouse button and choosing Build Project

project build Transfer the generated files on BeagleBone. You can use scp or ftp.

Give execution permissions to the file and run it

The result is of course the text inserted in the code

sample run