Skip to content

Commit 96636f2

Browse files
author
Jeroen88
committed
Merge branch 'master' into feature/HTTPClient_WiFiClient_parameter
2 parents d0d7466 + 319adc6 commit 96636f2

File tree

13 files changed

+358
-110
lines changed

13 files changed

+358
-110
lines changed

.travis.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,28 @@ script:
4444
- $TRAVIS_BUILD_DIR/tests/common.sh
4545

4646
deploy:
47-
provider: releases
48-
prerelease: true
49-
skip_cleanup: true
50-
api_key:
51-
secure: A4FBmqyhlzy33oPeZVolg2Q/A3ZcJ3WnRQqQJ3NAPy+qGM5xcboOYtwcLL9vKaHZGfUB7lUP9QVZFGou1Wrmo9DnPvAoe3+XvCaDRGzVMxeIpu7UStbBD4Knbh98tlbMvZCXYRlT4VcusI9bMLK6UWw4sMdPislBh2FEfglTiag=
52-
file_glob: true
53-
file:
54-
- package/versions/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
55-
- package/versions/$TRAVIS_TAG/package_esp8266com_index.json
56-
on:
57-
repo: esp8266/Arduino
58-
tags: true
59-
condition: "$BUILD_TYPE = package"
47+
- provider: releases
48+
draft: true
49+
skip_cleanup: true
50+
api_key:
51+
secure: A4FBmqyhlzy33oPeZVolg2Q/A3ZcJ3WnRQqQJ3NAPy+qGM5xcboOYtwcLL9vKaHZGfUB7lUP9QVZFGou1Wrmo9DnPvAoe3+XvCaDRGzVMxeIpu7UStbBD4Knbh98tlbMvZCXYRlT4VcusI9bMLK6UWw4sMdPislBh2FEfglTiag=
52+
file_glob: true
53+
file:
54+
- package/versions/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
55+
- package/versions/$TRAVIS_TAG/package_esp8266com_index.json
56+
on:
57+
repo: esp8266/Arduino
58+
tags: true
59+
condition: "$BUILD_TYPE = package"
60+
61+
- provider: script
62+
skip_cleanup: true
63+
script: bash package/deploy_package_index.sh
64+
on:
65+
repo: esp8266/Arduino
66+
tags: true
67+
condition: "$BUILD_TYPE = package"
68+
6069

6170
notifications:
6271
email:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
2828
#### Latest release [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/)
2929
Boards manager link: `http://arduino.esp8266.com/stable/package_esp8266com_index.json`
3030

31-
Documentation: [https://arduino-esp8266.readthedocs.io/en/2.4.1/](https://arduino-esp8266.readthedocs.io/en/2.4.1/)
31+
Documentation: [https://arduino-esp8266.readthedocs.io/en/2.4.2/](https://arduino-esp8266.readthedocs.io/en/2.4.2/)
3232

3333
### Using git version
3434
[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)

cores/esp8266/HardwareSerial.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ void HardwareSerial::flush()
108108
delayMicroseconds(11000000 / uart_get_baudrate(_uart) + 1);
109109
}
110110

111+
void HardwareSerial::startDetectBaudrate()
112+
{
113+
uart_start_detect_baudrate(_uart_nr);
114+
}
115+
116+
unsigned long HardwareSerial::testBaudrate()
117+
{
118+
return uart_detect_baudrate(_uart_nr);
119+
}
120+
121+
unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
122+
{
123+
time_t startMillis = millis();
124+
unsigned long detectedBaudrate;
125+
while ((time_t) millis() - startMillis < timeoutMillis) {
126+
if ((detectedBaudrate = testBaudrate())) {
127+
break;
128+
}
129+
yield();
130+
delay(100);
131+
}
132+
return detectedBaudrate;
133+
}
134+
111135
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
112136
HardwareSerial Serial(UART0);
113137
#endif

cores/esp8266/HardwareSerial.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ class HardwareSerial: public Stream
184184
return uart_has_overrun(_uart);
185185
}
186186

