Skip to content

Commit 039f4db

Browse files
author
Me No Dev
committed
Merge remote-tracking branch 'esp8266/master'
2 parents 617206d + dd81336 commit 039f4db

File tree

28 files changed

+585
-100
lines changed

28 files changed

+585
-100
lines changed

boards.txt

+122-10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ generic.menu.FlashMode.dio=DIO
4545
generic.menu.FlashMode.dio.build.flash_mode=dio
4646
generic.menu.FlashMode.qio=QIO
4747
generic.menu.FlashMode.qio.build.flash_mode=qio
48+
generic.menu.FlashMode.dout=DOUT
49+
generic.menu.FlashMode.dout.build.flash_mode=dout
50+
generic.menu.FlashMode.qout=QOUT
51+
generic.menu.FlashMode.qout.build.flash_mode=qout
4852

4953
generic.menu.UploadSpeed.115200=115200
5054
generic.menu.UploadSpeed.115200.upload.speed=115200
@@ -227,6 +231,113 @@ generic.menu.DebugLevel.all_____.build.debug_level=-DDEBUG_ESP_CORE -DDEBUG_ESP_
227231
# generic.menu.FlashSize.16M.build.spiffs_blocksize=8192
228232

229233
##############################################################
234+
# ESP8285 chip has built-in 1MB flash
235+
236+
esp8285.name=Generic ESP8285 Module
237+
238+
esp8285.upload.tool=esptool
239+
esp8285.upload.speed=115200
240+
esp8285.upload.resetmethod=ck
241+
esp8285.upload.maximum_size=434160
242+
esp8285.upload.maximum_data_size=81920
243+
esp8285.upload.wait_for_upload_port=true
244+
esp8285.serial.disableDTR=true
245+
esp8285.serial.disableRTS=true
246+
247+
esp8285.build.mcu=esp8266
248+
esp8285.build.f_cpu=80000000L
249+
esp8285.build.board=ESP8266_ESP01
250+
esp8285.build.core=esp8266
251+
esp8285.build.variant=generic
252+
esp8285.build.flash_mode=dout
253+
esp8285.build.flash_freq=40
254+
esp8285.build.spiffs_pagesize=256
255+
esp8285.build.debug_port=
256+
esp8285.build.debug_level=
257+
258+
esp8285.menu.CpuFrequency.80=80 MHz
259+
esp8285.menu.CpuFrequency.80.build.f_cpu=80000000L
260+
esp8285.menu.CpuFrequency.160=160 MHz
261+
esp8285.menu.CpuFrequency.160.build.f_cpu=160000000L
262+
263+
esp8285.menu.UploadSpeed.115200=115200
264+
esp8285.menu.UploadSpeed.115200.upload.speed=115200
265+
esp8285.menu.UploadSpeed.9600=9600
266+
esp8285.menu.UploadSpeed.9600.upload.speed=9600
267+
esp8285.menu.UploadSpeed.57600=57600
268+
esp8285.menu.UploadSpeed.57600.upload.speed=57600
269+
esp8285.menu.UploadSpeed.256000.windows=256000
270+
esp8285.menu.UploadSpeed.256000.upload.speed=256000
271+
esp8285.menu.UploadSpeed.230400.linux=230400
272+
esp8285.menu.UploadSpeed.230400.macosx=230400
273+
esp8285.menu.UploadSpeed.230400.upload.speed=230400
274+
esp8285.menu.UploadSpeed.460800.linux=460800
275+
esp8285.menu.UploadSpeed.460800.macosx=460800
276+
esp8285.menu.UploadSpeed.460800.upload.speed=460800
277+
esp8285.menu.UploadSpeed.512000.windows=512000
278+
esp8285.menu.UploadSpeed.512000.upload.speed=512000
279+
esp8285.menu.UploadSpeed.921600=921600
280+
esp8285.menu.UploadSpeed.921600.upload.speed=921600
281+
282+
esp8285.menu.FlashSize.1M512=1M (512K SPIFFS)
283+
esp8285.menu.FlashSize.1M512.build.flash_size=1M
284+
esp8285.menu.FlashSize.1M512.build.flash_ld=eagle.flash.1m512.ld
285+
esp8285.menu.FlashSize.1M512.build.spiffs_start=0x7B000
286+
esp8285.menu.FlashSize.1M512.build.spiffs_end=0xFB000
287+
esp8285.menu.FlashSize.1M512.build.spiffs_blocksize=8192
288+
esp8285.menu.FlashSize.1M512.upload.maximum_size=499696
289+
290+
esp8285.menu.FlashSize.1M256=1M (256K SPIFFS)
291+
esp8285.menu.FlashSize.1M256.build.flash_size=1M
292+
esp8285.menu.FlashSize.1M256.build.flash_ld=eagle.flash.1m256.ld
293+
esp8285.menu.FlashSize.1M256.build.spiffs_start=0xBB000
294+
esp8285.menu.FlashSize.1M256.build.spiffs_end=0xFB000
295+
esp8285.menu.FlashSize.1M256.build.spiffs_blocksize=4096
296+
esp8285.menu.FlashSize.1M256.upload.maximum_size=761840
297+
298+
esp8285.menu.FlashSize.1M192=1M (192K SPIFFS)
299+
esp8285.menu.FlashSize.1M192.build.flash_size=1M
300+
esp8285.menu.FlashSize.1M192.build.flash_ld=eagle.flash.1m192.ld
301+
esp8285.menu.FlashSize.1M192.build.spiffs_start=0xCB000
302+
esp8285.menu.FlashSize.1M192.build.spiffs_end=0xFB000
303+
esp8285.menu.FlashSize.1M192.build.spiffs_blocksize=4096
304+
esp8285.menu.FlashSize.1M192.upload.maximum_size=827376
305+
306+
esp8285.menu.FlashSize.1M160=1M (160K SPIFFS)
307+
esp8285.menu.FlashSize.1M160.build.flash_size=1M
308+
esp8285.menu.FlashSize.1M160.build.flash_ld=eagle.flash.1m160.ld
309+
esp8285.menu.FlashSize.1M160.build.spiffs_start=0xD3000
310+
esp8285.menu.FlashSize.1M160.build.spiffs_end=0xFB000
311+
esp8285.menu.FlashSize.1M160.build.spiffs_blocksize=4096
312+
esp8285.menu.FlashSize.1M160.upload.maximum_size=860144
313+
314+
esp8285.menu.FlashSize.1M144=1M (144K SPIFFS)
315+
esp8285.menu.FlashSize.1M144.build.flash_size=1M
316+
esp8285.menu.FlashSize.1M144.build.flash_ld=eagle.flash.1m144.ld
317+
esp8285.menu.FlashSize.1M144.build.spiffs_start=0xD7000
318+
esp8285.menu.FlashSize.1M144.build.spiffs_end=0xFB000
319+
esp8285.menu.FlashSize.1M144.build.spiffs_blocksize=4096
320+
esp8285.menu.FlashSize.1M144.upload.maximum_size=876528
321+
322+
esp8285.menu.FlashSize.1M128=1M (128K SPIFFS)
323+
esp8285.menu.FlashSize.1M128.build.flash_size=1M
324+
esp8285.menu.FlashSize.1M128.build.flash_ld=eagle.flash.1m128.ld
325+
esp8285.menu.FlashSize.1M128.build.spiffs_start=0xDB000
326+
esp8285.menu.FlashSize.1M128.build.spiffs_end=0xFB000
327+
esp8285.menu.FlashSize.1M128.build.spiffs_blocksize=4096
328+
esp8285.menu.FlashSize.1M128.upload.maximum_size=892912
329+
330+
esp8285.menu.FlashSize.1M64=1M (64K SPIFFS)
331+
esp8285.menu.FlashSize.1M64.build.flash_size=1M
332+
esp8285.menu.FlashSize.1M64.build.flash_ld=eagle.flash.1m64.ld
333+
esp8285.menu.FlashSize.1M64.build.spiffs_start=0xEB000
334+
esp8285.menu.FlashSize.1M64.build.spiffs_end=0xFB000
335+
esp8285.menu.FlashSize.1M64.build.spiffs_blocksize=4096
336+
esp8285.menu.FlashSize.1M64.upload.maximum_size=958448
337+
338+
339+
##############################################################
340+
230341
espduino.name=ESPDuino (ESP-13 Module)
231342

