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

4431 Commits

Author SHA1 Message Date
Max Prokhorov
6033ed35d5
Use subprocess.run in elf2bin (#8799)
Properly handle Popen object, it takes care of everything we need to do like .communicate() and handle timeouts. Introduce a small timeout to run so we also know when that happens
Clean-up with pythonic path join and formatting through f"" strings
2023-01-15 00:59:33 +03:00
david gauchard
39080e317e
delay / esp_delay: transparently manage recurrent scheduled functions (#8802)
Recurrent scheduled functions will always be running in background.

esp_delay()'s interval (intvl_ms) is internally kept to its highest value allowing to honor recurrent scheduled functions requirements.

It transparently allows to keep with the arduino and nonos-sdk trivial programming way and still use background services or drivers running regularly.
2023-01-14 22:25:57 +01:00
Max Prokhorov
e1c4a6c8e6
Portable python fix for mkbuildopts (#8804)
see #8226
mentioned in #8803
2023-01-14 21:22:28 +03:00
Max Prokhorov
840ef78237
Fix C builds (#8795)
Missing stdbool.h for 'bool' in features .h, at least one user is arduinoWebSockets
Adds minimal headers sanity-check script to verify that C builds work as expected

Also noticed and removed default argument from crc32() in internal .h that may be used in .c
(not sure how extern C & default worked simultaniously, but at least in our .cpp Gcc somehow figured out it is a no overload solution)
2023-01-11 03:48:30 +03:00
M Hightower
7e2da8b25b
Typo in EAP patch (#8797)
NONOSDK22x_191124 -> NONOSDK22x_191024
2023-01-09 21:36:26 +03:00
Max Prokhorov
df59774eb5
Pointer<->Int casts are not constexpr (#8796) 2023-01-09 21:07:57 +03:00
Earle F. Philhower, III
c8dcdede34
Remove 400b stack allocation from AdvWeb example (#8793)
The AdvancedWebServer.ino example allocated a 400 byte char array on the
stack which, in the case of the example, will work but in general is a
dangerous thing to show new users to try.

Instead, use a StreamString to generate the string on the heap.
2023-01-07 10:01:56 -08:00
Max Prokhorov
a76852a991
Fixup and hedgedoc (#8792) 2023-01-06 16:18:49 -08:00
david gauchard
a79b8f219c
fix printf format in updater debug messages (#8791) 2023-01-07 00:31:01 +01:00
Earle F. Philhower, III
a276195731
Document updating the GitHub deployment keys (#8790) 2023-01-07 00:17:29 +01:00
david gauchard
3212f15cef
back to dev (#8789) 2023-01-06 23:39:04 +01:00
david gauchard
8ae300d476
release 3.1.0 (#8788) 3.1.0 2023-01-06 22:06:06 +01:00
metarutaiga
66ecc33916
Move C++ constructor and destructor tables from .bss to .irom0 (flash) (#8737) 2023-01-05 17:33:00 +03:00
Max Prokhorov
f06710eb6e
hostByName timeout fixes (#8787)
* single impl
2023-01-05 14:29:14 +01:00
piotrcurious
3e357f32b1
Allow passing beacon interval to SoftAP config (#8695)
allow passing beacon_interval to the softAP
2023-01-05 09:54:05 +01:00
BackLogers
3f394616a6
Passing custom HTTPClient to HTTPUpdate (#8773)
This enables passing additional headers to HTTP query.
Based on ESP32 HTTPUpdate functionalities.
2023-01-05 09:38:12 +01:00
david gauchard
7cfb551f90
PHY status API for ethernet drivers (#8784)
* PHY status API for W5500 & ENC28J60 drivers
* move linkStatus() from ArduinoEthernet:: to LwipIntfDev::
* LwipIntfDev: include PHY status into ::connected()
2023-01-05 09:23:57 +01:00
Earle F. Philhower, III
c9f90a3ed3
Update to LittleFS 2.5.1 (very minor update) (#8786) 2023-01-04 14:48:57 +01:00
david gauchard
5a3da9a7d8
Fix Stream::parseFloat() (#8785)
cherry-pick updates for Stream::peekNextDigit() from AVR implementation: decimal dot is optionally allowed
2023-01-03 22:14:10 +03:00
Max Prokhorov
204d2c93a7
NONOS SDK clean-up (#8770)
Remove nonos-sdk-v2.2.0-28-g89920dc aka 3v0, since we have a real v3
Remove 3.0.0...3.0.4 to reduce overhead in maintaining a bunch or binary patches
Update our docs and menu opts to mention 'experimental' status

Old versions still remains in git history, so anyone wanting to play around with 3.0.x could still make use of that work
2023-01-03 01:40:53 +03:00
Dirk O. Kaar
3f1d608a19
EspSoftwareSerial release 7.0.0 with fix for compiler error (constexpr instance member function) and Rx IRQ callback (#8781) 2022-12-31 10:55:37 -08:00
M Hightower
137d421fdd
Fix flashinit panic not printing (#8762)
* fix panic not printing

* improve panic to accept 0 lineno

* always present detailed error message

* Added back lost edit

* For SDK v3.0+, adjust conditional build to remove duplicate call
to flashinit from user_init.
2022-12-22 19:13:01 +03:00
david gauchard
edfde6ba1a
lwip2: cleanup logging and use newlib printf (#8769)
https://github.com/d-a-v/esp82xx-nonos-linklayer/pull/61
2022-12-21 11:35:23 +03:00
M Hightower
4a639ab015
Added missing DRAM fallback to pvPortCallocIram, pvPortZallocIram, and (#8765)
pvPortMalloc(,,,true) case. Improved comments.
2022-12-19 20:51:12 +03:00
M Hightower
59b5bbab7a
Resolve flash address issues with SDK v3.0.0 (#8755)
* Reslove flash address issues with SDK v3.0.0

Fix EEPROM vs RF_CAL flash address conflict. The EEPROM address and
RF_CAL address were the same.

Add support for Flash size: "Mapping defined by Hardware and Sketch"

Change at_partition_table static from dynamic to static.

* Cleanup and improve comments

* Improve flash size and partition error reporting/indication

Changed set_pll() to mmu_set_pll() and made available for debug builds
and other settings where required.

Provide more checks and feedback in the debug builds and
trim code for production.

* Now supports FLASH_MAP_SUPPORT with SDKs v3.0

RF_CAL and system_parameter always occupy the last 5
sectors of flash memory.

* cleanup and refactoring
comment cleanup

* Add more build issolation when including flash_hal.h

* Improve details for autoconfig fail.

* requested changes
2022-12-19 19:44:26 +03:00
Krzysiek S
b565b8686d
Optimize disconnect method in WiFiSTA class (#8760) 2022-12-16 14:22:26 +01:00
Max Prokhorov
eda64f69a7
Stack decoder script (#8661)
* stack decoder
* +x
* cut here
* last alloc explain, line breaks
* capture
* print ctx line
* ...and dont ignore sp
* non-hyphenated arg for elf, toolchain path to bin/

either for when tools are already in PATH
or, using `pio pkg exec --package toolchain-xtensa python decoder.py ...`
(where package is a full version spec for pio registry)
2022-12-16 12:27:43 +01:00
Max Prokhorov
9dce0764af
Don't return true with WiFiClientSecureBearSSL::connected() when really disconnected (#8330)
* Don't return `true` with WiFiClientSecureBearSSL::connected() when disconnected

Apply the same condition as with normal WiFiClient - we are not connected
when it's not possible to both write and read.

Implement separate methods for actual connection status and the internal
ssl engine status and update methods that were previously using available()
for this purpose

Update examples to check available() when the intent is to only read the
data and not interact with the client in any other way. Also, use connect()
as a way to notify errors, no need to check things twice
2022-12-16 12:12:58 +01:00
M Hightower
4a0b66b017
Heap addendum to handle changes in NON-OS SDK 3.0.x (#8746)
## WPA2 Enterprise connections
References - merged PRs:
* https://github.com/esp8266/Arduino/pull/8529
* https://github.com/esp8266/Arduino/pull/8566 - these occurred with connect/disconnect with WPA-Enterprise
* https://github.com/esp8266/Arduino/pull/8736#issue-1470774550

The NON-OS SDK 3.0.x has breaking changes to the [`pvPortMalloc`](bf890b22e5/include/mem.h (L42)) function. They added a new `bool` argument for selecting a heap. 
```cpp
void *pvPortMalloc (size_t sz, const char *, unsigned, bool);
```

To avoid breaking the build, I added a new thin wrapper function `sdk3_pvPortMalloc` to `heap.cpp`. 
Edited new SDK LIBs to call `pvPortMalloc`'s replacement `sdk3_pvPortMalloc`.

They also added `pvPortZallocIram` and `pvPortCallocIram`, which are not a problem to support. Support added to `heap.cpp`.

Issues with WPA2 Enterprise in new SDKs:
* v3.0.0 and v3.0.1 - have the same memory leak and duplicate free bugs from before
* v3.0.2 through v3.0.5 - have the same memory leak; however, _no_ duplicate free crash.
* memory leak can be seen by cycling through setup, connect, disconnect, and clear setup - repeatedly.

Updated `wpa2_eap_patch.cpp` and binary patch scripts to handle v3.0.0 through v3.0.5.
Patched SDKs v3.0.0 through v3.0.5

## Duplicate Non-32-bit exception handler
Issue: At v3.0.0 and above `libmain.a` supplies a built-in exception handler (`load_non_32_wide_handler`) for non-32-bit access. Our non-32-bit access handler (`non32xfer_exception_handler`) overrides it. 

Solution: Add "weak" attribute to symbol `load_non_32_wide_handler`. Adjust the build to default to the SDK's built-in non-32-bit handler.  If there is a need to use our non-32-bit handler, make the selection from the Arduino IDE Tools menu `Non-32-Bit Access: "Byte/Word access to IRAM/PROGMEM (very slow)"`.

With SDKs v3.0.0 and above a "non-32-bit exception handler" is always present.
2022-12-16 11:11:19 +03:00
Krzysiek S
d3c8d272d7
Add eraseap option to WiFi disconnect method. (#8758)
Add eraseCredentials option to WiFi disconnect method (legacy default: true)
2022-12-15 10:30:29 +01:00
Dirk O. Kaar
64077df980
Keep Servo in the same position after re-attaching (#8753)
The current implementation of the Servo lib always resets the position when detaching.
In AVR Servo, this isn't the case, instead, it doesn't move the servo but leaves it as it was before getting detached.
2022-12-15 02:21:56 +03:00
Amju
9cd560b451
Add httpupdate lib import in ota example (#8667)
Docs doesn't include any reference to include <ESP8266httpUpdate.h> library in Advanced OTA Updater section. It took me some time to find out while reading the docs
2022-12-14 12:07:41 +01:00
Holger Müller
8e79833db6
add DEBUG payload output (#8745) 2022-12-14 11:27:41 +01:00
DarioGHub
a4a8782c56
Correct class name in readme.rst (#8751)
Text referred to an object name ESPHTTPUpdate, but context called for class name ESP8266HTTPUpdate
2022-12-11 09:10:56 -08:00
Dirk O. Kaar
6aa22aca8a
EspSoftwareSerial bug fix 6.17.1 (#8754) 2022-12-10 09:29:29 -08:00
Eli Lipsitz
da48a52d7a
Fix File::readString to work with binary data (#8742)
Previously, File::readString used a C-style string as an intermediate
buffer via the String += operator. This treats a NUL byte as a
terminator, making this function work incorrectly if the File contains
binary data.

This commit switches the function to use String::concat, which doesn't
treat NUL bytes any differently (and is a bit faster, because it doesn't
need to use strlen).
2022-12-06 22:56:49 +03:00
Max Prokhorov
3c6253109d
Fix CPPDEFINES loop (#8744)
Expect that (key, value) can be (key,)
2022-12-06 17:33:58 +03:00
metarutaiga
93537f94a8
Added NONOS SDK 3.0.0 ~ 3.0.5 (again) (#8736)
* Added NONOS SDK 3.0.0 ~ 3.0.5

* Added user_pre_init

* rf_cal[0] !=0x05,is 0x00

* # Remove mem_manager.o from libmain.a to use custom heap implementation, and time.o to fix redefinition of time-related functions
# Rename `hostname` and `default_hostname` symbols

* user_rf_pre_init

* Add system_func1() called by system_restart_local()

* Add commit log text

* Fixed user_rf_pre_init

* Style

* pio sdks

Co-authored-by: TAiGA <>
Co-authored-by: Maxim Prokhorov <prokhorov.max@outlook.com>
2022-12-06 13:43:48 +03:00
Max Prokhorov
ed6b957164
Skip .git{,hub} files when packaging (#8743) 2022-12-06 13:31:16 +03:00
DarioGHub
9701d3afb6
Add setClientTimeout() to ESP8266HTTPUpdate (#8740)
Shortening up the default hard-coded 8000 ms timeout, will save energy when module can't reach its update server, especially on battery powered projects, and otherwise provide adaptability to the local wlan. The ESPhttpUpdate object is auto-created by #including ESP8266HTTPUpdate. ESP8266HTTPUpdate also provides a constructor with param httpClientTimeout, but to use it required destroying the auto ESPhttpUpdate object, or creating a secondESPhttpUpdate(timeout) object.
2022-12-06 13:02:57 +03:00
RobertGnz
3c6db4ed9b
WiFiClient::abort() (#8738)
Api for saving heap when Client class is used by a Server (WiFiServer class): Client = Server.available().

Suppose the local end is the server and the remote end is the client, we will deal with heap memory at the local end.

When the local application (server) decides to close an active connection with a remote end it issues an Client.stop.
The stop() function calls the close() function of ClientContext class which in turn calls tcp_close.
The connexion is closed by tcp_close and the protocol control block (pcb) can be put in the following states depending on the requests sent by the remote: CLOSING, FIN_WAIT_1 and FIN_WAIT_2. In theses states pcbs are not freed, then consume some memory heap.
If an acknowledgment from the remote end is received, the pcb enter in TIME_WAIT state for some minutes but pcbs in TIME_WAIT state are not freed. Then consume some heap memory.
TIME_WAIT pcbs are automatically freed after some minutes or can be freed for instance issuing an tcp_kill_timewait()
in the local application which will free the oldest pcb in TIME_WAIT state.

If the connection is first closed from the remote end (the client), the local end (server) receive a connection termination request. It then acknowledge it and enter in CLOSE_WAIT state waiting for a connection termination request from the local application.
It then send a termination request and enter in LAST_ACK state until it receive an acknowledgment from the remote end.
After receiving the acknowledgment it enter in ClOSED state and the local pcb is freed leaving some room in the heap memory.

To summarize, when a connexion termination request is send by one end (remote or local), the local pcb is not freed immediatly.
This pcb can be in the following states: FIN_WAIT_1, FIN_WAIT_2, CLOSING, TIME_WAIT, CLOSE_WAIT, LAST_ACK.
As a consequence, some old pcbs from old closed connections are still consuming heap memory.

The local application can call tcp_kill_timewait hoping it will free some TIME_WAIT state pcbs. But if the server receive frequent connections requests and close them after sending whatever it has to send, there may be zero pcbs in TIME_WAIT state among all previously closed connections.

In case of insufficient memory to accept a new connection, lwip has developped a strategy: it successively tries to kill the oldest pcb in TIME_WAIT state, or in LAST_ACK state or in CLOSING state or the oldest active connection with lower priority than the new one.

As a matter of fact this "urgent" strategy is deployed only when very few heap memory remain available (less than some kb). In case of success, Client.available returns a valid Client but the local application will crash when sending or receiving data from the client (Client.read ou readuntil or available) because this need more heap memory and just some kb were freed in lwip to allocate the new pcb structure ans start the new connection.

The propose API is intended to avoid this drawback by calling the abort function of ClientContext which in turn calls tcp_abort which calls tcp_abandon. The connection is aborted and notified to the client with a RESET and the pcb and ressources associated are immediately released increasing the available heap memory.
2022-12-06 12:40:48 +03:00
Dirk O. Kaar
821ccde978
EspSoftwareSerial 6.17.0 (#8739) 2022-12-04 11:39:00 -08:00
M Hightower
fe451a814f
Fix typo in section list (#8726)
For GCC LD scripts, using commas in a section expression
sometimes cause problems.
2022-11-23 12:33:56 -08:00
seism0saurus
80bf716625
Only check the actual used lenght of the hash. (#8709) 2022-11-06 00:20:23 +03:00
M Hightower
3a2fe9ff0f
Correction on Heap API available from ISR (#8708)
* Correction on Heap API available from ISR

* Expand reason for avoid realloc/free
2022-11-04 16:07:31 +03:00
M Hightower
3d9aeeff2d
Fix pre-SDK Cache_Read_Enable for PUYA flash (#8658)
* Enable SPI_CS_SETUP for early ICACHE use

The SPI_CS_SETUP parameter has been observed set by RTOS SDK and NONOS SDK
as part of flash init/configuration. It may be necessary for some flash
chips to perform correctly with ICACHE hardware access. Turning on and
leaving it on should be okay.

* Cleanup comment

* Change umm_init to default to IRAM

Some flash chips (PUYA) have some unknown requirements for running with
early `Cache_Read_Enable`. They work fine after the SDK is started.
For now, change umm_init to default to IRAM.
Define UMM_INIT_USE_ICACHE to move to ICACHE and free up IRAM.

Added some experimental code that may indirectly support PUYA.

Note, until this issue is resolved, that HWDT Stack Dump is not
going to work with PUYA flash.

* typo

* Finalize fix for PUYA flash and preSDK use of Cache_Read_Enable.

This resolves the exception 0 issue with PUYA flash when using
flash/ICACHE for umm_init and/or using HWDT Stack Dump.
2022-11-04 13:51:53 +03:00
Max Prokhorov
e1081e30f5
Update README.md (#8706)
Remove unused Travis URL, update documentation links and add PlatformIO platform instructions
2022-11-03 18:38:01 +03:00
Max Prokhorov
fff12e3068
Updater lifetime callbacks (#8653)
follow-up of #8598 
similar to ArduinoOTA API, execute certain callback in the Updater context.
2022-11-03 08:58:53 +03:00
Max Prokhorov
27c0591756
Longer delays for Ticker and some internal updates (#8625)
Adds max duration check. In case it is over SDK limit, enable 'repeat'ing timer with a duration proportional to the original one and count until it executes N times, only then run the callback.
Code with durations less than that executes as usual. Original proposal was to not create anything or create some kind of error state... which seems counter-productive to not help out with this pretty solvable use-case.

Additional updates, while refactoring the class
- Stronger types for internal time management using `std::chrono::duration`. Works the same, `std::chrono::duration` handles seconds <-> milliseconds conversion, and we don't have to remember the time type in each method. (...and even allow `once()` and `attach` as overloads instead of the current `_ms`-suffix, in a future update)
- `::detach()` when timer finishes. Fixes (unintentional?) side-effect that we remain `::active()`. Plus, this destroys any lambda-bound variables that will persist with the Ticker object. And, since we can't re-arm with the existing function (`Ticker::attach_ms(uint32_t just_the_time)` and etc.)
- `std::variant` aka union for internal callback storage (kind-of similar to #6918). Instead of having two separate code paths, **always** attach our static function and dispatch using type info. Also helps with the issue described above, since it will call `std::function` dtor when ptr + arg is attached instead of doing nothing.
- smarter copy and move, detaching existing timer on assignment and detaching the moved-in timer object in both ctor and assignment. Copying or moving a running timer no longer blindly copies `_timer` pointer, allowing to disarm the original one. Since we are a simple wrapper around `os_timer_t`, just do the simpler thing (and not re-schedule the callback, try to store original times, etc. polledTimeout already does it and is copyable)
2022-11-01 20:15:14 +03:00
Max Prokhorov
04494f0729
Generic netif status callback and mDNS (#8705)
* sprinkle IPAddress(...).isSet() across our loops to avoid polling on a
  stopped interface. status callback and netif_is_up **does not
  guarantee and we could use the interface**!
* register *one* status callback per instance, e.g. when begin() is called
  multiple times (also notice a subtle issue with schedule function when
  instance is delete'ed)
* consistent LwipIntf callback signature. no need for rvalue, just pass
  stdfunc as-is and let the compiler figure it out
2022-11-01 03:01:40 +03:00