espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.34k stars 7.36k forks source link

SD_MMC.cpp build fails with latest ESP IDF (and with f586f5e) #1312

Closed hamishcunningham closed 6 years ago

hamishcunningham commented 6 years ago

hi, I just pulled the latest from this repo and the latest from ESP IDF and now my build fails as follows:

CXX build/arduino/libraries/SD_MMC/src//SD_MMC.o
In file included from /home/hamish/esp/esp-idf/components/fatfs/src/esp_vfs_fat.h:20:0,
                 from /home/hamish/more-fish/idf/snurgle/components/arduino/libraries/SD_MMC/src//SD_MMC.cpp:21:
/home/hamish/more-fish/idf/snurgle/components/arduino/libraries/SD_MMC/src//SD_MMC.cpp: In member function 'bool fs::SDMMCFS::begin(const char*, bool)':
/home/hamish/esp/esp-idf/components/driver/include/driver/sdmmc_host.h:49:1: sorry, unimplemented: non-trivial designated initializers not supported
 }
 ^
/home/hamish/more-fish/idf/snurgle/components/arduino/libraries/SD_MMC/src//SD_MMC.cpp:45:25: note: in expansion of macro 'SDMMC_HOST_DEFAULT'
     sdmmc_host_t host = SDMMC_HOST_DEFAULT();
                         ^
/home/hamish/esp/esp-idf/components/driver/include/driver/sdmmc_host.h:49:1: sorry, unimplemented: non-trivial designated initializers not supported
 }
 ^
/home/hamish/more-fish/idf/snurgle/components/arduino/libraries/SD_MMC/src//SD_MMC.cpp:45:25: note: in expansion of macro 'SDMMC_HOST_DEFAULT'
     sdmmc_host_t host = SDMMC_HOST_DEFAULT();
                         ^
/home/hamish/esp/esp-idf/components/driver/include/driver/sdmmc_host.h:49:1: sorry, unimplemented: non-trivial designated initializers not supported
 }
 ^
/home/hamish/more-fish/idf/snurgle/components/arduino/libraries/SD_MMC/src//SD_MMC.cpp:45:25: note: in expansion of macro 'SDMMC_HOST_DEFAULT'
     sdmmc_host_t host = SDMMC_HOST_DEFAULT();
                         ^
/home/hamish/more-fish/idf/snurgle/components/arduino/libraries/SD_MMC/src//SD_MMC.cpp:57:5: warning: missing initializer for member 'esp_vfs_fat_mount_config_t::allocation_unit_size' [-Wmissing-field-initializers]
     };
     ^
