Skip to content

Commit 3fa0ac8

Browse files
authored
Merge pull request esp8266#55 from esp8266/master
Update
2 parents ece9c86 + 122e870 commit 3fa0ac8

35 files changed

+11851
-10558
lines changed

.travis.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: bash
22
os: linux
3-
dist: trusty
3+
dist: bionic
44

55
git:
66
depth: 1
@@ -80,17 +80,13 @@ jobs:
8080
stage: build
8181
script: $TRAVIS_BUILD_DIR/tests/ci/host_test.sh
8282
install:
83-
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
84-
- sudo apt-get update -q
85-
- sudo apt-get install -y --allow-unauthenticated g++-7 gcc-7
8683
- sudo apt-get install valgrind lcov
87-
env: CC=gcc-7 CXX=g++-7
8884

8985
- name: "Docs"
9086
stage: build
9187
script: $TRAVIS_BUILD_DIR/tests/ci/build_docs.sh
9288
install:
93-
- sudo apt-get install python3-pip
89+
- sudo apt-get install python3-pip python3-setuptools
9490
- pip3 install --user -r doc/requirements.txt;
9591

9692
- name: "Style check"
@@ -101,11 +97,6 @@ jobs:
10197
- name: "Mock trivial test"
10298
stage: build
10399
script: $TRAVIS_BUILD_DIR/tests/buildm.sh
104-
install:
105-
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
106-
- sudo apt-get update -q
107-
- sudo apt-get install -y --allow-unauthenticated g++-7 gcc-7
108-
env: CC=gcc-7 CXX=g++-7
109100

110101
- name: "Mac OSX can build sketches"
111102
os: osx

