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

993 Commits

Author SHA1 Message Date
Drzony
79ea883fb3
New flash writing method with offset/memory/size alignment handling (#7514)
* Do not write more data than requested on PUYA flashes

* Always align flash reads/writes to 4 bytes

* fixup! Always align flash reads/writes to 4 bytes

This commit simplifies the code a bit and fixes a bug that caused wrong number of bytes to be
written

* fixup! Always align flash reads/writes to 4 bytes

* fixup! Always align flash reads/writes to 4 bytes

* Check for result before additional read/write

* Add overloads for unaligned reads/writes

* fixup! Add overloads for unaligned reads/writes

* fixup! Add overloads for unaligned reads/writes

* fixup! Add overloads for unaligned reads/writes

* fixup! Add overloads for unaligned reads/writes

* fixup! Add overloads for unaligned reads/writes

* fixup! Add overloads for unaligned reads/writes

* fixup! Add overloads for unaligned reads/writes

* Add tests for flashRead/flashWrite

* fixup! Add overloads for unaligned reads/writes

* fixup! Add tests for flashRead/flashWrite

* fixup! Add tests for flashRead/flashWrite

* fixup! Add overloads for unaligned reads/writes
2020-10-14 22:21:41 -07:00
Max Prokhorov
36b444dba3
Allow test framework to use cores/esp8266/Arduino.h directly (#7377)
* Allow test framework to use cores/esp8266/Arduino.h directly
* fix wps debugging
* some more missing debug.h
* Hunt down debug.h and roll-back
  TODO: rename it to something else... it is an internal header
* Move abs+round checks to test/device/test_sw
* Restore macros for C code
* fixup! Move abs+round checks to test/device/test_sw
* Fix bad c/p, actually try round with ints
* tweak c macros per review
* fix gcc-10 missing cerrno include
2020-10-06 16:18:00 +02:00
Harald
01cfc54ccb
Add missing sntp_init/sntp_stop (#7628) 2020-10-06 12:31:45 +02:00
Dirk Mueller
4aeb0f5cca
Use direct member initialization instead of ctr initialisation (#7558)
* Use direct member initialization instead of ctr initialisation

This removes a bit of code repetition.

* Add symbolic names for member initializers
2020-10-05 13:56:08 -07:00
Dirk O. Kaar
6f57c222c1 Eliminate code duplication by template for printNumber(...)/printFloat(...).
Move template defintion into cpp file - valid for private member function templates.
2020-09-30 20:29:53 +02:00
Dirk O. Kaar
0b502b3f7b Eliminate code duplication by template for println(...). 2020-09-30 20:29:53 +02:00
Dirk O. Kaar
8c725d5736 Fix for 32bit long used in long long printNumber. 2020-09-30 20:29:53 +02:00
Dirk O. Kaar
7e1d891e84 Revert to explicit calculation of modulo, saving 16 bytes in IROM. 2020-09-30 20:29:53 +02:00
Dirk O. Kaar
af53772e7b Extend Print class for 64bit integers. 2020-09-30 20:29:53 +02:00
Max Prokhorov
cc042b99d1
WString: c_str() returns null pointer after move (#7611)
* (test) WString: c_str() returns null pointer

target = std::move(source) does not reset buffer pointer back to the sso

* wstring: correctly do move invalidation & copy

based on the #7553 without isSSO -> isHeap rename and inline optimizations
additionally, remove useless pre-c++11 preprocessor checks

Co-authored-by: Takayuki 'January June' Suwa <jjsuwa@sys3175.com>
2020-09-27 08:11:52 -07:00
Labor-Et-Ars
a3281fe2f3
LEA mDNS v2 (#7540)
* LEAmDNSv2
2020-09-25 11:12:39 +02:00
Max Prokhorov
c24109fd57
WString: mark move ctor as noexcept (#7610)
ref.
- https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-move-noexcept
- https://rules.sonarsource.com/cpp/RSPEC-5018?search=noexecept
- https://clang.llvm.org/extra/clang-tidy/checks/performance-noexcept-move-constructor.html

> Move constructors of all the types used with STL containers, for
example, need to be declared noexcept. Otherwise STL will choose copy
constructors instead. The same is valid for move assignment operations.
2020-09-23 19:35:32 -07:00
david gauchard
40eb5747e4
sntp: use one time source and fix unsynchronized sntp time stamp (#7595)
* sntp: use one time source and fix unsynchronized sntp time stamp
* show subsecond synchro between time() and gettimeofday()
2020-09-12 18:22:38 +02:00
Ruggero Tomaselli
a460cb7935
Add clear method to IPAddress (#7586) 2020-09-09 12:24:35 +02:00
Ruggero Tomaselli
08f170510d
Check also if IP is not IPADDR_NONE (#7585) 2020-09-09 12:03:41 +02:00
Earle F. Philhower, III
2171a2e852
Fix gzip+signed OTA error (#7577)
The last 4 bytes of a GZIP file is the decompressed file length, and
are used in eboot to do sanity checks and know when decompression is
done.

Updater was incorrectly telling eboot to look at
"end-of-bin + sizeof(signing)", and when eboot did so it got an
incorrect value causing either the update to be skipped or for only a
portion of update to be completed.

Fix by adjusting the size back to the end of binary.
Fixes #7570
2020-09-04 08:57:03 -07:00
Dirk Mueller
8b7126d9e3
Fixup weird combination of oneline/multi line comments (#7566)
Although GCC seems to be able to grok it, it looks weird
in my editor. this is the only place in the code base where
this combination is used, so I hope its okay to remove it.
2020-09-02 08:55:44 -07:00
Dirk O. Kaar
c74dcc924c Force gcc inlining, use same style for getCycleCount as for getCpuFreqMHz. 2020-08-31 15:59:52 +02:00
Dirk O. Kaar
400632f818 Even more concise #if form. 2020-08-31 15:59:52 +02:00
Dirk O. Kaar
72051eea91 Inline, fewer LOC, remove redundant definition in cpp. 2020-08-31 15:59:52 +02:00
Earle F. Philhower, III
247d5f1218
Merge branch 'master' into stdnothrow 2020-08-30 12:39:55 -07:00
Dirk Mueller
953dfd945f
Avoid float-double-conversion (#7559)
Converting floats to doubles is very expensive on esp8266, so prefer
calculations or comparisons as float. This saves 10% (20 bytes) of the
String::parseFloat() code size and probably quite a bit of runtime
overhead.
2020-08-28 17:09:44 -04:00
david gauchard
53e4dec51f
getCpuFreqMHz(): fix when F_CPU is not defined (#7554) 2020-08-27 21:56:03 +02:00
david gauchard
f23e765ab1 fix displaying caller address 2020-08-25 11:00:48 +02:00
david gauchard
c111713208 overwrite weak new (std::nothrow) calls 2020-08-24 22:42:29 +02:00
david gauchard
2b6423edcc new w/ OOM raises an exception, shows the caller address for decoders 2020-08-24 22:15:33 +02:00
david gauchard
11f7d1766e remove (std::nothrow) where nullptr case is not handled
remove legacy new management
2020-08-24 09:51:58 +02:00
david gauchard
a16e1e5b8a fixes 2020-08-23 19:43:32 +02:00
david gauchard
f23caa2dcd Merge branch 'master' into stdnothrow 2020-08-23 19:28:21 +02:00
Cristian Popescu
c33a6a261d
Updater MD5 cleanup on begin (#7534)
Co-authored-by: Cristian Popescu <cristian.popescu@esolutions.ro>
2020-08-17 17:26:22 -07:00
david gauchard
6925982284 replace new by new (std::nothrow), remove arduino_new 2020-08-17 18:15:45 +02:00
Earle F. Philhower, III
5b3d290de8
Add synthetic IntegerDivideByZero exception (#7496)
The ROM routine __divsi3 is called by code whenever a division is needed,
because there is no divide unit on the ESP8266 core.  When the divide
routine in ROM hits a div-by-zero case, it jumpt to an ILL(egal instruction)
at a fixed address which causes a HW exception 0 (IllegalInsnException).

In the postmortem dump, when an ILL exception is detected at this address
in ROM, convert it to a DivByZeroException for printout (6).

Divde by zero errors now print as follows:
````
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (6):
epc1=0x4000dce5 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>
...
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
````

And will decode as follows:
````
Exception 6: IntegerDivideByZero: QUOS, QUOU, REMS, or REMU divisor operand is zero
PC: 0x4000dce5
EXCVADDR: 0x00000000

Decoding stack results
...
````
2020-08-16 17:50:17 -07:00
david gauchard
e0fedc577b
avoid circular #include dependence for PolledTimeout (#7356)
* move features to features.h

* fix std:: dependencies

* fix emulation on host

* api explanation
2020-08-15 15:24:35 -04:00
david gauchard
6feda9ebda
base64 class uses String, adding harmless #include (#7517) 2020-08-11 14:30:39 +02:00
Earle F. Philhower, III
3e567e9489
Add SerialEvent() callback to loop processing (#7505)
* Add SerialEvent() callback to loop processing

Match the AVR SerialEvent implicit callback.  Callback is executed
in normal user mode, not IRQ, so standard processing can be uses.

Fixes #752 after 5 years. :)

* Fix style
2020-08-05 20:13:37 -04:00
Earle F. Philhower, III
fc1aa554cd
Remove warnings when buinding NoAssert (#7499)
Parameters that are only used in an assert() statement are unused when
the NoAssert-NDEBUG option is used.  This causes the following unused
parameter warnings while building:

````
/home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Crypto.cpp: In function 'String {anonymous}::createBearsslHmac(const br_hash_class*, uint8_t, const String&, const void*, size_t, size_t)':
/home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Crypto.cpp:101:71: warning: unused parameter 'hashTypeNaturalLength' [-Wunused-parameter]
  101 | String createBearsslHmac(const br_hash_class *hashType, const uint8_t hashTypeNaturalLength, const String &message, const void *hashKey, const size_t hashKeyLength, const size_t hmacLength)
      |                                                         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Crypto.cpp: In function 'String {anonymous}::createBearsslHmacCT(const br_hash_class*, uint8_t, const String&, const void*, size_t, size_t)':
/home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Crypto.cpp:153:73: warning: unused parameter 'hashTypeNaturalLength' [-Wunused-parameter]
  153 | String createBearsslHmacCT(const br_hash_class *hashType, const uint8_t hashTypeNaturalLength, const String &message, const void *hashKey, const size_t hashKeyLength, const size_t hmacLength)
      |                                                           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
````

Mark them unused in the code to avoid the error.  The assert() still
works.
2020-08-03 18:03:23 -07:00
Drzony
85ea47e9bc
Fixed PUYA flash write buffer alignment (#7491)
* Fixed PUYA flash write buffer alignment (round up)
2020-07-30 11:03:49 -04:00
Earle F. Philhower, III
a679869155
BREAKING - analogWriteRange 8-bit default (#7456)
Matching standard Arduino cores, make the default analogWrite() take
values from 0...255.  Users can always use the analogWriteRange() call
to change to a different setup.

Add a `analogWriteResolution` which takes a number of bits and sets
the range from 0...(1<<bits)-1, part of the standard Arduino API.

Remove the PWMRANGE define.  It's non-standard and not generally valid
(i.e. it's fixed at 1024 of 256, but the real range varies depending on
what you last set).

Also add note about the change and how to fix pre 3.0 applications.

Fixes #2895
2020-07-28 17:39:38 -07:00
david gauchard
33083861c8
webserver hook: allow to handle external http protocol (#7459)
* webhook api
* simplify webserver debug printouts, move text to flash
* Hook examples in HelloServer example
* print executable code address in example
* simplify example per @mcspr suggestion
2020-07-28 23:34:26 +02:00
M Hightower
e815b9219b
Correct stack string buffer length. (#7488)
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
2020-07-26 10:01:21 -07:00
Jorg Neves Bliesener
0e12906950
Initialize _ledPin (#7487)
* Initialize _ledPin

_ledPin should be initialized to -1 in the constructor to avoid setting a random pin when calling Updater::end without having called Updater::begin before. This happens, for example, in the Homie software

* Fix field sequence
2020-07-26 12:39:55 -04:00
Develo
a6ccad4a24
Update Arduino.h (#7440) 2020-07-09 13:22:52 -07:00
david gauchard
af1bc71a9e
remove lwip-v1.4 specific code (#7436)
* remove lwip-v1.4 specific code

* ditto

* ditto

* fix ip4_addr definition

* CI: change debug builds to use IPv6, remove regular IPv6 builds

* ditto

* split pio CI in four (because they last twice the time of the other builds)

* remove option from pio

* remove lwIP-1.4 from doc

* restore pio CI splitting

* fix CI debug6 script

* ditto
2020-07-09 09:59:49 -07:00
Earle F. Philhower, III
d979b57d76
Upgrade to GCC 10.1 toolchain (#6294)
* Upgrade to GCC 9.1 toolchain

* Rebuilt using pure GNU binutils and GCC

Remove dependencies on earlier forked GNU utilities (gcc-xtensa,
binutils-gdb-xtensa) and just use GCC sources, unmodified (except for
patches in the esp-quick-toolchain directories).

* Rebuild bearssl using new toolchain

* Fix GDBstub linkage options

GDB works with pure GNU GCC and pure GNU binutils now.  Still warnings
galore, but tested with the example sketch in the docs.

* Fix digitalRead alias warning

* Remove gdb stub warnings w/a pragma

* Fix deprecated implicit copy ctors in IP code

Fix some warnings present in GCC8/9 in the IPAddress code

In AddressListIterator there was a copy constructor which simply copied
the structure bit-for-bit.  That's the default operation, so remove it
to avoid the warning there.

IPAddress, add a default copy constructor since the other copy
constructors are simply parsing from one format into a native ip_addr_t.

@d-a-v, can you give these a look over and see if they're good (since
IP stuff is really your domain).

* Fix AxTLS alias function defs to match real code

* Fix WiFiClientSecure implicit default copy ctor

These both use shared-ptrs to handle refcnts to allocated data, so using
the default copy constructor is fine (and has been in use for a long
time).

* Dummy size for heap to avoid GCC 8/9 warnings

Make GCC think _heap_start is large enough to avoid the basic (and
incorrect) bounds-checking warnings it produces.  The size chosen is
arbitrary and does not affect the actual size of the heap in any way.

* Make heap an undefined extend array

Instead of a bogus size, use an indefinite size for the heap to avoid
GCC warnings

* Trivial tab to space fix

* Update SDFat to remove FatFile warnings

* Fix ticker function cast warnings in GCC 9

The callback function is defined to take a (void*) as parameter, but our
templates let users use anything that fits inside sizeof(void*) to be
passed in.  Add pragmas to stop GCC warnings about this, since we
already check the size of the type will fit in the allocated space.

* Remove GCC support fcn that's in ROM

Manually delete the divdi3.so from the libgcc.a library by running the
updated EQT's 9.1-post script.

* Make exceptions work again, get std::regex up

Exceptions are broken on all builds (GCC4.8-9.1) due to the removal of
the PROGMEM non-32b read exception handler (added in the unstable
pre3.0.0).

Build the exception code with -mforce-l32 and patch
accordingly to avoid LoadStore errors.

Apply patches to select portions of the regex lib which use _stype_
(which is now in flash).

* Rebuild Bearssl using latest GCC push

* Automate building of BearSSL and LWIP w/new toolchain

* Workaround g++ template section problem for exception strings

G++ seems to throw out the section attributes for templates.  This means
that the __EXCSTR(a synonym for "PSTR()") is ignored and exception.what
strings are stored in RODATA, eating up RAM.

Workaround by using the linker to place the strings keying off their name
("*__exception_what__*").

* Rebuild moving exception.what to unique names

Exception.whats are now all in __exception_what__ and can be moved by
the linker to flash.  Works aroung G++ issue with segments being lost in
templates.

* Rebuild with new LWIP locking

* Update to latest libs, save iram

Move two GCC FP support routines out of iram since they are in ROM
already, saving some add'l IRAM.  Same list as gcc 4.8.

* Update BearSSL to latest release

* Fix umm_perf reference to ROM function

* Fix "reinterpret_case is not a constexpr" error

In GCC 9 (and 8 from what I read on SO), a cast of a const int to a
function pointer (via explicit or implicit reinterpret_cast) is not a
constexpr.
````
/home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_performance.cpp:45:36: error: a reinterpret_cast is not a constant expression
   45 | int constexpr (*_rom_putc1)(int) = (int (*)(int))(void*)0x40001dcc;
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
````

Remove the constexpr, potentially increasing heap usage by 4 bytes in
debug mode.

* Update libc.a to latest rev

* Full rebuild of toolchain and libs

* Upgrade to GCC 9.2, released in August 2019

Add builds for all 5 cross-compiles to pass CI

* Move to --std=gnu++14 (C++14 + GNU extensions)

* Fix Ticker merge conflict

* Fix json merge conflict

* One more merge diff fix

* Reapply Ticker.h casting warning fixes for gcc9

* Update with fixes from Sming repo for PSTR and ASM

* Upgrade to -gnu4 toolchain

* Move to gnu5 build with add'l softFP from ROM

* Move add'l softFP from IRAM to flash

Per @mikee47, we miss sone add'l soft-FP routined in the linker which
makes them end up in IRAM.  Move them explicitly into flash, like a
couple others we have already done this for.

* Move to std=c++17/c17 in platform, remove abs/round

Move to C++17 and C17 standards on the compiler options.

Remove "register" from core since it is deprecated.

Remove the #define abs() and #define round() which a) overwrote the
C stdlib definitions, poorly, and b) broke the GCC core code which used
"abs" as an internal function name.

Now abs() returns an integer, and not whatever was being absoluted.
fabs() etc. can be used if users need fload/double suport.

round() returns a double now, which is basically what it was returning
in the original case since adding/subtracting by a FP.

* Use std::abs/round to replace the macro definitions

Per discussion w/@devyte, preserve the abs() and round() functionality
via the using statement.

* Remove using std::abs which conflicted with C lib headers

* Add 2nd arg (exception handler) to ets_isr_t

Disassembly of the ROM shows there are 2 params to the ets_isr_t
callback.  The first is the arg passed in, the second is a pointer to an
exception frame where you can get info about when the IRQ happened.

* Move the gdbstub example to a subdir

The Arduino IDE and the build CI don't build it without a subdir, so
make one for gdbstub's example so it's visible and tested.

* Fix ets_irq_arratch redefinition and core IRQ handlers

Remove a duplicated, different declaration for ets_irq_attach from
ets_sys.h.  It never really even matched the other declaration in the
same header.

Update the core to IRQ handlers to fix the prototype and include the
2nd, unused frame parameter.

* Actually rebuild the libc.a using GCC 9.2

* Fix SPISlave interrupt attach's 2nd parameter

* Rebuild eboot.elf with GCC 9

* Update to latest SoftwareSerial for Delegate fix

* Upgrade to GCC 9.3

* Rebuild all arch toolchains

* Move to GCC 10.1

* Merge master and fix eboot build

GCC10 now uses `-fno-common` so the eboot global variables were being
placed in IRAM.  Adjust the makefile and rebuild to fix.

* Built complete toolchain for all archs

* Pull in latest PSTR changes and fix GCC10.1 build

Somehow the prior GCC build's -mforce32 patch wasn't applying correctly,
but I was still able to get a binary.  Fixed.  Also pulled in latest
PSTR changes in progmem.h

* Update platform.io to platform C/C++ standards

* Use PR's toolchain in platformio build

* Fix several asm warnings in PIO build

* Optional stack smash protection -fstack-protector

Add a menu to enable GCC's built-in stack smash protection.  When a
subroutine goes past its end of stack, generate a crashdump on function
exit like:

````
GCC detected stack overrun
Stack corrupted, stack smash detected.

>>>stack>>>

ctx: cont
sp: 3fffff20 end: 3fffffc0 offset: 0000
3fffff20:  40202955 00000001 0000001c 4020287e
3fffff30:  feefeffe 000000fd 00000000 00000000
...
<<<stack<<<
````

Disabled by default because there is a small per-function code overhead
(and CPU time if the function is called very frequently and is very
small).

BearSSL and LWIP are not built using stack smash detection, yet.

* Fix duplicated stc=gnu99/c17 in build

* Dump faulting function PC in stack overflow

Report a fake exception to have the exception decoder print the actual
faulting function.  This won't tell you where in the function the issue
happened, but it will tell you the function name first and foremost.

* Rebuild with Platform.io JSON tag in release tgzs
2020-07-07 11:12:43 -07:00
david gauchard
39c79d9bab
prepare 2.7.2 (#7429) 2020-07-07 10:22:00 +02:00
M Hightower
b26388812a
For UMM_CRITICAL_METRICS fixed time_stats initializer. (#7390)
* Corrected missed edit in check_poison_block() change variable ok
to bool.

Updated time_stats (used by UMM_CRITICAL_METRICS) initializer to
include UMM_POINSON_CHECK_LITE.

Update maintenace comment block for UMM_REALLOC_...

* Add missing defined(UMM_INTEGRITY_CHECK) to heap.cpp.
Fixes build case of UMM_INTEGRITY_CHECK and Debug port: "disabled"
2020-06-21 15:34:25 -07:00
Earle F. Philhower, III
a70e834d1e
Add a "-- CUT HERE --" marker to exception output (#7369)
Users aren't reporting/seeing the actual PC of failures because they
are only copying the >>stack<< into the decoder and not the Exception
line.  Add an ALL CAPS "CUT HERE FOR EXCEPTION DECODER" line to the
output to make it blindingly obvious to include the full crashdump
both in bug reports as well as exception decodes.
2020-06-11 15:24:21 -07:00
hreintke
7346754c09
API change to faciliate executer to know the number of active callbacks (#7361) 2020-06-08 14:19:18 -04:00
M Hightower
83523c0259
umm_malloc manual merge with upstream (#7337)
* umm_malloc manual merge with upstream

* Fix divide by zero, case when heap is 100% allocated.

* Removed extra line.

* Fixed block count for debug build. This resolves OOM events for debug build.
Correct overstepping array when freeing.

* Handle another corner case in example HeapMetric.ino.
Comment corrections.

* Revert - ESP.getMaxFreeBlockSize() is back to indicating the size of a
contiguous block of memory before the umm_malloc overhead is removed.

* Stale code cleanup and comment improvements
2020-06-07 20:00:15 -07:00
Mike Nix
51daecc236
Xmc flash 2 (#7317)
* Remove unnecessary XMC support from eboot

eboot is always run with the flash access speed set to 20MHz, so
there is no need for special treatment of XMC chips.

* After eboot copies the new firmware into place, verify the copy.

If the data written to flash is as expected, the line cmp:0 will be displayed
after the usual @cp:0 from eboot.

* Disable interrupts during the precached part of _SPICommand()

For some reason this was an issue during the reboot after an OTA update.
2020-05-26 20:04:49 -04:00