-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathESP32_11_FFS.ino
103 lines (90 loc) · 2.42 KB
/
ESP32_11_FFS.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <FFat.h>
#include <ESP32Time.h>
#include <ESP.h>
#include <Arduino.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ESPTelnetStream.h"
#define NUM_LEDS 1
#define DATA_PIN 2
extern void TStart();
int startup(char* rkfile, char* rlfile, int bootdev);
using namespace std;
char* ReadLine(bool fullDuplex = true, char lineBreak = '\n');
String Fnames[128];
int SelFile, cntr = 0;
int lbright = 0;
// List contents of SDCard.
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.printf(" File:%3d ", cntr + 1);
Serial.print(file.name());
Fnames[cntr++] = file.name();
Serial.print("\tSIZE: ");
Serial.println(file.size());
}
file = root.openNextFile();
}
}
void setup() {
char* bfr, rkfile[32], rlfile[32];
int bootdev = 0;
neopixelWrite(39, 0, 10, 0);
Serial.begin(115200);
while (!Serial)
{
yield();
}
Serial.println("Startup.....");
if (!FFat.begin()) {
Serial.println("FatFS Mount Failed");
while (1);
}
uint64_t cardSize = FFat.totalBytes() / 1024;
Serial.printf("FFS Size: %llu KByte\r\n", cardSize);
Serial.printf("FFS free: %d KByte\r\n", FFat.freeBytes() / 1024);
Serial.printf("Total heap: %d\r\n", ESP.getHeapSize());
Serial.printf("Free heap: %d\r\n", ESP.getFreeHeap());
Serial.printf("Alloc heap: %d\r\n", ESP.getMaxAllocHeap());
listDir(FFat, "/", 3);
Serial.printf("Enter index of RK05 image:");
bfr = ReadLine(true, '\r');
sscanf(bfr, "%d", &SelFile);
strcpy(rkfile, "/");
strcat(rkfile, Fnames[SelFile - 1].c_str());
Serial.printf("\r\nEnter index of RL01/2 image:");
bfr = ReadLine(true, '\r');
sscanf(bfr, "%d", &SelFile);
strcpy(rlfile, "/");
strcat(rlfile, Fnames[SelFile - 1].c_str());
Serial.printf("\r\nBoot: RK/RL:");
bfr = ReadLine(true, '\r');
if (bfr[1] == 'l' || bfr[1] == 'L')
bootdev = 1;
if (bootdev)
Serial.printf("\r\nBooting file:%s on RL0:\r\n", rlfile);
else
Serial.printf("\r\nBooting file:%s on RK0:\r\n", rkfile);
TStart();
startup(rkfile, rlfile, bootdev);
}