Sloeber Arduino

This is a step by step instruction to setup Sloeber “The Eclipse Arduino Ide” with OpenOcd and a FTDI 2232HL as debugger. With this you can debug your Arduino sketch real time on an Espressif ESP32 in circuit with jtag. As hardware for the debugger I used 2232HL. You can rename ino files without problems. Sloeber doesn't force you to name the ino file like the project. It is required only by Arduino IDE. Release folder of Sloeber project is a temporary folder. Arduino IDE makes the build in system temp folder. The project source set view would be a feature of Eclipse. I do not know if it has it.

Date
2019 Sep 12: Original file
2019 Sep 28: Added STM32 page, reorganized Mega644
2019 Nov 06: New WindowsTM instructions, new Sloeber version
2020 Jan 05: Added instructions for other libraries
Copyright
(c)2019 – 2020 by JR Ridgely, released under a Creative Commons, Non-Commercial, Share Alike 3.0 license.

There are two methods which have been tested. Either method will give you Eclipse with Arduino support. After the installation, you will need to add FreeRTOS and Doxygen support for ME507 use (see below). You may need to add additional support for your specific microcontroller and board.

Single Package

The easiest and recommended method is to download the pre-packaged Eclipse/Arduino system from http://eclipse.baeyens.it/index.shtml and install that. Versions are available for Windows(tm), MacOS(tm), and Linux(tm). This system works out of the box for basic Arduino programs which run on commonly available commercial Arduino boards. It works as well for custom boards which are designed to be Arduino compatible.

Update: Newer Version Available As of November 2019, you can go to https://github.com/Sloeber/arduino-eclipse-plugin/releases and get the version which works on your platform. This version has been tested on Linux and WindowsTM and compiles programs for microcontrollers (with Arduino) and PC's (with regular GCC). Seebelow for how to set up PC programming, though, which does not work out of the box but can be set up.

Eclipse with Additions

You can also install the Eclipse C++ IDE (called the 'CDE'), then add Arduino support. The very latest Eclipse IDE doesn't work with Sloeber's Arduino system, so get a slightly older version from https://www.eclipse.org/downloads/packages/release/2018-12/r where you must choose 'Eclipse IDE for C/C++ Developers' for your computer's OS. This gets you an installer which you use to set up Eclipse on that computer.

Run Eclipse, then click menu Help -> Eclipse Marketplace... Search for 'Arduino' and choose 'The Arduino Eclipse IDE V4 NamedSloeber (Product).' Install this package. It will require one or two restarts of Eclipse; also, watch the progress bar in the lower right of the Eclipse window – you can't use the package until the installation is complete. Note that there's an Eclipse menu item File -> Restart which provides a convenient way to restart the IDE.

In order to complete some homework assignments, you need to write programs which run on a PC, not a microcontroller. Setting up Eclipse for PC programming involves a few steps in addition to those which are needed to program microcontrollers. These steps vary depending on the operating system you're using. Please refer to the instructions on the following page:

  • Eclipse for PC Programming Eclipse for Linux, MacTM, and WindowsTM PC's

Some ports of Arduino have FreeRTOS support built in, so you don't have to add anything to use FreeRTOS. These ports include the nRF52 and ESP32 ports. If you're using another platform such as AVR or STM32, you'll need to take the steps shown below.

Download the Library

Go to the GitHub page hosting the library you need, such as

  • https://github.com/feilipu/Arduino_FreeRTOS_Library for AVR's
  • https://github.com/stm32duino/STM32FreeRTOS.git for STM32's

Download a .zip file containing the library. Open the file in an archive un-zipper and extract the files into a folder under your Arduino directory. A common location is home/Arduino/libraries on non-Windows(tm) computers, for example.

Add Library to Project

The following procedure must be followed for each project which uses FreeRTOS. Select your project in the Eclipse Project Explorer (in the left margin of the Eclipse window). Choose menu item Arduino -> Add a library to the selected project. Check the Arduino_FreeRTOS library option and press Finish. When you look at the source file editor, the line #include 'Arduino_FreeRTOS.h' (for AVR) or #include 'STM32FreeRTOS.h' (for STM32) should not show an error.

If the Arduino_FreeRTOS option isn't available in the library list or #include '...FreeRTOS.h' shows an error, check your private library path. Choose menu item Arduino -> Preferences, then pick item Arduino in the list at left. Make sure there is a Private library path which points to the folder inwhich your Arduino_FreeRTOS folder full of files is stored.

Adding the ME507 Support Library

You also need to add the ME507 library with tasks, shares, and queues. The code is on PolyLearn in a .zip file. Unzip this file into your Libraries directory; there should be a directory ME507 inside the directory called Libraries. Next, use the same method as for FreeRTOS above to tell Eclipse to add the ME507 library to the project. When Eclipse recognizes what a Task and a Share<uint8_t> are, it's working.

