Skip to content

partial incompatibility with arduino_GFX lib ? #1205

@ewaca

Description

@ewaca

I have started to work on my MP3 player with an esp32 wroom devkit on arduino 2.0 framework, and i used Tft_espi lib for my screen.
Since then, I have migrated my project on arduino 3.0 framework with an esp32 S3 module. TFT_espi is not working with arduino 3.0, so i have found a new lib for my screen : Arduino_GFX.

But if i use pauseResume() command, it works, the song is paused, but when a use this command again, it crash.
my testing code :
no declaration for my screen / play / after 5sec pauseresume() and print time in ms / 5sec later pauseresume() and print time

#include <Arduino.h>
#include "Audio.h"
#include <Arduino_GFX_Library.h>
#include <Fonts/FreeMono9pt7b.h>
//#include <stdio.h>
#include "sdkconfig.h"
#include <Wire.h>
#include <TFT_eSPI.h> 
#include "SD.h"
#include "FS.h"


#define pushButton_pin   3
 

// microSD Card Reader connections
#define SD_CS         10
#define SD_MOSI       11 
#define SD_MISO       13
#define SD_SCLK       12
static SPIClass spiSD{ HSPI };

// Pins for SPI bus for the display
#define TFT_CLK 40   //SPI Clock
#define TFT_DA  41   //SPI Data (MOSI)
#define TFT_DC  39   //Data/Command
#define TFT_CS  42   //Chip select
#define TFT_RST 37   //Reset
Arduino_DataBus *bus = new Arduino_ESP32SPI(38 /* DC */, 39 /* CS */, 40 /* SCK */, 41 /* MOSI */, GFX_NOT_DEFINED /* MISO */,HSPI);
//Arduino_GFX *tft = new Arduino_ST7789(bus, 42 /* RST */, 3 /* rotation */, true /* IPS */, 240 /* width */, 320 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 0 /* row offset 2 */);

// I2S Connections
#define CONFIG_IDF_TARGET_ESP32S3
#define I2S_DOUT      17
#define I2S_BCLK      16
#define I2S_LRC       18
 // Create Audio object
Audio audio;

void setup() {
  Serial.begin(115200);
 SPI.begin(SD_SCLK,SD_MISO,SD_MOSI,SD_CS);
     if (!SD.begin(SD_CS)) {

    Serial.println("Card Mount Failed");
    return;
  }
 delay(500);
  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
  audio.connecttoFS(SD,"/Arch Enemy/Will To Power/05-The Eagle Flies Alone.mp3");
}
long temp=0;
bool stop=false;

void loop() {
     temp=millis();
  
    vTaskDelay(1);
    audio.loop();
    if (temp>5000 && temp<10000)
    {
      if (stop==false )
      {
        stop=true;
      Serial.println(temp);
      audio.pauseResume();}
    }
    if (temp>10000)
    {
      if (stop==true)
      {
       stop=false;
      Serial.println(temp);
      audio.pauseResume();}
    }
}

and the serial monitor result :

5007
10001

now if i uncomment the tft declaration

#include <Arduino.h>
#include "Audio.h"
#include <Arduino_GFX_Library.h>
#include <Fonts/FreeMono9pt7b.h>
//#include <stdio.h>
#include "sdkconfig.h"
#include <Wire.h>
#include <TFT_eSPI.h> 
#include "SD.h"
#include "FS.h"


#define pushButton_pin   3
 

// microSD Card Reader connections
#define SD_CS         10
#define SD_MOSI       11 
#define SD_MISO       13
#define SD_SCLK       12
static SPIClass spiSD{ HSPI };

// Pins for SPI bus for the display
#define TFT_CLK 40   //SPI Clock
#define TFT_DA  41   //SPI Data (MOSI)
#define TFT_DC  39   //Data/Command
#define TFT_CS  42   //Chip select
#define TFT_RST 37   //Reset
Arduino_DataBus *bus = new Arduino_ESP32SPI(38 /* DC */, 39 /* CS */, 40 /* SCK */, 41 /* MOSI */, GFX_NOT_DEFINED /* MISO */,HSPI);
Arduino_GFX *tft = new Arduino_ST7789(bus, 42 /* RST */, 3 /* rotation */, true /* IPS */, 240 /* width */, 320 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 0 /* row offset 2 */);

