Skip to content

Commit 2a56cef

Browse files
committed
Merge pull request #6 from esp8266/esp8266
pull master
2 parents be74265 + cf424a9 commit 2a56cef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2708
-328
lines changed

boards.txt

+82-27
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,22 @@ generic.menu.FlashSize.2M.build.spiffs_end=0x1FB000
112112
generic.menu.FlashSize.2M.build.spiffs_blocksize=8192
113113
generic.menu.FlashSize.2M.upload.maximum_size=1044464
114114

115-
generic.menu.FlashSize.4M=4M (3M SPIFFS)
116-
generic.menu.FlashSize.4M.build.flash_size=4M
117-
generic.menu.FlashSize.4M.build.flash_ld=eagle.flash.4m.ld
118-
generic.menu.FlashSize.4M.build.spiffs_start=0x100000
119-
generic.menu.FlashSize.4M.build.spiffs_end=0x3FB000
120-
generic.menu.FlashSize.4M.build.spiffs_blocksize=8192
121-
generic.menu.FlashSize.4M.upload.maximum_size=1044464
115+
generic.menu.FlashSize.4M1M=4M (1M SPIFFS)
116+
generic.menu.FlashSize.4M1M.build.flash_size=4M
117+
generic.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld
118+
generic.menu.FlashSize.4M1M.build.spiffs_start=0x300000
119+
generic.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
120+
generic.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
121+
generic.menu.FlashSize.4M1M.build.spiffs_pagesize=256
122+
generic.menu.FlashSize.4M1M.upload.maximum_size=1044464
123+
124+
generic.menu.FlashSize.4M3M=4M (3M SPIFFS)
125+
generic.menu.FlashSize.4M3M.build.flash_size=4M
126+
generic.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld
127+
generic.menu.FlashSize.4M3M.build.spiffs_start=0x100000
128+
generic.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000
129+
generic.menu.FlashSize.4M3M.build.spiffs_blocksize=8192
130+
generic.menu.FlashSize.4M3M.upload.maximum_size=1044464
122131

123132
# disabled because espressif's bootloader refuses to write above 4M
124133
# generic.menu.FlashSize.8M=8M (7M SPIFFS)
@@ -154,11 +163,6 @@ huzzah.build.variant=adafruit
154163
huzzah.build.flash_mode=qio
155164
huzzah.build.flash_size=4M
156165
huzzah.build.flash_freq=40
157-
huzzah.build.flash_ld=eagle.flash.4m.ld
158-
huzzah.build.spiffs_start=0x100000
159-
huzzah.build.spiffs_end=0x3FB000
160-
huzzah.build.spiffs_pagesize=256
161-
huzzah.build.spiffs_blocksize=8192
162166

163167
huzzah.menu.CpuFrequency.80=80 MHz
164168
huzzah.menu.CpuFrequency.80.build.f_cpu=80000000L
@@ -176,6 +180,22 @@ huzzah.menu.UploadSpeed.256000.upload.speed=256000
176180
huzzah.menu.UploadSpeed.921600=921600
177181
huzzah.menu.UploadSpeed.921600.upload.speed=921600
178182

183+
huzzah.menu.FlashSize.4M3M=4M (3M SPIFFS)
184+
huzzah.menu.FlashSize.4M3M.build.flash_size=4M
185+
huzzah.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld
186+
huzzah.menu.FlashSize.4M3M.build.spiffs_start=0x100000
187+
huzzah.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000
188+
huzzah.menu.FlashSize.4M3M.build.spiffs_blocksize=8192
189+
huzzah.menu.FlashSize.4M3M.build.spiffs_pagesize=256
190+
191+
huzzah.menu.FlashSize.4M1M=4M (1M SPIFFS)
192+
huzzah.menu.FlashSize.4M1M.build.flash_size=4M
193+
huzzah.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld
194+
huzzah.menu.FlashSize.4M1M.build.spiffs_start=0x300000
195+
huzzah.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
196+
huzzah.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
197+
huzzah.menu.FlashSize.4M1M.build.spiffs_pagesize=256
198+
179199
##############################################################
180200
nodemcu.name=NodeMCU 0.9 (ESP-12 Module)
181201

