adafruit / Adafruit_ImageReader

Companion Arduino library for Adafruit_GFX to load images from SD card
68 stars 21 forks source link

Will not compile #45

Closed orenzav closed 3 years ago

orenzav commented 3 years ago

Hi,

I'm using the ImageReader example code (see below) to display images from an SD card. Hardware is an Adfruit ESP32 Feather and an Adafruit 1.44" Color TFT LCD Display with MicroSD Card breakout - ST7735R. I'm using PlatformIO (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.

I've searched the forums buy closest I've come across that's similar is this: https://github.com/espressif/arduino-esp32/issues/4115 which doesn't work

Error:

c:\Users\user\Documents\Arduino\libraries\Adafruit_SPIFlash\src\esp32\Adafruit_FlashTransport_ESP32.cpp: In member function 'SPIFlash_Device_t* Adafruit_FlashTransport_ESP32::getFlashDevice()':
c:\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;
   ^
c:\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() {

}
hathach commented 3 years ago

@orenzav I edited your post to make it easier to read, can you also provide the version of following libraries for reproducing:

also please attached your full compile log from Arduino IDE for analysis

orenzav commented 3 years ago

Hi,

Thanks for your reply: full compile log.txt

Adafruit_ImageReader is version 2.6.2 Adafruit_SPIFlash is version 3.7.0 BSP of arduino-esp32 - Really sorry not sure what this is where would I find it? Do you mean platform version as per below its Espressif 32 (3.3.2)

Full compile log from fresh as per attached

hathach commented 3 years ago

Can you please edit your post to have full log as attached txt file for readability

orenzav commented 3 years ago

Sorry, edited now and attached. Thanks.

hathach commented 3 years ago

no problem, I will try to reproduce the issue and post more update whenever I could

hathach commented 3 years ago

@orenzav I don't use platformio, can you post the compile log of the Arduino IDE

PS: now I read the issue more closely. Apparently it work with Arduino IDE 1.8 therefore It is probably something specific with platformIO and how they resolve the libraries dependency. Which I have no idea how to resolve. I would suggest you to post this issue to platformIO forum to see if there any fixes from people with the same issue. Arduino 2.0 is still experimental therefore It could have its own issue.

orenzav commented 3 years ago

OK thanks for your help, appreciated