PlatformIO Community

Adafruit Image Reader will not compile

Hi all,

Was wondering if anyone can help me:

I’m using the Adafruit ImageReader example code (see below) to display images from an SD card. Hardware is an Adafruit ESP32 Feather and I’m using an Adafruit 1.44" Color TFT LCD Display with MicroSD Card breakout - ST7735R. I’m using PlatformIO on VScode.

No matter what I seem to try I get a compiler error which appears to suggest that flash_t was not declared in scope for Adafruit_FlashTransport_ESP32.cpp

Interestingly (maybe) when I try and compile using Arduino 1.8.15 IDE it works.

Conversely if I try the same code again on Arduino 2.0 Beta11 IDE it also fails with the same error message above that PlatformIO gives me.

Fairly new to PlatformIO so I;m assuming its a library issue or something I’m doing wrong but struggling to see what I’m missing.

I’m using:

Adafruit_ImageReader is version 2.6.2
Adafruit_SPIFlash is version 3.7.0
Espressif 32 (3.3.2)

Error:
Users\user\Documents\Arduino\libraries\Adafruit_SPIFlash\src\esp32\Adafruit_FlashTransport_ESP32.cpp: In member function ‘SPIFlash_Device_t* Adafruit_FlashTransport_ESP32::getFlashDevice()’:
Users\user\Documents\Arduino\libraries\Adafruit_SPIFlash\src\esp32\Adafruit_FlashTransport_ESP32.cpp:54:3: error: ‘esp_flash_t’ was not declared in this scope
esp_flash_t const *flash = _partition->flash_chip;
^
Users\user\Documents\Arduino\libraries\Adafruit_SPIFlash\src\esp32\Adafruit_FlashTransport_ESP32.cpp:55:36: error: ‘flash’ was not declared in this scope
_flash_device.manufacturer_id = (flash->chip_id >> 16);
^
Compilation error: Error: 2 UNKNOWN: exit status 1

CODE:

// Adafruit_ImageReader test for Adafruit ST7735 TFT Breakout for Arduino.
// Demonstrates loading images from SD card or flash memory to the screen,
// to RAM, and how to query image file dimensions.
// Requires three BMP files in root directory of SD card:
// rgbwheel.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller's SPI interface for the screen
// (not 'bitbang') and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.

#include <Adafruit_GFX.h>         // Core graphics library
#include <Adafruit_ST7735.h>      // Hardware-specific library
#include <SdFat.h>                // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h>    // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions

// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD

// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.

#define SD_CS    33 // SD card select pin
#define TFT_CS   14 // TFT select pin
#define TFT_DC   32 // TFT display/command pin
#define TFT_RST  15 // Or set to -1 and connect to Arduino RESET pin

#if defined(USE_SD_CARD)
  SdFat                SD;         // SD card filesystem
  Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
  // SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
  #if defined(__SAMD51__) || defined(NRF52840_XXAA)
    Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
      PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
  #else
    #if (SPI_INTERFACES_COUNT == 1)
      Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
    #else
      Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
    #endif
  #endif
  Adafruit_SPIFlash    flash(&flashTransport);
  FatFileSystem        filesys;
  Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif

Adafruit_ST7735      tft    = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image       img;        // An image loaded into RAM
int32_t              width  = 0, // BMP image dimensions
                     height = 0;

void setup(void) {

  ImageReturnCode stat; // Status from image-reading functions

  Serial.begin(9600);
#if !defined(ESP32)
  while(!Serial);       // Wait for Serial Monitor before continuing
#endif

  tft.initR(INITR_144GREENTAB); // Initialize screen

  // The Adafruit_ImageReader constructor call (above, before setup())
  // accepts an uninitialized SdFat or FatFileSystem object. This MUST
  // BE INITIALIZED before using any of the image reader functions!
  Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
  // SD card is pretty straightforward, a single call...
  if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
    Serial.println(F("SD begin() failed"));
    for(;;); // Fatal error, do not continue
  }
