8000 Merge branch 'WIP-upstream-umm_malloc' of github.com:mhightower83/Ard… · esp8266/Arduino@4612235 · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 4612235

Browse files
committed
Merge branch 'WIP-upstream-umm_malloc' of github.com:mhightower83/Arduino into WIP-upstream-umm_malloc
2 parents 71b10fd + da47a79 commit 4612235

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1118
-217
lines changed

boards.txt

Lines changed: 166 additions & 76 deletions
Large diffs are not rendered by default.

cores/esp8266/Print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ size_t Print::write(const uint8_t *buffer, size_t size) {
4545

4646
size_t n = 0;
4747
while (size--) {
48-
size_t ret = write(*buffer++);
48+
size_t ret = write(pgm_read_byte(buffer++));
4949
if (ret == 0) {
5050
// Write of last byte didn't complete, abort additional processing
5151
break;

cores/esp8266/Print.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Print {
5656
size_t write(const char *str) {
5757
if(str == NULL)
5858
return 0;
59-
return write((const uint8_t *) str, strlen(str));
59+
return write((const uint8_t *) str, strlen_P(str));
6060
}
6161
virtual size_t write(const uint8_t *buffer, size_t size);
6262
size_t write(const char *buffer, size_t size) {

cores/esp8266/Updater.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "Updater.h"
2-
#include "Arduino.h"
32
#include "eboot_command.h"
43
#include <esp8266_peri.h>
54

@@ -11,10 +10,10 @@
1110
#endif
1211

1312
#if ARDUINO_SIGNING
14-
#include "../../libraries/ESP8266WiFi/src/BearSSLHelpers.h"
15-
static BearSSL::PublicKey signPubKey(signing_pubkey);
16-
static BearSSL::HashSHA256 hash;
17-
static BearSSL::SigningVerifier sign(&signPubKey);
13+
namespace esp8266 {
14+
extern UpdaterHashClass& updaterSigningHash;
15+
extern UpdaterVerifyClass& updaterSigningVerifier;
16+
}
1817
#endif
1918

2019
extern "C" {
@@ -39,7 +38,7 @@ UpdaterClass::UpdaterClass()
3938
, _progress_callback(nullptr)
4039
{
4140
#if ARDUINO_SIGNING
42-
installSignature(&hash, &sign);
41+
installSignature(&esp8266::updaterSigningHash, &esp8266::updaterSigningVerifier);
4342
#endif
4443
}
4544

cores/esp8266/abi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
3232
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
3333

3434

35-
#ifndef __cpp_exceptions
35+
#if !defined(__cpp_exceptions) && !defined(NEW_OOM_ABORT)
3636
void *operator new(size_t size)
3737
{
3838
void *ret = malloc(size);
@@ -52,7 +52,7 @@ void *operator new[](size_t size)
5252
}
5353
return ret;
5454
}
55-
#endif
55+
#endif // arduino's std::new legacy
5656

5757
void __cxa_pure_virtual(void)
5858
{

cores/esp8266/core_esp8266_features.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,37 @@
3232

3333
#define WIFI_HAS_EVENT_CALLBACK
3434

35+
#ifdef __cplusplus
36+
37+
#include <stdlib.h> // malloc()
38+
#include <stddef.h> // size_t
39+
40+
namespace arduino
41+
{
42+
extern "C++"
43+
template <typename T, typename ...TConstructorArgs>
44+
T* new0 (size_t n, TConstructorArgs... TconstructorArgs)
45+
{
46+
// n==0: single allocation, otherwise it is an array
47+
size_t offset = n? sizeof(size_t): 0;
48+
size_t arraysize = n? n: 1;
49+
T* ptr = (T*)malloc(offset + (arraysize * sizeof(T)));
50+
if (ptr)
51+
{
52+
if (n)
53+
*(size_t*)(ptr) = n;
54+
for (size_t i = 0; i < arraysize; i++)
55+
new (ptr + offset + i * sizeof(T)) T(TconstructorArgs...);
56+
return ptr + offset;
57+
}
58+
return nullptr;
59+
}
60+
}
61+
62+
#define arduino_new(Type, ...) arduino::new0<Type>(0, ##__VA_ARGS__)
63+
#define arduino_newarray(Type, n, ...) arduino::new0<Type>(n, ##__VA_ARGS__)
64+
65+
#endif // __cplusplus
3566

3667
#ifndef __STRINGIFY
3768
#define __STRINGIFY(a) #a
@@ -61,4 +92,4 @@ inline uint32_t esp_get_cycle_count() {
6192
}
6293
#endif // not CORE_MOCK
6394

64-
#endif
95+
#endif // CORE_ESP8266_FEATURES_H

cores/esp8266/uart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ uart_write(uart_t* uart, const char* buf, size_t size)
495495
size_t ret = size;
496496
const int uart_nr = uart->uart_nr;
497497
while (size--)
498-
uart_do_write_char(uart_nr, *buf++);
498+
uart_do_write_char(uart_nr, pgm_read_byte(buf++));
499499

500500
return ret;
501501
}

doc/eclipse/makefile.init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ESP8266_BASE = $(ARDUINO_BASE)/hardware/esp8266com/esp8266
1414
ESP8266_TOOLS = $(ESP8266_BASE)/tools
1515
XTENSA_TOOLS_ROOT = $(ESP8266_TOOLS)/xtensa-lx106-elf/bin
1616

17-
PYTHON_BIN = python
17+
PYTHON_BIN = python3
1818
ESPTOOL_PY_BIN = $(ESP8266_TOOLS)/esptool.py
1919
ESPOTA_PY_BIN = $(ESP8266_TOOLS)/espota.py
2020
ESPTOOL_BIN = $(ESP8266_TOOLS)/esptool/esptool.exe

doc/installing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Prerequisites
4343

4444
- Arduino 1.6.8 (or newer, current working version is 1.8.5)
4545
- git
46-
- Python 2.7 (https://python.org)
46+
- Python 3.x (https://python.org)
4747
- terminal, console, or command prompt (depending on your OS)
4848
- Internet connection
4949

@@ -110,7 +110,7 @@ Instructions - Windows 10
110110
.. code:: bash
111111
112112
cd esp8266/tools
113-
python get.py
113+
python3 get.py
114114
115115
- Restart Arduino
116116
@@ -184,7 +184,7 @@ Instructions - Other OS
184184
.. code:: bash
185185
186186
cd esp8266/tools
187-
python get.py
187+
python3 get.py
188188
189189
- Restart Arduino
190190

doc/ota_updates/readme.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Instructions below show configuration of OTA on NodeMCU 1.0 (ESP-12E Module) boa
193193
- esp8266/Arduino platform package 2.0.0 or newer - for instructions
194194
follow
195195
https://github.com/esp8266/Arduino#installing-with-boards-manager
196-
- Python 2.7 - https://www.python.org/
196+
- Python 3.x - https://www.python.org/
197197

198198
**Note:** Windows users should select “Add python.exe to Path”
199199
(see below – this option is not selected by default).

0 commit comments

Comments
 (0)
0