1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-09 03:41:41 +03:00

1177 Commits

Author SHA1 Message Date
david gauchard
d5eb265f78
WiFi config(): warning for legacy idioms (#9050) 2023-12-12 00:57:57 +01:00
Juraj Andrássy
9e73cf0021
LwipIntfDev - config static IP auto gw,mask,dns as in Arduino libraries (#9040)
for 'modern' Ethernet libraries W5100lwIP, W5500lwIP and ENC28J60lwIP
used without EthernetCompat
2023-12-01 10:36:35 +01:00
Juraj Andrássy
1efe5ee3fc
LwipIntfDev - add parameter's missing default value for dnsIP(n) (#9039) 2023-12-01 09:44:55 +01:00
david gauchard
32c858df6d
ask user not to post stack dumps, but to decode them (#9037)
* ask user not to post stack dumps, but to decode them
2023-11-24 09:32:29 +01:00
Juraj Andrássy
74c04c88c5
LwipIntfDev - method end() to enable repeated begin (#9023) 2023-11-12 23:41:08 +01:00
M Hightower
c84fda145c
Resolve HWDT Reset with core_esp8266_vm (#9025)
* Resolve HWDT Reset with core_esp8266_vm

With the newer GCC compiler (after tag 3.0.2), example virtualmem was crashing with a HWDT reset.
Reordered some SPI register set lines in spi_init().
New ordering was based on ::begin in SPI.cpp

This change may resolve issues describe in
https://github.com/esp8266/Arduino/discussions/9010

* Added memory barrier to changes
spi_ctrl appears to need setting before other SPI registers
2023-11-12 23:26:35 +01:00
Juraj Andrássy
097e59f2e1
LwipImtfDev - add DNS IP getters/setters and MAC getters (#9022)
Ethernet styles getters/setters and WiFi styles getters/setters
2023-11-10 10:27:38 +01:00
AriaN
31c1592ad6
add Stream::readStringUntil function that uses string terminator (#9011)
* add readStringUntil function with string terminator
* rename count parameter to untilTotalNumberOfOccurrences
2023-11-07 14:19:31 +01:00
M Hightower
a348833a81
A new approach for erasing WiFi Settings (#8828)
* A new approach for erasing WiFi Settings

Add support for hardware reset function call - simulates EXT_RST via HWDT.

Add reset selection to `ESP.eraseConfig()` for calling hardware reset
after erasing the WiFi Settings.

Update ArduinoOTA to use `ESP.eraseConfig(true)`

Externalized `ArduinoOTA.eraseConfigAndReset()`

Add OTA examples to illustrate using erase config changes.

* style
fixed confused example

* improve wording

* Add new state to retry eraseConfigAndReset

* Removed unreachable error test from examples.

Removed continuous retry of "eraseConfig" and allow the script to
assign an error handling option for "eraseConfig" failure.

Update example to use error handling option.

* In eboot for function ets_wdt_enable() added missing arguments

* Update comments and example

* Wording

* Rebuilt eboot.elf with current tools from ./get.py

* Requested changes.

* cleanup comments

* Update hardware_reset

Avoid using "[[noreturn]]" - not accepted for a .c file function
Updated to use __attribute__((noreturn)) to handle both .cpp and .c
file functions.
2023-08-29 17:24:07 +02:00
Luciano Martorella
1a4663fbe8
Add virtual beginMulticast(...) stub to UDP class (#8969)
* - Same UDP API of ESP32 core

* - PR review
2023-08-15 19:25:58 +03:00
david gauchard
b7f7b7488a
fix delay(0) (#8960) 2023-07-19 00:25:31 +02:00
M Hightower
dcceee8cbd
Fixes occasional UMM_POISON failure (#8953)
* Fixes occasional UMM_POISON failure

Bug introduced with PR fix #8914.
When a reallocated pointer could not grow in place, a replacement
allocation was created. Then UMM_POISON was written to the wrong block.

* Fix umm_poison data corruption on realloc when memory move is used.

Bug introduced with PR fix #8914

* refactored to resolve unused error in some build contexts
2023-07-18 23:34:42 +02:00
M Hightower
521ae60a89
Fix for dangerous relocation: j: cannot encode (#8925)
Fixes to recent changes to Postmortem to cover large jump offsets, use relaxed jump (J.L) in __wrap_system_restart_local.
Also add check that epc1 is a valid code address before reading.
2023-06-16 18:39:29 +03:00
M Hightower
57fa6cdc92
Soft WDT: detect deliberate infinite loop at Postmortem (#8918)
A popular method of handling an unrecoverable state is to reboot. The SDK does this in many places by printing a cryptic debug message followed by something equivalent to while(true){}, which compiles down to loop: j loop, creating a Soft WDT reset.
2023-05-01 02:05:32 +03:00
M Hightower
c517bfd997
umm_poison false positive from ISR (#8914)
The umm_poison logic runs outside the UMM_CRITICAL_* umbrella. When interrupt routines do alloc calls, it is possible to interrupt an in-progress allocation just before the poison is set, with a new alloc request resulting in a false "poison check fail" against the in-progress allocation. The SDK does mallocs from ISRs.

SmartConfig can illustrate this issue, see
https://github.com/esp8266/Arduino/issues/3494#issue-247919259

Other Sketches built with Debug: "Serial," that use the SDK's Promiscuous callbacks are also likely to encounter problems.
The SDK support for "Promiscuous Receive" allocates memory from an ISR context, occasionally interrupting the poison wrapper code before it finishes setting the poison fences resulting in a false poison failed event.
2023-04-28 15:57:50 +03:00
Takayuki 'January June' Suwa
65579d2908
Make precache() cleaner and more efficient (#8903)
No need to issue a MEMW instrunction per load from each cache line.
Only once after the last load is sufficient.

  MEMW ensures that all previous load, store, acquire, release, prefetch,
  and cache instructions perform before performing any subsequent load,
  store, acquire, release, prefetch, or cache instructions.

    -- MEMW (Memory Wait), 6. Instruction Descriptions,
                                      Xtensa ISA Reference Manual (p.409)
2023-04-06 01:26:34 +03:00
M Hightower
a76ef290ea
Support user_rf_pre_init() for SDK v3.0 (#8888)
* For SDK v3.0+, early system calls that were called from user_rf_pre_init
(SDK v2.2) need to now be called from user_pre_init.

Moved user_rf_pre_init() call to the end of user_pre_init() so we
can still perform early calls like: system_phy_set_rfoption(rf_mode),
system_phy_set_powerup_option(2), etc.

* Update comment

* Improve "spoof_init_data" enable/disable logic.
Out of an overabundance of caution, limit logic change to the
experimental SDK v3.0.5.
2023-03-30 19:54:28 +02:00
M Hightower
d3c102e717
Update documentation and arduino debug options (#8837)
* Update documentation

Describe how to improve Exception Decoder results.

Updated build option details.

* Added d-a-v's code. And updated description and debug macro.

* Update doc

Updated platform.txt - positioned -Os such that it can be overridden by `build.opt`.

Add suggestion of using `-Og` which may improve the Decoder's line number correlation
with the problem in the source code.

Untested adjustments to platformio-build.py

* Fixed code formatting

* Fixed example

Previously `-O3` in the example had no effect. It was overridden by later flags.
Reording the `-Os` allowed changing optimization to  work. Somehow this triggered
a new warning "Stream.h:50:7: warning: 'f.Stream::_startMillis' may be used
uninitialized in this function". Replaced `-O3` with `-Og`.

* Proposed "Debug port" menu change
Preserves a pathway for `build.opt` override.

* Update boards.txt.py and docs - WIP

* Improve organization of optimization content.
Use "Debug Optimization" for menu name.
The menu item defines the initial optimization.
platform.txt - optimization parameter can be overridden by build.opt.

* Add fallback value for build.debug_optim to platform.txt

* update text and undo changes to platformio-build.py

* tweak text

* Added ':orphan:' mark to a06-global-build-options.rst

* Update doc. Added link in page index to 'Improving Exception Decoder Results'

* Update text to reference PR#8868 improvements for leaf function.
2023-03-29 11:16:33 +02:00
david gauchard
a5d31a7187
deprecate and update Stream::send*(Print -> Stream) (#8874)
* deprecate and update Stream::send(Print -> Stream) in order to benefit from and use output's timeout value
2023-03-28 11:21:05 +02:00
david gauchard
210897ef83
Release 3.1.2 (#8893)
* release 3.1.2
2023-03-20 23:14:05 +01:00
M Hightower
84a59aa97f
Add reporting address interrupted by Soft WDT (#8851) 2023-03-11 18:22:10 +03:00
Bogg
503502f13b
Weak assignment in flash_hal (#8884)
The assignment done in FLASH_MAP_SETUP_CONFIG_ATTR did not apply the attribute to __flashdesc,
and made it impossible to override it with FLASH_MAP_SETUP_CONFIG.
2023-03-11 11:43:03 +01:00
M Hightower
be02af0504
Remove stale patch for SDK v1.1 and earlier (#8858)
rts_reg address referenced was not valid for SDK v2.0.0 and up.
rts_reg[30] = 0; cleared storaged used to set TestStaFreqCalValInput.
2023-02-23 01:02:55 +03:00
david gauchard
9a3d55c781
Fix String build warning with DEBUG_ESP_PORT but without DEBUG_ESP_CORE (#8849) 2023-02-05 15:35:56 +03:00
M Hightower
326be35c88
Postmortem improvements (#8839)
* divide by 0 reporting to point back at the divide function caller
* stack offset adjustments to be independent of __wrap_system_restart_local()'s stack frame size.
2023-02-01 18:57:32 +03:00
david gauchard
9c4a1239da
String: informative messages on issues (#8821)
Always enable messages when serial debug port is enabled
Allocation issue was not reported
2023-01-26 14:45:09 +03:00
Max Prokhorov
56107fb1f9
Properly handle u8 pointers when assigning and comparing (#8818)
* simplify ctors and operator=, use a common code paths instead of special handling here and there
* fix u8->u32 casts, copy before using u8 data
* do not use raw_address() internally
2023-01-20 12:26:12 +03:00
Max Prokhorov
0e5d358c3c
Version 3.1.1 (#8806) 2023-01-15 02:01:02 +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
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
david gauchard
a79b8f219c
fix printf format in updater debug messages (#8791) 2023-01-07 00:31:01 +01:00
david gauchard
8ae300d476
release 3.1.0 (#8788) 2023-01-06 22:06:06 +01:00
Max Prokhorov
f06710eb6e
hostByName timeout fixes (#8787)
* single impl
2023-01-05 14:29:14 +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
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
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
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
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
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
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
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
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
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
Max Prokhorov
bde8ef7af7
Nice stack smashing postmortem message (#8670)
Wire everything that relies on stack smashing detection to call
`__stack_chk_fail()` (aka what libssp / ssp / stack-protector uses)
Expose it in our debugging header

Rename overflow -> smashing, as these are different things we are trying
to detect (meaning, that we check for things writing there, not some
kind of `alloca` issue or the way `-fstack-check` would have worked)
ref. #8666

`-fstack-protector` continues to work as it always did
CONT replaces `abort()`, also moves its check to the loop wrapper to
avoid dumping otherwise useless SYS context memory
StackThunk replaces a similar `abort()` call
2022-10-31 07:15:42 +03:00
M Hightower
d3eddeb501
Ensure xPortGetFreeHeapSize reports DRAM (#8680)
Create dedicated function for xPortGetFreeHeapSize() that only reports on DRAM.
NONOS SDK API system_get_free_heap_size() relies on xPortGetFreeHeapSize() for the free Heap size.

Possible breaking change for multiple Heap Sketches calling system_get_free_heap_size(); it will now always report free DRAM Heap size.

Update and export umm_free_heap_size_lw() to report the free Heap size of the current Heap.
Updated ESP.getFreeHeap() to use umm_free_heap_size_lw().

Updated build options to supply exported umm_free_heap_size_lw() via either UMM_STATS or UMM_INFO.

Improved build option support via the SketchName.ino.globals.h method for Heap options: UMM_INFO, UMM_INLINE_METRICS, UMM_STATS, UMM_STATS_FULL, UMM_BEST_FIT, and UMM_FIRST_FIT. While uncommon to change from the defaults, you can review umm_malloc_cfgport.h for more details, which may help reduce your Sketch's size in dire situations. Assuming you are willing to give up some functionality.
For debugging UMM_STATS_FULL can offer additional stats, like Heap low water mark (umm_free_heap_size_min()).
2022-10-11 14:52:39 +03:00
Max Prokhorov
a0c7a85649
Fix Updater non-zero _verify->length() once again (#8545)
Amends #8507
I took the liberty to also do some refactoring; specifically, fixing signed vs. unsigned mismatch in len, using pointer object vs. the original manual malloc & free, try to have named constants for certain addresses and lengths, plus localize printing of u8 arrays.

The suggested test to have a 'dummy' verifier works just fine. (...how it actually works and gets the hash to compare with is a whole other question, though)

Another issue noticed while testing, in the underlying bearssl api there's an actual limit for hash length.
6105635531/inc/bearssl_rsa.h (L257)
2022-09-13 15:57:42 +03:00