#else
  // SPI or QSPI flash requires two steps, one to access the bare flash
  // memory itself, then the second to access the filesystem within...
  if(!flash.begin()) {
    Serial.println(F("flash begin() failed"));
    for(;;);
  }
  if(!filesys.begin(&flash)) {
    Serial.println(F("filesys begin() failed"));
    for(;;);
  }
#endif
  Serial.println(F("OK!"));

  // Fill screen blue. Not a required step, this just shows that we're
  // successfully communicating with the screen.
  tft.fillScreen(ST7735_BLUE);

  // Load full-screen BMP file 'lily128.bmp' at position (0,0) (top left).
  // Notice the 'reader' object performs this, with 'tft' as an argument.
  Serial.print(F("Loading lily128.bmp to screen..."));
  stat = reader.drawBMP("/lily128.bmp", tft, 0, 0);
  reader.printStatus(stat);   // How'd we do?
/*
  // Query the dimensions of image 'miniwoof.bmp' WITHOUT loading to screen:
  Serial.print(F("Querying miniwoof.bmp image size..."));
  stat = reader.bmpDimensions("/miniwoof.bmp", &width, &height);
  reader.printStatus(stat);   // How'd we do?
  if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
    Serial.print(F("Image dimensions: "));
    Serial.print(width);
    Serial.write('x');
    Serial.println(height);
  }

  // Load small BMP 'wales.bmp' into a GFX canvas in RAM. This should fail
  // gracefully on Arduino Uno and other small devices, meaning the image
  // will not load, but this won't make the program stop or crash, it just
  // continues on without it. Should work on Arduino Mega, Zero, etc.
  Serial.print(F("Loading wales.bmp to canvas..."));
  stat = reader.loadBMP("/wales.bmp", img);
  reader.printStatus(stat); // How'd we do?
*/
  delay(5000); // Pause 5 seconds before moving on to loop()
  
}

void loop() {
  
}

Compiler log