187+
void startDetectBaudrate();
188+
189+
unsigned long testBaudrate();
190+
191+
unsigned long detectBaudrate(time_t timeoutMillis);
192+
187193
protected:
188194
int _uart_nr;
189195
uart_t* _uart = nullptr;

cores/esp8266/uart.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "uart.h"
4545
#include "esp8266_peri.h"
4646
#include "user_interface.h"
47+
#include "uart_register.h"
4748

4849
const char overrun_str [] ICACHE_RODATA_ATTR STORE_ATTR = "uart input full!\r\n";
4950
static int s_uart_debug_nr = UART0;
@@ -739,3 +740,49 @@ uart_get_debug()
739740
{
740741
return s_uart_debug_nr;
741742
}
743+
744+
/*
745+
To start detection of baud rate with the UART the UART_AUTOBAUD_EN bit needs to be cleared and set. The ROM function uart_baudrate_detect() does this only once, so on a next call the UartDev.rcv_state is not equal to BAUD_RATE_DET. Instead of poking around in the UartDev struct with unknown effect, the UART_AUTOBAUD_EN bit is directly triggered by the function uart_detect_baudrate().
746+
*/
747+
void
748+
uart_start_detect_baudrate(int uart_nr)
749+
{
750+
USA(uart_nr) &= ~(UART_GLITCH_FILT << UART_GLITCH_FILT_S | UART_AUTOBAUD_EN);
751+
USA(uart_nr) = 0x08 << UART_GLITCH_FILT_S | UART_AUTOBAUD_EN;
752+
}
753+
754+
int
755+
uart_detect_baudrate(int uart_nr)
756+
{
757+
static bool doTrigger = true;
758+
759+
if (doTrigger)
760+
{
761+
uart_start_detect_baudrate(uart_nr);
762+
doTrigger = false;
763+
}
764+
765+
int32_t divisor = uart_baudrate_detect(uart_nr, 1);
766+
if (!divisor) {
767+
return 0;
768+
}
769+
770+
doTrigger = true; // Initialize for a next round
771+
int32_t baudrate = UART_CLK_FREQ / divisor;
772+
773+
static const int default_rates[] = {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400, 256000, 460800, 921600, 1843200, 3686400};
774+
775+
size_t i;
776+
for (i = 1; i < sizeof(default_rates) / sizeof(default_rates[0]) - 1; i++) // find the nearest real baudrate
777+
{
778+
if (baudrate <= default_rates[i])
779+
{
780+
if (baudrate - default_rates[i - 1] < default_rates[i] - baudrate) {
781+
i--;
782+
}
783+
break;
784+
}
785+
}
786+
787+
return default_rates[i];
788+
}

cores/esp8266/uart.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ bool uart_has_overrun (uart_t* uart); // returns then clear overrun flag
141141
void uart_set_debug(int uart_nr);
142142
int uart_get_debug();
143143

144+
void uart_start_detect_baudrate(int uart_nr);
145+
int uart_detect_baudrate(int uart_nr);
146+
144147

145148
#if defined (__cplusplus)
146149
} // extern "C"

doc/faq/a05-board-generator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ available in the IDE menu.
1919
How can I run the script ?
2020
~~~~~~~~~~~~~~~~~~~~~~~~~~
2121

22-
Python 2 needs to be installed on your system.
22+
Python needs to be installed on your system.
2323

2424
The script is located in the ``tools`` subdirectory of the core's root installation.
2525
It needs to be run from the root directory,