// I2S Connections
#define CONFIG_IDF_TARGET_ESP32S3
#define I2S_DOUT      17
#define I2S_BCLK      16
#define I2S_LRC       18
 // Create Audio object
Audio audio;

void setup() {
  Serial.begin(115200);
 SPI.begin(SD_SCLK,SD_MISO,SD_MOSI,SD_CS);
     if (!SD.begin(SD_CS)) {

    Serial.println("Card Mount Failed");
    return;
  }
 delay(500);
  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
  audio.connecttoFS(SD,"/Arch Enemy/Will To Power/05-The Eagle Flies Alone.mp3");
}
long temp=0;
bool stop=false;

void loop() {
     temp=millis();
  
    vTaskDelay(1);
    audio.loop();
    if (temp>5000 && temp<10000)
    {
      if (stop==false )
      {
        stop=true;
      Serial.println(temp);
      audio.pauseResume();}
    }
    if (temp>10000)
    {
      if (stop==true)
      {
       stop=false;
      Serial.println(temp);
      audio.pauseResume();}
    }
}

The serial monitor show that the song is paused, then resume and then it crash.

 5007
10001

assert failed: block_locate_free tlsf_control_functions.h:618 (block_size(block) >= *size)


Backtrace: 0x4037fb01:0x3fca3ce0 0x4037facd:0x3fca3d00 0x403876d5:0x3fca3d20 0x4038603a:0x3fca3e40 0x40385a97:0x3fca3e60 0x4037761b:0x3fca3e80 0x4037763d:0x3fca3eb0 0x403777d5:0x3fca3ed0 0x4208f8cb:0x3fca3ef0 0x42010025:0x3fca3f10 0x4201e285:0x3fca3f30 0x4201e385:0x3fca3f70
  #0  0x4037fb01 in panic_abort at /home/ewaca/.platformio/packages/framework-espidf/components/esp_system/panic.c:477
  #1  0x4037facd in esp_system_abort at /home/ewaca/.platformio/packages/framework-espidf/components/esp_system/port/esp_system_chip.c:87
  #2  0x403876d5 in __assert_func at /home/ewaca/.platformio/packages/framework-espidf/components/newlib/src/assert.c:80
  #3  0x4038603a in block_locate_free at /home/ewaca/.platformio/packages/framework-espidf/components/heap/tlsf/tlsf_control_functions.h:618 (discriminator 1)
      (inlined by) tlsf_malloc at /home/ewaca/.platformio/packages/framework-espidf/components/heap/tlsf/tlsf.c:444 (discriminator 1)
  #4  0x40385a97 in multi_heap_malloc_impl at /home/ewaca/.platformio/packages/framework-espidf/components/heap/multi_heap.c:216
  #5  0x4037761b in aligned_or_unaligned_alloc at /home/ewaca/.platformio/packages/framework-espidf/components/heap/heap_caps_base.c:93
      (inlined by) heap_caps_aligned_alloc_base at /home/ewaca/.platformio/packages/framework-espidf/components/heap/heap_caps_base.c:175
  #6  0x4037763d in heap_caps_malloc_base at /home/ewaca/.platformio/packages/framework-espidf/components/heap/heap_caps_base.c:202
  #7  0x403777d5 in heap_caps_malloc at /home/ewaca/.platformio/packages/framework-espidf/components/heap/heap_caps.c:84
  #8  0x4208f8cb in ps_malloc at /home/ewaca/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-psram.c:116
  #9  0x42010025 in ps_ptr<char>::alloc(unsigned int, char const*, bool) at .pio/libdeps/esp32s3/ESP32-audioI2S/src/psram_unique_ptr.hpp:186
      (inlined by) ps_ptr<char>::copy_from(char const*, unsigned int) at .pio/libdeps/esp32s3/ESP32-audioI2S/src/psram_unique_ptr.hpp:384
  #10 0x4201e285 in Audio::playAudioData() at .pio/libdeps/esp32s3/ESP32-audioI2S/src/Audio.cpp:4376 (discriminator 1)
      (inlined by) Audio::playAudioData() at .pio/libdeps/esp32s3/ESP32-audioI2S/src/Audio.cpp:4317 (discriminator 1)

i have tried to get current playtime, then use audio.stopsong and then start the song at the playtime i got before, it works

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions