Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/esp8266/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Links2004 committed Feb 2, 2016
2 parents 0404470 + 8a26750 commit ea95f2e
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 36 deletions.
55 changes: 54 additions & 1 deletion boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ thing.name=SparkFun ESP8266 Thing

thing.upload.tool=esptool
thing.upload.speed=921600
thing.upload.resetmethod=nodemcu
thing.upload.resetmethod=ck
thing.upload.maximum_size=434160
thing.upload.maximum_data_size=81920
thing.upload.wait_for_upload_port=true
Expand Down Expand Up @@ -606,6 +606,59 @@ thing.menu.UploadSpeed.512000.upload.speed=512000
thing.menu.UploadSpeed.921600=921600
thing.menu.UploadSpeed.921600.upload.speed=921600

##############################################################
thingdev.name=SparkFun ESP8266 Thing Dev

thingdev.upload.tool=esptool
thingdev.upload.speed=921600
thingdev.upload.resetmethod=nodemcu
thingdev.upload.maximum_size=434160
thingdev.upload.maximum_data_size=81920
thingdev.upload.wait_for_upload_port=true
thingdev.serial.disableDTR=true
thingdev.serial.disableRTS=true

thingdev.build.mcu=esp8266
thingdev.build.f_cpu=80000000L
thingdev.build.board=ESP8266_THING_DEV
thingdev.build.core=esp8266
thingdev.build.variant=thing
thingdev.build.flash_mode=dio
# flash chip: AT25SF041 (512 kbyte, 4Mbit)
thingdev.build.flash_size=512K
thingdev.build.flash_ld=eagle.flash.512k64.ld
thingdev.build.flash_freq=40
thingdev.build.debug_port=
thingdev.build.debug_level=

thingdev.menu.CpuFrequency.80=80 MHz
thingdev.menu.CpuFrequency.80.build.f_cpu=80000000L
thingdev.menu.CpuFrequency.160=160 MHz
thingdev.menu.CpuFrequency.160.build.f_cpu=160000000L

thingdev.menu.UploadTool.esptool=Serial
thingdev.menu.UploadTool.esptool.upload.tool=esptool
thingdev.menu.UploadTool.esptool.upload.verbose=-vv

thingdev.menu.UploadSpeed.115200=115200
thingdev.menu.UploadSpeed.115200.upload.speed=115200
thingdev.menu.UploadSpeed.9600=9600
thingdev.menu.UploadSpeed.9600.upload.speed=9600
thingdev.menu.UploadSpeed.57600=57600
thingdev.menu.UploadSpeed.57600.upload.speed=57600
thingdev.menu.UploadSpeed.256000.windows=256000
thingdev.menu.UploadSpeed.256000.upload.speed=256000
thingdev.menu.UploadSpeed.230400.linux=230400
thingdev.menu.UploadSpeed.230400.macosx=230400
thingdev.menu.UploadSpeed.230400.upload.speed=230400
thingdev.menu.UploadSpeed.460800.linux=460800
thingdev.menu.UploadSpeed.460800.macosx=460800
thingdev.menu.UploadSpeed.460800.upload.speed=460800
thingdev.menu.UploadSpeed.512000.windows=512000
thingdev.menu.UploadSpeed.512000.upload.speed=512000
thingdev.menu.UploadSpeed.921600=921600
thingdev.menu.UploadSpeed.921600.upload.speed=921600

##############################################################
esp210.name=SweetPea ESP-210

Expand Down
65 changes: 32 additions & 33 deletions cores/esp8266/MD5Builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,42 @@ void MD5Builder::addHexString(const char * data){
}

