Adjust the ::write implementation in Print and its overridden copy in
UART to allow it to silentely accept PROGMEM strings (since there is no
write_P macro).
Fixes#6383
This PR stops the 1ms-delay loop also when a tcp error occurs (previously this was done only when tcp had just connected or a write/send had succeeded).
The tcp error can be any, in this case with pubsubclient it is "connection refused" after the mqtt server disappeared and pubsubclient tries to reconnect.
* Correct critical section with interrupt level preserving and nest support
alternative. Replace ets_intr_lock()/ets_intr_unlock() with uint32_t
oldValue=xt_rsil(3)/xt_wrs(oldValue). Added UMM_CRITICAL_DECL macro to define
storage for current state. Expanded UMM_CRITICAL_... to use unique
identifiers. This helpt facilitate gather function specific timing
information.
Replace printf with something that is ROM or IRAM based so that a printf
that occurs during an ISR malloc/new does not cause a crash. To avoid any
reentry issue it should also avoid doing malloc lib calls.
Refactor realloc to avoid memcpy/memmove while in critical section. This is
only effective when realloc is called with interrupts enabled. The copy
process alone can take over 10us (when copying more than ~498 bytes with a
80MHz CPU clock). It would be good practice for an ISR to avoid realloc.
Note, while doing this might initially sound scary, this appears to be very
stable. It ran on my troublesome sketch for over 3 weeks until I got back from
vacation and flashed an update. Troublesome sketch - runs ESPAsyncTCP, with
modified fauxmo emulation for 10 devices. It receives lost of Network traffic
related to uPnP scans, which includes lots of TCP connects disconnects RSTs
related to uPnP discovery.
I have clocked umm_info critical lock time taking as much as 180us. A common
use for the umm_info call is to get the free heap result. It is common
to try and closely monitor free heap as a method to detect memory leaks.
This may result in frequent calls to umm_info. There has not been a clear
test case that shows an issue yet; however, I and others think they are or
have had crashes related to this.
I have added code that adjusts the running free heap number from _umm_malloc,
_umm_realloc, and _umm_free. Removing the need to do a long interrupts
disabled calculation via _umm_info.
Build optional, min/max time measurements for locks held while in info,
malloc, realloc, and free. Also, maintain a count of how many times each is
called with INTLEVEL set.
* Fixed. travis build complaint.
* Changes for https://github.com/esp8266/Arduino/pull/6274#pullrequestreview-259579883
* Added requested comment and missing comment for UMM_CRITICAL_PERIOD_ANALYZE.
* Updated comments and update xt_rsil()
* Moved xt_rsil&co (pulled in __STRINGIFY) definitions out of
Arduino.h, to cores/esp8266/core_esp8266_features.h
Added esp_get_cycle_count() to core_esp8266_features.h.
Updated umm_malloc and Esp.h to use new defines and location.
* Added "#ifndef CORE_MOCK" around conflicted area.
* Moved performance measurment and ESP specific definitions to
umm_performance.h/cpp. Removed testing asserts.
* Commented out umm analyze. Delay CRITICAL_SECTION_EXIT() in
umm_realloc() to avoid exposing a transient OOM condition to ISR.
* Missed file change. This commit has: Delay CRITICAL_SECTION_EXIT() in
umm_realloc() to avoid exposing a transient OOM condition to ISR.
* 2nd Path. Removed early release of critical section around memmove
to avoid a possible OOM for an ISR.
* improved variable name
* Resolved ISR OOM concern with `_umm_realloc()`
Updated realloc() to do a preliminary free() of unused space,
before performing a critical section exit and memmove.
This change was applied to the current _umm_realloc().
This change should reduce the risk of an ISR getting an
OOM, during a realloc memmove operation.
Added additional stats for verifying correct operation.
* Resolved ISR OOM concern in _umm_realloc()
Updated realloc() to do a preliminary free() of unused space,
before performing a critical section exit and memmove.
This change was applied to the current _umm_realloc().
This change should reduce the risk of an ISR getting an
OOM when interrupting an active realloc memmove operation.
Added additional stats for verifying correct operation.
Updated: for clarity and Travis-CI fail.
* Update to keep access to alternate printf in one file.
* Updated to use ISR safe versions of memmove, memcpy, and memset.
The library versions of memmove, memcpy, and memset were in flash.
Updated to use ROM functions ets_memmove, ets_memcpy, and ets_memset.
Additional note, the library version of memmove does not appear to
have been optimized. It took almost 10x longer than the ROM version.
Renamed printf macro to DBGLOG_FUNCTION and moved to umm_malloc_cfg.h.
Changed printf macro usage to use DBGLOG_FUNCTION.
* Update umm_malloc.cpp
Fix comment
* Add HTTP_HEAD to HTTPMethod
* Parse the HTTP_HEAD variant of HTTPMethod from a method string
* Add HTTP_HEAD to the ESP8266WebServer constants
* Skip sending the content of the response if the HTTP method is HEAD method
* Convert the HTTP status code 418 to string
This status code is an easter egg from the IETF and is described in
[RFC2324](https://tools.ietf.org/html/rfc2324#section-2.3.2)
A typo was present in several ifdefs which would allow a server to negotiate
an EC connection even when in basic SSL mode. When this happened, a crash
would occur (since there were no EC or advanced AES modes installed).
Fix the typo, fixes#6397
Fixes#6066
Preserve any existing sample rate for the I2S unit when performing an
`i2s_begin`. If nothing has ever been set, default to 44.1KHz as
before.
* Add a FS::check() optional method
Fixes#2634
Expose any low-level filesystem check operations for users, and add
documentation on this and the gc() methods.
* Update doc w/more gc() info and link
* Update LittleFS to current project head
Several bugfixes noted in the LittleFS added:
https://github.com/ARMmbed/littlefs/commits/master
* Also update SdFat to latest upstream head
Also adds a delay(0) every 5000 fat clusters examined to avoid WDT
errors on highly fragmented FAT filesystems.
Fixes#5116Fixes#2743
The Arduino WiFiClient object allows sending the same packet to all
connected clients of a WiFiServer. In their implementation it may make
sense, but on the 8266 with things like SSL it doesn't.
Update the docs to note that WiFiServer::write() is a no-op, and that
the app should use the WiFiCliebnt::write() on all connected clients as
appropriate.
Fixes#2567
Allow the web server to send plain C strings instead of requring they be
encapsulated inside a String class object. Saves memory vs. having to
convert C strings to Strings (i.e. duplication of data), overloads on
the efficient sendContent_P(char*) methods.
Looking at other projects, they're all building using gnu extensions
(-std=gnu++11). We're already embedding gnu-specific pragmas for
compile options, so I see no reason not to fall in line w/others on
this.
Fixes#4639
Default mode (no exceptions) will no longer use the stdc++ library new
allocator when there is not enough memory. Instead, it will return
nullptr. This is the pre-exceptions-available behavior (2.5.0 and
earlier).
When exceptions are enabled, use the real new and throw exceptions that
can be caught at higher levels, or which will crash the app with an
uncaught exception if they're not handled.
Update to #6309
Fixes#2090
The Updater checks that an update isn't already in progress on ::begin,
but when an error happens in the middle of an upload it's impossible to
actually reset this flag w/o a reboot.
Reset the state members (esp. _size) on any error condition so
that you can restart the transfer with a new ::begin. Any error
condition is fatal, anyway, so there is no reason not to clear the
current state at that point.
The SPIFFS config object was defined in FS.h in its own namespace, but
is not made easily available like other SPIFFS and FS objects because of
a missing `using` statement. Add it in FS.h
Fixes#6322
* Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x
Rebuild the entire toolchain (including standard libraries) with the
latest pgm_read_xxx headers included (which fix unaligned dword reads
from progmem and run faster/smaller, and a pgm_read_byte change which
removes an instruction on each read saving flash).
Pull in latest bearssl while we're at it, too, which speeds up EC
handshakes and reduced ROM usage, too.
* Fix C++ exceptions
Exception code now only does 32b aligned reads from progmem to access
the eh_table (some via -mforce-l32, some via hand-inserted pgm_read_x
macros).
Fixes#6151Fixes#6305Fixes#6198
Fixes#6068
Drop from the tools key all version:"1.20.0-26-gb404fb9" entries (which
were pre-2.0.0 and whose entry in platform versions was deleted on last
release).
* workaround when an exceptin occurs while in an ISR
* tuning for gdb
* remove dead code and rename defines/variables
* per reviews: naming, handle "unhandled return" case
* fix reset message
* Created empty method
* Changed method name from "empty" to "isEmpty". Created a new method to empty a string
* Changed method name from "empty" to "clear".
Cleans up all warnings seen w/GCC 9.1 to allow it to track the main
branch more easily until 3.x.
Does not include Ticker.h "fix" of pragmas around a function cast we're
doing that GCC9 doesn't like, that will be addressed separately and
maybe only in the 3.0 branch.
Does not include GDB hook fix, either, because the pragmas required
to disable the GCC9.1 warnings don't exist in 4.8 at all.
* Add a dump of received FP and CERT when in debug mode
To simplify BearSSL debugging, print the received FP (when it doesn't
match the expected) and the binary certificate (always), when in debug
mode.
* Add documentation section on FP mismatch in rare instances.
Without this the compiler may use memory references loaded to registers before the fence, in computation within the fence. These values could have changed before xt_rsil()
(critical section start) was called.
Note: this is needed to stop the compiler from reordering instructions at the critical section boundary.