In order to give user libs a change to update to the new symbols, re-add
the _SPIFFS_XX symbols to the linker file with a comment that they are
deprecated.
Also add back spiffs_hal_xxx functions, also marked as deprecated.
Fixes#6542
* Add EEPROM debug printouts, error check to example
Add debug printouts when EEPROM calls fail, even if the API doesn't
allow returning a success/failure code.
Adds error checking to the example to make it explicit that when you
call EEPROM::commit(), you need to look at the result code in your code.
Fixes#6551 , or would fix it if there was error checking in the MCVE.
* Clarify example error message
A number of non-genuine boards exist mainly from flea-bay sellers that
use under-sized and/or low quality flash chips which can not handle
a 40MHz FlashFreq properly.
This patch adds slower flash frequencies to the menu for generic ESP boards
so that these cheap knock-offs can be run in a stable manner, hopefully saving
some people a few headaches and keeping these boards out of landfill.
* Add code to select the UART for Boot ROM ets_putc which is used by
::printf, ets_printf_P in core_esp_postmortem.cpp and others.
ets_putc is a wrapper for uart_tx_one_char. uart_tx_one_char uses
the element buff_uart_no in UartDev (A structure in data area of the
Boot ROM) to select UART0 or UART1. uart_buff_switch is used to set
that entry.
The structure for UartDev can be found in uart.h from the
ESP8266_NONOS_SDK. As best I can tell the Boot ROM always
defaults to UART0.
* Fixes debug UART selection for ets_putc
This addresses an issue of UART selection for ROM function ets_putc,
which is used by ::printf, ets_printf_P in core_esp_postmortem.cpp
and others. Currently ets_putc stays on UART0 after
Serial1.setDebugOutput(true) is called.
ets_putc() is not affected by calls to ets_install_putc1.
Its UART selection is controlled by the ROM function uart_buff_switch.
Updated uart_set_debug() to call uart_buff_switch whenever debug is
enabled on an UART. For the case of disabling, a call to select UART0
is made, because there is no disable option for this print method.
* Removed fp_putc_t typedef, save for a later PR
Update EEPROM description with mention of current implementation limitations
Move ESP_EEPROM to Other Libraries, update description from upstream README
Add https://github.com/xoseperez/eeprom_rotate to Other Libraries as an alternative
When the FS_END was adjusted to end on a full block (i.e. rounded down)
to avoid filesystem issues, but _FS_end was changed. The EEPROM library
used _FS_end to implicitly calculate the start of the EEPROM data, so
this means after the _FS_end fix, EEPROM data written with prior
releases would "disappear."
Avoid the issue by explicitly calculating the EEPROM start location in
the linker, using the same formula as prior release.
Fixes#6531
* Allow SPIFFS update via ESP8266HTTPUpdateServer
This adds capability to update the SPIFFS image via
the same mechansism as firmware in the
ESP8266HTTPUpdateServer.
It does not provide any dependency or linkage between
firmware and spiffs image updating; they are each taken
on their own, each followed by a reboot.
(I wrote this before seeing the other PR for similar
functionality; I like this a bit better, becaue it uses
the available SPIFFS size, and does not hide magic numbers
(U_SPIFFS) in the html...)
(It also cleans up a stray \n from commit ace0622)
* A simple filter
* Review https://github.com/esp8266/Arduino/pull/3234#pullrequestreview-37773153
* Including suggestions for mobile first #3961
* SPIFFS rennamed to FS
* including comments from @earlephihower
* button renaming
* missing #include for LittleFS
* generic names as suggested by @d-a-v
* Fix WiFiClientSecure::available blocking
Added a check of WiFiClient::availableForWrite to prevent blocking writes when the _run_until blocking flag is false
* change availForWrite from int to size_t
* add timeout to _run_until loop
fixes#6464
* use polledTimeout with _timeout millis
Since IRAM is such a precious resource on the ESP8266, dump out its size
(and all other segments) at the end of the build process.
Ex:
Executable segment sizes:
IROM : 338932
IRAM : 27263
DATA : 1476
RODATA : 2896
BSS : 30304
Sketch uses 370567 bytes (35%) of program storage space. Maximum is 1044464 bytes.
Global variables use 34676 bytes (42%) of dynamic memory, leaving 47244 bytes for local variables. Maximum is 81920 bytes.
* Run makecorever.py before specific prebuild hooks.
When a sketch needs information that is in `core_version.h`, you
have to build a dummy sketch 1st to get `core_version.h` created.
Since `core_version.h` is created after the sketch is compiled.
Moved rebuild recipe hook for running `makecorever.py` core to run
before all _specific_ prebuild hooks. While this form of prebuild hook
is not explicitly listed, it seems like an intuitive expectation.
Recipie hooks of this form:
```
recipe.hooks.prebuild.NUMBER.pattern=...
```
build before recipies of this form:
```
recipe.hooks.SPECIFIC.prebuild.NUMBER.pattern=...
```
where `SPECIFIC` would be: sketch, libraries, core, linking, ...
* Added hack comment to platform.txt.
* Replace the SDK's use of ets_intr_lock/unlock with nestable versions
Testing has shown that there are several paths in the SDK that result in nested
calls to ets_intr_lock() / ets_intr_unlock() which may be a problem.
These functions also do not preserve the enabled interrupt level and may
result in code running with interrupts enabled when that is not intended.
This issue has recently been fixed in the Arduino code by using
xt_rsil() / xt_wsr_ps() but still exists in the Espressif SDK code.
This commit is intended to fix that and should be used in addition to the above.
The maximum nesting I have seen is 2 and lock/unlock calls appear to be balanced.
A max of 7 levels of nesting leaves plenty of room for that to change.
* make ets_intr_lock_stack uint16_t and behave like the original on over/underflow
The PS register is 15 bits, we should store the whole thing as xt_wsr_ps()
writes the whole thing.
Also if there is an underflow, we should make sure interrupts are enabled.
Same goes for overflow making sure interrupts are disabled, although this
is less important.
* Rename ets_intr_(un)lock_nest to ets_intr_(un)lock
This saves having to modify libmain.a, libpp.a and libnet80211.a to use the
nested versions.
Adjusts fix_sdk_libs.sh accordingly.
* Remove ets_intr_(un)lock from the rom .ld as we no longer use them
* ets_post() wrapper to preserve interrupt state
Add a wrapper around the ets_post code in rom to preserve the interrupt enable state.
Rather than modifying the SDK libs, rename ets_post in the .ld file and call the
wrapper "ets_post" to replace it.
As far as I can establish, ets_post is the only rom function in use by our code or
the SDK libs we use that causes calls to ets_intr_(un)lock.
* Add IRAM_ATTR to ets_intr_(un)lock and ets_post wrappers.
* Throw in a few comments and make ets_intr_lock_stack* static.
Build a single INO under a Windows VM on Travis to ensure
that the Win32 toolchain works properly.
In build.py, instead of making a string with spaces and then
splitting on " ", just make the list itself with individual parameters.
This will allow spaces in paths to be supported properly.
* Edited OTA readme, added Stream Interface snippet
Reworded for easier understanding. Changes mostly in first half of page.
* OTA docs: corrected typos, misc edits near end
* Incorporated suggestions from earlephilhower
Extra ^, removed TODO
Build a single sketch using a Travis-CI OSX instance to validate the
toolchain works properly on Macs.
Update the installed python3 symlink to point to the proper spot for OSX
(Python3 is in /usr/local/bin, not /usr/bin).
Fixes#6490
* mDNS debug option + AP address is used by default when STA is also present
* mDNS: store network interface, checking it is up
* igmp: force on selected interface (avoid crash *sometimes*)
* fix for all lwip2 ipv4 ipv6 & lwip1
* mdns: IPAddress is not needed to reference associated interface
* mdns: debug: fix print warnings
* emulation: add ets_strncpy
* emulation: truly emulate AddrList (remove fake one)
The get.py renamer uses some logic which results in the Win32 extracted
directory always ending up as `tools/python` and not `tools/python3`.
Adjust the zip archive and title to work around this (and the IDE
proper) issue.
* Move all scripts and documentation to Python3
Python 2 EOL is Jan 1, 2020. Migrate scripts to run under Python 3.
Under Windows, we're already running Python 3.7, by dumb luck. The
oddness is that the Windows standalone executable for Python 3 is called
"python" whereas under UNIX-like OSes it's called "python3" with
"python" always referring to the Python 2 executable. The ZIP needs to
be updated to include a Python3.exe (copy of Python.exe) so that we can
use the same command lines under Linux and Windows, and to preserve my
sanity.
Fixes#6376
* Add new Windows ZIP with python3.exe file
* Sort options in boards.txt generation for repeatability
The order of the board opts dict changes depending on the Python version
and machine, so sort the options before printing them to get a stable
ordering.
* Re-add Python2 compatibility tweaks
Most scripts can run as Python 2 or Python 3 with minimal changes, so
re-add (and fix, as necessary) compatibility tweaks to the scripts.
* Per @earlephilhower suggestion
* Hints from @earlephilhower
* Namespace BearSSL in core "feels" wrong - using catch-all esp8266 instead.
* After review remarks by @earlephilhower
Dropped routines form libc.a which are present and usable in ROM:
`ar dv libc.a lib_a-strcmp.o lib_a-strlen.o lib_a-strncmp.o lib_a-strstr.o lib_a-memcmp.o lib_a-memcpy.o lib_a-memmove.o lib_a-memset.o lib_a-bzero.o`
Left strcpy and strncpy in libc.a because they silently support PROGMEM
accesses as required by GCC optimizations.
Saves ~628 bytes in AdvancedWebServer example, from IROM (not IRAM).
Also allows mem* and str* routines to be safely called from inside an
ISR. Prior to this PR, these routines were stored in flash and not
IRAM, so they were technically illegal to call while in an ISR.
Fixes#6430
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)