Processing featheresp32 (platform: espressif32; board: featheresp32; framework: arduino)
-------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/featheresp32.html
PLATFORM: Espressif 32 (3.3.2) > Adafruit ESP32 Feather
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10006.210326 (1.0.6)
 - tool-esptoolpy 1.30100.210531 (3.1.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing adafruit/Adafruit GFX Library @ ^1.10.10
Library Manager: Adafruit GFX Library @ 1.10.11 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing Adafruit BusIO
Library Manager: Warning! More than one package has been found by Adafruit BusIO requirements:
 - adafruit/Adafruit BusIO @ 1.9.1
 - mertmechanic/Adafruit BusIO @ 1.7.3
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: Adafruit BusIO @ 1.9.1 has been installed!
Library Manager: Installing adafruit/Adafruit ST7735 and ST7789 Library @ ^1.7.3
Library Manager: Adafruit ST7735 and ST7789 Library @ 1.7.4 has been installed!
Library Manager: Installing dependencies...
Library Manager: Adafruit GFX Library @ 1.10.11 is already installed
Library Manager: Installing Adafruit seesaw Library
Library Manager: Adafruit seesaw Library @ 1.4.5 has been installed!
Library Manager: Installing dependencies...
Library Manager: Adafruit ST7735 and ST7789 Library @ 1.7.4 is already installed
Library Manager: Installing SD
Library Manager: Warning! More than one package has been found by SD requirements:
 - adafruit/SD @ 0.0.0-alpha+sha.041f788250
 - arduino-libraries/SD @ 1.2.4
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: SD @ 0.0.0-alpha+sha.041f788250 has been installed!
Library Manager: Adafruit BusIO @ 1.9.1 is already installed
Library Manager: Installing adafruit/Adafruit ImageReader Library @ ^2.6.2
Library Manager: Adafruit ImageReader Library @ 2.6.2 has been installed!
Library Manager: Installing dependencies...
Library Manager: Adafruit GFX Library @ 1.10.11 is already installed
Library Manager: Adafruit ST7735 and ST7789 Library @ 1.7.4 is already installed
Library Manager: Installing Adafruit HX8357 Library
Library Manager: Adafruit HX8357 Library @ 1.1.11 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing Adafruit STMPE610
Library Manager: Adafruit STMPE610 @ 1.1.3 has been installed!
Library Manager: Adafruit GFX Library @ 1.10.11 is already installed
Library Manager: Installing Adafruit TouchScreen
Library Manager: Adafruit TouchScreen @ 1.1.2 has been installed!
Library Manager: Installing Adafruit ILI9341
Library Manager: Warning! More than one package has been found by Adafruit ILI9341 requirements:
 - adafruit/Adafruit ILI9341 @ 1.5.9
 - links2004/Adafruit ILI9341 @ 1.0.0
 - peterus/Adafruit ILI9341 @ 1.5.6
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: Adafruit ILI9341 @ 1.5.9 has been installed!
Library Manager: Installing dependencies...
Library Manager: Adafruit GFX Library @ 1.10.11 is already installed
Library Manager: Installing Adafruit SSD1351 library
Library Manager: Adafruit SSD1351 library @ 1.2.7 has been installed!
Library Manager: Installing dependencies...
Library Manager: Adafruit GFX Library @ 1.10.11 is already installed
Library Manager: Installing Adafruit SSD1331 OLED Driver Library for Arduino
Library Manager: Warning! Could not install dependency {'name': 'Adafruit SSD1331 OLED Driver Library for Arduino', 'frameworks': ['arduino']} for package 'Adafruit ImageReader Library'
Library Manager: Installing Adafruit SPIFlash
Library Manager: Adafruit SPIFlash @ 3.7.0 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing Adafruit NeoPixel
Library Manager: Warning! More than one package has been found by Adafruit NeoPixel requirements: - adafruit/Adafruit NeoPixel @ 1.8.5
 - fkrenn12/Adafruit NeoPixel @ 1.7.0
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: Adafruit NeoPixel @ 1.8.5 has been installed!
Library Manager: Installing SdFat - Adafruit Fork

Unpacking  [##############################------]   84%
Unpacking  [##############################------]   85%
Unpacking  [###############################-----]   86%
Unpacking  [###############################-----]   87%
Unpacking  [###############################-----]   88%
Unpacking  [################################----]   89%
Unpacking  [################################----]   90%
Unpacking  [################################----]   91%
Unpacking  [#################################---]   91%
Unpacking  [#################################---]   92%
Unpacking  [#################################---]   93%
Unpacking  [#################################---]   94%
Unpacking  [##################################--]   94%
Unpacking  [##################################--]   95%
Unpacking  [##################################--]   96%
Unpacking  [###################################-]   97%
Unpacking  [###################################-]   98%
Unpacking  [###################################-]   99%
Unpacking  [####################################]  100%
Library Manager: SdFat - Adafruit Fork @ 1.2.4 has been installed!
Library Manager: Installing Adafruit EPD
Library Manager: Adafruit EPD @ 4.4.2 has been installed!
Library Manager: Installing dependencies...
Library Manager: Adafruit GFX Library @ 1.10.11 is already installed
Library Manager: SdFat - Adafruit Fork @ 1.2.4 is already installed
Library Manager: Adafruit SPIFlash @ 3.7.0 is already installed
Found 43 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit GFX Library> 1.10.11
|   |-- <SPI> 1.0
|   |-- <Adafruit BusIO> 1.9.1
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|-- <Adafruit ST7735 and ST7789 Library> 1.7.4
|   |-- <Adafruit GFX Library> 1.10.11
|   |   |-- <SPI> 1.0
|   |   |-- <Adafruit BusIO> 1.9.1
|   |   |   |-- <Wire> 1.0.1
|   |   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <Adafruit BusIO> 1.9.1
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <Adafruit ImageReader Library> 2.6.2
|   |-- <Adafruit SPIFlash> 3.7.0
|   |   |-- <SPI> 1.0
|   |   |-- <SdFat - Adafruit Fork> 1.2.4
|   |   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|   |-- <SdFat - Adafruit Fork> 1.2.4
|   |   |-- <SPI> 1.0
|   |-- <Adafruit GFX Library> 1.10.11
|   |   |-- <SPI> 1.0
|   |   |-- <Adafruit BusIO> 1.9.1
|   |   |   |-- <Wire> 1.0.1
|   |   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |-- <Adafruit BusIO> 1.9.1
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|-- <SdFat - Adafruit Fork> 1.2.4
|   |-- <SPI> 1.0
|-- <Adafruit SPIFlash> 3.7.0
|   |-- <SPI> 1.0
|   |-- <SdFat - Adafruit Fork> 1.2.4
|   |   |-- <SPI> 1.0
|-- <Wire> 1.0.1
Building in release mode
Compiling .pio\build\featheresp32\lib169\Adafruit SPIFlash\esp32\Adafruit_FlashTransport_ESP32.cpp.o
Compiling .pio\build\featheresp32\libd32\Adafruit ImageReader Library\Adafruit_ImageReader_EPD.cpp.o
Archiving .pio\build\featheresp32\libFrameworkArduinoVariant.a
In file included from .pio\libdeps\featheresp32\Adafruit ImageReader Library\Adafruit_ImageReader_EPD.cpp:1:0:
.pio\libdeps\featheresp32\Adafruit ImageReader Library\Adafruit_ImageReader_EPD.h:18:26: fatal error: Adafruit_EPD.h: No such file or directory

**********************************************************************
* Looking for Adafruit_EPD.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Adafruit_EPD.h"
* Web  > https://platformio.org/lib/search?query=header:Adafruit_EPD.h
*
**********************************************************************

compilation terminated.
Compiling .pio\build\featheresp32\FrameworkArduino\Esp.cpp.o
*** [.pio\build\featheresp32\libd32\Adafruit ImageReader Library\Adafruit_ImageReader_EPD.cpp.o] 
Error 1
.pio\libdeps\featheresp32\Adafruit SPIFlash\src\esp32\Adafruit_FlashTransport_ESP32.cpp: In member function 'SPIFlash_Device_t* Adafruit_FlashTransport_ESP32::getFlashDevice()':
.pio\libdeps\featheresp32\Adafruit SPIFlash\src\esp32\Adafruit_FlashTransport_ESP32.cpp:54:3: error: 'esp_flash_t' was not declared in this scope
   esp_flash_t const *flash = _partition->flash_chip;
   ^
.pio\libdeps\featheresp32\Adafruit SPIFlash\src\esp32\Adafruit_FlashTransport_ESP32.cpp:55:36: error: 'flash' was not declared in this scope
   _flash_device.manufacturer_id = (flash->chip_id >> 16);
                                    ^
*** [.pio\build\featheresp32\lib169\Adafruit SPIFlash\esp32\Adafruit_FlashTransport_ESP32.cpp.o] 
Error 1
================================== [FAILED] Took 37.41 seconds ==================================The terminal process "C:\Users\user\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--environment', 'featheresp32'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

What’s the platformio.ini?

Hi.

PlatformIO.ini

[env:featheresp32]
platform = espressif32
board = featheresp32
framework = arduino
lib_deps = 
    adafruit/Adafruit GFX Library@^1.10.10
    adafruit/Adafruit ST7735 and ST7789 Library@^1.7.3
    adafruit/Adafruit BusIO@^1.9.0
    adafruit/Adafruit ImageReader Library@^2.6.2
    adafruit/SdFat - Adafruit Fork@^1.2.4
    adafruit/Adafruit SPIFlash@^3.7.0

I can compile the sketch in the Arduino IDE using the 2.0.0 core (not the 2.0.0 beta core or 1.0.6) and a normal ESP32 (not a C2 or S3):

grafik

Note that PlatformIO is not using the 2.0.0 core but the previous

because currently multiple issues prevent this from working (https://github.com/platformio/platform-espressif32/issues/619). 2.0.0 integration in PlatformIO will probably need more time, and it preventing this library from compiling until the 2.0.0 core is usable.

Hi, many thanks for taking the time to look at this and feedback, appreciated. Looks like I will need to go back to the Arduino IDE then for now!