@@ -196,11 +216,6 @@ nodemcu.build.variant=nodemcu
196216
nodemcu.build.flash_mode=qio
197217
nodemcu.build.flash_size=4M
198218
nodemcu.build.flash_freq=40
199-
nodemcu.build.flash_ld=eagle.flash.4m.ld
200-
nodemcu.build.spiffs_start=0x100000
201-
nodemcu.build.spiffs_end=0x3FB000
202-
nodemcu.build.spiffs_pagesize=256
203-
nodemcu.build.spiffs_blocksize=8192
204219

205220
nodemcu.menu.CpuFrequency.80=80 MHz
206221
nodemcu.menu.CpuFrequency.80.build.f_cpu=80000000L
@@ -227,6 +242,22 @@ nodemcu.menu.UploadSpeed.512000.upload.speed=512000
227242
nodemcu.menu.UploadSpeed.921600=921600
228243
nodemcu.menu.UploadSpeed.921600.upload.speed=921600
229244

245+
nodemcu.menu.FlashSize.4M3M=4M (3M SPIFFS)
246+
nodemcu.menu.FlashSize.4M3M.build.flash_size=4M
247+
nodemcu.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld
248+
nodemcu.menu.FlashSize.4M3M.build.spiffs_start=0x100000
249+
nodemcu.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000
250+
nodemcu.menu.FlashSize.4M3M.build.spiffs_blocksize=8192
251+
nodemcu.menu.FlashSize.4M3M.build.spiffs_pagesize=256
252+
253+
nodemcu.menu.FlashSize.4M1M=4M (1M SPIFFS)
254+
nodemcu.menu.FlashSize.4M1M.build.flash_size=4M
255+
nodemcu.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld
256+
nodemcu.menu.FlashSize.4M1M.build.spiffs_start=0x300000
257+
nodemcu.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
258+
nodemcu.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
259+
nodemcu.menu.FlashSize.4M1M.build.spiffs_pagesize=256
260+
230261
##############################################################
231262
nodemcuv2.name=NodeMCU 1.0 (ESP-12E Module)
232263

@@ -247,11 +278,6 @@ nodemcuv2.build.variant=nodemcu
247278
nodemcuv2.build.flash_mode=dio
248279
nodemcuv2.build.flash_size=4M
249280
nodemcuv2.build.flash_freq=40
250-
nodemcuv2.build.flash_ld=eagle.flash.4m.ld
251-
nodemcuv2.build.spiffs_start=0x100000
252-
nodemcuv2.build.spiffs_end=0x3FB000
253-
nodemcuv2.build.spiffs_pagesize=256
254-
nodemcuv2.build.spiffs_blocksize=8192
255281

256282
nodemcuv2.menu.CpuFrequency.80=80 MHz
257283
nodemcuv2.menu.CpuFrequency.80.build.f_cpu=80000000L
@@ -278,6 +304,23 @@ nodemcuv2.menu.UploadSpeed.512000.upload.speed=512000
278304
nodemcuv2.menu.UploadSpeed.921600=921600
279305
nodemcuv2.menu.UploadSpeed.921600.upload.speed=921600
280306

307+
nodemcuv2.menu.FlashSize.4M3M=4M (3M SPIFFS)
308+
nodemcuv2.menu.FlashSize.4M3M.build.flash_size=4M
309+
nodemcuv2.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld
310+
nodemcuv2.menu.FlashSize.4M3M.build.spiffs_start=0x100000
311+
nodemcuv2.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000
312+
nodemcuv2.menu.FlashSize.4M3M.build.spiffs_blocksize=8192
313+
nodemcuv2.menu.FlashSize.4M3M.build.spiffs_pagesize=256
314+
315+
nodemcuv2.menu.FlashSize.4M1M=4M (1M SPIFFS)
316+
nodemcuv2.menu.FlashSize.4M1M.build.flash_size=4M
317+
nodemcuv2.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld
318+
nodemcuv2.menu.FlashSize.4M1M.build.spiffs_start=0x300000
319+
nodemcuv2.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
320+
nodemcuv2.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
321+
nodemcuv2.menu.FlashSize.4M1M.build.spiffs_pagesize=256
322+
323+
281324
##############################################################
282325
modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
283326

