Skip to content

Commit 854382a

Browse files
committed
Merge pull request #1 from esp8266/esp8266
Get latest
2 parents 4643cd1 + 674ddbe commit 854382a

File tree

18 files changed

+1945
-96
lines changed

18 files changed

+1945
-96
lines changed

README.md

+43-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This project brings support for ESP8266 chip to the Arduino environment. ESP8266
88
| OS | Build status | Latest release | Alpha Version |
99
| --- | ------------ | -------------- | --------------- |
1010
| Linux | [![Linux build status](http://img.shields.io/travis/igrr/Arduino.svg)](https://travis-ci.org/igrr/Arduino) | [arduino-1.6.1-linux64.tar.xz](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-linux64.tar.xz) | |
11-
| Windows | [![Windows build status](http://img.shields.io/appveyor/ci/igrr/Arduino.svg)](https://ci.appveyor.com/project/igrr/Arduino) | [arduino-1.6.1-p1-windows.zip](https://github.com/igrr/Arduino/releases/download/1.6.1-esp8266-1/arduino-1.6.1-p1-windows.zip) | [appveyor Build](https://ci.appveyor.com/project/igrr/Arduino/build/artifacts) |
11+
| Windows | [![Windows build status](http://img.shields.io/appveyor/ci/igrr/Arduino.svg)](https://ci.appveyor.com/project/igrr/Arduino) | [arduino-1.6.1-p1-windows.zip](https://github.com/igrr/Arduino/releases/download/1.6.1-esp8266-1/arduino-1.6.1-p1-windows.zip) | [appveyor 64Bit Build](https://ci.appveyor.com/project/igrr/Arduino/build/artifacts) |
1212
| OS X | | [arduino-1.6.1-macosx-java-latest-signed.zip](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-macosx-java-latest-signed.zip) | |
1313

1414

@@ -181,8 +181,48 @@ Libraries that don't rely on low-level access to AVR registers should work well.
181181

182182
#### Upload via serial port ####
183183
Pick the correct serial port.
184-
You need to put ESP8266 into bootloader mode before uploading code (pull GPIO0 low and
185-
toggle power).
184+
You need to put ESP8266 into bootloader mode before uploading code.
185+
186+
#### Minimal hardware Setup for Bootloading and usage ####
187+
188+
ESPxx Hardware
189+
190+
| PIN | Resistor | Serial Adapter |
191+
| ------------- | -------- | -------------- |
192+
| VCC | | VCC (3.3V) |
193+
| GND | | GND |
194+
| TX or GPIO2* | | RX |
195+
| RX | | TX |
196+
| GPIO0 | PullUp | DTR |
197+
| Reset* | | RTS |
198+
| GPIO15* | PullDown | |
199+
| CH_PD | PullUp | |
200+
201+
* Note
202+
- GPIO15 is also named MTDO
203+
- Reset is also named RSBT or REST (adding PullUp improves the stability of the Module)
204+
- GPIO2 is alternative TX for the boot loader mode
205+
206+
ESP01 example:
207+
208+
![ESP01 connect](https://raw.githubusercontent.com/Links2004/Arduino/esp8266/docs/ESP01_connect.jpg)
209+
210+
#### Minimal hardware Setup for Bootloading only ####
211+
ESPxx Hardware
212+
213+
| PIN | Resistor | Serial Adapter |
214+
| ------------- | -------- | -------------- |
215+
| VCC | | VCC (3.3V) |
216+
| GND | | GND |
217+
| TX or GPIO2 | | RX |
218+
| RX | | TX |
219+
| GPIO0 | | GND |
220+
| Reset | | RTS* |
221+
| GPIO15 | PullDown | |
222+
| CH_PD | PullUp | |
223+
224+
* Note
225+
- if no RTS is used a manual power toggle is needed
186226

187227
### Issues and support ###
188228

docs/rgisters_dump.txt

+1,157
Large diffs are not rendered by default.

hardware/esp8266com/esp8266/boards.txt

+47
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
menu.UploadSpeed=Upload Speed
22
menu.CpuFrequency=CPU Frequency
33
menu.FlashSize=Flash size
4+
45
##############################################################
56
generic.name=Generic ESP8266 Module
67

@@ -56,6 +57,52 @@ generic.menu.FlashSize.2M.build.flash_size=2M
5657
generic.menu.FlashSize.4M=4M
5758
generic.menu.FlashSize.4M.build.flash_size=4M
5859

60+
##############################################################
61+
modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
62+
63+
modwifi.upload.tool=esptool
64+
modwifi.upload.speed=115200
65+
modwifi.upload.resetmethod=ck
66+
modwifi.upload.maximum_size=2097152
67+
modwifi.upload.wait_for_upload_port=true
68+
modwifi.serial.disableDTR=true
69+
modwifi.serial.disableRTS=true
70+
71+
modwifi.build.mcu=esp8266
72+
modwifi.build.f_cpu=80000000L
73+
modwifi.build.board=MOD_WIFI_ESP8266
74+
modwifi.build.core=esp8266
75+
modwifi.build.variant=generic
76+
# Winbond W25Q16 flash
77+
modwifi.build.flash_mode=qio
78+
modwifi.build.flash_size=2M
79+
modwifi.build.flash_freq=40
80+
81+
modwifi.menu.CpuFrequency.80=80 MHz
82+
modwifi.menu.CpuFrequency.80.build.f_cpu=80000000L
83+
modwifi.menu.CpuFrequency.160=160 MHz
84+
modwifi.menu.CpuFrequency.160.build.f_cpu=160000000L
85+
86+
modwifi.menu.UploadSpeed.115200=115200
87+
modwifi.menu.UploadSpeed.115200.upload.speed=115200
88+
modwifi.menu.UploadSpeed.9600=9600
89+
modwifi.menu.UploadSpeed.9600.upload.speed=9600
90+
modwifi.menu.UploadSpeed.57600=57600
91+
modwifi.menu.UploadSpeed.57600.upload.speed=57600
92+
modwifi.menu.UploadSpeed.256000.windows=256000
93+
modwifi.menu.UploadSpeed.256000.upload.speed=256000
94+
modwifi.menu.UploadSpeed.230400.linux=230400
95+
modwifi.menu.UploadSpeed.230400.macosx=230400
96+
modwifi.menu.UploadSpeed.230400.macosx=230400
97+
modwifi.menu.UploadSpeed.230400.upload.speed=230400
98+
modwifi.menu.UploadSpeed.460800.linux=460800
99+
modwifi.menu.UploadSpeed.460800.macosx=460800
100+
modwifi.menu.UploadSpeed.460800.upload.speed=460800
101+
modwifi.menu.UploadSpeed.512000.windows=512000
102+
modwifi.menu.UploadSpeed.512000.upload.speed=512000
103+
modwifi.menu.UploadSpeed.921600=921600
104+
modwifi.menu.UploadSpeed.921600.upload.speed=921600
105+
59106
##############################################################
60107
nodemcu.name=NodeMCU (ESP8266 ESP-12 Module)
61108

hardware/esp8266com/esp8266/cores/esp8266/esp8266_peri.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C,
132132
#define T1I ESP8266_REG(0x60C) //Interrupt Status Register (1bit) write to clear
133133
//edge interrupt enable register
134134
#define TEIE ESP8266_DREG(0x04)
135-
#define TEIE1 0x02 //it for timer 1
135+
#define TEIE1 0x02 //bit for timer 1
136136

137137
//Timer 2 Registers (32bit CountUp Timer)
138138
#define T2L ESP8266_REG(0x620) //Load Value (Starting Value of Counter)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/*
2+
SDWebServer - Example WebServer with SD Card backend for esp8266
3+
4+
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
5+
This file is part of the ESP8266WebServer library for Arduino environment.
6+
7+
This library is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU Lesser General Public
9+
License as published by the Free Software Foundation; either
10+
version 2.1 of the License, or (at your option) any later version.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public
18+
License along with this library; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20+
21+
Have a FAT Formatted SD Card connected to the SPI port of the ESP8266
22+
The web root is the SD Card root folder
23+
File extensions with more than 3 charecters are not supported by the SD Library
24+
File Names longer than 8 charecters will be truncated by the SD library, so keep filenames shorter
25+
index.htm is the default index (works on subfolders as well)
26+
*/
27+
28+
#include <ESP8266WiFi.h>
29+
#include <WiFiClient.h>
30+
#include <ESP8266WebServer.h>
31+
#include <ESP8266mDNS.h>
32+
#include <SPI.h>
33+
#include <SD.h>
34+
35+
//do not go larger than 1460 bytes as that is the maximum that could fit in a packet
36+
#define WWW_BUF_SIZE 1460
37+
38+
const char* ssid = "**********";
39+
const char* password = "**********";
40+
const char* hostname = "esp8266sd";
41+
42+
MDNSResponder mdns;
43+
ESP8266WebServer server(80);
44+
45+
static bool hasSD = false;
46+
47+
bool loadFromSdCard(String path){
48+
String dataType = "text/plain";
49+
//handle default index
50+
if(path.endsWith("/")) path += "index.htm";
51+
52+
//set proper Content-Type for the most common extensions
53+
if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
54+
else if(path.endsWith(".htm")) dataType = "text/html";
55+
else if(path.endsWith(".css")) dataType = "text/css";
56+
else if(path.endsWith(".js")) dataType = "application/javascript";
57+
else if(path.endsWith(".png")) dataType = "image/png";
58+
else if(path.endsWith(".gif")) dataType = "image/gif";
59+
else if(path.endsWith(".jpg")) dataType = "image/jpeg";
60+
else if(path.endsWith(".ico")) dataType = "image/x-icon";
61+
else if(path.endsWith(".xml")) dataType = "text/xml";
62+
else if(path.endsWith(".pdf")) dataType = "application/pdf";
63+
else if(path.endsWith(".zip")) dataType = "application/zip";
64+
65+
//Try to open the file
66+
File dataFile = SD.open(path.c_str());
67+
68+
//if it's a folder, try to open the default index
69+
if(dataFile && dataFile.isDirectory()){
70+
path += "/index.htm";
71+
dataType = "text/html";
72+
dataFile = SD.open(path.c_str());
73+
}
74+
75+
//and finally if the file exists, stream the content to the client
76+
if (dataFile) {
77+
WiFiClient client = server.client();
78+
//send the file headers
79+
String head = "HTTP/1.1 200 OK\r\nContent-Type: ";
80+
head += dataType;
81+
head += "\r\nContent-Length: ";
82+
head += dataFile.size();
83+
head += "\r\n\r\n";
84+
client.print(head);
85+
86+
//partition the data packets to fit in a TCP packet (1460 bytes MAX)
87+
uint8_t obuf[WWW_BUF_SIZE];
88+
while (dataFile.available() > WWW_BUF_SIZE){
89+
dataFile.read(obuf, WWW_BUF_SIZE);
90+
client.write(obuf, WWW_BUF_SIZE);
91+
}
92+
//stream the last data left (size is at most WWW_BUF_SIZE bytes)
93+
uint16_t leftLen = dataFile.available();
94+
dataFile.read(obuf, leftLen);
95+
client.write(obuf, leftLen);
96+
97+
dataFile.close();
98+
return true;
99+
}
100+
return false;
101+
}
102+
103+
void tryLoadFromSdCard(){
104+
String message = "FileNotFound\n\n";
105+
if(hasSD){
106+
//try to load the URL from SD Card
107+
if(loadFromSdCard(server.uri())) return;
108+
} else {
109+
message = "SDCARD Not Detected\n\n";
110+
}
111+
server.send(404, "text/plain", message);
112+
}
113+
114+
void setup(void){
115+
uint8_t i = 0;
116+
Serial.begin(115200);
117+
118+
//setup WiFi
119+
WiFi.begin(ssid, password);
120+
Serial.print("\nConnecting to ");
121+
Serial.println(ssid);
122+
123+
//wait for WiFi to connect
124+
while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
125+
126+
//check if we have connected?
127+
if(i == 20){
128+
Serial.print("Could not connect to");
129+
Serial.println(ssid);
130+
//stop execution and wait forever
131+
while(1) delay(500);
132+
}
133+
Serial.print("Connected! IP address: ");
134+
Serial.println(WiFi.localIP());
135+
136+
//start mDNS Server
137+
if (mdns.begin(hostname, WiFi.localIP())) {
138+
Serial.println("MDNS responder started");
139+
Serial.print("You can now connect to http://");
140+
Serial.print(hostname);
141+
Serial.println(".local");
142+
}
143+
144+
//Attach handler
145+
server.onNotFound(tryLoadFromSdCard);
146+
147+
//start server
148+
server.begin();
149+
Serial.println("HTTP server started");
150+
151+
//init SD Card
152+
if (SD.begin(SS)){
153+
Serial.println("SD Card initialized.");
154+
hasSD = true;
155+
}
156+
}
157+
158+
void loop(void){
159+
mdns.update();
160+
server.handleClient();
161+
}

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/include/ClientContext.h

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class ClientContext {
169169

170170
_size_sent = will_send;
171171
DEBUGV(":wr\r\n");
172+
tcp_output( _pcb );
172173
_send_waiting = true;
173174
delay(5000); // max send timeout
174175
_send_waiting = false;

hardware/tools/esp8266/sdk/changelog.txt

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
esp_iot_sdk_v1.0.1_15_05_04_p1
2+
-------------------------------------------
3+
Here is a patch for station+softAP issue that users may have, based on SDK_v1.0.1,
4+
solved problem that connect to ESP8266 softAP may fail in station+softAP mode.
5+
6+
Sorry for the inconvenience.
7+
18
esp_iot_sdk_v1.0.1_15_04_24 Release Note
29
-------------------------------------------
310

0 commit comments

Comments
 (0)