1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

466 Commits

Author SHA1 Message Date
Ivan Grokhotkov
ce1b64bc43 Merge pull request #1320 from alltheblinkythings/SerialInterframeFixes
Fixes for poor HardwareSerial performance/crashes exacerbated by SDK1.5
2016-01-04 21:26:59 +08:00
Markus Sattler
995f02f437 add more debug levels 2016-01-02 12:54:34 +01:00
Markus Sattler
2b23b005aa allow control of enabling debug and debug level from IDE 2016-01-02 12:25:39 +01:00
Christopher Pascoe
9d7c2fd5be Remove duplicate 'return' (copy-and-paste error). 2015-12-29 17:04:15 -05:00
Christopher Pascoe
bc9493e690 Remove tracking of whether write() was called.
Tracking _written was required on AVR devices to work around a hardware
limitation when implementing flush().  The ESP8266 doesn't have the same
issue, so we can remove the tracking and make write() more lightweight.

The cost is a minor increase in work done in flush() when write() was not
previously called, but this should be much rarer than individual character
writes.
2015-12-29 12:46:25 -05:00
Christopher Pascoe
4ef0466578 Don't trip the WDT if interrupts are disabled during write() or flush().
Prior to this change, if interrupts were disabled during a call to
HardwareSerial::write() when the circular buffer was full, or
HardwareSerial::flush() when the circular buffer was non-empty,
we would loop forever and trip a watchdog timeout.
2015-12-29 12:05:15 -05:00
Markus Sattler
d9a7a816d5 include core_esp8266_features.h in arduino.h for easier usage, and add WIFI_HAS_EVENT_CALLBACK 2015-12-29 17:44:00 +01:00
Markus Sattler
85905c12f2 allow multiple event callbacks and add filter option 2015-12-29 17:31:57 +01:00
Markus Sattler
7edcda4a0f IPAddress allow uint32_t compare 2015-12-29 15:26:14 +01:00
Christopher Pascoe
c8772cfcd0 Make HardwareSerial::begin() and end() interrupt safe and disable TX/RX if we can't allocate a buffer for them.
Prior to this change, the interrupt could fire during initialisation,
necessitating a deep check that the HardwareSerial structure had valid
_tx_buffer or _rx_buffer each time an interrupt occurred.

By keeping uart_t's and HardwareSerial's (txEnabled, _tx_buffer) and
(rxEnabled, _rx_buffer) in sync, we can remove this extra check, as
well as fixing a null pointer dereference if e.g. _tx_buffer allocation
failed and write() was subsequently called.
2015-12-28 19:11:12 -05:00
Christopher Pascoe
cfe7ae1118 Put HardwareSerial and cbuf methods called from interrupt context in RAM.
This is required per the non-OS SDK doc, which states:
  "Using non-OS SDK, please do not call any function defined with
  ICACHE_FLASH_ATTR in the interrupt handler."