README.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and
1616
# Contents
1717
- Installing options:
1818
- [Using Boards Manager](#installing-with-boards-manager)
19-
- [Using git version](#using-git-version-basic-instructions)
19+
- [Using git version](#using-git-version)
2020
- [Using PlatformIO](#using-platformio)
2121
- [Building with make](#building-with-make)
2222
- [Documentation](#documentation)
@@ -38,35 +38,13 @@ Boards manager link: `https://arduino.esp8266.com/stable/package_esp8266com_inde
3838

3939
Documentation: [https://arduino-esp8266.readthedocs.io/en/2.5.2/](https://arduino-esp8266.readthedocs.io/en/2.5.2/)
4040

41-
### Using git version (basic instructions)
41+
### Using git version
4242
[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)
4343

44+
Also known as latest git or master branch.
45+
4446
- Install the current upstream Arduino IDE at the 1.8 level or later. The current version is on the [Arduino website](https://www.arduino.cc/en/main/software).
45-
- Go to Arduino directory
46-
- For Mac OS X, it is `Arduino.app` showing as the Arduino icon.
47-
This location may be your `~/Downloads`, `~/Desktop` or even `/Applications`.
48-
```bash
49-
cd <application-directory>/Arduino.app/Contents/Java
50-
```
51-
- For Linux, it is ~/Arduino by default.
52-
```bash
53-
cd ~/Arduino
54-
```
55-
- Clone this repository into hardware/esp8266com/esp8266 directory (or clone it elsewhere and create a symlink)
56-
```bash
57-
cd hardware
58-
mkdir esp8266com
59-
cd esp8266com
60-
git clone https://github.com/esp8266/Arduino.git esp8266
61-
cd esp8266
62-
git submodule update --init
63-
```
64-
- Download binary tools (you need Python 2.7)
65-
```bash
66-
cd esp8266/tools
67-
python get.py
68-
```
69-
- Restart Arduino
47+
- Follow the [instructions in the documentation](https://arduino-esp8266.readthedocs.io/en/latest/installing.html#using-git-version).
7048

7149
### Using PlatformIO
7250

cores/esp8266/Arduino.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,6 @@ void configTime(const char* tz, const char* server1,
285285

286286
#include "pins_arduino.h"
287287

288-
#ifndef PUYA_SUPPORT
289-
#define PUYA_SUPPORT 1
290-
#endif
291-
292288
#endif
293289

294290
#ifdef DEBUG_ESP_OOM

cores/esp8266/Esp.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21-
#include "Arduino.h"
21+
#include "Esp.h"
2222
#include "flash_utils.h"
2323
#include "eboot_command.h"
2424
#include <memory>
@@ -36,6 +36,14 @@ extern struct rst_info resetInfo;
3636

3737
//#define DEBUG_SERIAL Serial
3838

39+
#ifndef PUYA_SUPPORT
40+
#define PUYA_SUPPORT 1
41+
#endif
42+
#ifndef PUYA_BUFFER_SIZE
43+
// Good alternative for buffer size is: SPI_FLASH_SEC_SIZE (= 4k)
44+
// Always use a multiple of flash page size (256 bytes)
45+
#define PUYA_BUFFER_SIZE 256
46+
#endif
3947

4048
/**
4149
* User-defined Literals
@@ -577,7 +585,7 @@ bool EspClass::flashEraseSector(uint32_t sector) {
577585
}
578586

579587
#if PUYA_SUPPORT
580-
static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
588+
static SpiFlashOpResult spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
581589
if (data == nullptr) {
582590
return SPI_FLASH_RESULT_ERR;
583591
}
@@ -607,7 +615,7 @@ static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
607615
}
608616
rc = spi_flash_read(pos, flash_write_puya_buf, bytesNow);
609617
if (rc != SPI_FLASH_RESULT_OK) {
610-
return (int)rc;
618+
return rc;
611619
}
612620
for (size_t i = 0; i < bytesNow / 4; ++i) {
613621
flash_write_puya_buf[i] &= *ptr;
@@ -616,7 +624,7 @@ static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
616624
rc = spi_flash_write(pos, flash_write_puya_buf, bytesNow);
617625
pos += bytesNow;
618626
}
619-
return (int)rc;
627+
return rc;
620628
}
621629
#endif
622630

cores/esp8266/Esp.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323

2424
#include <Arduino.h>
2525

26-
#ifndef PUYA_SUPPORT
27-
#define PUYA_SUPPORT 0
28-
#endif
29-
#ifndef PUYA_BUFFER_SIZE
30-
// Good alternative for buffer size is: SPI_FLASH_SEC_SIZE (= 4k)
31-
// Always use a multiple of flash page size (256 bytes)
32-
#define PUYA_BUFFER_SIZE 256
33-
#endif
34-
3526
// Vendor IDs taken from Flashrom project
3627
// https://review.coreboot.org/cgit/flashrom.git/tree/flashchips.h?h=1.0.x
3728
typedef enum {

cores/esp8266/HardwareSerial.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,16 @@ int HardwareSerial::available(void)
108108

109109
void HardwareSerial::flush()
110110
{
111+
uint8_t bit_length = 0;
111112
if(!_uart || !uart_tx_enabled(_uart)) {
112113
return;
113114
}
114115

116+
bit_length = uart_get_bit_length(_uart_nr); // data width, parity and stop
115117
uart_wait_tx_empty(_uart);
116118
//Workaround for a bug in serial not actually being finished yet
117119
//Wait for 8 data bits, 1 parity and 2 stop bits, just in case
118-
delayMicroseconds(11000000 / uart_get_baudrate(_uart) + 1);
120+
delayMicroseconds(bit_length * 1000000 / uart_get_baudrate(_uart) + 1);
119121
}
120122

121123
void HardwareSerial::startDetectBaudrate()

cores/esp8266/cont.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21-
.text
21+
.section .irom0.text
2222
.align 4
2323
.literal_position
2424
.global cont_yield
@@ -84,7 +84,7 @@ cont_wrapper:
8484

8585
////////////////////////////////////////////////////
8686

87-
.text
87+
.section .irom0.text
8888
.align 4
8989
.literal_position
9090
.global cont_run

cores/esp8266/coredecls.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,21 @@ extern bool timeshift64_is_set;
1717
void esp_yield();
1818
void esp_schedule();
1919
void tune_timeshift64 (uint64_t now_us);
20-
void settimeofday_cb (void (*cb)(void));
2120
void disable_extra4k_at_link_time (void) __attribute__((noinline));
2221

2322
uint32_t sqrt32 (uint32_t n);
2423
uint32_t crc32 (const void* data, size_t length, uint32_t crc = 0xffffffff);
2524

2625
#ifdef __cplusplus
2726
}
27+
28+
#include <functional>
29+
30+
using TrivialCB = std::function<void()>;
31+
32+
void settimeofday_cb (TrivialCB&& cb);
33+
void settimeofday_cb (const TrivialCB& cb);
34+
2835
#endif
2936

3037
#endif // __COREDECLS_H

cores/esp8266/sntp-lwip2.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,22 @@
4242
#include <osapi.h>
4343
#include <os_type.h>
4444
#include "coredecls.h"
45+
#include "Schedule.h"
4546

46-
extern "C" {
47+
static TrivialCB _settimeofday_cb;
4748

48-
static void (*_settimeofday_cb)(void) = NULL;
49+
void settimeofday_cb (TrivialCB&& cb)
50+
{
51+
_settimeofday_cb = std::move(cb);
52+
}
4953

50-
void settimeofday_cb (void (*cb)(void))
54+
void settimeofday_cb (const TrivialCB& cb)
5155
{
5256
_settimeofday_cb = cb;
5357
}
5458

59+
extern "C" {
60+
5561
#if LWIP_VERSION_MAJOR == 1
5662

5763
#include <pgmspace.h>
@@ -478,7 +484,7 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
478484
sntp_set_system_time(tv->tv_sec);
479485

480486
if (_settimeofday_cb)
481-
_settimeofday_cb();
487+
schedule_function(_settimeofday_cb);
482488
}
483489
return 0;
484490
}

cores/esp8266/uart.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#include "user_interface.h"
4949
#include "uart_register.h"
5050

51+
#define MODE2WIDTH(mode) (((mode%16)>>2)+5)
52+
#define MODE2STOP(mode) (((mode)>>5)+1)
53+
#define MODE2PARITY(mode) (mode%4)
54+
5155
/*
5256
Some general architecture for GDB integration with the UART to enable
5357
serial debugging.
@@ -204,7 +208,14 @@ uart_read_char_unsafe(uart_t* uart)
204208
return -1;
205209
}
206210

207-
size_t
211+
uint8_t
212+
uart_get_bit_length(const int uart_nr)
213+
{
214+
// return bit length from uart mode, +1 for the start bit which is always there.
215+
return MODE2WIDTH(USC0(uart_nr)) + MODE2PARITY(USC0(uart_nr)) + MODE2STOP(USC0(uart_nr)) + 1;
216+
}
217+
218+
size_t
208219
uart_rx_available(uart_t* uart)
209220
{
210221
if(uart == NULL || !uart->rx_enabled)

cores/esp8266/uart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ int uart_get_debug();
147147
void uart_start_detect_baudrate(int uart_nr);
148148
int uart_detect_baudrate(int uart_nr);
149149

150+
uint8_t uart_get_bit_length(const int uart_nr);
150151

151152
#if defined (__cplusplus)
152153
} // extern "C"

doc/installing.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ Prerequisites
4747
- Python 3.x (https://python.org)
4848
- terminal, console, or command prompt (depending on your OS)
4949
- Internet connection
50+
- Uninstalling any core version installed via Board Manager
5051

5152
Instructions - Windows 10
5253
~~~~~~~~~~~~~~~~~~~~~~~~~
53-
- First, make sure you don't already have the ESP8266 library installed using the Board Manager (see above)
54+
- First, make sure you don't already have an ESP8266 core version installed
55+
using the Board Manager (see above). If you do, uninstall it from the
56+
Board Manager before proceeding.
5457

5558
- Install git for Windows (if not already; see https://git-scm.com/download/win)
5659

@@ -131,9 +134,14 @@ Note that you could, in theory install in ``C:\Program Files (x86)\Arduino\hardw
131134
Instructions - Other OS
132135
~~~~~~~~~~~~~~~~~~~~~~~
133136
137+
- First, make sure you don't already have an ESP8266 core version installed
138+
using the Board Manager (see above). If you do, uninstall it from the
139+
Board Manager before proceeding.
140+
134141
- Open the console and go to Arduino directory. This can be either your
135142
*sketchbook* directory (usually ``<Documents>/Arduino``), or the
136143
directory of Arduino application itself, the choice is up to you.
144+
137145
- Clone this repository into hardware/esp8266com/esp8266 directory.
138146
Alternatively, clone it elsewhere and create a symlink, if your OS
139147
supports them.

libraries/ESP8266WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ void setup() {
8585
Serial.swap();
8686
// Hardware serial is now on RX:GPIO13 TX:GPIO15
8787
// use SoftwareSerial on regular RX(3)/TX(1) for logging
88-
logger = new SoftwareSerial(3, 1);
89-
logger->begin(BAUD_LOGGER);
88+
logger = new SoftwareSerial();
89+
logger->begin(BAUD_LOGGER, 3, 1);
90+
logger->enableIntTx(false);
9091
logger->println("\n\nUsing SoftwareSerial for logging");
9192
#else
9293
logger->begin(BAUD_LOGGER);

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ESP8266HTTPUpdate::~ESP8266HTTPUpdate(void)
4343
{
4444
}
4545

46-
#ifdef HTTPUPDATE_1_2_COMPATIBLE
46+
#if HTTPUPDATE_1_2_COMPATIBLE
4747
HTTPUpdateResult ESP8266HTTPUpdate::update(const String& url, const String& currentVersion,
4848
const String& httpsFingerprint, bool reboot)
4949
{
@@ -94,7 +94,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::update(WiFiClient& client, const String& url
9494
return handleUpdate(http, currentVersion, false);
9595
}
9696

97-
#ifdef HTTPUPDATE_1_2_COMPATIBLE
97+
#if HTTPUPDATE_1_2_COMPATIBLE
9898
HTTPUpdateResult ESP8266HTTPUpdate::updateSpiffs(const String& url, const String& currentVersion, const String& httpsFingerprint)
9999
{
100100
HTTPClient http;
@@ -133,7 +133,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::updateSpiffs(WiFiClient& client, const Strin
133133
return handleUpdate(http, currentVersion, true);
134134
}
135135

136-
#ifdef HTTPUPDATE_1_2_COMPATIBLE
136+
#if HTTPUPDATE_1_2_COMPATIBLE
137137
HTTPUpdateResult ESP8266HTTPUpdate::update(const String& host, uint16_t port, const String& uri, const String& currentVersion,
138138
bool https, const String& httpsFingerprint, bool reboot)
139139
{

0 commit comments

Comments
 (0)