Arduino ESP32 flash分区表配置信息查询示例程序
Posted perseverance52
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Arduino ESP32 flash分区表配置信息查询示例程序相关的知识,希望对你有一定的参考价值。
Arduino ESP32 flash分区表配置信息查询示例程序
- 程序烧录前,先配置好分区信息
- 在board.txt里面对应的详细分区配置:C:\\Users\\Administrator\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6
- 我的分区配置文件位置C:\\Users\\Administrator\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\tools\\partitions
详细分区配置信息
- 示例程序
/* Code gathered by Marc MERLIN <marc_soft@merlins.org> from code found
on gitter (license unknown) and in esp32-arduino's
libraries/FFat/examples/FFat_Test/FFat_Test.ino */
#include <esp_partition.h>
#include "FFat.h"
void partloop(esp_partition_type_t part_type) {
esp_partition_iterator_t iterator = NULL;
const esp_partition_t *next_partition = NULL;
iterator = esp_partition_find(part_type, ESP_PARTITION_SUBTYPE_ANY, NULL);
while (iterator) {
next_partition = esp_partition_get(iterator);
if (next_partition != NULL) {
Serial.printf("partition addr: 0x%06x; size: 0x%06x; label: %s\\n", next_partition->address, next_partition->size, next_partition->label);
iterator = esp_partition_next(iterator);
}
}
}
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
Serial.printf("Listing directory: %s\\r\\n", dirname);
File root = fs.open(dirname);
if(!root){
Serial.println("- failed to open directory");
return;
}
if(!root.isDirectory()){
Serial.println(" - not a directory");
return;
}
File file = root.openNextFile();
while(file){
if(file.isDirectory()){
Serial.print(" DIR : ");
Serial.println(file.name());
if(levels){
listDir(fs, file.name(), levels -1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print("\\tSIZE: ");
Serial.println(file.size());
}
file.close();
file = root.openNextFile();
}
}
void setup(){
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println("Partition list:");
partloop(ESP_PARTITION_TYPE_APP);
partloop(ESP_PARTITION_TYPE_DATA);
Serial.println("\\n\\nTrying to mount ffat partition if present");
// Only allow one file to be open at a time instead of 10, saving 9x4 - 36KB of RAM
if(!FFat.begin( 0, "", 1 )){
Serial.println("FFat Mount Failed");
return;
}
Serial.println("File system mounted");
Serial.printf("Total space: %10lu\\n", FFat.totalBytes());
Serial.printf("Free space: %10lu\\n\\n", FFat.freeBytes());
listDir(FFat, "/", 5);
}
void loop(){}
- 串口打印信息
以上是关于Arduino ESP32 flash分区表配置信息查询示例程序的主要内容,如果未能解决你的问题,请参考以下文章
合宙ESP32C3基于Arduino IDE框架下配置分区表