doc/reference.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@ current speed. For example
155155
| Note that this implementation is **only for ESP8266 based boards**,
156156
and will not works with other Arduino boards.
157157
158+
159+
To detect an unknown baudrate of data coming into Serial use ``Serial.detectBaudrate(time_t timeoutMillis)``. This method tries to detect the baudrate for a maximum of timeoutMillis ms. It returns zero if no baudrate was detected, or the detected baudrate otherwise. The ``detectBaudrate()`` function may be called before ``Serial.begin()`` is called, because it does not need the receive buffer nor the SerialConfig parameters.
160+
161+
The uart can not detect other parameters like number of start- or stopbits, number of data bits or parity.
162+
163+
The detection itself does not change the baudrate, after detection it should be set as usual using ``Serial.begin(detectedBaudrate)``.
164+
165+
Detection is very fast, it takes only a few incoming bytes.
166+
167+
SerialDetectBaudrate.ino is a full example of usage.
168+
158169
Progmem
159170
-------
160171

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#define TIMEOUT (10000UL) // Maximum time to wait for serial activity to start
2+
3+
void setup() {
4+
// put your setup code here, to run once:
5+
6+
Serial.begin(115200);
7+
8+
// Serial.detectBaudrate() may also be called before Serial.begin()
9+
// There must be activity on the serial port for the baudrate to be detected
10+
unsigned long detectedBaudrate = Serial.detectBaudrate(TIMEOUT);
11+
12+
if (detectedBaudrate) {
13+
Serial.printf("\nDetected baudrate is %lu, switching to that baudrate now...\n", detectedBaudrate);
14+
15+
// Wait for printf to finish
16+
while (Serial.availableForWrite() != UART_TX_FIFO_SIZE) {
17+
yield();
18+
}
19+
20+
// Clear Tx buffer to avoid extra characters being printed
21+
Serial.flush();
22+
23+
// After this, any writing to Serial will print gibberish on the serial monitor if the baudrate doesn't match
24+
Serial.begin(detectedBaudrate);
25+
} else {
26+
Serial.println("\nNothing detected");
27+
}
28+
}
29+
30+
void loop() {
31+
// put your main code here, to run repeatedly:
32+
33+
}
34+

package/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Release tools
2+
3+
## Overview
4+
5+
This directory contains scripts used to automate the release process of esp8266/Arduino project.
6+
The purpose of the release process is to generate the following outputs from the repository:
7+
8+
* Boards manager package index for Arduino IDE (i.e. `package_esp8266_index.json`). See [specification](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.6.x-package_index.json-format-specification) of package index file for more info.
9+
10+
* Boards manager package for Arduino IDE. This is a .zip file which contains source code of esp8266/Arduino project, platform.txt, boards.txt and a few other supporting files. See [3-rd party hardware specification](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification) for more info about the layout of the boards manager package.
11+
12+
* Github Release for esp8266/Arduino project. This is used to host the boards manager package mentioned above, and also contains the release notes.
13+
14+
Here is an overview of the release process.
15+
16+
1. Release process starts when a maintainer pushes a tag into the repository.
17+
18+
2. Travis CI runs a build for this tag, and one of the jobs (with `BUILD_TYPE=package`) is used to prepare the boards manager package. This job runs `build_boards_manager_package.sh`.
19+
20+
3. `build_boards_manager_package.sh` does a few things to build the boards manager package (.zip) file and the json index:
21+
22+
* Pack source files into a zip file, excluding some files and tweaking platform.txt.
23+
* Download current latest package index json file from Github Releases. This file contains descriptions of all previous releases.
24+
* Generate package index for the new release.
25+
* Combines new release with previous releases in one json file (using `merge_packages.py` script).
26+
27+
4. Travis CI uploads boards manager package (.zip file) and package index (.json file) to Github Releases, creating a draft release at the same time.
28+
29+
5. Travis CI also uploads package index .json file to `http://arduino.esp8266.com/stable/package_esp8266_index.json`, i.e. well-known URL used by most users.
30+
31+
6. When the draft release is created, maintainer edits release description and inserts changelog into the description field, unmarks the release as draft, and publishes the release.
32+
33+
7. Housekeeping is performed in Github issue tracker to close the completed milestone, update issue tags, etc.
34+
35+
36+
## Creating a release (for maintainers)
37+
38+
1. Assemble release notes.
39+
40+
* Since most changes are integrated into master using squash-rebase policy (i.e. one commit per PR), `git log --oneline` gives a good overview of changes in the release.
41+
42+
* Prepare release notes in Markdown format.
43+
44+
* Combine related changes into the following categories, in that order:
45+
46+
- Core
47+
- *Libraries* — one section per library that received changes. If library only had a single change or a few changes, it is also okay to combine changes to a few such libraries under single "Other Libraries" entry.
48+
- Upstream dependencies
49+
- Documentation
50+
- Boards
51+
52+
* Not all commit descriptions which come from `git log` will explain changes well. Reword items as necessary, with the goal that a general user of this project should be able to understand what the change is related to. Preserve references to PRs or issues (`#XXXX`).
53+
54+
* Don't include fixes for issues which have been introduced since last release.
55+
56+
* Aggregate minor fixes (e.g. typos, small documentation changes) in a few items. Focus on preparing a good overview of the release for the users, rather than mentioning every change.
57+
58+
* When done, put release notes into a private Gist and send the link to other maintainers for review.
59+
60+
2. Tag the latest commit. In this project, tags have form `X.Y.Z`, e.g. `2.4.0`, or `X.Y.Z-rcN` for release versions. Notice that there's no `v`at the beginning of the tag. Tags must be annotated, not lightweight tags. To create a tag, use git command (assuming that the master branch is checked out):
61+
62+
```
63+
git tag -a -m "Release 2.4.0" 2.4.0
64+
```
65+
66+
Push the tag to esp8266/Arduino Github repository.
67+
68+
69+
3. Wait for Travis CI build for the tag to pass. Check that the new (draft) release has been created. Check that the boards manager package .zip file has been successfully uploaded as a release artifact.
70+
71+
4. Check that the package index downloaded from http://arduino.esp8266.com/stable/package_esp8266_index.json contains an entry for the new version (it may not be the first one).
72+
73+
5. Navigate to release list in Github, press "Edit" button to edit release description, paste release notes. Remove "draft" status of the release and publish it.
74+
75+
6. In the issue tracker, remove "staged-for-release" label for all issues which have it, and close them. Close the milestone associated with the released version.
76+
77+
7. Make a commit to master branch, updating the version in platform.txt file. This should correspond to the version of the *next* milestone.
78+
79+

