When reading from a `Stream`, like `File`, using a temporary buffer is counterproductive because it complexifies the code and increases memory usage.
It's also a source of confusion because it can create dangling pointers in the `JsonDocument`.
The only benefit of using a buffer is the reading speed, but I don't think speed is the focus in this example; if it were, it would use a buffer in `saveConfig()` too.
A function called with a flash string, which only has an implementation with `const String&` as argument will be compiled as if it is called with a `String` constructor wrapped around it.
For example this implementation in the .h file:
```c++
bool startsWith(const __FlashStringHelper *prefix) const {
return this->startsWith(String(prefix));
}
```
This is completely useless as the compiler will generate exactly the same code with or without this function implementation in the .h file.
However if we move the implementation to the .cpp file, this conversion to `String` is only added once in the compiled binary.
In my own project I already managed to shrink the largest (ESP32) build by more than 70k in size (!!) by just adding extra function calls with the conversion in the .cpp file.
This PR is just a simple optimisation which already shrinks a very small build of my project by almost 3k in build size. (custom_beta_ESP8266_4M1M PIO env of ESPEasy)
```
Flash: [======== ] 82.5% (used 862137 bytes from 1044464 bytes)
Flash: [======== ] 82.3% (used 859545 bytes from 1044464 bytes)
```
Larger builds may benefit even more.
* Respect linking order of libraries
Now has the same order as the Arduino IDE does with its platform.txt
* Remove double-referenced libs
* Change implementation style
Instead of injecting at magic indices, which might break when some other extra-scripts inject other libraries, let's create the LIBS array at the bottom in easy to understand and correct order.
When LittleFS.begin() or SDFS.begin() is called after the filesystem is
already mounted, don't unmount/remount. When an unmount happens, all old
Files become invalid (but the core doesn't know this), so you would end
up with random crashes in FS code.
Now, check for _mounted, and if so just return immediately from begin().
This mimics the original SPIFFS code.
Fixes https://github.com/earlephilhower/ESP8266Audio/issues/407
* Fix PRxxx printf format macros
Update toolchain (newlib) to supply proper definitions for PRxxx macros.
Fixes#8220
Added a PRxxx macro to an example to ensure CI will catch any problem like
this in the future.
When Python is installed on Windows separately (i.e. Windows Store,
Python.org MSI, etc.) it set the PYTHONHOME environment variable to
the installed path.
When we call our own portable Python, it tries to use the support
PYC files in PYTHONHOME. If they're from a different version of
Python, however, they won't work. Even though we're running our
own distributed Python.exe, we are crashing on the system-wide
Python installation.
Add -I to all python3 calls, ignore PYTHONHOME/etc. environment vars.
Tested under Ubuntu 18.04 Linux w/o any ill effects (we ship pyserial
ourselves and add it manually to the Python search path).
Fixes#8096, or should as I understand it.
* Recover the BearSSL crash stack before the Heap is initialized and zeros it.
* Added comments for hwdt_pre_sdk_init()
* Keep Basic ASM version of app_entry_redefinable and removed alternate "C"/Extended ASM version. Update comments.
* Improved example HwdtStackDump to use StackThunk
When using previous IDE versions, the use of an invalid category value caused a warning to be displayed on every compilation:
WARNING: Category 'Network' in library lwIP_PPP is not valid. Setting to 'Uncategorized'
WARNING: Category 'Network' in library lwIP_enc28j60 is not valid. Setting to 'Uncategorized'
WARNING: Category 'Network' in library lwIP_w5500 is not valid. Setting to 'Uncategorized'
WARNING: Category 'Network' in library lwIP_w5500 is not valid. Setting to 'Uncategorized'
List of valid category values:
https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
MMU option with 48K IRAM shared. This happended after changes that
increased IRAM code size that caused free IRAM for Heap to fall
below ~16K, then "new" would OOM out in WiFiClientSecureBearSSL.
Added private function to try IRAM first then switch to DRAM on fail
to WiFiClientSecureBearSSL for iobuff allocations.
* Make mkdir.py work unter python3 versions below 3.5
Because early versions of python3 did not have the optional arg "exist_ok" for "pathlib.Path(...).mkdir(...)" a build under this versions will abort with an error message.
This PR will modify the python script so that it works even under python 3.4 (and below).
* Added comments for ets_install_uart_printf and corrected it usage.
* Correct case for hotkey 'p'.
Added conditional build around option 'p' to call stack_thunk_dump_stack
which can only print when debug is enabled.
* Create pins_arduino.h
* Update boards.txt.py
* Update boards.txt
* done a "boards.txt.py --allgen"
* Removed the definition of LED_BUILTIN from variants/wifi_kit_8/pins_arduino.h, because this board has no build in lED
* Copy released JSON to board URL, not new one
Fixes#8180
The draft release generates a ZIP and JSON. Instead of rebuilding the ZIP
on the publish step (which may result in a different SHA256 due to file time
differences in the new ZIP), just copy the one from the published release
directly.
Also clean up and remove unneeded environment variables and CI steps.
* Be more paranoid about JSON format, check after d/l
Fix release packager issue. Seems when variable set in $GITHUB_ENV
quotation marks are not removed, resulting in URLs with
http://ddd.dd/blah/"3.0.1"/release and JSON entries with the same
quotation problem.
* Don't crash when includeing LittleFS.h w/no FS
The LittleFS constructor could cause a divide-by-zero error and crash the
chip during pre-main startup (i.e. when the constructors were called).
Avoid by only initializing the LittleFS control structure when there is
a filesystem specified in the flash layout.
* Be even more paranoid on begin() and format()
GCC 10.x seems to have a knack for crashing when a function which is declared
to return a value does not. Add a warning, present on all builds, when this
is the case. For more info see https://github.com/esp8266/Arduino/discussions/8160
Thanks to @hreintke and @mcspr for the tips.