Skip to content

Commit 1625a7d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents c2aa282 + e9dea9a commit 1625a7d

Some content is hidden

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

81 files changed

+1254
-254
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ python get.py
6464

6565
[PlatformIO](http://platformio.org) is an open source ecosystem for IoT
6666
development with cross platform build system, library manager and full support
67-
for Espressif (ESP8266) development. It works on the popular host OS: Mac OS X, Windows,
67+
for Espressif (ESP8266) development. It works on the popular host OS: macOS, Windows,
6868
Linux 32/64, Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).
6969

70-
- [What is PlatformIO?](http://docs.platformio.org/en/stable/what-is-platformio.html)
70+
- [What is PlatformIO?](http://docs.platformio.org/page/what-is-platformio.html)
7171
- [PlatformIO IDE](http://platformio.org/platformio-ide)
72-
- Quick Start with [PlatformIO IDE](http://docs.platformio.org/en/stable/ide/atom.html#quick-start) or [PlatformIO CLI](http://docs.platformio.org/en/stable/quickstart.html)
73-
- [Advanced using](http://docs.platformio.org/en/stable/platforms/espressif.html) -
72+
- Quick Start with [PlatformIO IDE](http://docs.platformio.org/page/ide/atom.html#quick-start) or [PlatformIO Core](http://docs.platformio.org/page/core.html)
73+
- [Advanced using](http://docs.platformio.org/page/platforms/espressif.html) -
7474
custom settings, uploading to SPIFFS, Over-the-Air (OTA) or using stage version
75-
- [Integration with other IDE](http://docs.platformio.org/en/stable/ide.html) -
76-
Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM and Visual Studio
77-
- [Project Examples](http://docs.platformio.org/en/stable/platforms/espressif.html#examples)
75+
- [Integration with Cloud and Standalone IDEs](http://docs.platformio.org/page/ide.html) -
76+
Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM and Visual Studio
77+
- [Project Examples](http://docs.platformio.org/page/platforms/espressif.html#examples)
7878

7979
### Building with make
8080

cores/esp8266/Esp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ EspClass ESP;
8383

8484
void EspClass::wdtEnable(uint32_t timeout_ms)
8585
{
86+
(void) timeout_ms;
8687
/// This API can only be called if software watchdog is stopped
8788
system_soft_wdt_restart();
8889
}
@@ -432,7 +433,7 @@ uint32_t EspClass::getSketchSize() {
432433
section_index < image_header.num_segments;
433434
++section_index)
434435
{
435-
section_header_t section_header = {0};
436+
section_header_t section_header = {0, 0};
436437
if (spi_flash_read(pos, (uint32_t*) &section_header, sizeof(section_header))) {
437438
return 0;
438439
}

cores/esp8266/Schedule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static int sCount = 0;
1616

1717
static void init_lists()
1818
{
19+
(void) init_lists;
1920
if (sCount != 0) {
2021
return;
2122
}

cores/esp8266/abi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ void __throw_bad_alloc()
104104

105105
void __throw_logic_error(const char* str)
106106
{
107+
(void) str;
107108
panic();
108109
}
109110

110111
void __throw_out_of_range(const char* str)
111112
{
113+
(void) str;
112114
panic();
113115
}
114116
}

cores/esp8266/cont_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void ICACHE_RAM_ATTR cont_init(cont_t* cont) {
3232
cont->struct_start = (unsigned*) cont;
3333

3434
// fill stack with magic values to check high water mark
35-
for(int pos = 0; pos < sizeof(cont->stack) / 4; pos++)
35+
for(int pos = 0; pos < (int)(sizeof(cont->stack) / 4); pos++)
3636
{
3737
cont->stack[pos] = CONT_STACKGUARD;
3838
}

cores/esp8266/core_esp8266_main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const char* core_release =
5252
} // extern "C"
5353

5454
int atexit(void (*func)()) {
55+
(void) func;
5556
return 0;
5657
}
5758

@@ -125,6 +126,7 @@ static void loop_wrapper() {
125126
}
126127

127128
static void loop_task(os_event_t *events) {
129+
(void) events;
128130
g_micros_at_task_start = system_get_time();
129131
cont_run(&g_cont, &loop_wrapper);
130132
if (cont_check(&g_cont) != 0) {

cores/esp8266/core_esp8266_phy.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <stdbool.h>
2626
#include <string.h>
2727
#include "c_types.h"
28+
#include "ets_sys.h"
29+
#include "spi_flash.h"
2830

2931
static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
3032
{
@@ -228,7 +230,7 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
228230
// 3: auto measure frequency offset and correct it, bbpll is 160M, it only can correct + frequency offset.
229231
// 5: use 113 byte force_freq_offset to correct frequency offset, bbpll is 168M, it can correct + and - frequency offset.
230232
// 7: use 113 byte force_freq_offset to correct frequency offset, bbpll is 160M , it only can correct + frequency offset.
231-
[112] = 3,
233+
[112] = 0,
232234

233235
// force_freq_offset
234236
// signed, unit is 8kHz
@@ -250,14 +252,20 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
250252
#define __get_rf_mode _Z13__get_rf_modev
251253
#define __run_user_rf_pre_init _Z22__run_user_rf_pre_initv
252254

253-
extern int __real_register_chipv6_phy(uint8_t* init_data);
254-
extern int __wrap_register_chipv6_phy(uint8_t* init_data)
255+
static bool spoof_init_data = false;
256+
257+
extern int __real_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
258+
extern int ICACHE_RAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
259+
260+
extern int ICACHE_RAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size)
255261
{
256-
if (init_data != NULL) {
257-
memcpy(init_data, phy_init_data, sizeof(phy_init_data));
258-
init_data[107] = __get_adc_mode();
262+
if (!spoof_init_data || size != 128) {
263+
return __real_spi_flash_read(addr, dst, size);
259264
}
260-
return __real_register_chipv6_phy(init_data);
265+
266+
memcpy(dst, phy_init_data, sizeof(phy_init_data));
267+
((uint8_t*)dst)[107] = __get_adc_mode();
268+
return 0;
261269
}
262270

263271
extern int __get_rf_mode(void) __attribute__((weak));
@@ -278,10 +286,16 @@ extern void __run_user_rf_pre_init(void)
278286
return; // default do noting
279287
}
280288

289+
uint32_t user_rf_cal_sector_set(void)
290+
{
291+
spoof_init_data = true;
292+
return flashchip->chip_size/SPI_FLASH_SEC_SIZE - 4;
293+
}
294+
281295
void user_rf_pre_init()
282296
{
283297
// *((volatile uint32_t*) 0x60000710) = 0;
284-
298+
spoof_init_data = false;
285299
volatile uint32_t* rtc_reg = (volatile uint32_t*) 0x60001000;
286300
if((rtc_reg[24] >> 16) > 4) {
287301
rtc_reg[24] &= 0xFFFF;
@@ -295,3 +309,7 @@ void user_rf_pre_init()
295309
}
296310
__run_user_rf_pre_init();
297311
}
312+
313+
314+
void ICACHE_RAM_ATTR user_spi_flash_dio_to_qio_pre_init() {}
315+

cores/esp8266/core_esp8266_postmortem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static void print_stack(uint32_t start, uint32_t end);
4646
//static void print_pcs(uint32_t start, uint32_t end);
4747

4848
extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
49+
(void) rst_info;
50+
(void) stack;
51+
(void) stack_end;
4952
}
5053

5154
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
@@ -183,6 +186,7 @@ void abort(){
183186
}
184187

185188
void __assert_func(const char *file, int line, const char *func, const char *what) {
189+
(void) what;
186190
s_panic_file = file;
187191
s_panic_line = line;
188192
s_panic_func = func;

cores/esp8266/core_esp8266_timer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
static volatile timercallback timer1_user_cb = NULL;
3131

3232
void ICACHE_RAM_ATTR timer1_isr_handler(void *para){
33+
(void) para;
3334
if ((T1C & ((1 << TCAR) | (1 << TCIT))) == 0) TEIE &= ~TEIE1;//edge int disable
3435
T1I = 0;
3536
if (timer1_user_cb) {
@@ -77,6 +78,7 @@ void ICACHE_RAM_ATTR timer1_disable(){
7778
static volatile timercallback timer0_user_cb = NULL;
7879

7980
void ICACHE_RAM_ATTR timer0_isr_handler(void* para){
81+
(void) para;
8082
if (timer0_user_cb) {
8183
// to make ISR compatible to Arduino AVR model where interrupts are disabled
8284
// we disable them before we call the client ISR

cores/esp8266/core_esp8266_wiring.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static uint32_t micros_overflow_count = 0;
3636
#define REPEAT 1
3737

3838
void delay_end(void* arg) {
39+
(void) arg;
3940
esp_schedule();
4041
}
4142

@@ -53,6 +54,7 @@ void delay(unsigned long ms) {
5354
}
5455

5556
void micros_overflow_tick(void* arg) {
57+
(void) arg;
5658
uint32_t m = system_get_time();
5759
if(m < micros_at_last_overflow_tick)
5860
++micros_overflow_count;

cores/esp8266/core_esp8266_wiring_digital.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static interrupt_handler_t interrupt_handlers[16];
115115
static uint32_t interrupt_reg = 0;
116116

117117
void ICACHE_RAM_ATTR interrupt_handler(void *arg) {
118+
(void) arg;
118119
uint32_t status = GPIE;
119120
GPIEC = status;//clear them interrupts
120121
uint32_t levels = GPI;

cores/esp8266/core_esp8266_wiring_pwm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ extern void __analogWrite(uint8_t pin, int value)
187187
}
188188
if((pwm_mask & (1 << pin)) == 0) {
189189
if(pwm_mask == 0) {
190-
memset(&_pwm_isr_data, 0, sizeof(struct pwm_isr_data*));
190+
memset(&_pwm_isr_data, 0, sizeof(_pwm_isr_data));
191191
start_timer = true;
192192
}
193193
pinMode(pin, OUTPUT);

cores/esp8266/heap.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,60 @@
1010

1111
void* _malloc_r(struct _reent* unused, size_t size)
1212
{
13+
(void) unused;
1314
return malloc(size);
1415
}
1516

1617
void _free_r(struct _reent* unused, void* ptr)
1718
{
19+
(void) unused;
1820
return free(ptr);
1921
}
2022

2123
void* _realloc_r(struct _reent* unused, void* ptr, size_t size)
2224
{
25+
(void) unused;
2326
return realloc(ptr, size);
2427
}
2528

2629
void* _calloc_r(struct _reent* unused, size_t count, size_t size)
2730
{
31+
(void) unused;
2832
return calloc(count, size);
2933
}
3034

3135
void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
3236
{
37+
(void) file;
38+
(void) line;
3339
return malloc(size);
3440
}
3541

3642
void ICACHE_RAM_ATTR vPortFree(void *ptr, const char* file, int line)
3743
{
44+
(void) file;
45+
(void) line;
3846
free(ptr);
3947
}
4048

4149
void* ICACHE_RAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line)
4250
{
51+
(void) file;
52+
(void) line;
4353
return calloc(count, size);
4454
}
4555

4656
void* ICACHE_RAM_ATTR pvPortRealloc(void *ptr, size_t size, const char* file, int line)
4757
{
58+
(void) file;
59+
(void) line;
4860
return realloc(ptr, size);
4961
}
5062

5163
void* ICACHE_RAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
5264
{
65+
(void) file;
66+
(void) line;
5367
return calloc(1, size);
5468
}
5569

cores/esp8266/libb64/cdecode.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ For details, see http://sourceforge.net/projects/libb64
66
*/
77

88
#include "cdecode.h"
9+
#include <stdint.h>
910

10-
int base64_decode_value(char value_in){
11-
static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
12-
static const char decoding_size = sizeof(decoding);
11+
static int base64_decode_value_signed(int8_t value_in){
12+
static const int8_t decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
13+
static const int8_t decoding_size = sizeof(decoding);
1314
value_in -= 43;
1415
if (value_in < 0 || value_in > decoding_size) return -1;
1516
return decoding[(int)value_in];
@@ -20,10 +21,10 @@ void base64_init_decodestate(base64_decodestate* state_in){
2021
state_in->plainchar = 0;
2122
}
2223

23-
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in){
24-
const char* codechar = code_in;
25-
char* plainchar = plaintext_out;
26-
char fragment;
24+
static int base64_decode_block_signed(const int8_t* code_in, const int length_in, int8_t* plaintext_out, base64_decodestate* state_in){
25+
const int8_t* codechar = code_in;
26+
int8_t* plainchar = plaintext_out;
27+
int8_t fragment;
2728

2829
*plainchar = state_in->plainchar;
2930

@@ -36,7 +37,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
3637
state_in->plainchar = *plainchar;
3738
return plainchar - plaintext_out;
3839
}
39-
fragment = (char)base64_decode_value(*codechar++);
40+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
4041
} while (fragment < 0);
4142
*plainchar = (fragment & 0x03f) << 2;
4243
case step_b:
@@ -46,7 +47,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
4647
state_in->plainchar = *plainchar;
4748
return plainchar - plaintext_out;
4849
}
49-
fragment = (char)base64_decode_value(*codechar++);
50+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
5051
} while (fragment < 0);
5152
*plainchar++ |= (fragment & 0x030) >> 4;
5253
*plainchar = (fragment & 0x00f) << 4;
@@ -57,7 +58,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
5758
state_in->plainchar = *plainchar;
5859
return plainchar - plaintext_out;
5960
}
60-
fragment = (char)base64_decode_value(*codechar++);
61+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
6162
} while (fragment < 0);
6263
*plainchar++ |= (fragment & 0x03c) >> 2;
6364
*plainchar = (fragment & 0x003) << 6;
@@ -68,7 +69,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
6869
state_in->plainchar = *plainchar;
6970
return plainchar - plaintext_out;
7071
}
71-
fragment = (char)base64_decode_value(*codechar++);
72+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
7273
} while (fragment < 0);
7374
*plainchar++ |= (fragment & 0x03f);
7475
}
@@ -77,10 +78,22 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
7778
return plainchar - plaintext_out;
7879
}
7980

80-
int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out){
81+
static int base64_decode_chars_signed(const int8_t* code_in, const int length_in, int8_t* plaintext_out){
8182
base64_decodestate _state;
8283
base64_init_decodestate(&_state);
83-
int len = base64_decode_block(code_in, length_in, plaintext_out, &_state);
84+
int len = base64_decode_block_signed(code_in, length_in, plaintext_out, &_state);
8485
if(len > 0) plaintext_out[len] = 0;
8586
return len;
8687
}
88+
89+
int base64_decode_value(char value_in){
90+
return base64_decode_value_signed(*((int8_t *) &value_in));
91+
}
92+
93+
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in){
94+
return base64_decode_block_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out, state_in);
95+
}
96+
97+
int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out){
98+
return base64_decode_chars_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out);
99+
}

cores/esp8266/libc_replacements.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ int ICACHE_RAM_ATTR _read_r(struct _reent* unused, int file, char *ptr, int len)
8383
}
8484

8585
int ICACHE_RAM_ATTR _write_r(struct _reent* r, int file, char *ptr, int len) {
86+
(void) r;
8687
if (file == STDOUT_FILENO) {
8788
while(len--) {
8889
ets_putc(*ptr);
@@ -93,6 +94,7 @@ int ICACHE_RAM_ATTR _write_r(struct _reent* r, int file, char *ptr, int len) {
9394
}
9495

9596
int ICACHE_RAM_ATTR _putc_r(struct _reent* r, int c, FILE* file) {
97+
(void) r;
9698
if (file->_file == STDOUT_FILENO) {
9799
return ets_putc(c);
98100
}

0 commit comments

Comments
 (0)