@@ -355,6 +398,7 @@ thing.build.flash_freq=40
355398
thing.build.spiffs_start=0x6B000
356399
thing.build.spiffs_end=0x7B000
357400
thing.build.spiffs_blocksize=4096
401+
thing.build.spiffs_pagesize=256
358402

359403
thing.menu.CpuFrequency.80=80 MHz
360404
thing.menu.CpuFrequency.80.build.f_cpu=80000000L
@@ -400,11 +444,6 @@ esp210.build.variant=generic
400444
esp210.build.flash_mode=qio
401445
esp210.build.flash_size=4M
402446
esp210.build.flash_freq=40
403-
esp210.build.flash_ld=eagle.flash.4m.ld
404-
esp210.build.spiffs_start=0x100000
405-
esp210.build.spiffs_end=0x3FB000
406-
esp210.build.spiffs_pagesize=256
407-
esp210.build.spiffs_blocksize=8192
408447

409448
esp210.menu.CpuFrequency.80=80 MHz
410449
esp210.menu.CpuFrequency.80.build.f_cpu=80000000L
@@ -429,6 +468,22 @@ esp210.menu.UploadSpeed.512000.upload.speed=512000
429468
esp210.menu.UploadSpeed.921600=921600
430469
esp210.menu.UploadSpeed.921600.upload.speed=921600
431470

471+
esp210.menu.FlashSize.4M3M=4M (3M SPIFFS)
472+
esp210.menu.FlashSize.4M3M.build.flash_size=4M
473+
esp210.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld
474+
esp210.menu.FlashSize.4M3M.build.spiffs_start=0x100000
475+
esp210.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000
476+
esp210.menu.FlashSize.4M3M.build.spiffs_blocksize=8192
477+
esp210.menu.FlashSize.4M3M.build.spiffs_pagesize=256
478+
479+
esp210.menu.FlashSize.4M1M=4M (1M SPIFFS)
480+
esp210.menu.FlashSize.4M1M.build.flash_size=4M
481+
esp210.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld
482+
esp210.menu.FlashSize.4M1M.build.spiffs_start=0x300000
483+
esp210.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
484+
esp210.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
485+
esp210.menu.FlashSize.4M1M.build.spiffs_pagesize=256
486+
432487
##############################################################
433488
# wifio.name=Wifio
434489
#

cores/esp8266/Esp.cpp

