PlatformIO Community

How to get SPI_master to work ESP_IDF

[crosspost from reddit thread]

I created a project mostly copying ESP’s example SPI project which interfaces a classic arduino TFT 320x240 display. The first challenge will be determining pinout, although my logic analyzer will come in handy for that. The current problem I have is that I cannot compile the project for the life of me. After copying over all the files from the official repo into my project, I found that it cannot locate the image to convert to a binary format I suppose. I get the following error:

.pioenvs/esp32doit-devkit-v1/src/decode_image.o:(.literal.decode_image+0x14): undefined reference to `_binary_image_jpg_start'
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32doit-devkit-v1/firmware.elf] Error 1

The _binary_image_jpg_start refers to line 25 in decode_image.c. So presumably the linker does not know where to find that reference? Unlike in most projects, the makefile has the command COMPONENT_EMBED_FILES := image.jpg in it. However I’m doubtful this file is getting read when I hit the compile/upload button, at least when in the project directory. PlatformIO uses a different folders than the bare ESP IDF example. I came across this documentation but I don’t really know if this is what I need to do. What the heck is “SPIFFS”!? Including image.jpg and makefile in this /data folder did nothing. I don’t understand anything beyond step 2 here, I’m fairly new to PlatformIO. Step 3 resulted in the following error:

Could not find the `spiffs` section in the partitions table /home/maxim/.platformio/packages/framework-espidf/components/partition_table/partitions_singleapp.csv

I also went down the rabbit hole of attempting to modify the more promising platformio.ini file by appending:

build_flags = -DCOMPONENT_EMBED_TXTFILES= ~/Documents/PlatformIO/Projects/alarm_clock/data/image.jpg

however this doesn’t work:

*** [.pioenvs/esp32doit-devkit-v1/firmware.elf] Implicit dependency `/home/maxim/.platformio/platforms/espressif32/builder/~/Documents/PlatformIO/Projects/alarm_clock/data/image.jpg' not found, needed by target `.pioenvs/esp32doit-devkit-v1/firmware.elf'.

It tries to include a path going to the .projectio folder that leads to where all the framework files are, but I cannot escape from that location to point to where the image actually is. Adding the image to that path just results in it not liking that it’s a JPEG, so I suspect this is a dead end.

/home/maxim/.platformio/platforms/espressif32/builder/image.jpg: file not recognized: File format not recognized

So I’m fairly lost, I don’t know what else to try. How is this supposed to work? My goal is to have the display working as a starting point to mess with FreeRTOS and Bluetooth LE.

Okay, back to the beginning.

Since it’s using the Makefile command / macro


it is not using the SPIFFS filesystem. It’s directly reading the file and placing the binary contents into the firmware as constant data.

PlatformIO can do exactly the same using the same macro, as you have found out. However, the filename is encoded as the name of the created variable by which the file content can be accessed in the firmware code! Basically the created symbol is called _binary_<file path here>_start (together with the _end of it).

Since you have the error

The code is expecting this filename. So, just place the image.jpg in the main top project folder (not under src/!) and say

build_flags = -DCOMPONENT_EMBED_TXTFILES=image.jpg

Of course, another solution would be to place it under src/ and then adapt the name of the symbol the firmware accesses the data from. E.g., from the official example,

Then we simply do

Note how since embedded file is under src/aws_root_ca.pem the generated name is now _binary_src_aws_root_ca_pem_start.

For your code, you would have to change it there