1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-25 20:02:37 +03:00

1101 Commits

Author SHA1 Message Date
M Hightower
e6fc76ab5f
Fix, calloc now fails on extra-large request. (#8482)
Added code to handle multiply overflow in calloc.
Added code to handle add overflow in umm_poison_*
2022-02-12 22:24:59 +01:00
david gauchard
f60defc3d3
flash-size agnostic builds (#6690)
* flash: mapping definition by sketch at runtime depending on flash chip size and user configuration
2022-02-10 18:25:18 +01:00
Paulo Cabral Sanz
9f536e68f8
WString: avoid writing to const storage (#8463)
This avoids the null termination requirement of both String::substring and String::lastIndexOf by using APIs that don't require it. So we can stop writing to the buffer inside of const functions.

I also changed wbuffer to make it non const.
2022-01-28 15:51:45 +03:00
Benedikt Eliasson
f4ef6fd7d8
fix Stream.read into buffer ignoring every second byte (#8452) (#8453) 2022-01-18 15:21:13 +01:00
M Hightower
9fcf14f81f
Fix VM Address mask (#8440)
* Fix VM Address mask

Adjust VM Address mask to allow up to 8M Byte parts.
Allow for free heap size values over 64K
  ESP.getHeapStats(, uint32_t,)
  uint32_t getMaxFreeBlockSize();

* Fix example

* Update MockEsp.cpp for uint32_t on EspClass::getMaxFreeBlockSize()

* Added comment about heap size limitation and static_assert to verify.
Updated boards.txt to show correct External memory size and Heap size.
2022-01-12 01:35:46 +03:00
david gauchard
4c07113ff5
lwIP: v2.1.3 + dhcp fixes (#8319)
* lwIP: v2.1.3
* interface set as default when gw is valid
2022-01-06 12:38:36 +01:00
david gauchard
a05a71fa9d
import getLocalTime() from esp32/Arduino (#8413)
* import getLocalTime() from esp32/Arduino
follows #8407
2022-01-04 22:20:20 +01:00
M Hightower
f26201e6a9
Sync umm_malloc style with upstream (#8426)
Upstream umm_malloc at git hash id 4dac43c3be7a7470dd669323021ba238081da18e
processed all project files with the style program uncrustify.

This PR updates our ported version of umm_malloc processed with "uncrustify".
This should make subsequent merges of upstream into this port easier.

This also makes the style more consistant through umm_malloc.
2022-01-03 22:36:03 +01:00
david gauchard
dde2c769db
StreamConstPtr: disallow passing a String temporary (#8410)
* StreamConstPtr: prevent from passing a temporary String instance
* unconditionally allow progmem chars
* missing virtual destructor in Stream
(warning: deleting object of abstract class type 'Stream' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor])
2022-01-03 13:42:27 +01:00
M Hightower
e5a214e6f1
Fix umm_blocks() (#8429)
Extracted fix from upstream for umm_blocks() - On allocations that were too
large, umm_blocks() could return an incorrectly truncated value when the result
is cast to uint16_t.
2022-01-03 11:44:17 +01:00
david gauchard
2492057b61
LittleFS: add overrides for Stream::send (#8386)
* littlefs: add overrides for Stream::send
2021-11-29 20:39:37 +01:00
Andrej Pala
d5444c4aa3
I2C clock phase correction in START condition (#8383)
* A clock phase correction in write_start(void)

Some devices require the data wire SDA to be held down at the moment while the clock wire is pulled down too to execute the start condition (e.g. devices using "TinyWires.h" library). This change follows a behaviour of Arduino Wire.h library, where the SCL signal is pulled down in half of period of start condition.

* Formatting of modification restyled

* Removing mathematical operations from delay

* Comments added
2021-11-28 18:33:01 +03:00
adams13x13
0761f6f672
Add stream string includes (#8367) 2021-11-09 16:09:20 -08:00
Dirk O. Kaar
c7c7d0518b
Remove the HAVE_ESP_SUSPEND define. (#8342)
The define was in the feature development branch, now after merge into main it is redundant, and should not be part of the next release point.
2021-10-17 01:51:53 +03:00
Dirk O. Kaar
c312a2eaf1
Implement esp_yield() as a replacement for delay(0)
esp_yield() now also calls esp_schedule(), original esp_yield() function renamed to esp_suspend().

Don't use delay(0) in the Core internals, libraries and examples. Use yield() when the code is
supposed to be called from CONT, use esp_yield() when the code can be called from either CONT or SYS.
Clean-up esp_yield() and esp_schedule() declarations across the code and use coredecls.h instead.

Implement helper functions for libraries that were previously using esp_yield(), esp_schedule() and
esp_delay() directly to wait for certain SYS context tasks to complete. Correctly use esp_delay()
for timeouts, make sure scheduled functions have a chance to run (e.g. LwIP_Ethernet uses recurrent)

Related issues:
- #6107 - discussion about the esp_yield() and esp_delay() usage in ClientContext
- #6212 - discussion about replacing delay() with a blocking loop
- #6680 - pull request introducing LwIP-based Ethernet
- #7146 - discussion that originated UART code changes
- #7969 - proposal to remove delay(0) from the example code
- #8291 - discussion related to the run_scheduled_recurrent_functions() usage in LwIP Ethernet
- #8317 - yieldUntil() implementation, similar to the esp_delay() overload with a timeout and a 0 interval
2021-10-17 00:19:01 +03:00
M Hightower
b7a2f44b50
Update mmu_get... and mmu_set... (#8290)
These changes are needed to address bugs that can emerge with the improved optimization from the GCC 10.3 compiler.

Updated performance inline functions `mmu_get_uint8()`, ... and `mmu_set_uint8()`, ...  to comply with strict-aliasing rules. 
Without this change, stale data may be referenced. This issue was revealed in discussions on https://github.com/esp8266/Arduino/issues/8261#issue-963529268 

Changes to avoid over-optimization of 32-bit wide transfers from IRAM, turning into 8-bit or 16-bit transfers by the new GCC 10.3 compiler. This has been a reoccurring/tricky problem for me with the new compiler. 

So far referencing the 32-bit value loaded by way of an Extended ASM R/W output register has stopped the compiler from optimizing down to an 8-bit or 16-bit transfer.

Example:
```cpp
  uint32_t val;
  __builtin_memcpy(&val, v32, sizeof(uint32_t));
  asm volatile ("" :"+r"(val)); // inject 32-bit dependency
  ...
```

Updated example `irammem.ino`
* do a simple test of compliance to strict-aliasing rules
* For `mmu_get_uint8()`, added tests to evaluate if 32-bit wide transfers were converted to an 8-bit transfer.
2021-10-13 03:47:12 +03:00
david gauchard
9d024d17fd
comments on Arduino flush() method (#8318) 2021-09-29 15:22:30 +02:00
TD-er
211606fe9c
[WString] Reduce build size by implementing flash string calls in .cpp (#8106)
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.
2021-09-04 11:43:18 -07:00
david gauchard
14c3798d4f
release 3.0.2 (#8242) 2021-07-26 22:27:44 +02:00
Dirk O. Kaar
bc302511f5
Clean up use of "byte" as a type. uint8_t or (C++17) std::byte are better. (#8090) 2021-07-26 21:20:45 +02:00
M Hightower
8a42163a50
Call umm_init just before starting SDK (#8207)
* 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
2021-07-19 07:58:37 -07:00
Paulo Cabral Sanz
c9f27410f7
Fix NO_GLOBAL_INSTANCES for Serial ports (#8184) 2021-07-17 16:21:37 -07:00
Paulo Cabral Sanz
2946ce055c
Avoid copying past end of buffer in String.concat (#8198) 2021-07-08 16:35:09 -07:00
M Hightower
a105bdd359
add comments and corrections (#8201)
* 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.
2021-07-08 16:11:58 -07:00
Earle F. Philhower, III
af513f666f
Release 3.0.1 (#8177) 2021-06-26 10:44:22 -07:00
Juraj Andrássy
15da1635b6
LwipIntfDev.h - apply static DNS config (#8076)
DNS setting was not applied. Additionally default values for dns parameters in config are added.
2021-06-18 11:21:07 +02:00
Earle F. Philhower, III
f1310c046b
Make String reallocation warning more descriptive (#8131)
Fixes #8130
2021-06-17 08:01:32 -07:00
david gauchard
2897679060
Release process fix & major/minor/rev macro addition (#8126)
* update release process to the new CI
* generate ARDUINO_ESP8266_{MAJOR,MINOR,REVISION} in core_version.h
* makecorever: new option `-r` for release
2021-06-16 15:51:17 +02:00
Dirk O. Kaar
40116feb33
Normalize core header's include guard. (#8110) 2021-06-09 09:55:27 -07:00
Earle F. Philhower, III
2185f9bd73
BREAKING - "i2s.h" removed, I2S library added (#8108)
* BREAKING - "i2s.h" removed, I2S library added

An "i2S.h" header was present in prior cores, but this conflicts with the
Arduino standard I2S.h header for the I2S class under Windows (because of
case insensitivity).

Initial 3.0.0 release has a redirect "i2s.h" file in the cores directory to
redirect to the "I2S.h" file in the library, but under Windows this resulted
in the IDE not building the I2S library and link errors.

Remove the offending header.  Code will need to mode to including "I2S.h"
instead (which will include both the Arduino class as well as the low-level
definitions).

Fixes #8107

* Update examples to use proper I2S.h version
2021-06-08 23:12:23 +02:00
david gauchard
325619a4c2
makeword: sync header and implementation (#8097)
makeword: sync header and implementation
2021-06-02 23:42:31 +02:00
Earle F. Philhower, III
60fe7b4ca8
Add code-spell spelling checks to CI (#8067)
Help find and fix silly spelling errors as they are added to the repo.
2021-05-23 08:53:04 -07:00
Dirk O. Kaar
f382fc9d77 Refactoring to PolledTimeout or optimistic_yield on the grounds that these are not wait loops on slow input. 2021-05-18 15:43:27 +02:00
Dirk O. Kaar
117f163099
Move _stopPWM in phase PWM to IRAM (#8048) 2021-05-17 14:50:33 -07:00
Wong "Sadale" Cho Ching
25e1b3b61c
Added IRAM_ATTR to _stopPWM() so that digitalWrite() would work inside ISR. Fixes #8043 (#8044) 2021-05-17 19:56:24 +02:00
david gauchard
7b6baf0fed
release 3.0.0 (#8034) 2021-05-16 02:06:06 +02:00
Max Prokhorov
0aaadd9fa1
WString: return bool instead of unsigned char (#7939)
Clean up the intent, resulting assembly stays the same.
2021-05-15 14:49:09 -07:00
Dirk O. Kaar
5f21c61c7c
ESP has no data members, is used as singleton object, and can be called before C++ runtime setup during boot: make all member functions static. (#8006) 2021-05-15 11:14:58 -07:00
M Hightower
1a381477ec
Updated HWDT one missed ICACHE_RAM_ATTR (#8018) 2021-05-06 10:45:55 +02:00
M Hightower
bc816c657b
Updated HWDT to use IRAM_ATTR instead of ICACHE_RAM_ATTR. (#8013) 2021-05-02 14:58:54 +02:00
david gauchard
f4178e58dc
fixes for WiFiClient::write(Stream) (#7987)
fixes for WiFiClient::write(Stream) and Stream transfers
- remove deprecated WiFiClient::write(Stream,size)
- fix and deprecate WiFiClient::write(Stream) to use Stream::sendAll instead of ::sendAvailable
- update ESP8266WebServer::streamFile to use file.sendAll(client) instead of client.write(file)
- remove stream dependence in ClientContext
- Stream::send(): honor timeout in all case, avoid short transfer when output is temporarily full
- example WiFiEcho: show sendAll and sendAvailable
2021-04-27 16:02:19 +02:00
Dirk O. Kaar
457692101a
Move prototype for enablePhaseLockedWaveform linker magic into header that's included by default instead of particular internal core header. (#7996) 2021-04-22 14:02:54 -07:00
Dirk O. Kaar
cfbbd6f22d
enableWiFiAtBootTime() should be declared in ESP8266WiFi.h (#7993) 2021-04-18 22:17:14 +02:00
Dirk O. Kaar
41de4115fd
Resolve "PWM-locked" / "phase-locked" waveform merge leftover in Servo lib (#7978)
Library was overlooked in "PWM-locked" / "phase-locked" waveform mode merge.
2021-04-17 13:43:02 -07:00
david gauchard
1cc6960a55
[BREAKING] Disable WiFi at boot by default (#7902)
* Disable WiFi at boot by default

* +define WIFI_IS_OFF_AT_BOOT

* remove now useless example

* mv enableWiFiAtBootTime() to core_esp8266_features.h

* sync with master

* per @earlephilhower review: a file was missing

* doc

* WiFi persistence is now false by default

* fix doc

* ditto

* doc: remove sphinx warnings (fix links and formatting)

* fix link name

* fix doc

* legacy: restore persistence

* undeprecate preinit()

* move force modem up to when mode has changed (per @mcspr review)

* do not wake up from sleep when mode if OFF

* fix doc per review
2021-04-09 23:01:11 +02:00
M Hightower
da6ec83b5f
Hardware WDT Stack Dump Tool (#7010)
* Hardware WDT Stack Dump

This Sketch demonstrates the use of a tool to print a stack dump
at reboot after a Hardware WDT event.

The module hwdt_app_entry.cpp writes a stack dump to the serial interface
after a Hardware Watchdog Timer has struck and a new boot cycle has begun.
The sketch must properly initialized the Serial port before the crash.

hwdt_app_entry.cpp is the core file that does the work.

* Corrected Style. Improved HWDT reset detectionat boot.

* Style and typos

* Update comments.

* Improvements to reset reason determination.
Improved comments.
Added option to match the UART speed used by the sketch.
Added option to print greeting at the start to indicate the HWDT stack dump code is active.
Isolated logic for handling strings: one assuming they are not inited at
the time the code is running and one that does. The later appears to be the case.

* Style plus
Fix issue with HWDT reason detection when sketch crashes too fast.
Added sample sketch menu option for crashing with a function defined
with a weak attribute via prototype, but never actually defined in
full function form. eg. `void trouble(void){return;}`

* Moved all configuration options to the top.
Adjusted configuration option order for most likely to be used to the top.
Tried to improve comments.
Replace numbers with enum values.

* Removed clutter of having an alternate printing method.
Regular global strings have worked reliably.
Tweaked reset reason detection.
Reordered elements in global structure.
Improve #if test for debug option
Always improving comments.

* Added delays around uart_div_modify. This appeara to resolve the lost
data problem that occurs when printing after a flash upload using esptool.
Curiously, esptool stub also uses similar delays.
Word choices and description improvements.

* Finished TODO looked at assembly of app_entry_redefinable to confirm
no mixed up stack frame was created. Also removed no longer needed
extra level of function calling.
Use existing macros from uart_register,h to handle getting current
UART speed. Added some missing `const`.

* Comment changes.
Added a few newlines to printing.
Decreased the settling delay after the uart_div_modify call.

* Improved comments.
Print caution message when stack integrity checks failed.

* Several corrections to set_uart_speed
Comment improvements
Added missing ";"

* Removed unused include.
Code cleanup.
Comments.

* Now runs from flash before SDK is started.
Cache_Read_Enable working. Free 1K of IRAM and 200 bytes of DRAM.

* Changed ICACHE size from 32K to 16K to avoid conflict with
SDK or core selecting smaller 16K ICACHE.

The Issue: Cache_Read_Enable does not clear the bit field when mapping IRAM to
ICACHE on register 0x3FF00024. Thus, no problem upgrading from 16K to 32K;
however, you cannot downgrade from 32K to 16K. These bits are cleared at boot.

Improved uart data rate change handling.

Update comments.

* Added support to print ThunkStack.
Adjustments to inline asm. Added "memory" when callx0 is used.

* comment cleanup. added missing additional #if defined()
Made structure name unique. Changed HWDT_INFO to HWDR_INFO_S.

* Update style used for structure and typedef to match that used in core
when snake case is used. Moved a constexpr block up a scope so that
some #ifdef debug code compiles again.

* Updated comments

* Corrected new errors from upgrade to GCC 10.1 toolchain related to
constexpr and casting integers to pointers.
Cleared warning for asm.

* Work around divide by 0 HWDT event under toolchain 10.1.

* Changes to move feature into core.

Making ready for selection via tools menu, updated defines to DEBUG_ESP_,,, format.
Added HWDT and HWDT_NO4KEXTRA options to boards.txt.py. These options are selectable
from Arduino IDE 'Tools->Debug Level'
Converted macro names that use to be constexprs to uppercase.
Update comments. Added comments to maintainers anotated by '//C'
Revised example.

* Fix stack character buffer length.

* Updated comment to reflect support via Arduino IDE Tools menu.

* Improve meshing of HWDT and NOEXTRA4K

* Made compatible with `disable_extra4k_at_link_time()` usage.

Changed to strings containing "no4kextra" to "noextra4k" to be consistant with
original usage.

Updated example to provide indications of which build options were used or resulted.

Some comment cleanup.

* CI style

* Adjusted down the ROM Stack space for the extra 4K Heap option.
If too large, a really bad crashes occurs.

Updated the example to start WiFi. This helps double check ROM
Stack space size is not too small at start.

Removed stale comment.

Changed cont stack check functions to make globally available.

* Add replacement aes_unwrap for the debug HWDT option.
Improves the SYS stack space available when using the extra 4K Heap
option in conjunction with HWDT. Replaces the ROM AES buffer at
0x3FFFEA80 with one provided by malloc().

* Update umm_info_safe_printf_P to support default of unaligned PROGMEM strings.

* Improve cont stack trace for yielding case.
Check if cont stack is yielding to SYS, use g_pcont->sp_yield to limit the
amount of the cont stack dumped.

Generalized dev logic path to create a generalized debug function hwdt_pre_sdk_init_icache.

* Added missed update to heap.cpp for change to use PSTR instead of PSTR4

* Updated comments and #if in aes_unwrap.

* Update boards.txt
2021-04-08 01:35:49 +02:00
PurpleAir
57fbd69a93
Merge branch 'master' into master 2021-04-04 15:43:19 -06:00
david gauchard
0593cbdc00
Merge branch 'master' into master 2021-04-04 23:02:43 +02:00
Dirk O. Kaar
cd7d137774 Per review. 2021-04-04 19:36:38 +02:00
Dirk O. Kaar
2e214843db Minor code cleanup. 2021-03-31 15:33:57 +02:00