+26-1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) {
280280
return (2_MB);
281281
case 0x1440EF: // W25Q80
282282
return (1_MB);
283+
case 0x1340EF: // W25Q40
284+
return (512_kB);
283285

284286
default:
285287
return 0;
@@ -289,7 +291,7 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) {
289291
String EspClass::getResetInfo(void) {
290292
if(resetInfo.reason != 0) {
291293
char buff[200];
292-
sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
294+
sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : resetInfo.reason == 6 ? "EXT_SYS_RST" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
293295
return String(buff);
294296
}
295297
return String("flag: 0");
@@ -400,3 +402,26 @@ bool EspClass::updateSketch(Stream& in, uint32_t size, bool restartOnFail, bool
400402
if(restartOnSuccess) ESP.restart();
401403
return true;
402404
}
405+
406+
static const int FLASH_INT_MASK = ((B10 << 8) | B00111010);
407+
408+
bool EspClass::flashEraseSector(uint32_t sector) {
409+
ets_isr_mask(FLASH_INT_MASK);
410+
int rc = spi_flash_erase_sector(sector);
411+
ets_isr_unmask(FLASH_INT_MASK);
412+
return rc == 0;
413+
}
414+
415+
bool EspClass::flashWrite(uint32_t offset, uint32_t *data, size_t size) {
416+
ets_isr_mask(FLASH_INT_MASK);
417+
int rc = spi_flash_write(offset, (uint32_t*) data, size);
418+
ets_isr_unmask(FLASH_INT_MASK);
419+
return rc == 0;
420+
}
421+
422+
bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size) {
423+
ets_isr_mask(FLASH_INT_MASK);
424+
int rc = spi_flash_read(offset, (uint32_t*) data, size);
425+
ets_isr_unmask(FLASH_INT_MASK);
426+
return rc == 0;
427+
}

cores/esp8266/Esp.h

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ class EspClass {
117117
FlashMode_t getFlashChipMode();
118118
uint32_t getFlashChipSizeByChipId();
119119

120+
bool flashEraseSector(uint32_t sector);
121+
bool flashWrite(uint32_t offset, uint32_t *data, size_t size);
122+
bool flashRead(uint32_t offset, uint32_t *data, size_t size);
123+
120124
uint32_t getSketchSize();
121125
uint32_t getFreeSketchSpace();
122126
bool updateSketch(Stream& in, uint32_t size, bool restartOnFail = false, bool restartOnSuccess = true);

cores/esp8266/FS.cpp

+20-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ size_t File::write(uint8_t c) {
2929
if (!_p)
3030
return 0;
3131

32-
_p->write(&c, 1);
32+
return _p->write(&c, 1);
3333
}
3434

3535
size_t File::write(const uint8_t *buf, size_t size) {
3636
if (!_p)
3737
return 0;
3838

39-
_p->write(buf, size);
39+
return _p->write(buf, size);
4040
}
4141

4242
int File::available() {
@@ -167,6 +167,13 @@ bool FS::begin() {
167167
return _impl->begin();
168168
}
169169

170+
bool FS::format() {
171+
if (!_impl) {
172+
return false;
173+
}
174+
return _impl->format();
175+
}
176+
170177
File FS::open(const String& path, const char* mode) {
171178
return open(path.c_str(), mode);
172179
}
@@ -186,6 +193,17 @@ File FS::open(const char* path, const char* mode) {
186193
return File(_impl->open(path, om, am));
187194
}
188195

196+
bool FS::exists(const char* path) {
197+
if (!_impl) {
198+
return false;
199+
}
200+
return _impl->exists(path);
201+
}
202+
203+
bool FS::exists(const String& path) {
204+
return exists(path.c_str());
205+
}
206+
189207
Dir FS::openDir(const char* path) {
190208
if (!_impl) {
191209
return Dir();

cores/esp8266/FS.h

+5
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,14 @@ class FS
9292

9393
bool begin();
9494

95+
bool format();
96+
9597
File open(const char* path, const char* mode);
9698
File open(const String& path, const char* mode);
9799

100+
bool exists(const char* path);
101+
bool exists(const String& path);
102+
98103
Dir openDir(const char* path);
99104
Dir openDir(const String& path);
100105

cores/esp8266/FSImpl.h

+2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class DirImpl {
6363
class FSImpl {
6464
public:
6565
virtual bool begin() = 0;
66+
virtual bool format() = 0;
6667
virtual FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) = 0;
68+
virtual bool exists(const char* path) = 0;
6769
virtual DirImplPtr openDir(const char* path) = 0;
6870
virtual bool rename(const char* pathFrom, const char* pathTo) = 0;
6971
virtual bool remove(const char* path) = 0;

cores/esp8266/HardwareSerial.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ uart_t* uart_init(int uart_nr, int baudrate, byte config, byte mode) {
290290
uart->txPin = (uart->txEnabled)?1:255;
291291
if(uart->rxEnabled) pinMode(uart->rxPin, SPECIAL);
292292
if(uart->txEnabled) pinMode(uart->txPin, SPECIAL);
293+
IOSWAP &= ~(1 << IOSWAPU0);
293294
break;
294295
case UART1:
295296
uart->rxEnabled = false;

cores/esp8266/IPAddress.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ size_t IPAddress::printTo(Print& p) const {
6464
return n;
6565
}
6666

67+
String IPAddress::toString()
68+
{
69+
char szRet[16];
70+
sprintf(szRet,"%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]);
71+
return String(szRet);
72+
}
73+

cores/esp8266/IPAddress.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define IPAddress_h
2222

2323
#include <stdint.h>
24+
#include <WString.h>
2425
#include <Printable.h>
2526

2627
// A class to make it easier to handle and pass around IP addresses
@@ -70,6 +71,7 @@ class IPAddress: public Printable {
7071
IPAddress& operator=(uint32_t address);
7172

7273
virtual size_t printTo(Print& p) const;
74+
String toString();
7375

7476
friend class EthernetClass;
7577
friend class UDP;

0 commit comments

Comments
 (0)