232343
espduino.upload.tool=esptool
@@ -944,7 +1055,7 @@ d1_mini.serial.disableRTS=true
9441055

9451056
d1_mini.build.mcu=esp8266
9461057
d1_mini.build.f_cpu=80000000L
947-
d1_mini.build.board=ESP8266_NODEMCU
1058+
d1_mini.build.board=ESP8266_WEMOS_D1MINI
9481059
d1_mini.build.core=esp8266
9491060
d1_mini.build.variant=d1_mini
9501061
d1_mini.build.flash_mode=dio
@@ -995,7 +1106,6 @@ d1_mini.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
9951106
d1_mini.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
9961107
d1_mini.menu.FlashSize.4M1M.build.spiffs_pagesize=256
9971108

998-
9991109
##############################################################
10001110
d1.name=WeMos D1(Retired)
10011111

@@ -1010,7 +1120,7 @@ d1.serial.disableRTS=true
10101120

10111121
d1.build.mcu=esp8266
10121122
d1.build.f_cpu=80000000L
1013-
d1.build.board=ESP8266_NODEMCU
1123+
d1.build.board=ESP8266_WEMOS_D1MINI
10141124
d1.build.core=esp8266
10151125
d1.build.variant=d1
10161126
d1.build.flash_mode=dio
@@ -1215,11 +1325,9 @@ wifinfo.serial.disableDTR=true
12151325
wifinfo.serial.disableRTS=true
12161326

12171327
wifinfo.build.mcu=esp8266
1218-
wifinfo.build.f_cpu=160000000L
12191328
wifinfo.build.core=esp8266
12201329
wifinfo.build.variant=wifinfo
1221-
wifinfo.build.flash_mode=qio
1222-
wifinfo.build.board=ESP8266_NODEMCU
1330+
wifinfo.build.board=WIFINFO
12231331
wifinfo.build.spiffs_pagesize=256
12241332
wifinfo.build.debug_port=Serial1
12251333
wifinfo.build.debug_level=Wifinfo
@@ -1300,20 +1408,20 @@ wifinfo.menu.ESPModule.ESP12.build.spiffs_blocksize=8192
13001408
wifinfo.menu.ESPModule.ESP12.build.spiffs_pagesize=256
13011409
wifinfo.menu.ESPModule.ESP12.upload.maximum_size=1044464
13021410

1303-
wifinfo.menu.CpuFrequency.80=80 MHz
1304-
wifinfo.menu.CpuFrequency.80.build.f_cpu=80000000L
13051411
wifinfo.menu.CpuFrequency.160=160 MHz
13061412
wifinfo.menu.CpuFrequency.160.build.f_cpu=160000000L
1413+
wifinfo.menu.CpuFrequency.80=80 MHz
1414+
wifinfo.menu.CpuFrequency.80.build.f_cpu=80000000L
13071415

13081416
wifinfo.menu.FlashFreq.40=40MHz
13091417
wifinfo.menu.FlashFreq.40.build.flash_freq=40
13101418
wifinfo.menu.FlashFreq.80=80MHz
13111419
wifinfo.menu.FlashFreq.80.build.flash_freq=80
13121420

1313-
wifinfo.menu.FlashMode.dio=DIO
1314-
wifinfo.menu.FlashMode.dio.build.flash_mode=dio
13151421
wifinfo.menu.FlashMode.qio=QIO
13161422
wifinfo.menu.FlashMode.qio.build.flash_mode=qio
1423+
wifinfo.menu.FlashMode.dio=DIO
1424+
wifinfo.menu.FlashMode.dio.build.flash_mode=dio
13171425

13181426
wifinfo.menu.UploadSpeed.115200=115200
13191427
wifinfo.menu.UploadSpeed.115200.upload.speed=115200
@@ -1385,6 +1493,10 @@ coredev.menu.FlashMode.dio=DIO
13851493
coredev.menu.FlashMode.dio.build.flash_mode=dio
13861494
coredev.menu.FlashMode.qio=QIO
13871495
coredev.menu.FlashMode.qio.build.flash_mode=qio
1496+
coredev.menu.FlashMode.dout=DOUT
1497+
coredev.menu.FlashMode.dout.build.flash_mode=dout
1498+
coredev.menu.FlashMode.qout=QOUT
1499+
coredev.menu.FlashMode.qout.build.flash_mode=qout
13881500

13891501
coredev.menu.UploadSpeed.115200=115200
13901502
coredev.menu.UploadSpeed.115200.upload.speed=115200

