ESP-01 problém s SPIFFS na device 6014
Napsal: 28 čer 2018, 10:06
Zdravím,
mám problém se zápisem a čtení dat z flash pomocí SPIFFS. Čtení asi funguje, protože když na flash uploadnu soubor pomocí "ESP8266 Sketch Data Upload" v menu nástroje, tak soubor pomocí SPIFFS.readStringUntil('\n') přečtu, ale jakmile z programu zapíšu do souboru pomocí SPIFFS.println("něco"), tak z něj nejde přečíst co jsem do něj zapsal. Zjistil sem že problém je v (asi)nové čipu, který se hlásí jako Device:6014 (vyčteno pomocí esptool.py flash_id), protože pokud to samé nahraju do ESP Device:e0, tak to funguje.
Tady je testovací program a výpisy z esptool :
#include <ESP8266WiFi.h>
#include <FS.h> //Include File System Headers
const char* filename = "/samplefile.txt";
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
//Initialize File System
if(SPIFFS.begin())
{
Serial.println("SPIFFS Initialize....ok");
}
else
{
Serial.println("SPIFFS Initialization...failed");
}
//Format File System
if(SPIFFS.format())
{
Serial.println("File System Formated");
}
else
{
Serial.println("File System Formatting Error");
}
//Create New File And Write Data to It
//w=Write Open file for writing
File f = SPIFFS.open(filename, "w");
if (!f) {
Serial.println("file open failed");
}
else
{
//Write data to file
Serial.println("Writing Data to File");
f.print("This is sample data which is written in file");
f.close(); //Close file
}
}
void loop() {
int i;
//Read File data
File f = SPIFFS.open(filename, "r");
if (!f) {
Serial.println("file open failed");
}
else
{
Serial.println("Reading Data from File:");
//Data from file
for(i=0;i<f.size();i++) //Read upto complete file size
{
Serial.print((char)f.read());
}
f.close(); //Close file
Serial.println("File Closed");
}
delay(5000);
}
vystup Manufacturer:e0(4014):
SPIFFS Initialize....ok
File System Formated
Writing Data to File
Reading Data from File:
This is sample data which is written in fileFile Closed
vystup Manufacturer:85(6014):
SPIFFS Initialize....ok
File System Formated
Writing Data to File
Reading Data from File:
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮File Closed
Vypisy z esptool:
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: b4:e6:2d:22:f6:e5
Uploading stub...
Running stub...
Stub running...
Manufacturer: 85
Device: 6014
Detected flash size: 1MB
Hard resetting via RTS pin...
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: 5c:cf:7f:8e:8d:26
Uploading stub...
Running stub...
Stub running...
Manufacturer: e0
Device: 4014
Detected flash size: 1MB
Hard resetting via RTS pin...
mám problém se zápisem a čtení dat z flash pomocí SPIFFS. Čtení asi funguje, protože když na flash uploadnu soubor pomocí "ESP8266 Sketch Data Upload" v menu nástroje, tak soubor pomocí SPIFFS.readStringUntil('\n') přečtu, ale jakmile z programu zapíšu do souboru pomocí SPIFFS.println("něco"), tak z něj nejde přečíst co jsem do něj zapsal. Zjistil sem že problém je v (asi)nové čipu, který se hlásí jako Device:6014 (vyčteno pomocí esptool.py flash_id), protože pokud to samé nahraju do ESP Device:e0, tak to funguje.
Tady je testovací program a výpisy z esptool :
#include <ESP8266WiFi.h>
#include <FS.h> //Include File System Headers
const char* filename = "/samplefile.txt";
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
//Initialize File System
if(SPIFFS.begin())
{
Serial.println("SPIFFS Initialize....ok");
}
else
{
Serial.println("SPIFFS Initialization...failed");
}
//Format File System
if(SPIFFS.format())
{
Serial.println("File System Formated");
}
else
{
Serial.println("File System Formatting Error");
}
//Create New File And Write Data to It
//w=Write Open file for writing
File f = SPIFFS.open(filename, "w");
if (!f) {
Serial.println("file open failed");
}
else
{
//Write data to file
Serial.println("Writing Data to File");
f.print("This is sample data which is written in file");
f.close(); //Close file
}
}
void loop() {
int i;
//Read File data
File f = SPIFFS.open(filename, "r");
if (!f) {
Serial.println("file open failed");
}
else
{
Serial.println("Reading Data from File:");
//Data from file
for(i=0;i<f.size();i++) //Read upto complete file size
{
Serial.print((char)f.read());
}
f.close(); //Close file
Serial.println("File Closed");
}
delay(5000);
}
vystup Manufacturer:e0(4014):
SPIFFS Initialize....ok
File System Formated
Writing Data to File
Reading Data from File:
This is sample data which is written in fileFile Closed
vystup Manufacturer:85(6014):
SPIFFS Initialize....ok
File System Formated
Writing Data to File
Reading Data from File:
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮File Closed
Vypisy z esptool:
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: b4:e6:2d:22:f6:e5
Uploading stub...
Running stub...
Stub running...
Manufacturer: 85
Device: 6014
Detected flash size: 1MB
Hard resetting via RTS pin...
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: 5c:cf:7f:8e:8d:26
Uploading stub...
Running stub...
Stub running...
Manufacturer: e0
Device: 4014
Detected flash size: 1MB
Hard resetting via RTS pin...