This avoids an "Illegal instruction" exception with epc1 pointing at a valid
instruction (in flash) for one of the moved methods.
2015-12-28 18:35:27 -05:00
Christopher Pascoe
83398f6011 Don't bother testing isRxEnabled() on UART1 - it is always false. 2015-12-28 17:55:16 -05:00
Christopher Pascoe
e83dd4d241 Use lightweight tests when we only care if the buffer is empty or full. 2015-12-28 17:53:10 -05:00
Christopher Pascoe
e147314f97 Re-enable interrupts before directly enqueuing characters in the UART FIFO.
Not sure why, but this reduces the occurrence rate of an occasional ~3.25 or
~7μs intercharacter delay, which was interfering with use of the UART to
generate precise timing pulses (such as driving WS2812 LEDs).
2015-12-28 17:44:28 -05:00
Markus Sattler
50ad8ccdf5 rework StreamString::write to use String internal buffer direct.
#1289
2015-12-23 13:40:16 +01:00
Ivan Grokhotkov
1c7b81660b Merge pull request #1289 from gtalusan/short_writes
handle short writes
2015-12-23 10:15:57 +03:00
Ivan Grokhotkov
60baf802e1 Add function to measure stack high water mark (thanks @g3gg0) 2015-12-23 10:13:01 +03:00
Ivan Grokhotkov
66a88ac8d2 Fix bad DEBUGV argument (thanks @g3gg0) 2015-12-23 10:11:40 +03:00
George Talusan
70c85c0901 handle short writes 2015-12-22 21:31:30 -05:00
Ivan Grokhotkov
cda14204fe Fix SPIFFS path length check, add notes about FSInfo structure (#1273) 2015-12-22 11:52:50 +03:00
Ivan Grokhotkov
d460de8879 Merge branch 'me-no-dev-master'
* me-no-dev-master:
  fix identation
  optimize pwm interrupt handler for better precision
2015-12-22 11:17:33 +03:00
Christopher Pascoe
63f1e40106 Fix RAM corruption caused by our hook of register_chipv6_phy(init_data*).
"init_data", when non-NULL, is on the heap, and the register_chipv6_phy call
sometimes modifies data in (at least) the offset range [128:249], suggesting
that it is a buffer larger than 128 bytes in size (the size of our
"phy_init_data" buffer).  When we use our static buffer (prior to this
change), the call could would overwrite the .rodata section and lead to
undefined behaviour.

To address this, just patch the heap-allocated buffer with our data.

Move phy_init_data to flash as it's now readonly and never modified.
2015-12-21 19:18:29 -08:00
Me No Dev
a33dba099f fix identation 2015-12-21 13:54:29 +02:00
Me No Dev
1ae423021a optimize pwm interrupt handler for better precision 2015-12-21 13:50:29 +02:00
Markus Sattler
fa7f7bde81 add _verifyHeader and _verifyEnd
_verifyHeader is called before the beginning of the update progress to verify the first byte using peek
_verifyEnd is called on the end before the eboot command is written to verify first byte + flash config

add missing _reset() on timeout
2015-12-20 12:45:36 +01:00
Markus Sattler
53e01932d3 add magic byte check for Update class
Note: only check of first 0xE9 possible.
2015-12-20 11:46:00 +01:00
Markus Sattler
898737422e ESP class - move interpretation of magic bytes in function 2015-12-19 14:30:13 +01:00
Markus Sattler
8032f77476 add missing ! for the checkFlashConfig call 2015-12-18 08:37:25 +01:00
Markus Sattler
02e6b2fc16 setMD5 has now returns bool
handle setMD5 failed in HTTP update
reset UpdaterClass when MD5 check failed
see: #1244
2015-12-18 08:30:35 +01:00
Ivan Grokhotkov
b66ddbf93a Update to SDK 1.5 (#1102) 2015-12-17 23:14:59 +03:00
Markus Sattler
f57ab609ec move flash size check to a function in ESP class,
allow real size bigger the IDE for Update
2015-12-17 13:02:14 +01:00
Markus Sattler
b2de8735c8 check current flash before starting update, to avoid update problems.
see: #1111
2015-12-16 19:45:55 +01:00
Christopher Pascoe
55e0dab799 Protect HardwareSerial's cbuf usage with InterruptLock. 2015-12-13 19:39:47 -08:00
Christopher Pascoe
afbc049cc9 Make the circular buffer's _size and _bufend members immutable. 2015-12-13 19:17:15 -08:00
Ivan Grokhotkov
e7024fb5b4 SPIFFS: check if path length is valid (#1089) 2015-12-10 23:25:54 +03:00
Markus Sattler
7ea4eb452d fix String bug
length where returning something that is not 0 while buffer where NULL!?
2015-12-10 17:37:09 +01:00
Markus Sattler
49536c78d3 add more debug to Updater.cpp 2015-12-10 17:24:39 +01:00
Markus Sattler
0389657614 give the IP stack more time to handle the data
may help with #1157
2015-12-10 12:48:36 +01:00
Markus Sattler
a9ce1b4f2e add Authorization support for HTTP client 2015-12-09 13:51:55 +01:00
Markus Sattler
62f38bfef3 add base64 class 2015-12-09 13:51:39 +01:00
Markus Sattler
44af3d5e89 Merge remote-tracking branch 'remotes/esp8266/master' 2015-12-08 11:33:25 +01:00
Markus Sattler
02e22b38cb add define RANDOM_REG32 ESP8266_DREG(0x20E44) 2015-12-08 11:33:15 +01:00
Ivan Grokhotkov
93aaa8667d Merge pull request #1166 from alltheblinkythings/SerialStuff
Always arm the "TX FIFO Empty" interrupt after we write into _tx_buffer.
2015-12-07 22:10:41 +03:00
Jens Hauke
dd89de4dad Make pgm_read_byte() and pgm_read_word() usable from c files.
The two defines used reinterpret_cast<> which is only available when
compiling with c++. Now using plain old c casts instead.
2015-12-07 18:01:15 +01:00
Christopher Pascoe
d8417c2855 Remove a check in room() for (_begin == _end). It's covered by the (_end >= _begin) case. 2015-12-07 00:31:46 -08:00
Christopher Pascoe
7133a6c1f9 Ensure that we never write an out of bounds value (_bufend) to _begin or _end, even temporarily.
Testing:
  - Boot tested, ran basic serial I/O code

Notes:
  - Before this change, there are instruction like "s32i.n <reg>, <this>, <_begin>" in the
    disassembled output, followed by an overwrite if <reg> turns out to be _bufend.
    After this change, there is only one store instruction to <_begin> per function.
2015-12-07 00:23:46 -08:00
Christopher Pascoe
cc0a8ead55 Always arm the "TX FIFO Empty" interrupt after we write into _tx_buffer.
This avoids a race where the interrupt handler detects an empty _tx_buffer
just before we write data into it.

Note that commit d6f62943d4b511e7d5fe6147096c8979890416f5 works around
this race when data is continually added to _tx_buffer in the hung state.
We revert that change here as the race should no longer occur.

Testing performed:
 - set UART_CONF1.txfifo_empty_thrhd=0x70 (which exacerbates the issue)
 - generate a ~240 byte burst of data, sent in back-to-back Serial1.write(, 4)
   calls, optionally followed by a Serial1.flush()
Test results:
 - before this change, observe occasional unsent data and hang in flush()
   (if used).
 - after this change, data is sent as expected.
2015-12-06 21:03:05 -08:00
Ivan Grokhotkov
ee314f2cdc fix portInput(Output, Mode)Register definitions to return pointers (#1110) 2015-12-06 20:54:35 +03:00
Ivan Grokhotkov
c6c7d24750 Add __throw_logic_error (#1136) 2015-12-06 20:39:54 +03:00
Markus Sattler
0173749ef2 Merge remote-tracking branch 'remotes/esp8266/master' 2015-12-05 17:19:05 +01:00