BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Rudolph's FT800-FT813-5.x library not compiling on arduino IDE for ESP32  (Read 11897 times)

vigiler

  • Newbie
  • *
  • Posts: 3
    • View Profile

Hello,

I know that platformio it's better than arduino, but i'm used to work with arduino IDE.
Trying to compile on Arduino IDE the "hello world" example for an ESP32 i cannot compile, i get theese errors on EVE_cpp_target.cpp, lines 232, 233, and 238. Compiler doesn't know "SPI2_HOST", so i've changed to "VSPI_HOST", and them another compiler error, compiler doesn't know "SPI_DMA_CH_AUTO", after investigating this value can be true or false. Wether i put true or false arduino compiles successfully the example, but after uploading to my Riverdi RiTFT50 it doesn't do anything, black screen.

Can you Rudolph help me to make it work?

Thnak you for your work and help.
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 391
    • View Profile

Hi,

I know that platformio it's better than arduino, but i'm used to work with arduino IDE.

I get you, but it is not so much platformio against arduino but using platformio to do arduino programing. :-)
For me this is not exactly about platformio either, more using platformio with vscode as vscode is a much better editor.
Platformio does a few things better than the arduino ide, like supporting more boards out of the box and allowing to set build flags for example.

On the other side there are limits to what you can do with platformio, like there is no Baremetall support for the RP2040, "only" Arduino,
the ATSAM I am mostly using do not have CMSIS/Baremetall support either in the "Atmel SAM" framework, "only" Arduino und Zyphr RTOS.
Next I have two newer STM32 Nucleo boards that I can not use with platformio, yet.
Then there is RX660, S32K, RH850, PIC, probably countless other controllers with no suport or limited support.
Just saying, I believe the gras is greener over here but it is not all green either. :-)

Quote
Trying to compile on Arduino IDE the "hello world" example for an ESP32 i cannot compile, i get theese errors on EVE_cpp_target.cpp, lines 232, 233, and 238. Compiler doesn't know "SPI2_HOST", so i've changed to "VSPI_HOST", and them another compiler error, compiler doesn't know "SPI_DMA_CH_AUTO", after investigating this value can be true or false. Wether i put true or false arduino compiles successfully the example, but after uploading to my Riverdi RiTFT50 it doesn't do anything, black screen.

Can you Rudolph help me to make it work?

Thnak you for your work and help.

Which ESP32 package are you using exactly in what version and with what Arduino IDE?

I checked platform-espressif32 and arduino-esp32.
This sounds like a compatibility issue between one using ESP-IDF 5 and the other using ESP-IDF 4.
However, the latest version of arduino-esp32 is v2.0.9 and it is using ESP-IDF v4.4.4.
And platform-espressif32 added support for arduino-esp32 v2.0.9 with release 6.3.0.
So this really should be the same arduino core that both are using.

Ok, lets see what happens, I am using Arduino IDE 2.1.0 since this is the one I currently have in working condition.
I added https://espressif.github.io/arduino-esp32/package_esp32_index.json to the boards manager and installed the esp32 package v2.0.9.

Ugh, ESP32 board overflow error. :-) First world problems, what board do I actually have? :-)

I selected "ESP32 Wrover Module" for a quick test and apart from a few warnings about missing initializers it compiles.
Fixed these.

I have a "BPI-Leaf-S3" that I only bought for the ESP-S3. And it actually is in the list of boards, nice.
With platformio I usually build for dfrobot_firebeetle2_esp32s3 which is close enough and also in the list.

Checking the pins, EVE_target_Arduino_ESP32.h has other pins configured as I have wired, so I just changed these.
EVE_target_Arduino_ESP32.h is not displayed by the Arduino IDE though since it is in a sub-folder, so you need to add it to the sketch.

Code: [Select]
...
#if !defined(EVE_CS)
#define EVE_CS 10
#endif

#if !defined(EVE_PDN)
#define EVE_PDN 14
#endif

#if !defined(EVE_SCK)
#define EVE_SCK 12
#endif

#if !defined(EVE_MISO)
#define EVE_MISO 13
#endif

#if !defined(EVE_MOSI)
#define EVE_MOSI 11
#endif
...

With platformio I can set these in the platformio.ini and therefore do not need to change that file.

Checking EVE_config.h, it's set to EVE_RVT50H which I also happen to have on my desk now.
The EVE_RiTFT50 is for RVT50xQBxxxxx which is using a BT815.
But I also happen to have one of these. :-)

Still compiles and now I uploaded it to the board - works. :-)
« Last Edit: June 05, 2023, 07:29:23 PM by Rudolph »
Logged

vigiler

  • Newbie
  • *
  • Posts: 3
    • View Profile

Hello Rudolph,

I have to use arduino ide 1.8.19 because new version of the ide doesn't support at the moment uploading files to the ESP32.