bool MD5Builder::addStream(Stream & stream, const size_t total_len) {
const int buf_size = 512;
int bytesleft = total_len;
uint8_t * buf = (uint8_t*) malloc(buf_size);
if(buf) {
while((stream.available() > -1) && (bytesleft > 0)) {
const int buf_size = 512;
int bytesleft = total_len;
uint8_t * buf = (uint8_t*) malloc(buf_size);
if(buf) {
while((stream.available() > -1) && (bytesleft > 0)) {
// get available data size
int sizeAvailable = stream.available();
if(sizeAvailable) {
int readBytes = sizeAvailable;

// get available data size
int sizeAvailable = stream.available();
if(sizeAvailable) {
int readBytes = sizeAvailable;

// read only the asked bytes
if(readBytes > bytesleft) {
readBytes = bytesleft ;
}
// read only the asked bytes
if(readBytes > bytesleft) {
readBytes = bytesleft ;
}

// not read more the buffer can handle
if(readBytes > buf_size) {
readBytes = buf_size;
}
// not read more the buffer can handle
if(readBytes > buf_size) {
readBytes = buf_size;
}

// read data
int bytesread = stream.readBytes(buf, readBytes);
bytesleft -= bytesread;
if(bytesread > 0) {
MD5Update(&_ctx, buf, bytesread);
}
}
// time for network streams
delay(0);
// read data
int bytesread = stream.readBytes(buf, readBytes);
bytesleft -= bytesread;
if(bytesread > 0) {
MD5Update(&_ctx, buf, bytesread);
}
// not free null ptr
free(buf);
return (bytesleft == 0);
} else {
return false;
}
// time for network streams
delay(0);
}
// guaranteed not null
free(buf);
return (bytesleft == 0);
} else {
return false;
}
}

void MD5Builder::calculate(void){
Expand All @@ -77,7 +76,7 @@ void MD5Builder::getChars(char * output){
}

String MD5Builder::toString(void){
char out[32];
char out[33];
getChars(out);
return String(out);
}
19 changes: 18 additions & 1 deletion doc/boards.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ title: Supported Hardware
* [NodeMCU 1\.0](#nodemcu-10)
* [Olimex MOD\-WIFI\-ESP8266\-DEV](#olimex-mod-wifi-esp8266-dev)
* [Olimex MOD\-WIFI\-ESP8266](#olimex-mod-wifi-esp8266)
* [Olimex ESP8266\-EVB](#olimex-esp8266-evb)
* [SparkFun ESP8266 Thing](#sparkfun-esp8266-thing)
* [SweetPea ESP\-210](#sweetpea-esp-210)
* [ESPino](#espino)
Expand Down Expand Up @@ -77,12 +78,28 @@ Since jumper IO0JP is tied to GPIO0, which is PIN 21, you'll have to ground it b

UART pins for programming and serial I/O are GPIO1 (TXD, pin 3) and GPIO3 (RXD, pin 4).

Get the board schematics [here](https://github.com/OLIMEX/ESP8266/blob/master/HARDWARE/MOD-WIFI-ESP8266-DEV/MOD-WIFI-ESP8266-DEV_schematic.pdf)
You can find the board schematics [here](https://github.com/OLIMEX/ESP8266/blob/master/HARDWARE/MOD-WIFI-ESP8266-DEV/MOD-WIFI-ESP8266-DEV_schematic.pdf)

## Olimex MOD-WIFI-ESP8266

This is a stripped down version of the above. Behaves identically in terms of jumpers but has less pins readily available for I/O. Still 2 MB of SPI flash.

## Olimex ESP8266-EVB

It's a Olimex MOD-WIFI-ESP8266-DEV module installed on the headers of a development board which features some breakout connectors, a button (GPIO0) and a relay (GPIO5).

Programming is pretty straightforward: the board is supported in the Arduino IDE after [installing it via the Board Manager](https://github.com/esp8266/Arduino#installing-with-boards-manager). To download a program you just have to connect GND/RX/TX from a serial/USB adapter to the UEXT connector and press the only button before applying power to enter UART mode.

Don't connect 5V from the serial/USB adapter to the board or you won't be able to power cycle it for UART mode.

You can find the board schematics [here](https://github.com/OLIMEX/ESP8266/blob/master/HARDWARE/ESP8266-EVB/ESP8266-EVB_Rev_A.pdf).

[This guide](https://www.olimex.com/Products/IoT/ESP8266-EVB/resources/ESP8266-EVB-how-to-use-Arduino.pdf) is also useful for the first setup, since it contains the UEXT connector pinout.

Board variants include:
* ESP8266-EVB-BAT: comes with built-in LiPo charger and step-up converter
* ESP8266-EVB-BAT-BOX: as above, but enclosd in a plastic box (non-weatherproof)

## SparkFun ESP8266 Thing ###

Product page: https://www.sparkfun.com/products/13231
Expand Down
1 change: 1 addition & 0 deletions doc/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Libraries that don't rely on low-level access to AVR registers should work well.
- [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)).
- [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library.git)
- [DHT-sensor-library](https://github.com/adafruit/DHT-sensor-library) - Arduino library for the DHT11/DHT22 temperature and humidity sensors. Download latest v1.1.1 library and no changes are necessary. Older versions should initialize DHT as follows: `DHT dht(DHTPIN, DHTTYPE, 15)`
- [Encoder](https://github.com/PaulStoffregen/Encoder) - Arduino library for rotary encoders. Version 1.4 supports ESP8266.
- [NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) - Adafruit's NeoPixel library, now with support for the ESP8266 (use version 1.0.2 or higher from Arduino's library manager).
- [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with ESP8266. Use the "DmaDriven" or "UartDriven" branches for ESP8266. Includes HSL color support and more.
- [PubSubClient](https://github.com/Imroy/pubsubclient) - MQTT library by @Imroy.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/ota_updates/a-ota-upload-password-prompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions doc/ota_updates/ota_updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ title: OTA Update
* [Application Example](#application-example)
* [Classic OTA](#classic-ota)
* [ArduinoOTA](#arduinoota)
* [Password Protection](#password-protection)
* [Troubleshooting](#troubleshooting)
* [Web Browser](#web-browser)
* [Requirements](#requirements-1)
Expand Down Expand Up @@ -228,6 +229,40 @@ IP address: 192.168.1.100
**Note:** To be able to upload your sketch over and over again using OTA, you need to embed OTA routines inside. Please use BasicOTA.ino as an example.


#### Password Protection

Protecting your OTA uploads with password is really straightforward. All you need to do, is to include the following statement in your code:

```cpp
ArduinoOTA.setPassword((const char *)"123");

```

Where ``` 123 ``` is a sample password that you should replace with your own.

Before implementing it in your sketch, it is a good idea to check how it works using *BasicOTA.ino* sketch available under *File > Examples > ArduinoOTA*. Go ahead, open *BasicOTA.ino*, uncomment the above statement that is already there, and upload the sketch. To make troubleshooting easier, do not modify example sketch besides what is absolutely required. This is including original simple ``` 123 ``` OTA password. Then attempt to upload sketch again (using OTA). After compilation is complete, once upload is about to begin, you should see prompt for password as follows:

![Password prompt for OTA upload](a-ota-upload-password-prompt.png)

Enter the password and upload should be initiated as usual with the only difference being ``` Authenticating...OK ``` message visible in upload log.

![ Authenticating...OK during OTA upload](a-ota-upload-password-authenticating-ok.png)

You will not be prompted for a reentering the same password next time. Arduino IDE will remember it for you. You will see prompt for password only after reopening IDE, or if you change it in your sketch, upload the sketch and then try to upload it again.

Please note, it is possible to reveal password entered previously in Arduino IDE, if IDE has not been closed since last upload. This can be done by enabling *Show verbose output during: upload* in *File > Preferences* and attempting to upload the module.

![Verbose upload output with password passing in plan text](a-ota-upload-password-passing-upload-ok.png)

The picture above shows that the password is visible in log as it is passed to *espota.py* upload script.

Another example below shows situation when password is changed between uploads.

![Verbose output when OTA password has been changed between uploads](a-ota-upload-password-passing-again-upload-ok.png)

When uploading, Arduino IDE used previously entered password, so the upload failed and that has been clearly reported by IDE. Only then IDE prompted for a new password. That was entered correctly and second attempt to upload has been successful.


#### Troubleshooting

If OTA update fails, first step is to check for error messages that may be shown in upload window of Arduino IDE. If this is not providing any useful hints try to upload again while checking what is shown by ESP on serial port. Serial Monitor from IDE will not be useful in that case. When attempting to open it, you will likely see the following:
Expand Down
2 changes: 1 addition & 1 deletion doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ESP8266 has a single ADC channel available to users. It may be used either to re

To read external voltage applied to ADC pin, use `analogRead(A0)`. Input voltage range is 0 — 1.0V.

To read VCC voltage, ADC pin must be kept unconnected. Additionally, the following line has to be added to the sketch:
To read VCC voltage, use `ESP.getVcc()` and ADC pin must be kept unconnected. Additionally, the following line has to be added to the sketch:

```c++
ADC_MODE(ADC_VCC);
Expand Down

0 comments on commit ea95f2e

Please sign in to comment.