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

717 Commits

Author SHA1 Message Date
aguaviva
cf21dfda64 i2s can send now buffers (#5349)
* i2s can send now buffers

* adding mono and stereo, with blocking and non blocking support

* fixing crash

* cosmetic changes

* we dont need the & 0xffff

* using unsigned integers since we'll never be using negative numbers
2018-11-24 02:00:34 -03:00
Matej Sychra
aa22c07312 clock stretch fix done right (#5363) 2018-11-22 14:21:21 -02:00
david gauchard
74ca42f829 Sketch emulation on host (#5342)
* WIP compile examples on host with 'make examples'

* WIP bufferize tcp input

* WIP Makefile

* WIP network to rework, tcp/udp to factorize, udp addresses broken

* minor changes to the core

* WIP basic udp working

* WIP mdns

* WIP mcast receiving, not sending

* WIP mdns OK

* beta version

* SSL + doc

* update travis host test command

* licenses

* typo

* doc: arduino builder is not around: declare functions before calling them

* fix with latest SSL PR, compile in 32 bits mode

* fix make clean

* make -m32 optional

* 32bits compiler ability tester

* WIP

* WIP (fix 1 vtable error, still another one to hunt with using spiffs)

* example astyle

* fix os_printf_plus

* load / save mock spiffs

* fix style

* fix using spiffs/mock

* don't mess ram

* update doc

* remove leftover

* optimization -Os except for CI, rename ARCH32 to FORCE32

* revert useless cast (not even compiled)

* remove unused function

* use proper type for pointer arithmetics

* makefile: sketch object and cpp file moved to bin/ directories
easier to clean, and IDE don't like them

* changes for review

* make use of %zd

* less verbose makefile by default (option)

* update readme
2018-11-20 18:51:45 -02:00
Earle F. Philhower, III
2f4380777e Move BearSSL from STACK_PROXY to a real, thunked 2nd stack (#5168)
* Update to BearSSL 0.6+ release, add AES_CCM modes

Pull in latest BearSSL head (0.6 + minor additions) release and add AES_CCM
modes to the encryption options.

* Enable the aes_ccm initialization in client/server

* Initial attempt

* Working code with second stack thunking

* Remove #ifdefs in .S file, not needed.

* Clean up thunks and remove separate stack flag

* Fix PIO assembler errors

* Remove #ifdef code changes, ensure same code as PC

Remove "#ifdef ESP8266;...;#else;...;#endif" brackets in BearSSL to
ensure the host-tested code is the same as the ESP8266-run code.

* Move to latest BearSSL w/EC progmem savings

* Merge with master

* Add br_thunk_* calls to do ref counting, painting

Add reference counting br_thunk_add/del_ref() to replace stack handling code
in the class.

Add in stack painting and max usage calculation.

* Add in postmortem stack dump hooks

When a crash occurs while in the second stack, dump the BSSL stack and
then also the stack that it was called from (either cont or sys).

* Update stack dump to match decoder expectations

* Move thunk to code core for linkiage

The thunk code needs to be visible to the core routines, so move it to the
cores/esp8266 directory.  Probably need to refactor the stack setup and the
bearssl portion to avoid dependency on bearssl libs in cores/esp8266

* Add 2nd stack dump utility routine

* Refactor once more, update stack size, add stress

Make stack_thunks generic, remove bearssl include inside of cores/esp8266.

Allocate the stack on a WiFiServerSecure object creation to avoid
fragmentation since we will need to allocate the stack to do any
connected work, anyway.

A stress test is now included which checks the total BearSSL second
stack usage for a variety of TLS handshake and certificate options
from badssl.org.

* Update to latest to-thunks branch

* Add BearSSL device test using stack stress

Run a series of SSL connection and transmission tests that stress
BearSSL and its stack usage to the device tests.

Modify device tests to include a possible SPIFFS generation and
upload when a make_spiffs.py file is present in a test directory.

* Use bearssl/master branch, not /to-thunks branch

Update to use the merged master branch of bearssl.  Should have no code
changes.
2018-11-14 23:29:24 -03:00
Earle F. Philhower, III
6e0c0e3dcc Only stop waveforms actually running in ISR (#5308)
The ISR could end up writing a 0 to a GPIO that had previously been
stopped, effectively overwriting user writes to those pins.  Fix to
only actually disable and write when a pin was enabled and times out.

Fixes #5306
2018-11-05 09:41:18 -03:00
Develo
8ae0746e4a
Add missing decrement operator to I2C clockCount (#5292) 2018-10-29 16:30:21 -03:00
Matej Sychra
cb05b86d49 I2C slave support (originally by bjoham) (#5226)
* I2C slave support; resolving conflicts against current master

* removed unused argument, updateded to hopefully pass Travis

* cleaning up commit as requested by https://github.com/esp8266/Arduino/pull/5162#pullrequestreview-162242359

* cleaning up commit as requested by https://github.com/esp8266/Arduino/pull/5162#pullrequestreview-162242359

* type fix
2018-10-26 12:04:16 -03:00
david gauchard
a063c2b36f
fix http parsing (#5262)
* follows #5252
* use const refs where relevant (aka stop being nasty with ram and cpu)
2018-10-23 22:17:54 +02:00
david gauchard
6218c40740 fix md5 comparison (#5265) 2018-10-20 23:20:25 -03:00
Earle F. Philhower, III
d742df84e5
Make stopWaveform call interrupt callable (#5248)
* Make stopWaveform call interrupt callable

Match the behavior of pre-2.4.2 PWM by allowing stopWaveform to be
called from an interrupt.

Fixes #5247

* Move to O2, save ~500 bytes of code

The actual runtime difference of -O2 vs -O3 is quite small, but -O3
takes ~500 more bytes of code (~300 more in IRAM, ~200 more in PMEM).
2018-10-16 16:39:22 -07:00
Earle F. Philhower, III
1b1b0a28a8
Add stack repainting call to ESP class (#5221)
Allow the unused stack to be reset to the check value at any time in
the application, allowing for delta-stack calculations to be done.

Add ESP.resetFreeContStack() class method for general use.

Add in some dumping in the BearSSL_Validation example to show the
usage for those that care.
2018-10-11 08:55:30 -07:00
david gauchard
9fb4a05d67 Fix led-pin in updater, also no need to backup LED state (#5217) 2018-10-08 07:02:27 -07:00
Jeroen88
13f374666d Add WiFiClient parameter to HTTPClient (#4980)
Make HTTPClient take a WiFiClient parameter, allowing you to pass in a
simple HTTP WiFiClient or a BearSSL or axTLS WiFiClientSecure with
any desired verification options.  Deprecate the older, TLSTraits methods.
Add basic HttpsClient example.

Add optional LED feedback to the Update class
2018-10-06 07:50:03 -07:00
david gauchard
83a8076db8 ClientContext (tcp) updates (#5089)
* +sync, get/set default nodelay, sync

* default nodelay=1

* update flush()

* fix return value

* ClientContext: put things together

* ClientContext: fix debugging messages

* WiFiClient: move static members out of the class, add comments

* remove circular dependency

* parameter and return value for Client::flush&stop, flush timeout raised to 300ms

* tcp flush: restart timer on ack receive

* OTA protocol needs setNoDelay(true)

* fix Ethernet with Client changes

* 1 line unredable -> 5 lines readable code

* doc

* Update client-class.rst

* Added details for getters
2018-09-25 10:47:27 -03:00
Earle F. Philhower, III
bc2d4ec18b Allow GPIO 9 and 10 for waveform generation (#5055)
* Allow GPIO 9 and 10 for waveform generation

While most ESP8266 modules use quad-io mode for their SPI flash ROM,
there are some which only use dual-io mode.  Allow the unused pins
(GPIO 9 and 10) to have waveforms generated on them.  Should the user try
this on a quad-io mode board, expect very bad things to happen.

* Add variant for 8285 to init GPIO 9/10

The 8285 only has 2-bit flash IO, so the other two pins can be used as
inputs (9/10).  Set them to input to mirror the way other pins are set
up.

* Update waveform gen to only allow 9/10 on 8285

Update the common.h in both generic (remove TODO, it's done!) and the
8285 variant to make isFlashInterfacePin macro correct.  Use that macro
to disable pins 9 and 10 in the common, non-8285 case.
2018-09-17 22:58:06 -03:00
Develo
0e0e34c614
implement EspClass::getFreeContStack method (#5133)
* implement EspClass::getFreeContStack method

* Remove unneeded extern

* Really remove unneeded extern
2018-09-13 16:02:53 -03:00
david gauchard
ce28a76a24 metric for heap fragmentation (#5090)
* +Esp.getHeapUnfragness()

* only in debug mode

* default value

* always enable, 64->32, light 32 integer square root, comments

* fix when debugging is disabled

* give credits

* cosmetics

* fragmentation metric updates (doc, better api, added getMaxFreeBlockSize())

* api reworked, +example

* fixe types, fix names

* coding style fix

* use astyle for example
2018-09-10 01:50:01 -03:00
Ivan Grokhotkov
0713a01db8 Fix iostream related issues (#5047)
* add stubs for more exception throw calls

Fixes https://github.com/esp8266/Arduino/issues/3358

* libc: make putc_r implementation weak

newlib provides its own implementation of _putc_r, which will call
_write_r (possibly after buffering). Make our implementation weak to
allow using the one from newlib.

Fixes https://github.com/esp8266/Arduino/issues/4630

* libc: fix incorrect return value of _write_r call

Should return number of bytes written, actually returned zero. This
resulted in std::cout going into failed state after the first write.

* tests: add test for output to std::cout
2018-08-26 13:47:01 -04:00
david gauchard
85e68093e9
Automatic stack location selection (SYS or HEAP), enable per library AR-chive in arduino build system (#5018)
Automatic stack location selection (SYS or HEAP), enable per library AR-chive in arduino build system 

* enable dot_a_linkage on internal libraries
* add device tests
* boards generator: deprecate --noextra4k/--allowWPS and fix documentation
2018-08-20 14:35:52 +02:00
Anthony Elder
5c7dbf4e4b Add instantly option to deepSleep (#5052)
* Add instantly option to deepSleep

* Move system_deep_sleep_instant to a new deepSleepInstant function
2018-08-19 05:46:33 -03:00
Anthony Elder
61cc11da22 revert e02932f (#619 works now without it) (#5056) 2018-08-19 04:38:18 -03:00
Earle F. Philhower, III
d96c8f393e
Move some exception strings to PROGMEM (#5050)
The memory allocation failure message was accidentally stored in RAM
and not in PROGMEM.

panic() did not place the __FILE__ string in PROGMEM, either.

Move both to PROGMEM, save ~64 bytes of heap (depends on size of path
of the Arduino core library).
2018-08-16 08:15:02 -07:00
Earle F. Philhower, III
831e75d79e Enclose PROGMEM segment names in quotes (#5049)
__FILE__ is used to name the segments used for each PROGMEM constant,
but __FILE__ may have a space in it.  This would cause compilation
errors.

Add quotes around the entire segment name to work around this.
2018-08-15 16:04:56 -03:00
Earle F. Philhower, III
56b98fd4df Move all PROGMEM to their own section (#5048)
According to the GCC man page, __section__ attributes should only be used
for global variables.  However, the PROGMEM and ICACHE_RODATA macros use
this variable decorator even for local variables.  Most of the time it works,
but when a static or inlined function tries to use a PROGMEM/PSTR/etc.
variable the compiler can throw an error like:
  error: XXX causes a section type conflict with YYY

Change the PROGMEM macro to emit a section name that is unique (a combo
of the file, line, and counter variables to ensure uniqueness).  The
standard linker script will place them properly in .IROM without
any changes.

Fixes #5036 and others.
2018-08-15 11:46:13 -03:00
Jeroen88
e4d9c279ef Function added to detect baudrate (#4978)
* Function added to detect baudrate

* Added uart_start_detect_baudrate, detectBaudrate() wrappers for HardwareSerial and an example usage SerialDetectBaudrate.ino

* Some layout changes to pass Travis tests

* Some more nitty-gritty layout changes to pass Travis tests

* Some even more nitty-gritty layout changes to pass Travis tests

* renamed one function to testBaudrate() and updated doc/reference.rst

* Minor updates to doc/reference.rst

* New lines added
2018-08-01 15:33:25 -04:00
WEMOS Electronics
799193888a Fix digitalPinToBitMask(), portOutputRegister(), portInputRegister() … (#4964)
* fix digitalPinToBitMask(), portOutputRegister(), portInputRegister() and portModeRegister() error when the pin is GPIO16.
2018-07-28 10:07:01 -07:00
Earle F. Philhower, III
9c846bd52e
Fix concat not 0-terminating when String shrunk (#4962)
As @devyte noticed, PR #4955 has an issue when you catenate a string to
itself and the string used to hold a longer value because it does not
explicitly 0-terminate the resulting string.  If the string was extended,
however, reserve() would 0-terminate by default.

Always terminate the result of `s += s;` now.
2018-07-26 09:07:28 -07:00
Earle F. Philhower, III
ff74813d54 Fix String creation and concat issues (#4955)
When a string is concatted to itself, the pointer to its c_str can change
due to realloc().  This would invalidate the passed-in pointer being
concatted, and cause a use-after-free error.  Special case this to avoid
the issue.  Now "a += a;" works properly.

Also use sprintf(%{l}d) instead of non-POSIX ltoa/itoa calls to construct a
string from a signed number (in base 10 only).  The non-posix versions don't
handle INT_MIN properly on either host_tests or on the ESP8266.
2018-07-24 16:20:57 -04:00
Earle F. Philhower, III
bde83e8ea2
Fix waveform missing edges on cycle rollover (#4945)
When the ESP cycle counter rolls over, the "now" can be smaller than the
next-edge time of a waveform generator.  This would cause the edge to be
missed on that specific pin, and make it look like PWM was hung.

Use proper comparison between current time and edge time.

Fixes #4944

Also remove the "sigma-delta.c.unused" file which was replaced by a
working one some time ago.
2018-07-21 18:46:51 -07:00
LaborEtArs
3f6be5ecc8 Adjusted buffer size algorithm (#4934)
Use cencode.h defined macros to calculate the needed buffer size.
2018-07-19 18:16:51 -04:00
Earle F. Philhower, III
63ab79e549
Fix overlapping memcpy call in String::trim (#4938)
memcpy() is undefined when source and destination overlap.  String::trim
uses it when shifting the string left to remove left padding.

Replace with memmove() which is always safe, even when overlapped.
2018-07-18 18:36:31 -07:00
Earle F. Philhower, III
96a340eb51 Fix intermittent host tests failure (#4932)
MD5Builder tests have been randomly, non-repeatably failing due to a problem
with the returned value of MD5Builder.

Valgrind detected a strncpy with an overlapping memory range, which is
an undefined operation.  Fix it with a memmove instead, and get rid
of a couple #define redefinitions which were causing compile warnings
on the host side as well.
2018-07-16 23:22:55 -04:00
Earle F. Philhower, III
fcf2ac5d3d
Optimize waveform stop routines (#4920)
Thanks to ideas from @shimarin for offering ideas to speed up the stopWaveform
calls which may help things like SoftwareSerial run better.

Optimize the stopWaveform routine to abort fast and early whenever possible.

Remove the stopWaveform call from digitalRead().  If you're running a waveform
on a pin and try to read it, that is a logic error and you'll end up reading the
waveform and not the outside world's view of the pin.
2018-07-12 12:45:48 -07:00
teejaydub
60b21ef568 Copy the existing flash mode over the one set in an OTA update image. (#4877) 2018-07-11 12:30:56 -04:00
Tomoatsu Shimada
e6af980b85 Avoid unnecessary waveform de-initialization which corrupts softwareserial (#4913) 2018-07-10 12:40:14 -07:00
Earle F. Philhower, III
d948a1ff2a
Don't stop a waveform simply by calling pinMode (#4906)
Setting a pin direction would cause a waveform generator attached to it to stop.
This could cause PWM to stop if pinMode() is called while running (as it was
called in __analogWrite()).

Remove the stopWaveform call from pinMode, the Tone, analogWrite, or Servo
that initiated the waveform has responsibility for stopping it (and it does)
when complete, irrespective of the pinMode.

Fixes #4905
2018-07-08 20:27:13 -07:00
david gauchard
e486887f18
optionally allow WPS (#4889) 2018-07-06 16:45:25 +02:00
liebman
12d52220ae pin 16 is allowed for analogWrite (#4895) 2018-07-05 18:19:52 -07:00
hreintke
87991aba9f ScheduledInterrupts should still use current schedule_function(..) (#4890) 2018-07-04 12:55:07 -04:00
david gauchard
d580f40e44
fix scheduled interrupt #4609 by @shimarin (#4879) 2018-07-02 23:33:55 +02:00
Earle F. Philhower, III
be7a732b9d Compatibility and IRQ fixed for waveform/tone/pwm (#4872)
* Compatibility and IRQ fixed for waveform/tone/pwm

Fix a compiler ambiguity introduced with a floating point frequency option
for tone().  Thanks to @Rob58329 for discovering this and proposing the
fix.

Match original analogWrite behavior by going from 0...1023 (PWMRANGE) and
not 0...1024, and also explicitly set the analogWrite pin to an OUTPUT.
Thanks to @jandrassy for finding this.

Fixes #4380 discovered by @cranphin where interrupts were disabled on a
stopWaveform().  Remove that completely and bracket the update of non-atomic
fields in the structure with disable/enable IRQs for safety.

* Fix tone(int,int,int) infinite loop

Explicitly cast the frequency, when passed in as an int, to an
unsigned int.  Verified with snippet:
  tone(D1, (int)1000, 500);
  tone(D1, (unsigned int)1000, 500);
  tone(D1, 1000.0, 500);
  tone(D1, (int)1000);
  tone(D1, (unsigned int)1000);
  tone(D1, 1000.0);
2018-07-02 13:02:49 -04:00
hreintke
641c5cdc61 Scheduled Interrupt (#4609)
* Scheduled Interrupt

* use capital letter for Schedule.h

* Prevent memory leak when attach is called multiple times without detach

* Add improved schedule_function

* WIP : Integrate FunctionalInterrupt & ScheduledInterrupt

* Fix travis error
2018-06-19 17:26:57 -04:00
Earle F. Philhower, III
ebda795f34
Support multiple tone(), analogWrite(), and Servo (#4640)
Remove and rewrite all the parts of the core/libraries using TIMER1
and consolidate into a single, shared waveform generation interrupt
structure.  Tone, analogWrite(), Servo all now just call into this
shared resource to perform their tasks so are all compatible
and can be used simultaneously.

This setup enables multiple tones, analogWrites, servos, and stepper
motors to be controlled with reasonable accuracy.  It uses both TIMER1
and the internal ESP cycle counter to handle timing of waveform edges.
TIMER1 is used in non-reload mode and only edges cause interrupts.  The
interrupt is started and stopped as required, minimizing overhead when
these features are not being used.

A generic "startWaveform(pin, high-US, low-US, runtime-US)" and
"stopWaveform(pin)" allow for further types of interfaces.  Minimum
high or low period is ~1 us.

Add a tone(float) method, useful when working with lower frequencies.

Fixes #4321.  Fixes 4349.
2018-06-07 18:38:58 -07:00
david gauchard
73d36bbc80
fix base64_encode_expected_len (#4786) 2018-06-07 15:40:17 +02:00
Earle F. Philhower, III
5a033835e1
Add a build directory for libbearssl.a (#4736)
Simple git submodule and makefile for building the bearssl library
from source in the Arduino tree.
2018-05-23 19:50:26 -07:00
fabianoms
758b0bd124 Minimizing code redundancy (#4695)
String's destructor does the same as the 'invalidate' method.
2018-04-28 17:02:08 -03:00
Ivan Grokhotkov
5d5ea92a4d
Move continuation stack from .bss onto sys stack (#4622) 2018-04-18 11:19:49 +08:00
Peter Hoddie
16a4f22194 save 192 RAM bytes when attachInterrupt unused (#4601) 2018-04-17 17:16:06 -03:00
david gauchard
2315ac20bc
import use of __PROG_TYPES_COMPAT__ define for compatibility with old arduino code (#4619)
restrict usage of deprecated typedefs "prog_*", and cast "pgm_read_*"'s address parameters to "const void*"  only when __PROG_TYPES_COMPAT__ is defined.
also add <avr/pgmspace.h> compatibility
2018-04-10 12:23:33 +02:00
Bryce Schober
3a110aa698 Allow other ESP debug port class types (#4611)
... by casting to void pointers before comparison to avoid compile error
2018-04-06 11:23:46 +02:00