Sloeber Arduino

  1. Sloeber Arduino
  2. Sloeber Arduino Debug

Sloeber install platform Arduino-esp32 from github. If playback doesn't begin shortly, try restarting your device. 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 in which your ArduinoFreeRTOS folder full of files is stored. Configure the Sloeber plugin. After the installation you should notice a new Toolbar, which allows you to compile and flash your Arduino. Initially, the projects are not configured, as you may require to add the toolchain: Click on Window - Preferences; Open the Arduino window - Platforms and Boards; Depending on your Arduino, choose the board. Arduino IDE takes the first option as default. If that is no buildopt.h this should work out of the box both in Sloeber and Arduino IDE. In this case you can reference the buildopt.h in the sketch folder and it doesn't have to be a.h file. So no copy needed in prebuild.

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)

Sloeber

Installing Sloeber “The Eclipse Arduino Ide”

  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

Sloeber Arduino

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

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.

How to use it?

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:

  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.

In future I am planning some DS18B20 temperature measuring with ESP8266 and to show the values I will be using 1.8″ GLCD. Like the one on the photo below (top and bottom view):

I program ESP8266 using Sloeber which is basically Arduino using Eclipse. I like Eclipse a lot.

I am using Adafruit_ST7735 and Adafruit_GFX libraries.

First we need to connect everything. Below is connection table:

GLCDESP8266
1 – RSTD0
2 – CSD1
3 – D/CD2
4 – DIND7
5 – CLKD5
6 – VCC+3V3
7 – BL+3V3
8 – GNDGND

Now we start coding. First we select File -> New -> Arduino Sketch in Sloeber…

…next we give name to project (anything you want that doesn’t exist already) and click Next (do not click Finish!!!)

…if we didn’t do ESP8266 project before we need to set some settings (your COM port might be different from mine). Again click Next (NOT Finish to continue)…

…here we choose empty project (Default ino file) and click Finish…

…and here we have project created:

I use dark theme for ease on the eyes. You can change this by clicking Window -> Preferences and under General -> Appearance select Dark:

While in these settings also check that you have checked both checkboxes marked below:

Now we start creating our program. First we add includes for GLCD libraries. Sloeber needs Arduino.h included:

2
#define TFT_CS D1

Next we need a couple of color definitions for later:

2
4
6
#include <Adafruit_GFX.h> // Core graphics library
//#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>

We also now need to include .cpp and .h files in the library. See above where we disabled them, just do reverse procedure.

Now the project will argue about tft.initR we need to change it to:

2
4
// For 1.44' and 1.8' TFT with ST7735 (including HalloWing) use:
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
// For 1.3', 1.54', and 2.0' TFT with ST7789:
Adafruit_ST7789 tft=Adafruit_ST7789(TFT_CS,TFT_DC,TFT_RST);

If you try program now the colors would be inverted. We can correct this in Adafruit_ST7789.cpp at line 69. Change from ST77XX_INVON to ST77XX_INVOFF.

There is one more thing to be corrected, in this same file. At line 102 there is an if statement for different resolutions we will ad the missing one and correct the offset at the same time. Replace the current code with this: