Skip to content

Commit fc83952

Browse files
committed
Merge pull request #438 from Links2004/esp8266
update SDK to esp_iot_sdk_v1.1.2_15_06_16_p1
2 parents 496fee1 + 98815fe commit fc83952

40 files changed

+588
-144
lines changed

Diff for: .gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.lss
1313
hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
1414
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
1515
hardware/arduino/bootloaders/caterina_LUFA/.dep/
16-
build/libastylej-*.zip
16+
build/*.zip
1717
build/windows/work/
1818
build/windows/*.zip
1919
build/windows/*.tgz
@@ -56,6 +56,9 @@ avr-toolchain-*.zip
5656
/hardware/tools/esp8266/utils/
5757
/hardware/tools/esp8266/xtensa-lx106-elf
5858
/hardware/tools/esp8266/esptool.exe
59+
/hardware/esp8266com/esp8266/tools/xtensa*
60+
/hardware/esp8266com/esp8266/tools/esptool*
61+
/hardware/esp8266com/esp8266/tools/utils
5962
/hardware/tools/avr/
6063
/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/
6164
/hardware/tools/bossac.exe

Diff for: boards.txt

+4-10
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ generic.build.board=ESP8266_ESP01
2121
generic.build.core=esp8266
2222
generic.build.variant=generic
2323
generic.build.flash_mode=qio
24-
generic.build.flash_size=512K
25-
generic.build.flash_freq=40
26-
generic.build.flash_ld=eagle.flash.512k.ld
27-
generic.build.spiffs_start=0x6B000
28-
generic.build.spiffs_end=0x7B000
2924
generic.build.spiffs_pagesize=256
30-
generic.build.spiffs_blocksize=4096
3125

3226
generic.menu.CpuFrequency.80=80 MHz
3327
generic.menu.CpuFrequency.80.build.f_cpu=80000000L
@@ -123,10 +117,10 @@ generic.menu.FlashSize.4M.upload.maximum_size=1044464
123117
# generic.menu.FlashSize.16M.build.spiffs_end=0x1000000
124118
# generic.menu.FlashSize.16M.build.spiffs_blocksize=8192
125119

126-
# generic.menu.FlashFreq.40=40MHz
127-
# generic.menu.FlashFreq.40.build.flash_freq=40
128-
# generic.menu.FlashFreq.80=80MHz
129-
# generic.menu.FlashFreq.80.build.flash_freq=80
120+
generic.menu.FlashFreq.40=40MHz
121+
generic.menu.FlashFreq.40.build.flash_freq=40
122+
generic.menu.FlashFreq.80=80MHz
123+
generic.menu.FlashFreq.80.build.flash_freq=80
130124

131125
##############################################################
132126
modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)

Diff for: cores/esp8266/Arduino.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ unsigned long micros(void);
195195
void delay(unsigned long);
196196
void delayMicroseconds(unsigned int us);
197197
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
198+
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
198199

199200
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
200201
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
@@ -236,21 +237,24 @@ void loop(void);
236237

237238
#define min(a,b) ((a)<(b)?(a):(b))
238239
#define max(a,b) ((a)>(b)?(a):(b))
240+
#define _min(a,b) ((a)<(b)?(a):(b))
241+
#define _max(a,b) ((a)>(b)?(a):(b))
239242

240243
uint16_t makeWord(uint16_t w);
241244
uint16_t makeWord(byte h, byte l);
242245

243246
#define word(...) makeWord(__VA_ARGS__)
244247

245248
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
249+
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
246250

247251
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
248252
void noTone(uint8_t _pin);
249253

250254
// WMath prototypes
251255
long random(long);
252256
long random(long, long);
253-
void randomSeed(unsigned int);
257+
void randomSeed(unsigned long);
254258
long map(long, long, long, long, long);
255259

256260

Diff for: cores/esp8266/Esp.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern struct rst_info resetInfo;
3232

3333
// #define DEBUG_SERIAL Serial
3434

35-
35+
3636
/**
3737
* User-defined Literals
3838
* usage:
@@ -97,8 +97,8 @@ void EspClass::wdtFeed(void)
9797

9898
void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
9999
{
100-
system_deep_sleep_set_option(static_cast<int>(mode));
101-
system_deep_sleep(time_us);
100+
system_deep_sleep_set_option(static_cast<int>(mode));
101+
system_deep_sleep(time_us);
102102
}
103103

104104
extern "C" void esp_yield();
@@ -280,8 +280,8 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) {
280280

281281
String EspClass::getResetInfo(void) {
282282
if(resetInfo.reason != 0) {
283-
char buff[150];
284-
sprintf(&buff[0], "Fatal exception:%d flag:%d epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
283+
char buff[200];
284+
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);
285285
return String(buff);
286286
}
287287
return String("flag: 0");
@@ -400,6 +400,13 @@ bool EspClass::updateSketch(Stream& in, uint32_t size) {
400400
return false;
401401
}
402402

403+
if(addr == freeSpaceStart) {
404+
// check for valid first magic byte
405+
if(*((uint8 *) buffer.get()) != 0xE9) {
406+
return false;
407+
}
408+
}
409+
403410
noInterrupts();
404411
rc = SPIWrite(addr, buffer.get(), willRead);
405412
interrupts();
@@ -426,7 +433,7 @@ bool EspClass::updateSketch(Stream& in, uint32_t size) {
426433
ebcmd.args[1] = 0x00000;
427434
ebcmd.args[2] = size;
428435
eboot_command_write(&ebcmd);
429-
436+
430437
ESP.restart();
431438
return true; // never happens
432439
}

Diff for: cores/esp8266/HardwareSerial.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ size_t HardwareSerial::write(uint8_t c) {
620620

621621
while(_tx_buffer->room() == 0) {
622622
yield();
623+
uart_arm_tx_interrupt(_uart);
623624
}
624625

625626
_tx_buffer->write(c);

Diff for: cores/esp8266/Print.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ size_t ICACHE_FLASH_ATTR Print::print(const Printable& x) {
127127
}
128128

129129
size_t ICACHE_FLASH_ATTR Print::println(void) {
130-
size_t n = print("\r\n");
131-
return n;
130+
return print("\r\n");
132131
}
133132

134133
size_t ICACHE_FLASH_ATTR Print::println(const String &s) {

Diff for: cores/esp8266/Stream.h

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ class Stream: public Print {
6969
}
7070
// returns true if target string is found, false if timed out
7171

72+
bool find(char target) { return find (&target, 1); }
73+
7274
bool findUntil(const char *target, const char *terminator); // as find but search ends if the terminator string is found
7375
bool findUntil(const uint8_t *target, const char *terminator) {
7476
return findUntil((char *) target, terminator);

Diff for: cores/esp8266/WMath.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#include <stdlib.h>
2828
}
2929

30-
void randomSeed(unsigned int seed) {
30+
void randomSeed(unsigned long seed) {
3131
if(seed != 0) {
3232
srand(seed);
3333
}

Diff for: cores/esp8266/cbuf.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ class cbuf {
3939
}
4040

4141
size_t room() const {
42-
if(_end >= _begin) return _size - (_end - _begin) - 1;
43-
42+
if(_end >= _begin) {
43+
return _size - (_end - _begin) - 1;
44+
}
45+
if(_begin == _end) {
46+
return _size;
47+
}
4448
return _begin - _end - 1;
4549
}
4650

Diff for: cores/esp8266/core_esp8266_main.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ void init_done() {
121121

122122
extern "C" {
123123
void user_init(void) {
124-
system_rtc_mem_read(0, &resetInfo, sizeof(struct rst_info));
125-
struct rst_info info = { 0 };
126-
system_rtc_mem_write(0, &info, sizeof(struct rst_info));
124+
struct rst_info *rtc_info_ptr = system_get_rst_info();
125+
126+
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
127+
127128

128129
uart_div_modify(0, UART_CLK_FREQ / (115200));
129130

Diff for: cores/esp8266/core_esp8266_wiring_pulse.c

+4
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) {
3030
while(digitalRead(pin) == state && (micros() - start) < timeout);
3131
return micros() - start;
3232
}
33+
34+
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) {
35+
return pulseIn(pin, state, timeout);
36+
}

Diff for: doc/eclipse/1_Install_New_Software.png

12.4 KB
Loading

Diff for: doc/eclipse/2_Install_software.png

62.4 KB
Loading

Diff for: doc/eclipse/eclipse.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Eclipse with Arduino ESP8266
2+
===========================================
3+
4+
### What to Download ###
5+
- [arduino IDE](https://www.arduino.cc/en/Main/Software)
6+
- [Eclipse IDE for C/C++ Developers](http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/marsr)
7+
- [Java](http://www.java.com/)
8+
9+
### Setup Arduino ###
10+
see the [Readme](https://github.com/esp8266/Arduino#installing-with-boards-manager)
11+
12+
### Setup Eclipse ###
13+
- [step 1](http://www.baeyens.it/eclipse/how_to.shtml#/c)
14+
- [step 2](http://www.baeyens.it/eclipse/how_to.shtml#/e)
15+
- go to Window --> preferences --> Arduino
16+
- add as private hardware path the Part to the ESP8266
17+
18+
###### example private hardware path
19+
Windows: C:\Users\[username]\AppData\Roaming\Arduino15\packages\esp8266\hardware
20+
Linux: /home/[username]/.arduino15/packages/esp8266/hardware
21+
22+
### Eclipse wont build ###
23+
if eclipse dont find the path to the Compiler add to the platform.txt
24+
after:
25+
```
26+
version=1.6.4
27+
```
28+
this:
29+
```
30+
runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/../../../tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9
31+
runtime.tools.esptool.path={runtime.platform.path}/../../../tools/esptool/0.4.4
32+
```
33+
Note:
34+
- the path may changed, check the current version.
35+
- each update over the Arduino IDE will remove the fix
36+
- may not needed in future if Eclipse Plugin get an Update
37+
38+

Diff for: libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

+62-14
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ extern "C" void esp_schedule();
4040
extern "C" void esp_yield();
4141

4242
ESP8266WiFiClass::ESP8266WiFiClass()
43-
: _useApMode(false)
43+
: _smartConfigStarted(false)
44+
, _smartConfigDone(false)
45+
, _useApMode(false)
4446
, _useClientMode(false)
4547
, _useStaticIp(false)
4648
{
@@ -121,7 +123,7 @@ uint8_t ESP8266WiFiClass::waitForConnectResult(){
121123
}
122124

123125

124-
// You will have to set the DNS-Server manually later since this will not enable DHCP
126+
// You will have to set the DNS-Server manually later since this will not enable DHCP2
125127
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet)
126128
{
127129
struct ip_info info;
@@ -358,12 +360,47 @@ void ESP8266WiFiClass::_scanDone(void* result, int status)
358360
}
359361

360362
}
361-
esp_schedule();
363+
364+
ESP8266WiFiClass::_scanStarted = false;
365+
ESP8266WiFiClass::_scanComplete = true;
366+
367+
if(!ESP8266WiFiClass::_scanAsync) {
368+
esp_schedule();
369+
}
362370
}
363371

372+
int8_t ESP8266WiFiClass::scanComplete() {
373+
374+
if(_scanStarted) {
375+
return WIFI_SCAN_RUNNING;
376+
}
377+
378+
if(_scanComplete) {
379+
return ESP8266WiFiClass::_scanCount;
380+
}
364381

365-
int8_t ESP8266WiFiClass::scanNetworks()
382+
return WIFI_SCAN_FAILD;
383+
}
384+
385+
void ESP8266WiFiClass::scanDelete()
366386
{
387+
if (ESP8266WiFiClass::_scanResult)
388+
{
389+
delete[] reinterpret_cast<bss_info*>(ESP8266WiFiClass::_scanResult);
390+
ESP8266WiFiClass::_scanResult = 0;
391+
ESP8266WiFiClass::_scanCount = 0;
392+
}
393+
_scanComplete = false;
394+
}
395+
396+
int8_t ESP8266WiFiClass::scanNetworks(bool async)
397+
{
398+
if(ESP8266WiFiClass::_scanStarted) {
399+
return WIFI_SCAN_RUNNING;
400+
}
401+
402+
ESP8266WiFiClass::_scanAsync = async;
403+
367404
if(_useApMode) {
368405
// turn on AP+STA mode
369406
mode(WIFI_AP_STA);
@@ -377,22 +414,29 @@ int8_t ESP8266WiFiClass::scanNetworks()
377414
{
378415
disconnect();
379416
}
380-
381-
if (ESP8266WiFiClass::_scanResult)
382-
{
383-
delete[] reinterpret_cast<bss_info*>(ESP8266WiFiClass::_scanResult);
384-
ESP8266WiFiClass::_scanResult = 0;
385-
ESP8266WiFiClass::_scanCount = 0;
386-
}
387417

418+
scanDelete();
419+
388420
struct scan_config config;
389421
config.ssid = 0;
390422
config.bssid = 0;
391423
config.channel = 0;
392424
config.show_hidden = 0;
393-
wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiClass::_scanDone));
394-
esp_yield();
395-
return ESP8266WiFiClass::_scanCount;
425+
if(wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiClass::_scanDone))) {
426+
ESP8266WiFiClass::_scanComplete = false;
427+
ESP8266WiFiClass::_scanStarted = true;
428+
429+
if(ESP8266WiFiClass::_scanAsync) {
430+
delay(0); // time for the OS to trigger the scan
431+
return WIFI_SCAN_RUNNING;
432+
}
433+
434+
esp_yield();
435+
return ESP8266WiFiClass::_scanCount;
436+
} else {
437+
return WIFI_SCAN_FAILD;
438+
}
439+
396440
}
397441

398442
void * ESP8266WiFiClass::_getScanInfoByIndex(int i)
@@ -645,6 +689,10 @@ void ESP8266WiFiClass::printDiag(Print& p)
645689

646690
}
647691

692+
bool ESP8266WiFiClass::_scanAsync = false;
693+
bool ESP8266WiFiClass::_scanStarted = false;
694+
bool ESP8266WiFiClass::_scanComplete = false;
695+
648696
size_t ESP8266WiFiClass::_scanCount = 0;
649697
void* ESP8266WiFiClass::_scanResult = 0;
650698

0 commit comments

Comments
 (0)