1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

3589 Commits

Author SHA1 Message Date
david gauchard
216680bb57 weak hook preinit() #2111 #2133 #2136 (#5395)
* weak hook early_setup() #2111 #2133 #2136

* rename to early_init (more "c" vs early_setup which is more "c++arduino")

* example

* improve earlyWiFi example, slightly change AddrList interface, move WiFi sketches into WiFi examples

* fix CI

* fix local CI runner

* fix local CI runner

* rename early_init() to preinit()

* + static ESP8266WiFiClass::preinit_wifi_off()

* update early disable wifi example

* example update

* IPv6 example update

* Update ESP8266WiFiGeneric.h

camelCase for static method name

* Update ESP8266WiFiGeneric.cpp

camelCase for static method name

* Update EarlyDisableWiFi.ino

Expand comment, fix static method name

* Update core_esp8266_main.cpp

Expanded comment.

* Update core_esp8266_main.cpp

Expanded comment

* Update EarlyDisableWiFi.ino

Expanded comment
2018-12-03 20:54:27 -08:00
Earle F. Philhower, III
2ec3daa225 Use Python JSON to format packages.json file (#5429)
The packages JSON file which includes the boards, tools, etc. and needs to
have consistent formatting to be reproducible.  The current boards.txt.py
uses a REGEX to string-replace a bit of it, but that bit has a different
indent than the rest of the file.

Use Python's JSON writer to format the whole file repeatably.
2018-12-04 00:26:18 -03:00
Earle F. Philhower, III
f68362e78f
Add in Win64 pointers to Win32 tools (#5427)
Some needed tools are not yet built for Win64, so use the Win32 binaries.
Add them to the platform.json file so get.py and Arduino can find them.
2018-12-03 13:35:13 -08:00
Earle F. Philhower, III
f770d1a213 Add %z and %x to printf backend (#5424)
* Add %z and %x to printf backend

%z is a C99 format used for size_t and was not included in any printf.
On the 8266 it's a no-op as size_t==int, so ignore it and things just
work.

%x lowercase support added back in (wasn't present in nano-printf).

* Update to toolchain built newlib, fix link error

Previous commit was a hand build and copy, this one used the full
toolchain and should not include atexit().
2018-12-03 17:26:31 -03:00
Earle F. Philhower, III
2f907f47bb
Fix pgmspace 32-bit read macros (#5425)
Looks like the pgm_read_(32bit) defines were not used in the main core, and
they contained syntax errors when invoked due to some bad bracket/parens.

Fix the macros
2018-12-03 11:14:10 -08:00
david gauchard
50cbdc0b92 update AddrList and examples (#5422) 2018-12-03 15:15:50 -03:00
david gauchard
31bee50102
IPAddress: allow misaligned source in constructor (#5421) 2018-12-03 16:59:38 +01:00
Alwin Arrasyid
ca3678f7c1 ESPectro Core board support (#5419) 2018-12-03 15:27:06 +01:00
Earle F. Philhower, III
6280e98b03 Enable exceptions, update to optimized newlib, migrate to new toolchain (#5376)
* Move to PROGMEM aware libc, allow PSTR in printf()

A Newlib (libc) patch is in progress to move the _P functions from inside
Arduino into first-class citizens in libc.  This Arduino patch cleans up
code that's been migrated there.  Binaries for the new libs are included
because it seems they're part of the Arduino git tree, and should be
replaced with @igrr built ones when/if the Newlib changes are accepted.

Notable changes/additions for Arduino:
Allow for use of PROGMEM based format and parameter strings in all
*printf functions.  No need for copying PSTR()s into RAM before printing
them out (transparently saves heap space when using _P functions) and
makes it easier to print out constant strings for applications.

Add "%S" (capital-S) format that I've been told, but cannot verify,
is used in Arduino to specify a PROGMEM string parameter in printfs,
as an alias for "%s" since plain "%s" can now handle PROGMEM.

Optimized the memcpy_P, strnlen_P, and strncpy_P functions to use 32-bit
direct reads whenver possible (source and dest alignment mediated), but
there is still room for improvement in others.

Finally, move several constant arrays from RODATA into PROGMEM and
update their accessors.  Among these are the ctype array, ~260 bytes,
mprec* arrays, ~300 bytes, and strings/daycounts in the time
formatting functions, ~200 bytes.  All told, sketches will see from
300 to 800 additional RAM heap free on startup (depending on their
use of these routines).

* Fix merge error in #ifdef/#endif

* Fix host test using the newlib generic pgmspace.h

Host tests now use the sys/pgmspace.h for compiles instead of the
ESP8266-specific version.

* Update with rebuilt libraries using latest newlib

* Include binaries built directly from @igrr repo

Rebuild the binaries using a git clone of
https://github.com/igrr/newlib-xtensa

Build commands for posterity:
````
rm -rf ./xtensa-lx106-elf/
./configure --prefix=<DIR>/esp8266/tools/sdk/libc --with-newlib \
            --enable-multilib --disable-newlib-io-c99-formats \
            --disable-newlib-supplied-syscalls \
            --enable-newlib-nano-formatted-io --enable-newlib-reent-small \
            --enable-target-optspace \
            --program-transform-name="s&^&xtensa-lx106-elf-&" \
            --disable-option-checking --with-target-subdir=xtensa-lx106-elf \
            --target=xtensa-lx106-elf
rm -f etc/config.cache
CROSS_CFLAGS="-fno-omit-frame-pointer -DSIGNAL_PROVIDED -DABORT_PROVIDED"\
             " -DMALLOC_PROVIDED" \
  PATH=<DIR>/esp8266/tools/xtensa-lx106-elf/bin/:$PATH \
  make all install
````

* Fix merge define conflict in c_types.h

* Fix strlen_P misaligned source error

Include fix from newlib-xtensa/fix-strlen branch cleaning up misaligned
access on a non-aligned source string.

* Fix strlen_P and strcpy_P edge cases

Ran the included test suite on ESP8266 tstring.c with the following defines:
 #define MAX_1 50
 #define memcmp memcmp_P
 #define memcpy memcpy_P
 #define memmem memmem_P
 #define memchr memchr_P
 #define strcat strcat_P
 #define strncat strncat_P
 #define strcpy strcpy_P
 #define strlen strlen_P
 #define strnlen strnlen_P
 #define strcmp strcmp_P
 #define strncmp strncmp_P

Uncovered edge case and return value problems in the optimized versions of
the strnlen_P and strncpy_P functions.  Corrected.

* Fix memcpy_P return value

memcpy-1.c test suite showed error in return value of memcpy_P.  Correct it.

* Fix strnlen_P/strlen_P off-by-4 error

Random crashes, often on String constructors using a PSTR, would occur due
to the accelerated strnlen_P going past the end of the string. Would make
debug builds fail, too (ESP.getVersionString() failure).

Fix to fall through to normal copy on a word that's got a 0 byte anywhere
in it.

* Add device tests for libc functional verification

Add test suite used to debug libc optimized _P functions to the device
tests.

* Rebuild from igrr's repo (same source as prior)

Rebuild .a from igrr's repo at 347260af117b4177389e69fd4d04169b11d87a97

* WIP - add exceptions

* Fix exception to have 0-terminator

* Move some exception constants to TEXT from RODATA

* Remove throw stubs

* Move more exception stuff to ROM

* Enable exceptions in platform.io

* Remove atexit, is duplicated in rebuilt lib

Need to look at the quick-toolchain options, there seems to be a definition
for atexit defined there (libgcc?) that needs to be excised.  For now,
remove our local do-nothing copy.

* Update libgcc to remove soft-fp functions

The esp-quick-toolchain generated libgcc.a needed to have the soft-FP routines
that are in ROM removed from it.  Remove them in the new esp-quick-toolchain
and update.

* Fix merge typos in Makefile

* Add unhandled exception handler to postmortem

* Return our atexit() handler

* Latest stdc++, minimize exception emercengy area

* Remove atexit from newlib

atexit was defined in newlib strongly, but we also define a noop atexit in core.
Since we never exit, use the core's noop and delete the atexit from libc.a

Updated in esp-quick-toolchain as well.

* Move __FUNCTION__ static strings to PROGMEM

__FUNCTION__ is unlikely to be a timing sensitive variable, so move it to
PROGMEM and not RODATA (RAM) using linker magic.

asserts() now should take no RAM for any strings.

* Clean up linker file, update to latest stdc++

* Update to latest stdc++ which doesn't call strerror

* Update to GCC5.1 exception emergency allocator

Using GCC 5.1's emergency memory allocator for exceptions, much less
space is required in programs which do not use exceptions and when
space is allocated it is managed more efficiently.

* Initial try with new compiler toolchain

* Include newlib built from esp-quick-toolchain

* Update JSON with all new esp-quick-toolchain builds

* Use 64bit Windows compiler on 64bit Windows

* Dump std::exception.what() when possible

When doing the panic on unhandled exceptions, try and grab the
.what() pointer and dump it as part of the termination info.
Makes it easy to see mem errors (std::bad_alloc) or std::runtime_error
strings.

* Use scripted install from esp-quick-toolchain

Makes sure proper libraries and includes are present by using a
scripted installation from esp-quick-install instead of a manual
one.

* Update eqk to remove atexit, fix packaging diff
2018-12-03 03:37:14 -03:00
Develo
4941711505 Implement for ssid a similar approach as for passphrase (#5411)
* Implement for ssid a similar approach as for passphrase

* Additional fixes for 32-char ssid
2018-12-02 21:25:13 -08:00
Earle F. Philhower, III
d8acfffdb0
Add cryptographically signed update support (#5213)
Using a pluggable architecture, allow updates delivered via the Update
class to be verified as signed by a certificate.  By using plugins, avoid
pulling either axTLS or BearSSL into normal builds.

A signature is appended to a binary image, followed by the size of the
signature as a 32-bit int.  The updater takes a verification function
and checks this signature using whatever method it chooses, and if it
fails the update is not applied.

A SHA256 hash class is presently implemented for the signing hash (since
MD5 is a busted algorithm).

A BearSSLPublicKey based verifier is implemented for RSA keys.  The
application only needs the Public Key, while to sign you can use
OpenSSL and your private key (which should never leave your control
or be deployed on any endpoints).

An example using automatic signing is included.

Update the docs to show the signing steps and how to use it in the
automatic and manual modes.

Also remove one debugging line from the signing tool.

Saves ~600 bytes when in debug mode by moving strings to PMEM

Windows can't run the signing script, nor does it normally have OpenSSL
installed.  When trying to build an automatically signed binary, warn
and don't run the python.
2018-12-02 19:57:47 -08:00
Develo
e5d50a6e4b
Split AddrList into object-iterator-container components (#5410)
* Split AddrList into object-iterator-container components

* Update AddrList.h

Remove gist code
2018-12-02 23:46:39 -03:00
david gauchard
773f306ef9 more compatibility fixes to IPAddress, restore INADDR_ANY, INADDR_NONE (#5416) 2018-12-02 22:43:19 -03:00
david gauchard
324b3f9678 IPAddress updates (#5409)
* restore definition of ip_addr (=ipv4_addr) when IPv6 is not enabled

* overload IPAddress:operator == and != to avoid ambiguousness

* brings lwIP's INADDR_NONE (which is IPv4 255.255.255.255, suposed to be invalid address but it is)

* inet_aton is a lwIP define, rename Ethernet DNS implementation of this to prevent name collision
that's because IPAddress now includes lwip/inet.h
2018-12-01 23:21:33 -03:00
apicquot
4b16fa0a33 Added 2M generic boards (#5404)
* added generic boards
2M (SPIFFS 128K)
2M (SPIFFS 256K)
2018-12-01 14:10:17 -08:00
liebman
00bc89eb48 fix compilation error - can't find axTLS::WiFiServerSecure (#5407) 2018-12-01 07:21:59 -08:00
chilliwebs
53b3aaee60 usn and udn differences cause issues with smarthings (#5401)
I recently starting playing around with a few esp8266-01s and tried to use the SSDP libraries to work with Smarthings discovery:

https://docs.smartthings.com/en/latest/cloud-and-lan-connected-device-types-developers-guide/building-lan-connected-device-types/building-the-service-manager.html

on the docs there are example grovy files that do simple service discovery, i was not able to get SSDP to work correctly, though i was able to find some other projects that did (python fauxmo works for alexa, but with modifications i was able to make it work for custom devices in ST).

after digging to figure out why the python code was working and the ESP SSDP lib was not i noticed there is a string comparison in the grovy file and it was failing to match the udn with the original usn device id. The ST groovy code could be changed to remedy this problem but i wonder if it should be fixed here, because so many other examples of SSDP discovery take care in ensuring the usn and udn match exactly.

___________

Summary, I think the USN and UDN values should match exactly. This will fix issues, allowing for much easier integration with smart hubs that need the device  ids to match. Allowing me to use these libraries and not need to roll a custom SSDP handler.
2018-11-30 22:16:02 -03:00
Earle F. Philhower, III
c1297cc8a4
Split PIO job into even and odd builds (#5405)
PIO is taking 27+ minutes now, very close to the runtime limit.

Split into even and odd, just like standard Arduino.  Each PIO job
takes ~14-15 minutes and can go in parallel.
2018-11-30 15:56:29 -08:00
Develo
7f7e658d66
Add SD.end() method, including arg to leave SPI up (#5402)
* Add SD.end() method with endSPI flag as arg

* cleanup and fix a default arg

* Fix typo
2018-11-30 18:25:47 -03:00
david gauchard
92373a9837 Deprecate axTLS, update examples (#5366)
* update examples

* fix serial<->tcp example, use STASSID instead of SSID (name collision)

* fix HTTPSRequest.ino

* update AxTLS HTTPS examples, update AxTLS API to deprecated

* fixes

* fixes + fix astyle (no preproc directives) + restyling script

* fix HTTPClient library

* fixes

* common.sh: do not reload arduino when already present (for locally CI testing)

* common.sh: do not reload ArduinoJson when already present (for locally CI testing)

* fix

* fix

* fix deprecated example

* fix WiFiHTTPSServer.ino

* reduce footprint

* wipfix

* fix led builtin

* fix example

* finished updating APSSID on all examples

* style

* restyle examples

* helper to run CI test locally

* local CI runner more verbose

* +const

* deprecation deprecation

* deprecation

* Update NTPClient.ino

const char[] => const char *

* Update interactive.ino

const char[] => const char *
2018-11-29 20:49:27 -08:00
DiamondDrake
8f28c88f9c Added naive content length to upload struct (#5142)
Content length provides context into the size of the upload, it's not
the exact form body size it's off by the request header info, but it was
already parsed by the library and provides little to no additional
overhead to pass on for use in request handlers.
2018-11-29 17:24:55 -08:00
Sen Haerens
1fb9b4e0ee Allow override of macros in core_version.h (#5268) 2018-11-29 15:16:58 -08:00
Luc
440a3aae7f Expose post args during upload (#4935)
Currently post args are only available at the end of upload but they are already listed - this PR just expose them with minimal changes
It also set a define for post args array size originaly set to 32
2018-11-29 13:52:55 -08:00
Earle F. Philhower, III
9ec03ed3f6
Move WiFi debug messages to PMEM (#5388)
Save ~1200 bytes in debug mode by making debug strings into PSTRs().
2018-11-29 12:55:40 -08:00
david gauchard
2486405e52 documentation: add quick links (#5391)
* doc: quick links

* ditto
2018-11-29 11:50:03 -08:00
david gauchard
116da1881c update HTTPCLIENT_1_1_COMPATIBLE (#5389)
* update HTTPCLIENT_1_1_COMPATIBLE: #if instead if #ifdef, set to 1 by default
host emulation updates

* host CI: minor simplification

* revert -j
2018-11-29 10:42:44 -08:00
david gauchard
4f86a68b56
fix espconn and err_t (#5392) 2018-11-29 18:17:33 +01:00
david gauchard
c6777149a8
constexpr helpers to identify core version (#5269) 2018-11-29 17:10:33 +01:00
Earle F. Philhower, III
fcdffc5dfd
Save 2.3K in HTTPClient debug mode by PSTR (#5387)
Convert the HTTPClient debug macro to store strings in PROGMEM and
use the printf_P method to dump them.

Saves ~2.3KB heap when in debug mode.
2018-11-29 06:37:07 -08:00
Earle F. Philhower, III
e7d3cf62b6
Don't clear authentication options on a ::stop (#5386)
Many objects now expect a WiFiClient* object to be passed to them and
potentially re-used multiple times (HTTPClient, others).  Clearing the
authentication options on a ::stop means they can never reconnect.

Remove the option clearing in ::stop

Fixes #5379
2018-11-28 16:12:01 -08:00
david gauchard
dc5e352676
fix host emulation (#5382) 2018-11-28 12:37:59 +01:00
dav1901
5fcb8f1dac Check if AP exists before adding it (#5373) 2018-11-27 22:01:15 -03:00
david gauchard
5c4db3acf4
IPv6 on esp8266-nonos-sdk and arduino (#5136) 2018-11-27 23:07:47 +01:00
Develo
a501d3ca3b
PolledTimeout Class for wrapping millis() loops (WIP) (#5198)
* PolledTimeout Class for wrapping millis() loops

* Add yield policies, improve reset, add host tests

* Fix copyright, comments

* adjust host tests for better time precision

* add fuzzyness to timing tests for CI jitter

* add blink example with polledTimeout

* improve namespace and type naming, add copyright, comments

* fix astyle
2018-11-26 10:57:49 -03:00
dav1901
cd05bae0e8 Pass string objects by reference (#5378) 2018-11-25 11:18:44 -03:00
Develo
72ad9353fc
Fix rtc mem bounds check (#5372) 2018-11-24 16:14:54 -03:00
Develo
3d70f43277
cleanup/unify flash sector size define value (#5327)
* cleanup/unify sector size define value

* replicate spi_flash_sec_size.h file for host tests

* further flash geometry cleanup, remove host test duplicate file
2018-11-24 02:59:12 -03:00
aguaviva
cf21dfda64 i2s can send now buffers (#5349)
* i2s can send now buffers

* adding mono and stereo, with blocking and non blocking support

* fixing crash

* cosmetic changes

* we dont need the & 0xffff

* using unsigned integers since we'll never be using negative numbers
2018-11-24 02:00:34 -03:00
Earle F. Philhower, III
19a0a0b6fd
Remove obsolete BSSL debug print routines (#5368)
Fixes #5356
2018-11-23 12:08:40 -08:00
Earle F. Philhower, III
016f3b8103
Move from container to VM per Travis requirements (#5367)
Remove "sudo: false" from travis.yaml due to Travis changes:
https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration
2018-11-22 21:29:36 -08:00
dav1901
5d573652e4 Check for WEP when setting authmode (#5364)
* check if wep is enabled when setting authmode

* add requested changes
2018-11-22 18:19:37 -02:00
Matej Sychra
aa22c07312 clock stretch fix done right (#5363) 2018-11-22 14:21:21 -02:00
david gauchard
74ca42f829 Sketch emulation on host (#5342)
* WIP compile examples on host with 'make examples'

* WIP bufferize tcp input

* WIP Makefile

* WIP network to rework, tcp/udp to factorize, udp addresses broken

* minor changes to the core

* WIP basic udp working

* WIP mdns

* WIP mcast receiving, not sending

* WIP mdns OK

* beta version

* SSL + doc

* update travis host test command

* licenses

* typo

* doc: arduino builder is not around: declare functions before calling them

* fix with latest SSL PR, compile in 32 bits mode

* fix make clean

* make -m32 optional

* 32bits compiler ability tester

* WIP

* WIP (fix 1 vtable error, still another one to hunt with using spiffs)

* example astyle

* fix os_printf_plus

* load / save mock spiffs

* fix style

* fix using spiffs/mock

* don't mess ram

* update doc

* remove leftover

* optimization -Os except for CI, rename ARCH32 to FORCE32

* revert useless cast (not even compiled)

* remove unused function

* use proper type for pointer arithmetics

* makefile: sketch object and cpp file moved to bin/ directories
easier to clean, and IDE don't like them

* changes for review

* make use of %zd

* less verbose makefile by default (option)

* update readme
2018-11-20 18:51:45 -02:00
david gauchard
b504881be4 document wificlient loop (#5355)
fix #5257
2018-11-20 17:37:21 -02:00
Earle F. Philhower, III
2f4380777e Move BearSSL from STACK_PROXY to a real, thunked 2nd stack (#5168)
* Update to BearSSL 0.6+ release, add AES_CCM modes

Pull in latest BearSSL head (0.6 + minor additions) release and add AES_CCM
modes to the encryption options.

* Enable the aes_ccm initialization in client/server

* Initial attempt

* Working code with second stack thunking

* Remove #ifdefs in .S file, not needed.

* Clean up thunks and remove separate stack flag

* Fix PIO assembler errors

* Remove #ifdef code changes, ensure same code as PC

Remove "#ifdef ESP8266;...;#else;...;#endif" brackets in BearSSL to
ensure the host-tested code is the same as the ESP8266-run code.

* Move to latest BearSSL w/EC progmem savings

* Merge with master

* Add br_thunk_* calls to do ref counting, painting

Add reference counting br_thunk_add/del_ref() to replace stack handling code
in the class.

Add in stack painting and max usage calculation.

* Add in postmortem stack dump hooks

When a crash occurs while in the second stack, dump the BSSL stack and
then also the stack that it was called from (either cont or sys).

* Update stack dump to match decoder expectations

* Move thunk to code core for linkiage

The thunk code needs to be visible to the core routines, so move it to the
cores/esp8266 directory.  Probably need to refactor the stack setup and the
bearssl portion to avoid dependency on bearssl libs in cores/esp8266

* Add 2nd stack dump utility routine

* Refactor once more, update stack size, add stress

Make stack_thunks generic, remove bearssl include inside of cores/esp8266.

Allocate the stack on a WiFiServerSecure object creation to avoid
fragmentation since we will need to allocate the stack to do any
connected work, anyway.

A stress test is now included which checks the total BearSSL second
stack usage for a variety of TLS handshake and certificate options
from badssl.org.

* Update to latest to-thunks branch

* Add BearSSL device test using stack stress

Run a series of SSL connection and transmission tests that stress
BearSSL and its stack usage to the device tests.

Modify device tests to include a possible SPIFFS generation and
upload when a make_spiffs.py file is present in a test directory.

* Use bearssl/master branch, not /to-thunks branch

Update to use the merged master branch of bearssl.  Should have no code
changes.
2018-11-14 23:29:24 -03:00
dav1901
41de43a263 Update ESP8266HTTPUpdateServer library (#5297)
* Converted C type strings to String object

* Converted C type strings to String object
2018-11-13 00:43:21 -03:00
Develo
979e5cebd9
Update generic-class.rst (#5338)
Fix link to WiFiEvents
Add note about WiFiClients and WiFiServers going down when a WiFi interface goes down, and that it's the user's responsibility to bring them back up.
2018-11-12 22:56:20 -03:00
Develo
055748ff6f
Fix debug provision for DNSServer (#5329) 2018-11-09 16:58:12 -03:00
Develo
e948ad1999
deprecate RTC_REG macros in favor of TIMER_REG macros (old typo in macro names) (#5326) 2018-11-09 14:53:58 -03:00
dav1901
79a6f36a02 Fix doc for ESP8266WiFi (#5325)
* Fix WiFiAP doc

* Fix softAP doc

* Fix doc
2018-11-08 07:06:54 -08:00