I have a 30-pin ESP32 Board of Espressif Systems. I am aware that the 32-bit LX6 Processor of the board does not have on-chip flash memory. The Espressif Systems has added an off-chip SPI-port based flash memory as per following connection diagram (Fig-1).
The type of the chip indicates its size as 4-MByte which I want to verify running the following sketch picked up from web; however, it does not get compiled due to missing of ESP.h and SPIFFS.h files.
I have searched the web for these files without luck. Would appreciate your help in getting these header files or a working sketch.
Figure-1:
Non-functional Test Sketch (copy paste from web):
#include <ESP.h>
#include <SPIFFS.h>
void setup() {
Serial.begin(9600);
delay(1000);
// Initialize the SPIFFS file system
if (!SPIFFS.begin(true)) {
Serial.println("Initialization failed!");
return;
}
// size of the compiled program
uint32_t program_size = ESP.getSketchSize();
// size of the file system
FSInfo fs_info;
SPIFFS.info(fs_info);
uint32_t file_system_size = fs_info.totalBytes;
// used size of the file system
uint32_t file_system_used = fs_info.usedBytes;
// free size in the flash memory
uint32_t free_size = ESP.getFlashChipSize() - program_size - file_system_size + file_system_used;
Serial.print("Program size: ");
Serial.print(program_size);
Serial.println(" bytes");
Serial.print("File system size: ");
Serial.print(file_system_size);
Serial.println(" bytes");
Serial.print("File system used: ");
Serial.print(file_system_used);
Serial.println(" bytes");
Serial.print("Free space: ");
Serial.print(free_size);
Serial.println(" bytes");
}
void loop() {
// Do Nothing Here
}
I have already installed the ESP32 support, and I can see the following board (s) by clicking on the Tools of the Tools Bar:
ESP32 Arduino
There is an example in the IDE named SPIFFS_test which has included FS.h and SPIFFS.h files and the sketch gets uploaded (though at this moment I don't know what this sketch is doing!)
I have just now followed the link. The esp26 board was already installed and yet I have updated it via Board Manager. The sketch of post #1 is still not compiled. The error message is posted below:
What is the difference between Board File and Library File?
From where can I get ESP.h and SPIFFS.h Library files in order to get my sketch of post #1 compiled? Should I be able to include these two files in my IDE using Library Manager or these are automatically included when the esp32 Board is installed?
Board files contain the definitions for boards such as the mapping between the pins on the chip and the pins on the board and other board specific parameters
Library files contain code that can be called by your sketches
Note that some libraries may be specific to particular boards and a number of them will be installed when you install a board
Installation of a board using IDE 1.x is a 2 stage process
First put the required URL in the Additional Boards field of Preferences so that the IDE knows where to find the board file. Then use the Board Manager to actually install the board files and make the board definition available to the IDE
There is only one Compiler package in the IDE and is dealing with different boards (UNO, ESP32 for example) which contain processors of differing instruction sets. However, the high level code like digitalWrite() is the same for both boards.
The Compiler chooses the right instruction set for the right processor; as a result, the high level codes are correctly transformed into corresponding executable binary codes.
My question is: where does this mapping table (high level code vs processor-specific binary codes) reside -- within the Compiler or the Board File?
Definitely not. Each board package usually has its own compiler. E.g. on windows the ESP32 compiler resides in C:\Users\username\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc. The board package contains much more than mappings and parameters. There is a lot of software in it - board specific versions of the standard libraries, core specific software and tools to get it running.
I have travelled across the above tree and have visited all the folders/files.
There are so much code lines and text lines -- have they all been created by human being or some kind of assistances are taken from machines?
When IDE is called upon, then all the executable files are loaded into memory or they remain in the secondary storage device and called upon when needed in response to the click on the Verify/Compile button?
Drawing kind attention of the veteran Forum members to my issue posted in this thread -- is there a way to make the following API-based code to work to know the off-chip flash size of ESP32? You may suggest any other possible ways.
I asked chatGPT for help and it has supplied me some trustworthy codes which I have tailored as follows to get the size of the off-chip flash memory of ESP32. The sketch has worked and reported the flash size as 4 MB.
Thanks to all who have participated with me in my journey of learning the architecture and programming of "32-bit LX6 Microcontroller using ESP32 Dev Kit".