/home/hamish/esp/esp-idf/make/component_wrapper.mk:273: recipe for target 'libraries/SD_MMC/src//SD_MMC.o' failed
make[1]: *** [libraries/SD_MMC/src//SD_MMC.o] Error 1
/home/hamish/esp/esp-idf/make/project.mk:457: recipe for target 'component-arduino-build' failed
make: *** [component-arduino-build] Error 2

Any ideas? More details below Thanks! Hamish

Hardware:

Board: Adafruit ESP32 Feather Core Installation/update date: 12th April IDE name: IDF component Flash Frequency: 40Mhz Upload Speed: 921600

Description:

IDF-based compile breaks with latest commits.

Sketch:

// main.cpp

// IDF includes...
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "Arduino.h"

static const char *TAG = "MAIN";

/////////////////////////////////////////////////////////////////////////////
// example code from the adafruit library touchpaint_featherwing example
// (with minimal changes)

/***************************************************
  This is our library for the Adafruit HX8357D Featherwing
  ----> http://www.adafruit.com/products/2050

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/

#include <SPI.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_HX8357.h>
#include <Adafruit_STMPE610.h>

#ifdef ESP8266
   #define STMPE_CS 16
   #define TFT_CS   0
   #define TFT_DC   15
   #define SD_CS    2
#endif
#ifdef ESP32
   #define STMPE_CS 32
   #define TFT_CS   15
   #define TFT_DC   33
   #define SD_CS    14
#endif
#ifdef __AVR_ATmega32U4__
   #define STMPE_CS 6
   #define TFT_CS   9
   #define TFT_DC   10
   #define SD_CS    5
#endif
#ifdef ARDUINO_SAMD_FEATHER_M0
   #define STMPE_CS 6
   #define TFT_CS   9
   #define TFT_DC   10
   #define SD_CS    5
#endif
#ifdef TEENSYDUINO
   #define TFT_DC   10
   #define TFT_CS   4
   #define STMPE_CS 3
   #define SD_CS    8
#endif
#ifdef ARDUINO_STM32_FEATHER
   #define TFT_DC   PB4
   #define TFT_CS   PA15
   #define STMPE_CS PC7
   #define SD_CS    PC5
#endif
#ifdef ARDUINO_FEATHER52
   #define STMPE_CS 30
   #define TFT_CS   13
   #define TFT_DC   11
   #define SD_CS    27
#endif

#define TFT_RST -1

Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 3800
#define TS_MAXX 100
#define TS_MINY 100
#define TS_MAXY 3750

// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void hx8357_setup() {
  ESP_LOGD(TAG, "HX8357D Featherwing touch test!"); 

  if (!ts.begin()) {
    ESP_LOGD(TAG, "Couldn't start touchscreen controller");
    while (1);
  }
  ESP_LOGD(TAG, "Touchscreen started");

  tft.begin(HX8357D);
  tft.fillScreen(HX8357_BLACK);
    // make the color selection boxes
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, HX8357_RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, HX8357_YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, HX8357_GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, HX8357_CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, HX8357_BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, HX8357_MAGENTA);
  tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, HX8357_BLACK);
  tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);

  // select the current color 'red'
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
  currentcolor = HX8357_RED;
}

void hx8357_loop(void) {
  // Retrieve a point  
  TS_Point p = ts.getPoint();

  // ESP_LOGD(TAG, "X = "); ESP_LOGD(TAG, p.x); ESP_LOGD(TAG, "\tY = ");
  // ESP_LOGD(TAG, p.y); ESP_LOGD(TAG, "\tPressure = "); ESP_LOGD(TAG, p.z); 

  // Scale from ~0->4000 to tft.width using the calibration #'s
  p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
  p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());

  if (p.y < BOXSIZE) {
     oldcolor = currentcolor;

     if (p.x < BOXSIZE) { 
       currentcolor = HX8357_RED; 
       tft.drawRect(0, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
     } else if (p.x < BOXSIZE*2) {
       currentcolor = HX8357_YELLOW;
       tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
     } else if (p.x < BOXSIZE*3) {
       currentcolor = HX8357_GREEN;
       tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
     } else if (p.x < BOXSIZE*4) {
       currentcolor = HX8357_CYAN;
       tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
     } else if (p.x < BOXSIZE*5) {
       currentcolor = HX8357_BLUE;
       tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
     } else if (p.x < BOXSIZE*6) {
       currentcolor = HX8357_MAGENTA;
       tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
     } else if (p.x < BOXSIZE*7) {
       currentcolor = HX8357_WHITE;
       tft.drawRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, HX8357_RED);
     } else if (p.x < BOXSIZE*8) {
       currentcolor = HX8357_BLACK;
       tft.drawRect(BOXSIZE*7, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
     }

     if (oldcolor != currentcolor) {
        if (oldcolor == HX8357_RED) 
          tft.fillRect(0, 0, BOXSIZE, BOXSIZE, HX8357_RED);
        if (oldcolor == HX8357_YELLOW) 
          tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, HX8357_YELLOW);
        if (oldcolor == HX8357_GREEN) 
          tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, HX8357_GREEN);
        if (oldcolor == HX8357_CYAN) 
          tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, HX8357_CYAN);
        if (oldcolor == HX8357_BLUE) 
          tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, HX8357_BLUE);
        if (oldcolor == HX8357_MAGENTA) 
          tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, HX8357_MAGENTA);
        if (oldcolor == HX8357_WHITE) 
          tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, HX8357_WHITE);
        if (oldcolor == HX8357_BLACK) 
          tft.fillRect(BOXSIZE*7, 0, BOXSIZE, BOXSIZE, HX8357_BLACK);
     }
  }

  if (((p.y-PENRADIUS) > 0) && ((p.y+PENRADIUS) < tft.height())) {
    tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
  }
}
/////////////////////////////////////////////////////////////////////////////

// a FreeRTOS task function wrapping the example sketch loop
void touchpaint_featherwing(void *pvParameter) {
  hx8357_setup();
  while(1) {
    micros(); //update overflow
    hx8357_loop();
    vTaskDelay(
      10 / portTICK_PERIOD_MS // https://github.com/espressif/esp-idf/issues/1646
    ); // & https://github.com/espressif/arduino-esp32/issues/595 but doesn't fix
  }
}

// main
extern "C" void app_main()
{
  const BaseType_t TASK_CORE = 1;
  xTaskCreatePinnedToCore(
    touchpaint_featherwing, "touchpaint_task",
    8192, NULL, 1000, NULL, TASK_CORE
  );
}

Debug Messages:

see make output above 
Curclamas commented 6 years ago

I can confirm this, I think @me-no-dev already implemented a fix in his branch: 6e99108fb45e61201084526f4de84b4e721a0590 , if you want to try: I think this should fix it.

hamishcunningham commented 6 years ago

Thanks @Curclamas that worked for me :)

Curclamas commented 6 years ago

@hamishcunningham I think this issue should stay open as long as the fixes are not yet upstream in master.