-
Notifications
You must be signed in to change notification settings - Fork 1
/
flash_config_check.cpp
35 lines (30 loc) · 1.29 KB
/
flash_config_check.cpp
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
#include "flash_config_check.h"
#include <ESP8266WiFi.h>
String flashConfigCache = "";
String& flashChipConfigCheck() {
if (flashConfigCache.length() == 0) {
uint32_t realSize = ESP.getFlashChipRealSize();
uint32_t ideSize = ESP.getFlashChipSize();
FlashMode_t ideMode = ESP.getFlashChipMode();
char buffer[128];
sprintf(buffer, "Flash real id: %08X\n", ESP.getFlashChipId());
flashConfigCache += buffer;
sprintf(buffer, "Flash real size: %u bytes\n\n", realSize);
flashConfigCache += buffer;
sprintf(buffer, "Flash ide size: %u bytes\n", ideSize);
flashConfigCache += buffer;
sprintf(buffer, "Flash ide speed: %u Hz\n", ESP.getFlashChipSpeed());
flashConfigCache += buffer;
sprintf(buffer, "Flash ide mode: %s\n",
(ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" :
ideMode == FM_DOUT ? "DOUT"
: "UNKNOWN"));
flashConfigCache += buffer;
if (ideSize != realSize) {
flashConfigCache += "Flash Chip configuration wrong!\n";
} else {
flashConfigCache += "Flash Chip configuration ok.\n";
}
}
return flashConfigCache;
}