Adding Libraries, Arduino Style

Many Arduino libraries are set up to allow Eclipse to semi-automatically add them to your projects and load updates when available. Such libraries each come with a .json file showing the location of the library. To use one of these libraries, find the .json file address on the library's home page (on GitHub or wherever) and enter that address into the Arduino -> Preferences -> Third Party Index URL's list:

Of course, you need not have all these packages installed on your system! Click Apply and Close, then choose Arduino -> Preferences -> Platforms and Boards and choose the library of interest from the list:

The Eclipse marketplace contains Eclox, a package which integrates Doxygen support. It's not required to work with Doxygen, but it can be very convenient. Run Eclipse, then click menu Help -> Eclipse Marketplace... Search for 'eclox.' Install the package. You'll have to be OK with installing untrusted packages, but hey, this is safer than running Windows(tm). See https://github.com/theolind/mahm3lib/wiki/Integrating-Doxygen-with-Eclipse for instructions on how to use Eclox. Pressing the @ button which Eclox puts into the toolbar is a very quick and convenient way to run Doxygen.

  • Eclipse + Arduino for the ATMega644 Family Using the ATMega644P, 1284P, and similar
  • Eclipse + Arduino for the STM32 Using Eclipse + Arduino with STM32's
  • Eclipse + Arduino for the nRF52 Family Using Eclipse + Arduino with nRF52's
  • (Support for Atmel XMega processors is still being worked on)

The very creatively named plugin MercurialEclipse can be used to streamline the use of Mercurial to manage your projects. Some people may prefer the plugins, while others may prefer TortoiseHg or another program. Searching for Mercurial in the Eclipse Marketplace finds the plugin for installation, and https://bitbucket.org/mercurialeclipse/main/wiki/First_steps.wiki has rather old but usable instructions for using the plugin.

Sloeber Arduino

You may be able to improve the speed of uploading with a USB-Tiny ISP programmer by adding a -B 1 flag in the file arduinoPlugin/packages/arduino/hardware/avr/1.x.xx/platform.txt in your Eclipse installation directory. Look for the tag tools.avrdude.program.pattern and add the -B 1 right before the -Uflash:... instruction, separated by spaces. Note: The code below should all be on one line; it's broken into three lines below for readability:

tools.avrdude.program.pattern='{cmd.path}''-C{config.path}' {program.verbose}
{program.verify} -p{build.mcu} -c{protocol} {program.extra_params}
-B 1 '-Uflash:w:{build.path}/{build.project_name}.hex:i'

Esp32 jtag debugger with Sloeber

on October 1, 2018

This is a step by step instruction to setup Sloeber “The Eclipse Arduino Ide” with OpenOcd and a FTDI 2232HL as debugger. With this you can debug your Arduino sketch real time on an Espressif ESP32 in circuit with jtag.

As hardware for the debugger I used 2232HL board from Ali-express , this one was around $14. However every board with a FTDI 2232hl will work.
The 2232HL is a 3.3V device so don’t connect to 5V hardware or else the smoke will escape and the 2232HL will stop working.

You need to connect it like this to your hardware:
AD0 – TCK (Gpio13)
AD1 – TDI (Gpio12)
AD2 – TDO (Gpio15)
AD3 – TMS (Gpio14)
GND – GND
Optional serial port:
CD0 – TXD (Gpio3)
CD1 – RXD (Gpio1)

Installing Sloeber “The Eclipse Arduino Ide”

Sloeber arduino debug
  1. Download Sloeber
  2. Extract the gz to the directory of your choice, in this tutorial we use c:sloeber
  3. Let’s setup some basic stuff for Sloeber.
  4. Arduino -> Preference -> platform and boards
  5. Check Arduino AVR boards and esp8266 2.4.2 (or newer) both are not really necessary for the esp32, but it’s nice to have some samples and libraries.

Installing Esp32 Arduino and Sdk

  1. In Sloeber File -> Import -> Projects from git -> Clone URI and copy the url https://github.com/espressif/arduino-esp32.git in the URI field.
  2. Press next and uncheck all the branches except master, press next again.
  3. Change the directory to C:sloeberarduino-esp32 and press next again.
  4. Choose Import as general project and press next again.
  5. Let’s add it to the ide, Arduino -> Preferences -> Platforms and boards
  6. Press the new button next to the Private hardware path and enter C:sloeberarduino-esp32 in the path box.
  7. Press Apply and close
  8. Now we need to download the Esp32 sdk, browse with windows to C:sloeberarduino-esp32tools and click on get.exe
  9. Done