I'm using ESP32-wroover, although would for sure work with ESP32.

Greetings
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 391
    • View Profile

Ok, Arduino IDE 1.8.19 it is.
I swapped around the /AppData/Local/Arduino15 folders to make the 1.x one active.
Then I added https://espressif.github.io/arduino-esp32/package_esp32_index.json to "Addtional Boards Manager URLs" and installed the ESP32 package v2.09,
started IDE 1.8.19, opened the projected that is attached above, selected "DOIT ESP32 DEVKIT V1" since that worked with the ESP32 WROOM-32 board when using PlatformIO.
I changed the pins again:
Code: [Select]
#if !defined(EVE_CS)
#define EVE_CS 13
#endif

#if !defined(EVE_PDN)
#define EVE_PDN 12
#endif

#if !defined(EVE_SCK)
#define EVE_SCK 18
#endif

#if !defined(EVE_MISO)
#define EVE_MISO 19
#endif

#if !defined(EVE_MOSI)
#define EVE_MOSI 23
#endif

And it compiles just fine.
I can not get it to upload to the board though, something about the serial connection or the drivers not working.
On the serial monitor I get this though when pushing the reset button:
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xe
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x0,hd_drv:0x00,wp_drv:0x0
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4

And still:
A serial exception error occurred: Cannot configure port, something went wrong. Original message: PermissionError(13,
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.

I hate it when crap like this happens.

For the chance that a different board might behave differently I am trying to buy a new ESP32 board.
But all the ESP32-WROVER boards I can find are using a CH340 USB/Serial chip like the Wroom32 board I already have.

Hmm, I had more boards but I can't find these anymore, like a ESP32-CAM but this one did not have USB at all.


Edit:
I got two new ESP32 boards and while one was advertised as "ESP32 WROVER Development Board" it turned out as WROOM32 board.
So I have two different new WROOM32 boards now.

My old WROOM32 board is still not working, same error, for whatever reason.
One of my new boards is using a CH340C, the other one is using a CP2102. I can upload to both of the new boards just fine.

And I learned something, never ever use "Sketch" / "Add File..." in Arduino IDE 1 in order to edit a file from a sub-folder that is otherwise not getting displayed.
I added EVE_target/EVE_target_Arduino_ESP32.h to change the pins.

And this opportunity to learn something did cost me a number of hours.
The seemingly exact same code worked fine when compiled with PlatformIO and resulted in a watchdog-reset when compiling it with Arduino IDE 1.8.19.
It hang in EVE_cpp_target.cpp / EVE_init_spi() when calling spi_bus_initialize().
And the problem in the end was that when adding the file the Arduino IDE actually copies it to the project folder.
I edited a copy of EVE_target_Arduino_ESP32.h that the code does not use while EVE_target/EVE_target_Arduino_ESP32.h remained untouched and therefore the I/O pins for the SPI were all wrong...ouch.

Now the code works from both the Arduino IDE 1.8.19 and PlatformIO with only a minute detail.
The code compiled with PlatformIO runs a little bit faster since I compile it with -O2 while the default is -Os.


And to my surprise, the Arduino version runs significantly faster now than the native version.
Using the same ESP-IDF based code.
It looks like the ESP-IDF SPI functions in arduino-esp32 are not the same, the pauses between single byte transfers when sending a couple of bytes are shorter.
The pauses are still ridiculously long for a controller running with 240MHz, I measure 9.9µs (PIO Arduino, -O2), 10.0µs (Arduino, -Os) and 13.2µs for (PIO ESP-IDF, -O2).
In contrast I measured 640ns with an ATSAMC21 running 48MHz and 280ns with an ATSAME51 running 120MHz but these are not burdened with a RTOS and my code writes directly to the SPI registers.

The screen update is done using DMA and while the transfer of the data takes the same 113.48µs, the times from CS down to start of the transfer and from end of the transfer to CS up are different.

CS down to start
Arduino: 20.3µs
ESP-IDF: 27.6µs
C21: 860ns

end of data to CS up
Arduino: 5µs
ESP-IDF: 8.4µs
C21: 780ns

I do wonder what is going on there with ESP32.

Another comparision, the 600MHz Teensy 4.1 has 225ns between two SPI.transfer() calls, so going thru the Arduino SPI class.

« Last Edit: June 11, 2023, 05:02:41 PM by Rudolph »
Logged

vigiler

  • Newbie
  • *
  • Posts: 3
    • View Profile

Hi Rudolph,
I've updated library for Esp32 in arduino, and compiles fine for ESP32 WROOVER.
Also can upload code to the ESP and works, although the star it's distorsioned as you can see in the pic.

Greetings.
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 391
    • View Profile

Please either try the last version I attached (and modify the pins if necessary), or attach a version with the modifications that you did, or well, preferably both. :-)
« Last Edit: June 13, 2023, 07:33:18 PM by Rudolph »
Logged