Why isn't PlatformIO finding all font files in SPIFFS

This is output from the Arduino sketch

SPIFFS initialization succesfull

—Dir: /:
FILE: /NotoSansBold-15.vlw
FILE: /SansSerif36.vlw
FILE: /NotoSansBold-36.vlw

Next output is from PlatformIO program

orv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8

SPIFFS available!

Listing directory: /
/NotoSansBold-36.vlw 159260 bytes
Font file NotoSansBold-15 not found!
5
Font file NotoSansBold-15 not found!
5
Font file NotoSansBold-15 not found!
5

PlatformIO is a great IDE, but this is really very very annoying!
How on earth is this possible?

There could be a problem with the allocated size for the SPIFFS partition or the creation if the SPIFFS archive if that file is not found. If the file is in data/ and you did execute the project task “Upload Filesystem Image” and the file is not there (and the code didn’t delete it), it’s a bug somewhere.

Can you upload the whole project?

I will, but right now I’ve to find out how to use my ‘personal access token’ to push to GitHub.
See you later.

Well, that was quit an experience. But, here it is:

This project has no “data” folder? Where are the font files that supposed to be uploaded?

I used an Arduino sketch to upload those files to the ESP32.
The output from that sketch shows that those files are actually uploaded to the ESP32.
"
—Dir: /:
FILE: /NotoSansBold-15.vlw
FILE: /SansSerif36.vlw
FILE: /NotoSansBold-36.vlw
"
Weird thing is that executing the module ‘listDir(…)’ in the platformIO program, there’s only one font file listed.

I also tried a version with the font files in a data folder, but that didn’t change things.

Just for completeness’ sake, can you upload the data folder with the original files to the repo anyways?

I tried it again with font files in the data folder, but this is the output:
SPIFFS available!

Font file data/NotoSansBold-15.vlw not found!
Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d2938 PS : 0x00060730 A0 : 0x800f3eac A1 : 0x3ffb1ed0
A2 : 0x3ffb9548 A3 : 0x00000053 A4 : 0x0000001f A5 : 0x00000053
A6 : 0xa0ef90ce A7 : 0xff000000 A8 : 0x00000001 A9 : 0x3ffb1eb0
A10 : 0x00000053 A11 : 0x00000000 A12 : 0x3ffb96a8 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0xa0ef90d8 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffc

ELF file SHA256: 0000000000000000

Backtrace: 0x400d2938:0x3ffb1ed0 0x400f3ea9:0x3ffb1f00 0x400d3736:0x3ffb1f20 0x400d3845:0x3ffb1f40 0x400d3419:0x3ffb1f60 0x400d1176:0x3ffb1f80 0x400d49e9:0x3ffb1fb0 0x400863c1:0x3ffb1fd0

Rebooting…
ets Jun 8 2016 00:22:57
over and over again.

Here’s the latest code:

I suppose you can check (if you like) previous separate branches.

After you have called SPIFFS.begin() it will expose the SPIFFS filesystem under the base path

So if wanted an absolute path that would be "/spiffs/NotoSansBold-15.vlw". However, looking at the implementation

It is more appropriate to add -DFONT_FS_AVAILABLE to the build_flags of the platformio.ini this is automatically enabled through SMOOTH_FONT

Additonally it automatically constructs the path as follows

so one can either call

pTft->loadFont("NotoSansBold-15", SPIFFS);

or

pTft->loadFont("NotoSansBold-15");

which works for me.

(And since the filesystem is object to open the file, it is automatically already relative to its mounting point, no need to add /spiffs/)

--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8

SPIFFS available!

------------
------------
------------

(notice no crash but also no sensor values since no sensor attached).

Preceeding that is of course a filesystem upload.

Thank you for this explanation. So the above statement works for you.
Then the question remains:
the Arduino sketch reported:
SPIFFS initialization succesfull
—Dir: /:
FILE: /NotoSansBold-15.vlw
FILE: /SansSerif36.vlw
FILE: /NotoSansBold-36.vlw
So the Arduino sketch reported the on SPIFFS stored files correctly.

How can it be that the PlatformIO program, in which I use the same code as the Arduino sketch, reports only:
SPIFFS available!
Listing directory: /
/NotoSansBold-36.vlw 159260 bytes

Well, I’ll start a new project and do some double checking on the code.

What is the exact Arduino sketch that is run on the ESP32?

Just as simple as this:

#include <SPIFFS.h>
void setup() 
{
   Serial.begin(115200);
  if (!SPIFFS.begin(true))
  {
    Serial.printf("\nSPIFFS initialization failed!\n");
    vTaskDelay(1000 / portTICK_PERIOD_MS);
  }
  Serial.printf("\nSPIFFS initialization succesfull\n");
  Serial.printf("================================\n\n");
  listSPIFFS();
}

void loop() {
    // put your main code here, to run repeatedly:
}

void listSPIFFS()
{
  Serial.printf("---Dir: /:\n");
  File root = SPIFFS.open("/", "r");
  File file = root.openNextFile("r");
  while(file)
  { 
    Serial.printf("File name: %s\n", file.name());
    file = root.openNextFile();
  }
} // end listSPIFFS() -----------------------------------------------------------