ESP32, Arduino IDE and libraries

Hello guys, I am interested to use Arduino IDE with (only with) ESP32 based boards, so I would like to have an Arduino IDE dedicated only to ESP32. At the moment I have a normal Arduino installation where I installed also the ESP32 boards and libraries. The problem is that the IDE uses both the Arduino and the ESP32 libraries and sometime this does not work as some examples do not work (for instance the SD examples).
What I would like to have:

  1. Arduino IDE ESP32 dedicated installation
  2. ESP32 core library installed (no AVR/ARM core library installed)
  3. ESP32 dedicated and Arduino libraries (based on core libraries) as Adafruit libraries.
    Is that possible? And How? It could be OK if it is a Arduino 1.8.x installation as a Arduino 2.x.x installation.

Alternatively may be OK a working example as a SD card example (one of the libraries gaving me problems on ESP32 boards).
Thanks,
Massimo

I'm using portable installs for the individual platforms.

I however have not tried to remove the original Arduino cores from my esp install.

The direction of my current project, I am going to use a SD card module. I just started coding on the ESP32's SD API. I have the SPI initialization completed and I just started in on SD card configuration. I will not be using a library, instead I'll be address the ESP32's SPI and SD modules directly.

You can use ESPRESSIF's IDE as a ESP32 only IDE.

Seems to me there are some compatibility problems, I tried to build the Cardinfo example using a ESP32 board and it does not compile. Looking at the SD.h/SD.cpp files used and automatically selected by the IDE, I verified that the SPI pins declaration are missing because there is no support for ESP32 (no #define ESP32 or similar). So, I suppose there are other similar problems around and in the "standard" Arduino libraries. This is the risk when we try to support many architectures/microcontrollers with a couple of files and a lot of #ifdef

There are other problems on ESPRESSIF's IDE... I am testing it, platform.io, Eclipse/CDT and Eclipse/Sloeber (it is a version with the Sloeber Arduino plugin already installed and configured). In general terms the major problems come from library management, too much automatic, I would prefer to have more freedom to select the modules to make the library, it should solve the problems I see. If all the tests will fail I will be forced to collect the ESP32 core library, build it and move to a "normal" cpp project. To develop with ESP32 there are 2 options: EspressIf C framework and ESP32 Arduino compatible libraries, I am already using the 1st but now I would give a chance to the 2nd.

I think Arduino IDE 1.8.x will be your best option. That will allow you to use the portable installation method mentioned previously:

Arduino IDE 2.x does not have support for portable installation capability at the moment, so there isn't a good way to have multiple isolated installations of Arduino IDE 2.x (though you could have one installation of Arduino IDE 2.x isolated from your other portable Arduino IDE 1.8.x installations if you like).

If you want to remove the bundled Arduino AVR Boards platform from the Arduino IDE installation, just make sure you are using a recent version of the Arduino IDE because some older versions had a bug that caused them to rely on the presence of that bundled installation (https://github.com/arduino/Arduino/issues/10580).

Can you please post code and the error message. When I compile SD example code for the ESP32 the ide has not problem picking the correct library

Using library SD at version 2.0.0 in folder: C:\Users\UserName\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\SD

Arduino:1.8.16 (Windows 10), Scheda:"DOIT ESPduino32, 80MHz, 921600, None"

In file included from C:\Users\massimo\Documents\Arduino\libraries\SD\examples\CardInfo\CardInfo.ino:24:0:

C:\Users\massimo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\SD\src/SD.h:31:30: error: 'SS' was not declared in this scope

 bool begin(uint8_t ssPin=SS, SPIClass &spi=SPI, uint32_t frequency=4000000, const char * mountpoint="/sd", uint8_t max_files=5, bool format_if_empty=false);

                          ^

CardInfo:27:1: error: 'Sd2Card' does not name a type

Sd2Card card;

^

CardInfo:28:1: error: 'SdVolume' does not name a type

SdVolume volume;

^

CardInfo:29:1: error: 'SdFile' does not name a type

SdFile root;

^

C:\Users\massimo\Documents\Arduino\libraries\SD\examples\CardInfo\CardInfo.ino: In function 'void setup()':

CardInfo:50:8: error: 'card' was not declared in this scope

if (!card.init(SPI_HALF_SPEED, chipSelect)) {

    ^

CardInfo:50:18: error: 'SPI_HALF_SPEED' was not declared in this scope

if (!card.init(SPI_HALF_SPEED, chipSelect)) {

              ^

CardInfo:63:11: error: 'card' was not declared in this scope

switch (card.type()) {

       ^

CardInfo:64:10: error: 'SD_CARD_TYPE_SD1' was not declared in this scope

 case SD_CARD_TYPE_SD1:

      ^

CardInfo:67:10: error: 'SD_CARD_TYPE_SD2' was not declared in this scope

 case SD_CARD_TYPE_SD2:

      ^

CardInfo:70:10: error: 'SD_CARD_TYPE_SDHC' was not declared in this scope

 case SD_CARD_TYPE_SDHC:

      ^

CardInfo:78:8: error: 'volume' was not declared in this scope

if (!volume.init(card)) {

    ^

CardInfo:78:20: error: 'card' was not declared in this scope

if (!volume.init(card)) {

                ^

CardInfo:84:18: error: 'volume' was not declared in this scope

Serial.println(volume.clusterCount());

              ^

CardInfo:109:3: error: 'root' was not declared in this scope

root.openRoot(volume);

^

CardInfo:112:11: error: 'LS_R' was not declared in this scope

root.ls(LS_R | LS_DATE | LS_SIZE);

       ^

CardInfo:112:18: error: 'LS_DATE' was not declared in this scope

root.ls(LS_R | LS_DATE | LS_SIZE);

              ^

CardInfo:112:28: error: 'LS_SIZE' was not declared in this scope

root.ls(LS_R | LS_DATE | LS_SIZE);

                        ^

Più di una libreria trovata per "SD.h"

Usata: C:\Users\massimo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\SD

Non usata: C:\Program Files (x86)\Arduino\libraries\SD

Non usata: C:\Users\massimo\Documents\Arduino\libraries\SD

exit status 1

'Sd2Card' does not name a type

Questo report potrebbe essere più ricco di informazioni abilitando l'opzione
"Mostra un output dettagliato durante la compilazione"
in "File -> Impostazioni"

Unfortunately, you can not just run the examples from the standard SD library and compile for the ESP32. As you have discovered, not all the functionality is supported.

The ESP32 uses its own version of the SD library. You will need to review the library files in the core, and adapt the available functions and syntax to your needs.

Exactly... that is the point... I am trying with a dedicated portable installation, may be it will work.

What you are missing is that the correct library was used:

So the Arduino IDE is behaving exactly as it should. The only problem is that you are using the wrong sketch. Doing that will cause a problem no matter how well you isolate the IDE. Just make sure to use the sketches that were written for the ESP32 SD library. You will find them under the Arduino IDE's File > Examples > SD menu after you have selected one of the ESP32 boards from the Tools > Board menu.

Even though the subject of isolated installations of the Arduino IDE is interesting to discuss and explore, you might be better off keeping your focus on your project instead.

Well, a local installation seems to solve the main problem, now there is a correct list of sketches for the ESP32 and, I do not know if it is the result of the last update (2.0.0) from ESP-IF, it builds the sketch. Now a new problem arised... I am not able to upload the skerch to the board, I alredy searched trough the forum and the net but I found only solutions that do not work in my case, this is the error:
java.lang.NullPointerException
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingProgrammer(SerialUploader.java:295)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:90)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
at processing.app.SketchController.upload(SketchController.java:732)
at processing.app.SketchController.exportApplet(SketchController.java:703)
at processing.app.Editor$UploadHandler.run(Editor.java:2061)
at java.lang.Thread.run(Thread.java:748)

I can say that the board has a CH340 chip, that works with esp-if tools in cli mode and also using platform.io and using Eclipse (it uses the esp-if tools in the python form or in exe form). So, there is no problem with the CH340 driver. I tried also with an installed release of Arduino IDE and nothing changed, seems that the problem is related only to Arduino IDE 1.8.16

I found that changing the board with another one the problem is solved.

My board is a Wemos D1 R32 v. 1.0.0 that is a clone of ESPduino32 that is listed as DOIT ESPduino32 on the board manager. If I change the board to DOIT ESP32 DEVKIT V1 the IDE builds and loads it correctly.

Searching for the differences I found only 2 different pins_arduino.h files not justifying the problem, may be that the Arduino IDE internally uses a bootloader or any other tool not in the variants folder and subfolders, may be in the tools subfolders but I did not find any trace about that.

So, at the moment, I modified a little bit the pins_arduino.h of the DOIT ESP32 DEVKIT V1 board to be compatible with the syntax of DOIT ESPduino32 also.

But I am sure there is something to understand better, somewhere there is a bug.

I appreciate that English is not your first language, but your post is very hard to read because it is a single slab of text. Broken into paragraphs like this is is easier to read and I am sure that the same would be true in Italian

I found that changing the board with another one the problem is solved.

My board is a Wemos D1 R32 v. 1.0.0 that is a clone of ESPduino32 that is listed as DOIT ESPduino32 on the board manager. If I change the board to DOIT ESP32 DEVKIT V1 the IDE builds and loads it correctly.

Searching for the differences I found only 2 different pins_arduino.h files not justifying the problem, may be that the Arduino IDE internally uses a bootloader or any other tool not in the variants folder and subfolders, amy be in the tools subfolders but I did not find any trace about that.

So, at the moment, I modified a little bit the pins_arduino.h of the DOIT ESP32 DEVKIT V1 board to be compatible with the syntax of DOIT ESPduino32 also. But I am sure there is something to understand better, somewhere there is a bug.

It was a copy and paste, today I have big internet connection problems, seems that this area is served not so well both from the cabled and the mobile networks, I was editing it (seems that copy and paste does not know the shift+enter) when the net went down... so took some time to edit and upload it the 2nd time.

You are rigth, it is a wrong example but it is under the examples for every board. Only after I updated the esp32 boards to 2.0.0 some examples disappeared from the "every board" section so may be that esp-if made some mistakes in previous releases. Now I see the SD examples only in the ESP32 boards section and the IDE uses the right library. Next step: I will try to remove every board and library not related to ESP32 in my portable installation just to see if the IDE works anyway. In this way I would have a portable installation dedicated to ESP32 boards that is what I would like to have.