Replace the FTDI by Winusb driver

  1. Download Zadig , no need to install just run it.
  2. Click Options -> List All devices
  3. Choose in the dropdownbox USB <-> Serial Convertor (interface 0).Be careful here that you select the correct device.
  4. Choose the WinUSB (V6.1.xxxx.xxxxx) driver and press the Install driver button
    Note: For some reason sometimes (win update?, other usb port) windows will roll back to the original FTDI driver and you have to do this again.

Installing OpenOcd

  1. Download OpenOcd for the Esp32 from Github (I have used 0.10.0 20180920 version)
  2. Extract the content to C:SloeberOpenocd
  3. Download the cfg file for the debugger and place it in C:sloeberopenocd-esp32shareopenocdscriptsinterfaceftdi
    Note: this file is for the Ftdi 2232HL based debugger that I have. For other debugger look in the C:sloeberopenocd-esp32shareopenocdscriptsinterface directory. This cfg file can work with other Ftdi based hardware, but I can’t guaranty nor support that.
  4. Connect your debugger to the Esp32 hardware and let’s see if it works by typing on the command line: C:sloeberopenocd-esp32binopenocd.exe –f c:sloeberopenocd-esp32shareopenocdscriptsinterfaceftdiquantum.cfg
  5. If you get something as in the picture above with the “device found …..Tensilica” in it you rock. The hardware and OpenOcd are working

Setting up a new sketch

  1. Lets start a new project, Arduino -> new sketch, give the project a name and press next
  2. Platform holder c:/sloeber/arduino-esp32 , fill in the rest with the board etc you have. Port is the comport your board is connected to, not the jtag. Press next
  3. Choose Sample sketch -> example -> 01.basics and check blink. Press finish
  4. We need to set some build options for the debugger, right click on your project map, Arduino -> tab compile options and enter in the append to C and C++ field -ggdb -Og. These compiler options are not needed for a production version.
  5. Let’s compile, press Arduino -> verify
  6. And upload it to your board Arduino -> upload sketch. If you have a led connected to the pin as defined in the sketch is should blink now.

Setting up the debugger in Sloeber

  1. Right click in the project explorer window on your project and choose Debug as -> Debug configurations.
  2. Choose GDB openOCD debugging and add a new configuration by clicking on the + at the left upper corner.
  3. On the debugger tab check Start OpenOCD locally
  4. Executable path will be C:sloeberopenocd-esp32binopenocd.exe
  5. GDB port: 3333
  6. Add to Config options -s C:sloeberopenocd-esp32shareopenocdscripts -f interfaceftdiquantum.cfg -f targetesp32.cfg -c “adapter_khz 3000”
  7. Check Start GDB session
  8. Executable name for the GDB client will be C:sloeberarduino-esp32toolsxtensa-esp32-elfbinxtensa-esp32-elf-gdb.exe

  9. Select the Startup tab and set these settings
  10. Check Initial reset, Type: init
  11. In the command box enter:
    target remote:3333
    mon reset halt
    x $a1=0
  12. Uncheck Enable ARM semihosting
  13. Check load symbols, use project binary should be already have your project name
  14. Uncheck Load executable, debug in ram, Pre-run, Set program counter at (hex)
  15. Set the checkbox Set breakpoint at and fill in textbox loop
  16. Check Continue

  17. Press the Debug button and there you go

Sloeber Arduino Due

You can also program the ESP32 automatic with the jtag before debugging, add in the command box as described in step 61. below the target remote:3333 line
monitor program_esp32 c:/users/evert/Documents/sloeber-workspace/Testesp32/release/Testesp32.bin 0x10000 verify
Note: It was not possible to use in the command box Eclipse variable like {project_loc}, this would be handy so you don’t have to change every project the hard coded path. These variable like {project_loc} contains backslash “” and GDB expects forward slash”/”. I did a lot of Google reading but couldn’t find a solution, if you have one let me know.

Sloeber Arduino Debug

How to use it?

Sloeber Arduino

It’s a bit out of scope of this tutorial how to describe full the debug function in Sloeber. Because Sloeber is based on Eclipse there is enough videos etc available to help you out.
To start a debug session you have to Right click your project -> Debug As -> Debug configuration and press debug. Sloeber will then switch to the debug perspective
As a quick reference have a look at this:

Sloeber arduino tutorial
  1. Program code window, program is paused at loop(), this because we set this in step 65.
  2. Thread window, here you can see all the threads that are running on the Esp32.
  3. Control buttons, with these you can start, pause, stop and step in various ways trough your code.
  4. Perspective view, you can switch between code and debug perspective
  5. Various windows to see and influence variable, breakpoints etc. Peripherals is unfortunately not working yet.
  6. Some more windows here, cpu registers and Serial monitor view are the most used.

Note: If you copy the settings direct from this page watch out that punctuation marks like and are not copied correct (they have an other, wrong ascii value) and will give problems or error’s. Just retype them and it should work fine.