1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

3128 Commits

Author SHA1 Message Date
Earle F. Philhower, III
4b596d8fb1 Fix boards-manager install issues on Linux and Windows (#5898)
* Fix packaged python paths for Windows

Fixes #5881

The path to python.exe on Windows needs to change depending on whether
it is installed via the boards manager or GIT (similar to the compiler
paths).  Adjust accordingly.

* Add python-placeholder to make boardsmanager happy

An empty "python" directory will be created by the boards-manager
installer.  Required because all archs need all tools defined.

* Make the placeholder include a symlink for "python"

* Fix esptool windows python path

Fixes a typo in the python path for Windows for upload.

* Fix esptool windows python path

Fixes a typo in the python path for Windows for upload.

* Fix tools path when in GIT mode for upload
2019-04-10 07:32:50 -04:00
Earle F. Philhower, III
0f4c9f7103 Split IRAM into 2 linker sections to move std::fcn (#5922)
* Split IRAM into 2 linker sections to move std::fcn

Callbacks need to be placed in IRAM when being called from an IRQ (like
the SPISlave callbacks).

This can be done by hacking the std::functional header and making every
single specialization of the template into an IRAM section, which would
take a lot of space for no benefit in the majority of cases.

The alternate is to specify the single instantiation types/operators
required, but the problem is the flash segment matcher would match them
before the IRAM section was begun, and rules for them would just not be
applied.

Get around this by splitting the IRAM section definition into .text and
.text1.  This is linker syntactic sugar and does not actually change the
on-chip layout.  But it does allow us to put the exception vectors at
the required absolute addresses and add single functions to IRAM.

* Add .text1 segment to space used calculation in IDE

* All functional callers are now placed in IRAM

* Write out the .text1 segment to the BIN

The extra segment name needs to be placed into the output binary as
well, or else only the init code gets stored and none of the real app is
present.  This leads to an infinite boot loop.

This change adds in the segment to the generated image.
2019-04-10 10:49:31 +02:00
Earle F. Philhower, III
fa0db2e3ab Fix crash in certain PMEM printf format parsing (#5968)
In some cases the printf implememtation would call an internal puts()
implementation which did not use pgm_read_byte() to access the format
string.  In many operating modes this would work, but in interrupts or
when flash was disabled you'd get crashes.

Updated newlib to use pgm_read_byte in that one spot and recompiled.
2019-04-10 09:33:09 +02:00
Dirk O. Kaar
e1c8bf8df2 Update EspSoftwareSerial to release 5.0.0. (#5965)
* Update EspSoftwareSerial to release 5.0.0.

(Includes half-duplex patch for SerialStress.ino)

* Updated EspSoftwareSerial to allow Platformio builds that lack defaults for RX/TX defines.
2019-04-09 16:14:02 -04:00
david gauchard
77451d6ec9
Hardware SPI BREAKING: unswap mode 2 and 3 for portability (#5948)
* Hardware SPI BREAKING: unswap mode 2 and 3 for portability
use SPI.restoreEsp8266LegacyMode2And3() for former behaviour
2019-04-06 01:13:09 +02:00
david gauchard
a1796f455a
lwIP-v2: new patch to randomize tcp source ports (#5906)
ref: d-a-v/esp82xx-nonos-linklayer#31
origin: #5902
me-no-dev/ESPAsyncTCP#108

Following the links above is instructive.
To summarize:

    * currently and from a long time lwIP tcp client connections always uses the same tcp source port number right after boot
    * this port number is increased everytime a new one is needed (= new tcp client connection)
      (to be noted, linux has the same increasing behavior)
    * when connecting to the same server (right after boot), the triplet (esp-ip-address, source port, destination port) are the same, and may hit remote server list of sockets in time-wait-state (previous connection unproperly closed from the same esp). Consequently the new connection fails when it happens.
    * this is happening only when debugging (esp reboots often, in less time than time-wait expiration), so the nasty effect is amplified especially when bugs are being chased
    * efforts had been done when espressif's lwIP implementation wasn't open source, with WiFiClient::setLocalPortStart() #632 but it must be explicitely called with a different random number at every reboot. Efficient but not ideal.

This PR uses espressif firmware's r_rand() everytime a new local source port is needed. A different source port number is now showed by tcpdump right after boot. Source port range and duplication is verified everytime in lwIP's src/core/tcp.c:tcp_new_port(). It is implemented as a local patch for upstream lwIP so it is valid not only with WiFiClient but also with @me-no-dev's Async libraries (they don't use WiFiClient).

WiFiClient::setLocalPortStart() is still usable with the same effects as before.
2019-04-05 17:26:51 +02:00
david gauchard
9a2ed274f3 polledTimeout: add option to use CPU count instead of millis() (#5870)
* polledTimeout: add option to use CPU count instead of millis()

* use more "using" alias

* more c++/clear code, using typename (thanks @devyte)

* rename class name to include unit, introduce timeMax() and check it with assert()

* remove useless defines

* improve api readability, add micro-second unit

* update example

* mock: emulate getCycleCount, add/fix polledTimeout CI test

* + nano-seconds, assert -> message, comments, host test

* allow 0 for timeout (enables immediate timeout, fix division by 0)

* typo, set member instead of local variable

* unify error message

* slight change on checkExpired() allows "never expired"
also removed printed message, add YieldAndDelay, simplify calculations

* remove traces of debug.h/cpp in this PR

* include missing <limits> header

* back to original expired test, introduce boolean _neverExpires, fix reset(), getTimeout() is invalid

* fix expiredOneShot with _timeout==0 check

* reenable getTimeout()

* expose checkExpired with unit conversion

* fix timing comments, move critical code to iram

* add member ::neverExpires and use it where relevant

* improve clarity

* remove exposed checkExpired(), adapt LEAmDNS with equivalent

* add API ::resetToNeverExpires(), use it in LEAmDNS

* remove offending constness from ::flagged() LEAmDNS (due do API fix in PolledTimeout)

* simplify "Fast" base classes

* minor variable rename

* Fix examples

* compliance with good c++ manners

* minor changes for consistency

* add missing const

* expired() and bool() moved to iram

* constexpr compensation computing

* add/update comments

* move neverExpires and alwaysExpired
2019-04-05 10:50:53 -03:00
david gauchard
f0eb5509a0
use static_assert to check on fw structure changes over updates (fix) (#5946) 2019-04-03 23:17:09 +02:00
david gauchard
ca79f2ce39
use static_assert to check on fw structure changes over updates (#5939) 2019-04-02 00:44:27 +02:00
Evgeny Dontsov
68c0a1cc9e sta_config_equal (#5937)
* sta_config_equal

* sta_config_equal bug update
2019-04-01 15:38:09 -03:00
david gauchard
c1e439d447
fix lwip-v1.4 compilation (#5935) 2019-03-31 23:04:42 +02:00
ufocia
f139519061 Correct out of bounds condition and remove an unnecessary cast (#5924)
C arrays are 0 indexed, accordingly writing to array[255] actually writes to the 256th position, which is naturally out of bounds of a 255 item array. increasing the size of the array to 256 corrects that error. Also, 0 is an int and requires a cast into a char, '\0' is just a cleaner (a more syntactically pedantic) way to achieve the same end.
2019-03-27 17:27:20 -07:00
david gauchard
2e75e88c49
bugfix: restore WiFi::setSleepMode functionality with sdk-2.2.x (#5919) 2019-03-26 14:07:49 +01:00
Zachary Drew
7a2e935f53 Fix OTA in AP mode (#5894)
OTA is broken in AP mode because ESP8266mDNS is checking whether the station is connected before processing. Change the logic to WiFi.isConnected() OR WiFi.softAPgetStationNum()>0 fixes the issue.
2019-03-21 12:05:16 -07:00
Ahmed El Sharnoby
e829221833 Fix ssdp (#5750)
* Update ESP8266SSDP.h

Fix SSDP bug: The response to M-Search Packet with ST field set to UUID should be with the UUID not the Device Type
Integrated 'uuid:' prefix into the char array of the _uuid

* Update ESP8266SSDP.cpp

Fix SSDP bug: The response to M-Search Packet with ST field set to UUID should be with the UUID not the Device Type
Integrated 'uuid:' prefix into the char array of the _uuid

* include 'uuid:' in format String and in flash

* Update ESP8266SSDP.cpp
2019-03-21 18:21:48 +01:00
Max Prokhorov
8961bba94e LEAmDNS: remove implicit debug statements (#5895) 2019-03-21 17:04:12 +01:00
Juppit
b270f4907c include submodules with git clone --recursive (#5882)
* include submodules
You may also need to run this update recursively ('git submodule update --init --recursive').
2019-03-21 15:48:23 +01:00
Juppit
70c3547eb3 Update link in platform.txt (#5900)
The link to the Arduino-IDE-1.5-3rd-party-Hardware-specification has changed in the meantime,
from https://github.com/arduino/Arduino/wiki/Arduino-IDE---1.5-3rd-party-Hardware-specification
to https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
2019-03-21 13:54:55 +01:00
Earle F. Philhower, III
54240d2cc5
Fix String::replace() garbage at end of string (#5897)
* Fix String::replace() 

Fixes #5883 and supercedes #5890

The replace() function was using len() while in the middle of buffer
operations.  In SSO mode len() is not stored separately and is a call to
strlen(), which may not be legal if you're in the middle of overwriting
the SSO buffer, as was the case in ::replace when the replacement string
was longer than the find string.  This caused potential garbage at the
end of the string when accessed.  Instead, just cache the length in a
local while doing the operation.

Add in test cases from #5890 as well as some new ones that fail on the
unmodified core.

* Fix stack smashing error on 64b

When pointers are 8 bytes long, the size of a String is larger than 16
chars.  Increase the allocated array we're using in the test to avoid a
"stack smashing" error.

* Manually call destructor in test

Just for clarity, manually call the destructor for the Strings() that
are "placement new'd" in the String tests.  It is a no-op for the
existing test, since thanks to SSO there are no memory allocations, but
will help in case someone adds tests later which include longer strings.
2019-03-20 06:18:04 -07:00
Jiri Bilek
64e30b270b Fix the changed structure of the input file (#5891)
The input file containing certificates has changed.
2019-03-18 15:15:59 -07:00
Earle F. Philhower, III
68bcc41429 Fix SSID reporting for 32-char SSIDs (#5889)
Fixes 5853
2019-03-17 23:06:41 -03:00
david gauchard
d19fc3b647
fix boards.txt.py with python3 (#5887)
* fix boards.txt.py with python3

* fix boards.txt.py to generate same order when using python2 or python3
2019-03-16 23:27:44 +01:00
david gauchard
a3ea816e65
add optional espressif fw nonos-sdk 2.2.x (19.03.13) (#5873) 2019-03-14 13:35:26 +01:00
david gauchard
e5b4de3633
fix DEBUG macros (#5728)
* fix DEBUG macros

All fmt strings in flash
fix #5658

This also allows to avoid warnings and easy mistakes with (no brace):
    if (something)
        DEBUGV("blah");

* use newlib unaligned-compatible printf for DEBUGV

* remove useless putprintf since ::printf already uses ets_putc
2019-03-14 11:19:21 +01:00
Earle F. Philhower, III
9365f6d116
Fix Serial.write(0) overloading (#5878)
Add missing "using Print::write" to the HWSerial class to get the proper
overrides to make Serial.write(0) and Serial1.write(0) work as expected.
2019-03-13 18:06:15 -07:00
liebman
e46ccae9d5 optionally allow redirects on HTTPClient & OTA updates (#5009)
* optionally allow redirects on http OTA updates

* Refactored HTTPClient::begin(url...) & setURL functions, now only beginInternal parses URL, sets ports
Added HTTPRedirect example.

* fix indentation for style check

* add space after while for style check

* don't use deprecated begin method in redirect example

* moved redirect handling code to HTTPClient.
only GET and HEAD requests are currently handled automatically
Redirects that fail to be automatically handled return the redirect code as before

* added support for POST/303 redirect
added device redirect tests

* add missing getLocation() implementation

* if the new location is only a path then only update the URI
2019-03-13 01:51:17 +01:00
Thomas Friedrichsmeier
071eeb8b67 Allow to disable DHCP gateway offer when set up of AP. (#4421) 2019-03-13 00:28:41 +01:00
Earle F. Philhower, III
02f54e85fd
Reimplement SD.h write methods exactly in File (#5861)
* Reimplement SD.h write methods exactly in File

Replace the individual override with the existing SD.h File's
implementation for all methods of File::write.

Fixes #5846

* Add add'l tests

* Fix Print and File incompatible writes w/casts

Print and File have ambiguous resolutions for single-argument
write(0)s.

Fix by adding explicit methods.  A write of any integer will not be a
const char* write (i.e. won't write a string) but will instead just
write the integer truncated to 8 bits (as makes sense).

* Use 256byte chunks in ::write template

Reduce stack requirements for templated writes to 256bytes, matching the
size uses in WiFiClient/etc. (from 512bytes).  Reduces the chance of
stack overflow.

* Move write(int) methods up to Print.h

Remove some technical debt by moving the ::write(int/short/long) methods
out of FS and HardwareSerial and up into Print.h.
2019-03-12 13:58:00 -07:00
Tomoatsu Shimada
192aaa4291 Adjust python module search path to avoid picking up pre-existing pyserial/esptool instead of one under tools/ (#5854) 2019-03-09 09:35:30 -08:00
Christoph Laimer
aa8d3482d3 const for Ticker::active() (#5850) 2019-03-08 09:35:38 -03:00
david gauchard
2528013c5d
small addons (#5847)
* make (static) ESP8266WebServer::responseCodeToString visible and usable
* esp8266:coreVersionNumeric(): add a define and comment-example to check on its usability
2019-03-07 11:37:38 +01:00
Earle F. Philhower, III
b1da9eda46
SD Filesystem compatible with 8266 File, using latest SdFat (#5525)
* Add a FAT filesystem for SD cards to Arduino FS

Arduino forked a copy of SD lib several years ago, put their own wrapper
around it, and it's been languishing in our ESP8266 libraries ever since
as SD. It doesn't support long file names, has class names which
conflict with the ESP8266 internal names, and hasn't been updated in
ages.

The original author of the SD library has continued work in the
meantime, and produced a very feature rich implementation of SdFat. It
unfortunately also conflicts with the class names we use in ESP8266
Arduino and has a different API than the internal SPIFFS or proposed
LittleFS filesystem objects.

This PR puts a wrapper around the latest and greatest SdFat library,
by forking it and wrapping its classes in a private namespace "sdfat,"
and making as thin a wrapper as possible around it to conform to
the ESP8266 FS, File, and Dir classes.

This PR also removes the Arduino SD.h class library and rewrites it
using the new SDFS filesystem to make everything in the ESP8266
Arduino core compatible with each other.

By doing so it lets us use a single interface for anything needing a
file instead of multiple ones (see SDWebServer and how a different
object is needed vs. one serving from SPIFFS even though the logic is
all the same). Same for BearSSL's CertStores and probably a few others
I've missed, cleaning up our code base significantly.

Like LittleFS, silently create directories when a file is created with
a subdirectory specifier ("/path/to/file.txt") if they do not yet exist.

Adds a blacklist of sketches to skip in the CI process (because SdFat
has many examples which do not build properly on the ESP8266).

Now that LittleFS and SDFS have directory support, the FS needs to be
able to communicate whether a name is one or the other.  Add a simple
bool FS::isDirectory() and bool FS::isFile() method.  SPIFFS doesn't
have directories, so if it's valid it's a file and reported as such.

Add ::mkdir/::rmdir to the FS class to allow users to make and destroy
subdirectories.  SPIFFS directory operations will, of course, fail
and return false.

Emulate a 16MB SD card and allow test runner to exercise it by using
a custom SdFat HOST_MOCK-enabled object.

Throw out the original Arduino SD.h class and rewrite from scratch using
only the ESP8266 native SDFS calls.  This makes "SD" based applications
compatible with normal ESP8266 "File" and "FS" and "SPIFFS" operations.

The only major visible change for users is that long filenames now are
fully supported and work without any code changes.  If there are static
arrays of 11 bytes for old 8.3 names in code, they will need to be
adjusted.

While it is recommended to use the more powerful SDFS class to access SD
cards, this SD.h wrapper allows for use of existing Arduino libraries
which are built to only with with that SD class.

Additional helper functions added to ESP8266 native Filesystem:: classes
to help support this portability.

The rewrite is good enough to run the original SDWebServer and SD
example code without any changes.

* Add a FSConfig and SDFSConfig param to FS.begin()

Allows for configuration values to be passed into a filesystem via the
begin method.  By default, a FS will receive a nullptr and should so
whatever is appropriate.

The base FSConfig class has one parameter, _autoFormat, set by the
default constructor to true.

For SPIFFS, you can now disable auto formatting on mount failure by
passing in a FSConfig(false) object.

For SDFS a SDFSConfig parameter can be passed into config specifying the
chip select and SPI configuration.  If nothing is passed in, the begin
will fail since there are no safe default values here.

* Add FS::setConfig to set FS-specific options

Add a new call, FS::setConfig(const {SDFS,SPIFFS}Config *cfg), which
takes a FS-specific configuration object and copies any special settings
on a per-FS basis.  The call is only valid on unmounted filesystems, and
checks the type of object passed in matches the FS being configured.

Updates the docs and tests to utilize this new configuration method.

* Add ::truncate to File interface

Fixes #3846

* Use polledTimeout for formatting yields, cleanup

Use the new polledTimeout class to ensure a yield every 5ms while
formatting.

Add in default case handling and some debug messages when invalid inputs
specified.

* Make setConfig take const& ref, cleaner code

setConfig now can take a parameter defined directly in the call by using
a const &ref to it, leading to one less line of code to write and
cleaner reading of the code.

Also clean up SDFS implementation pointer definition.
2019-03-06 02:14:44 +00:00
david gauchard
61a8a6b14e
emulation on host: fix nasty delay (#5840)
emulation with socket: fix nasty delay
        properly check all return values (read() returning 0 indicates closed peer)
        ClientContext::state() triggers read() to check for closed peer

uart emulation on tty: add cmdline -b debug option to disable raw tty

hide annoying MOCK messages, add cmdline -v option to show them

uart emulation on tty: check more return values

emulation on host: tcp/udp port shifting: new cmdline -s(port Shift) option
2019-03-05 16:59:39 +01:00
Ivan Kravets
22eeb94587 Use ArduinoJson 5.x for PlatformIO tests (#5843) 2019-03-05 15:35:43 +01:00
Clemens Kirchgatterer
bde1ce0e01 Remove redundant check for zero size SPIFFS partition (#5841)
The check if the end address of the SPIFFS partition is smaller or equal to the start of the partition breaks sketches that are linked with zero size SPIFFS linker scripts, but create their own SPIFFS partition later at arbitrary flash locations. But this check can safely be removed, because the check if the the SPIFFS partition is of size 0 is done a few lines further down anyway.
2019-03-05 09:24:45 -03:00
Earle F. Philhower, III
82da5c76b9 Fix minor warning w/Ubuntu18.04 in host test build (#5829)
GCC reports the following warning about ignoring the return value of
write() (to the console/UART in this instance).

common/MockUART.cpp: In function ‘void uart_do_write_char(int, char)’:
common/MockUART.cpp:67:8: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
   write(uart_nr + 1, &c, 1);
   ~~~~~^~~~~~~~~~~~~~~~~~~~

Add a simple warning printout to STDERR which may not be the same as the
UART stream and could succeed.
2019-03-02 14:37:03 -03:00
Develo
418857aae7
Implement sntp_get|set_timezone_in_seconds() (#5828)
* Implement sntp_get|set_timezone_in_seconds()

* Fix typo

* Fix typo

* Get lwip1.4 to compile

This is just a workaround to get lwip1.4 to compile. It doesn't implement sntp_set_timezone_in_seconds() correctly, but rather does pretty much the same as sntp_set_timezone().
2019-03-01 14:35:38 -03:00
Earle F. Philhower, III
ead83c16a6 Add .git to BearSSL repo reference (#5827)
The BearSSL submodule reference is missing the .git extension on the
URL.  Add it, to match the rest of the repos.
2019-02-28 02:01:07 -03:00
Earle F. Philhower, III
5632e8156f Fix repaintable stack calculation (#5821)
* Fix repaintable stack calculation

Fixes #5794 as found by @mattbradford83

* Overwrite last word of stack as well

Under-by-one error would not reset the absolute end of the stack, adjust
comparison to fix.
2019-02-26 22:37:42 -03:00
Earle F. Philhower, III
95cf925719
Add OOM check and debug message in CertStore (#5820)
Fixes #5819
2019-02-26 02:46:25 +00:00
Ivan Kravets
d507c799f7 PlatformIO: Append FLASHMODE_* macro (#5813) 2019-02-26 01:22:07 +00:00
Robin Richtsfeld
ca2f31a6f2 Make signing.py Python2.6+ and Python3+ compat (#5807)
Make the signing header generation work under Python2.6+ and Python 3+.
2019-02-25 21:01:47 +00:00
Ivan Kravets
167f39dab6 PlatformIO: Make exceptions off by default #5538 (#5814) 2019-02-23 23:25:33 +00:00
Clemens Kirchgatterer
21926a69b6 emulation on host: fix wrong tty_restore instead of restore_tty variable (#5809) 2019-02-23 11:30:44 +01:00
Clemens Kirchgatterer
ef44211eea emulation on host: Add full UART driver emulation. (#5785)
* emulation on host: Add full UART driver emulation.

  This PR replaces the high level Serial mock with a more complete
  UART driver. This way the HardwareSerial works without any
  modifications. Additionally the driver supports UART0 and UART1
  at the same time (UART0 is directed to stdout and UART1 writes
  to stderr). RX is implemented by switching the terminal into raw
  non-blocking mode and injecting each key-press directly into the
  FIFO of UART0. A new command line switch -c was added to ignore
  CTRL-C and send it via serial as well. The decumentation was
  updated accordingly.

  Reading and setting of GPIOs does only write to stderr, when compiled
  with D=1. But this is subject to be replaced with a proper GPIO emu
  anyway. Reading from GPIO0 now returns 1 instead of 0 because this is
  most likely a low active input.

* Fixed unused variable.

* Remove unused functions, as long as there are no debug macros using them.

* Move user_interface.cc from MOCK_CPP_FILES_EMU to MOCK_CPP_FILES.

* Move optimistic_yield() from user_interface.cpp to Arduino.cpp

* Remove atexit() weak declaration (fixes segfault when calling atexit).

* Improve resetting of terminal after program exit, convert \r to \r\n.

* Show error, when STDOUT is not a TTY, minor code cleanung.
2019-02-22 16:50:55 +01:00
Earle F. Philhower, III
53f51b5811
Clean up uploader.py, use implied paths (#5805)
No need to explicitly send in full paths for esptool and pyserial Python
libs because they're in well known locations relative to upload.py.

Make upload.py calculate these on-the-fly and clean up platform.txt.
2019-02-21 21:40:45 +00:00
Earle F. Philhower, III
472faf73a2
Use Pythonic way of calling esptool, avoid fork(#5797)
Simply import the pyserial and esptool modules directly into upload.py
instead of trying to fake things with os.fork()s.  Reduces code and is
more Pythonic.
2019-02-21 19:03:15 +00:00
david gauchard
f08346a73e
Fix host emulation (sdk changes) (#5802) 2019-02-21 17:04:17 +01:00
david gauchard
3d41ccf032 fix typo in platform.txt (#5800)
fix #5798: from @AcuarioCat: There is a typo in platform.txt on line 87 that causes makecorever.py to fail.
2019-02-21 11:39:07 -03:00
Earle F. Philhower, III
22eed42d50 Use local copy of python distro to include a subdir (#5796) 2019-02-20 18:14:38 +01:00