package/arduino-esp8266-travis.enc

432 Bytes
Binary file not shown.

package/deploy_package_index.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#
3+
# This script updates package index hosted on arduino.esp8266.com.
4+
# Normally is run by Travis CI for tagged versions, as a deploy step.
5+
6+
tag=`git describe --tags`
7+
8+
cd $(dirname "$0")
9+
10+
# Decrypt and install SSH private key.
11+
# "encrypted_xxx_key" and "encrypted_xxx_iv" are environment variables
12+
# known to Travis CI builds.
13+
openssl aes-256-cbc -K $encrypted_3f14690ceb9b_key -iv $encrypted_3f14690ceb9b_iv -in arduino-esp8266-travis.enc -out arduino-esp8266-travis -d
14+
eval "$(ssh-agent -s)"
15+
chmod 600 arduino-esp8266-travis
16+
ssh-add arduino-esp8266-travis
17+
18+
# Set SSH server public key
19+
echo "arduino.esp8266.com,104.131.82.128 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAvoxsdf1jJ1XX7RrCtAQyjvZ3b33bWYfB/XDvEMLtxnJhZr+P/wa7yuZ+UJJ1wuJc+wcIMBNZ2Zz/MbdRMey7A=" \
20+
>> $HOME/.ssh/known_hosts
21+
22+
branch=stable
23+
24+
base_dir=apps/download_files/download
25+
26+
# Upload package_esp8266com_index.json
27+
ssh $ssh_dl_server "mkdir -p $base_dir/versions/$tag"
28+
scp versions/$tag/package_esp8266com_index.json $ssh_dl_server:$base_dir/versions/$tag/
29+
30+
# Change symlink for stable version
31+
oldver=$(ssh $ssh_dl_server "readlink $base_dir/$branch")
32+
newver="versions/$tag"
33+
echo "Changing version of $branch from $oldver to $newver"
34+
35+
ssh $ssh_dl_server "pushd apps/download_files/download && ln -snf versions/$tag $branch"

0 commit comments

Comments
 (0)