cores/esp8266/Arduino.h

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ extern "C" {
7373
#define MSBFIRST 1
7474

7575
//Interrupt Modes
76-
#define DISABLED 0x00
7776
#define RISING 0x01
7877
#define FALLING 0x02
7978
#define CHANGE 0x03

cores/esp8266/Esp.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
112112
esp_yield();
113113
}
114114

115+
bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)
116+
{
117+
if (size + offset > 512) {
118+
return false;
119+
} else {
120+
return system_rtc_mem_read(64 + offset, data, size);
121+
}
122+
}
123+
124+
bool EspClass::rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size)
125+
{
126+
if (size + offset > 512) {
127+
return false;
128+
} else {
129+
return system_rtc_mem_write(64 + offset, data, size);
130+
}
131+
}
132+
115133
extern "C" void __real_system_restart_local();
116134
void EspClass::reset(void)
117135
{

cores/esp8266/Esp.h

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ class EspClass {
9494

9595
void deepSleep(uint32_t time_us, RFMode mode = RF_DEFAULT);
9696

97+
bool rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size);
98+
bool rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size);
99+
97100
void reset();
98101
void restart();
99102

cores/esp8266/abi.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ void __throw_logic_error(const char* str)
106106
{
107107
panic();
108108
}
109+
110+
void __throw_out_of_range(const char* str)
111+
{
112+
panic();
113+
}
109114
}
110115

111116
// TODO: rebuild windows toolchain to make this unnecessary:

cores/esp8266/core_esp8266_main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ static void loop_task(os_event_t *events) {
119119
}
120120

121121
static void do_global_ctors(void) {
122-
void (**p)(void);
123-
for(p = &__init_array_start; p != &__init_array_end; ++p)
124-
(*p)();
122+
void (**p)(void) = &__init_array_end;
123+
while (p != &__init_array_start)
124+
(*--p)();
125125
}
126126

127127
extern "C" void __gdb_init() {}

cores/esp8266/core_esp8266_si2c.c

+15
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,18 @@ unsigned char twi_readFrom(unsigned char address, unsigned char* buf, unsigned i
197197
}
198198
return 0;
199199
}
200+
201+
uint8_t twi_status(){
202+
if (SCL_READ()==0) return I2C_SCL_HELD_LOW; //SCL held low by another device, no procedure available to recover
203+
int clockCount = 20;
204+
205+
while (SDA_READ()==0 && clockCount>0){ //if SDA low, read the bits slaves have to sent to a max
206+
twi_read_bit();
207+
if (SCL_READ()==0) return I2C_SCL_HELD_LOW_AFTER_READ; //I2C bus error. SCL held low beyond slave clock stretch time
208+
}
209+
210+
if (SDA_READ()==0) return I2C_SDA_HELD_LOW; //I2C bus error. SDA line held low by slave/another_master after n bits.
211+
212+
if(!twi_write_start()) return I2C_SDA_HELD_LOW_AFTER_INIT; //line busy. SDA again held low by another device. 2nd master?
213+
else return I2C_OK; //all ok
214+
}

cores/esp8266/core_esp8266_timer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void timer1_attachInterrupt(timercallback userFunc) {
5050
ETS_FRC1_INTR_ENABLE();
5151
}
5252

53-
void timer1_detachInterrupt() {
53+
void ICACHE_RAM_ATTR timer1_detachInterrupt() {
5454
timer1_user_cb = 0;
5555
TEIE &= ~TEIE1;//edge int disable
5656
ETS_FRC1_INTR_DISABLE();
@@ -95,7 +95,7 @@ void timer0_attachInterrupt(timercallback userFunc) {
9595
ETS_CCOMPARE0_ENABLE();
9696
}
9797

98-
void timer0_detachInterrupt() {
98+
void ICACHE_RAM_ATTR timer0_detachInterrupt() {
9999
timer0_user_cb = NULL;
100100
ETS_CCOMPARE0_DISABLE();
101101
}

cores/esp8266/esp8266_peri.h

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ extern uint8_t esp8266_gpioToFn[16];
169169
#define RTCIC ESP8266_REG(0x724) //RTC INT Clear
170170
#define RTCIE ESP8266_REG(0x728) //RTC INT Enable
171171

172+
#define RTC_USER_MEM ((volatile uint32_t*)0x60001200)
173+
172174
//IO SWAP Register
173175
#define IOSWAP ESP8266_DREG(0x28)
174176
#define IOSWAPU 0 //Swaps UART

cores/esp8266/twi.h

+7
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,19 @@
2626
extern "C" {
2727
#endif
2828

29+
#define I2C_OK 0
30+
#define I2C_SCL_HELD_LOW 1
31+
#define I2C_SCL_HELD_LOW_AFTER_READ 2
32+
#define I2C_SDA_HELD_LOW 3
33+
#define I2C_SDA_HELD_LOW_AFTER_INIT 4
34+
2935
void twi_init(unsigned char sda, unsigned char scl);
3036
void twi_stop(void);
3137
void twi_setClock(unsigned int freq);
3238
void twi_setClockStretchLimit(uint32_t limit);
3339
uint8_t twi_writeTo(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop);
3440
uint8_t twi_readFrom(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop);
41+
uint8_t twi_status();
3542

3643
#ifdef __cplusplus
3744
}

doc/boards.md

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ title: Supported Hardware
1717
* [ESPino](#espino)
1818
* [WifInfo](#WifInfo)
1919
* [Generic ESP8266 modules](#generic-esp8266-modules)
20+
* [Generic ESP8285 modules](#generic-esp8285-modules)
2021
* [Serial Adapter](#serial-adapter)
2122
* [Minimal Hardware Setup for Bootloading and Usage](#minimal-hardware-setup-for-bootloading-and-usage)
2223
* [ESP to Serial](#esp-to-serial)
@@ -271,6 +272,13 @@ the first value respects the pin setup of the Pins 0, 2 and 15.
271272
note:
272273
- number = ((GPIO15 << 2) | (GPIO0 << 1) | GPIO2);
273274

275+
## Generic ESP8285 modules
276+
277+
ESP8285 ([datasheet](http://espressif.com/sites/default/files/documentation/0a-esp8285_datasheet_en_v1.0_20160422.pdf)) is a multi-chip package which contains ESP8266 and 1MB flash.
278+
All points related to bootstrapping resistors and recommended circuits listed above apply to ESP8285 as well.
279+
280+
Note that since ESP8285 has SPI flash memory internally connected in DOUT mode, pins 9 and 10 may be used as GPIO / I2C / PWM pins.
281+
274282
## WeMos D1
275283
Product page: http://wemos.cc
276284

doc/libraries.md

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ APIs related to deep sleep and watchdog timer are available in the `ESP` object,
8383

8484
`ESP.deepSleep(microseconds, mode)` will put the chip into deep sleep. `mode` is one of `WAKE_RF_DEFAULT`, `WAKE_RFCAL`, `WAKE_NO_RFCAL`, `WAKE_RF_DISABLED`. (GPIO16 needs to be tied to RST to wake from deepSleep.)
8585

86+
`ESP.rtcUserMemoryWrite(offset, &data, sizeof(data))` and `ESP.rtcUserMemoryRead(offset, &data, sizeof(data))` allow data to be stored in and retrieved from the RTC user memory of the chip respectively. Total size of RTC user memory is 512 bytes, so offset + sizeof(data) shouldn't exceed 512. Data should be 4-byte aligned. The stored data can be retained between deep sleep cycles. However, the data might be lost after power cycling the chip.
87+
8688
`ESP.restart()` restarts the CPU.
8789

8890
`ESP.getResetReason()` returns String containing the last reset resaon in human readable format.
@@ -168,3 +170,5 @@ Libraries that don't rely on low-level access to AVR registers should work well.
168170
- [SdFat-beta](https://github.com/greiman/SdFat-beta) - SD-card library with support for long filenames, software- and hardware-based SPI and lots more.
169171
- [FastLED](https://github.com/FastLED/FastLED) - a library for easily & efficiently controlling a wide variety of LED chipsets, like the Neopixel (WS2812B), DotStar, LPD8806 and many more. Includes fading, gradient, color conversion functions.
170172
- [OLED](https://github.com/klarsys/esp8266-OLED) - a library for controlling I2C connected OLED displays. Tested with 0.96 inch OLED graphics display.
173+
- [MFRC522](https://github.com/miguelbalboa/rfid) - A library for using the Mifare RC522 RFID-tag reader/writer.
174+
- [Ping](https://github.com/dancol90/ESP8266Ping) - lets the ESP8266 ping a remote machine.

0 commit comments

Comments
 (0)