Skip to content

Commit ae13809

Browse files
committed
Update SDK to 2.0.0
- Update SDK header files and libraries to SDK 2.0.0 plus 2.0.0_16_08_09 patch - Remove mem_manager.o from libmain.a (replaced with umm_malloc) - Disable switch from DIO to QIO mode for certain flash chips (saves IRAM space) - Add user_rf_cal_sector_set; it points to rf_init_data sector. - Change the way rf_init_data is spoofed. This is now done by wrapping spi_flash_read and returning the data we need during startup sequence. - Place lwip library into flash using linker script instead of section attributes (saves IRAM space)
1 parent 61787b2 commit ae13809

Some content is hidden

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

46 files changed

+794
-122
lines changed

cores/esp8266/core_esp8266_phy.c

+26-8
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+

platform.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implici
3131
compiler.S.cmd=xtensa-lx106-elf-gcc
3232
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
3333

34-
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy
34+
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read
3535

3636
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
3737
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc

tools/sdk/changelog.txt

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
ESP8266_NONOS_SDK_V2.0.0_16_07_19 Release Note
2+
----------------------------------------------
3+
1. Updated libphy.a to 1055, fixed an issue of large current in Light-sleep.
4+
2. Updated AT+ to 1.3.0:
5+
2.1 Added Light-sleep wakeup command, AT+WAKEUPGPIO;
6+
2.2 Fixed abnormal AT+CWDHCPS IP allocation;
7+
2.3 Added at_sdio demo under example directory.
8+
3. Fixed probable system default when calling cur and def interfaces.
9+
4. Fixed the issue of high current in Deep-sleep mode without disabling SPI first.
10+
5. Fixed an issue where the SDK would crash when switching from AP to Station mode by calling wifi_set_phy_mode.
11+
6. Updated secondary boot loader to v1.6:
12+
6.1 Supports AT + based on SDIO;
13+
6.2 Supports entering testing mode through GPIO.
14+
7. Added support for MXIC Flash QIO mode.
15+
8. Fixed exception caused during TCP handshake and retransmission.
16+
9. Fixed issues in ESP-NOW.
17+
10. Added ESP-PAIR (Simple-Pair) feature, for APIs please refer to ESP8266 SDK API Guide.
18+
11. wpa2-enterprise time function derivation and time check disable can be set by users.
19+
12. Support for PEAP/TTLS in wpa2-enterprise, for APIs please refer to ESP8266 SDK API Guide.
20+
13. Added mqtt demos under examples directory.
21+
14. Other issue fixes.
22+
15. Resolved an issue that RF_Init_data sector may be broken in stress test. Provided a function user_rf_cal_sector_set which has to be added in application by software developer. More details about user_rf_cal_sector_set refer to documentation "2C-ESP8266__SDK__API Guide". (Resolved in ESP8266_NONOS_SDK_V1.5.4.1)
23+
16. Fix a potential risk that will cause rf not work after external reset. (Resolved in ESP8266_NONOS_SDK_V1.5.4.1)
24+
17. Add SDIO AT support. (Resolved in ESP8266_NONOS_SDK_V1.5.4.1)
25+
18. Fix a potential bug in espconn. (Resolved in ESP8266_NONOS_SDK_V1.5.4.1)
26+
27+
128
ESP8266_NONOS_SDK_V1.5.4_16_05_20 Release Note
229
----------------------------------------------
330
Optimization:

tools/sdk/include/eagle_soc.h

+5
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
//RTC reg {{
174174
#define REG_RTC_BASE PERIPHS_RTC_BASEADDR
175175

176+
#define RTC_STORE0 (REG_RTC_BASE + 0x030)
177+
#define RTC_STORE1 (REG_RTC_BASE + 0x034)
178+
#define RTC_STORE2 (REG_RTC_BASE + 0x038)
179+
#define RTC_STORE3 (REG_RTC_BASE + 0x03C)
180+
176181
#define RTC_GPIO_OUT (REG_RTC_BASE + 0x068)
177182
#define RTC_GPIO_ENABLE (REG_RTC_BASE + 0x074)
178183
#define RTC_GPIO_IN_DATA (REG_RTC_BASE + 0x08C)

tools/sdk/include/espnow.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ enum esp_now_role {
1010
ESP_NOW_ROLE_IDLE = 0,
1111
ESP_NOW_ROLE_CONTROLLER,
1212
ESP_NOW_ROLE_SLAVE,
13+
ESP_NOW_ROLE_COMBO,
1314
ESP_NOW_ROLE_MAX,
1415
};
1516

tools/sdk/include/simple_pair.h

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2015 -2018 Espressif System
3+
*
4+
*/
5+
6+
#ifndef __SIMPLE_PAIR_H__
7+
#define __SIMPLE_PAIR_H__
8+
9+
typedef enum {
10+
SP_ST_STA_FINISH = 0,
11+
SP_ST_AP_FINISH = 0,
12+
SP_ST_AP_RECV_NEG,
13+
SP_ST_STA_AP_REFUSE_NEG,
14+
/* all following is err */
15+
SP_ST_WAIT_TIMEOUT,
16+
SP_ST_SEND_ERROR,
17+
SP_ST_KEY_INSTALL_ERR,
18+
SP_ST_KEY_OVERLAP_ERR, //means the same macaddr has two different keys
19+
SP_ST_OP_ERROR,
20+
SP_ST_UNKNOWN_ERROR,
21+
SP_ST_MAX,
22+
} SP_ST_t;
23+
24+
25+
typedef void (*simple_pair_status_cb_t)(u8 *sa, u8 status);
26+
27+
int register_simple_pair_status_cb(simple_pair_status_cb_t cb);
28+
void unregister_simple_pair_status_cb(void);
29+
30+
int simple_pair_init(void);
31+
void simple_pair_deinit(void);
32+
33+
int simple_pair_state_reset(void);
34+
int simple_pair_ap_enter_announce_mode(void);
35+
int simple_pair_sta_enter_scan_mode(void);
36+
37+
int simple_pair_sta_start_negotiate(void);
38+
int simple_pair_ap_start_negotiate(void);
39+
int simple_pair_ap_refuse_negotiate(void);
40+
41+
int simple_pair_set_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key);
42+
int simple_pair_get_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key);
43+
44+
45+
#endif /* __SIMPLE_PAIR_H__ */

tools/sdk/include/user_interface.h

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "queue.h"
1717
#include "user_config.h"
1818
#include "spi_flash.h"
19+
#include "gpio.h"
1920

2021
#ifndef MAC2STR
2122
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
@@ -178,6 +179,7 @@ typedef struct bss_info {
178179
sint16 freq_offset;
179180
sint16 freqcal_val;
180181
uint8 *esp_mesh_ie;
182+
uint8 simple_pair;
181183
} bss_info_t;
182184

183185
typedef struct _scaninfo {
@@ -606,4 +608,7 @@ bool wifi_set_user_ie(bool enable, uint8 *m_oui, uint8 type, uint8 *user_ie, uin
606608
int wifi_register_user_ie_manufacturer_recv_cb(user_ie_manufacturer_recv_cb_t cb);
607609
void wifi_unregister_user_ie_manufacturer_recv_cb(void);
608610

611+
void wifi_enable_gpio_wakeup(uint32 i, GPIO_INT_TYPE intr_status);
612+
void wifi_disable_gpio_wakeup(void);
613+
609614
#endif

tools/sdk/include/wpa2_enterprise.h

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef __WPA2_ENTERPRISE_H__
2+
#define __WPA2_ENTERPRISE_H__
3+
4+
typedef long os_time_t;
5+
6+
struct os_time {
7+
os_time_t sec;
8+
os_time_t usec;
9+
};
10+
11+
typedef int (* get_time_func_t)(struct os_time *t);
12+
13+
int wifi_station_set_wpa2_enterprise_auth(int enable);
14+
15+
int wifi_station_set_enterprise_cert_key(u8 *client_cert, int client_cert_len,
16+
u8 *private_key, int private_key_len,
17+
u8 *private_key_passwd, int private_key_passwd_len);
18+
void wifi_station_clear_enterprise_cert_key(void);
19+
20+
int wifi_station_set_enterprise_ca_cert(u8 *ca_cert, int ca_cert_len);
21+
void wifi_station_clear_enterprise_ca_cert(void);
22+
23+
int wifi_station_set_enterprise_username(u8 *username, int len);
24+
void wifi_station_clear_enterprise_username(void);
25+
26+
int wifi_station_set_enterprise_password(u8 *password, int len);
27+
void wifi_station_clear_enterprise_password(void);
28+
29+
int wifi_station_set_enterprise_new_password(u8 *new_password, int len);
30+
void wifi_station_clear_enterprise_new_password(void);
31+
32+
void wifi_station_set_enterprise_disable_time_check(bool disable);
33+
bool wifi_station_get_enterprise_disable_time_check(void);
34+
35+
void wpa2_enterprise_set_user_get_time(get_time_func_t cb);
36+
37+
38+
#endif /* __WPA2_ENTERPRISE_H__ */

tools/sdk/ld/eagle.app.v6.common.ld

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ SECTIONS
163163
*libgcc.a:_udivdi3.o(.literal .text)
164164
*libsmartconfig.a:(.literal .text .literal.* .text.*)
165165
*libstdc++.a:(.literal .text .literal.* .text.*)
166+
*liblwip_gcc.a:(.literal .text .literal.* .text.*)
167+
*liblwip_src.a:(.literal .text .literal.* .text.*)
166168
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text .irom.text.*)
167169
_irom0_text_end = ABSOLUTE(.);
168170
_flash_code_end = ABSOLUTE(.);

tools/sdk/ld/eagle.rom.addr.v6.ld

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ PROVIDE ( SPI_read_status = 0x400043c8 );
2020
PROVIDE ( SPI_write_status = 0x40004400 );
2121
PROVIDE ( SPI_write_enable = 0x4000443c );
2222
PROVIDE ( Wait_SPI_Idle = 0x4000448c );
23+
PROVIDE ( Enable_QMode = 0x400044c0 );
2324
PROVIDE ( SPIEraseArea = 0x40004b44 );
2425
PROVIDE ( SPIEraseBlock = 0x400049b4 );
2526
PROVIDE ( SPIEraseChip = 0x40004984 );

tools/sdk/lib/libat.a

35.6 KB
Binary file not shown.

tools/sdk/lib/libcrypto.a

22.9 KB
Binary file not shown.

tools/sdk/lib/libdriver.a

65.3 KB
Binary file not shown.

tools/sdk/lib/libespnow.a

23.2 KB
Binary file not shown.

tools/sdk/lib/libgcc.a

587 KB
Binary file not shown.

tools/sdk/lib/libjson.a

0 Bytes
Binary file not shown.

tools/sdk/lib/liblwip.a

14 KB
Binary file not shown.

tools/sdk/lib/liblwip_536.a

345 KB
Binary file not shown.

tools/sdk/lib/liblwip_gcc.a

119 KB
Binary file not shown.

tools/sdk/lib/libmain.a

29.1 KB
Binary file not shown.

tools/sdk/lib/libmesh.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libnet80211.a

11.5 KB
Binary file not shown.

tools/sdk/lib/libphy.a

-1.16 KB
Binary file not shown.

tools/sdk/lib/libpp.a

3.42 KB
Binary file not shown.

tools/sdk/lib/libsmartconfig.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libssl.a

-620 Bytes
Binary file not shown.

tools/sdk/lib/libupgrade.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libwpa.a

92 Bytes
Binary file not shown.

tools/sdk/lib/libwpa2.a

93.1 KB
Binary file not shown.

tools/sdk/lib/libwps.a

0 Bytes
Binary file not shown.

tools/sdk/lwip/include/arch/cc.h

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
#include "osapi.h"
4141
#define EFAULT 14
4242

43+
#undef ICACHE_FLASH_ATTR
44+
#define ICACHE_FLASH_ATTR
45+
4346
//#define LWIP_PROVIDE_ERRNO
4447

4548
#if (1)

tools/sdk/lwip/include/lwip/app/espconn.h

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "lwip/dns.h"
55
#include "os_type.h"
6+
#include "lwip/app/espconn_buf.h"
67

78
#if 0
89
#define espconn_printf(fmt, args...) os_printf(fmt,## args)
@@ -32,6 +33,8 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
3233
#define ESPCONN_ARG -12 /* Illegal argument. */
3334
#define ESPCONN_IF -14 /* Low_level error */
3435
#define ESPCONN_ISCONN -15 /* Already connected. */
36+
#define ESPCONN_TIME -16 /* Sync Time error */
37+
#define ESPCONN_NODATA -17 /* No data can be read */
3538

3639
#define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */
3740
#define ESPCONN_RESP_TIMEOUT -29 /* ssl handshake no response*/
@@ -186,6 +189,8 @@ typedef struct _espconn_msg{
186189
//***********Code for WIFI_BLOCK from upper**************
187190
uint8 recv_hold_flag;
188191
uint16 recv_holded_buf_Len;
192+
//*******************************************************
193+
ringbuf *readbuf;
189194
}espconn_msg;
190195

191196
#ifndef _MDNS_INFO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* ringbuf.h
3+
*
4+
* Created on: Apr 22, 2016
5+
* Author: liuhan
6+
*/
7+
8+
#ifndef _ESPCONN_BUF_H_
9+
#define _ESPCONN_BUF_H_
10+
11+
/*
12+
* ringbuffer.c
13+
*
14+
* Created on: Apr 22, 2016
15+
* Author: liuhan
16+
*/
17+
#include "c_types.h"
18+
19+
#include "ets_sys.h"
20+
#include "os_type.h"
21+
22+
typedef struct ringbuf_t {
23+
uint8_t *buf;
24+
uint8_t *head, *tail;
25+
size_t size;
26+
} ringbuf, *ringbuf_t;
27+
28+
ringbuf_t ringbuf_new(size_t capacity);
29+
30+
size_t ringbuf_buffer_size(const struct ringbuf_t *rb);
31+
32+
void ringbuf_reset(ringbuf_t rb);
33+
34+
void ringbuf_free(ringbuf_t *rb);
35+
36+
size_t ringbuf_capacity(const struct ringbuf_t *rb);
37+
38+
size_t ringbuf_bytes_free(const struct ringbuf_t *rb);
39+
40+
size_t ringbuf_bytes_used(const struct ringbuf_t *rb);
41+
42+
int ringbuf_is_full(const struct ringbuf_t *rb);
43+
44+
int ringbuf_is_empty(const struct ringbuf_t *rb);
45+
46+
const void* ringbuf_tail(const struct ringbuf_t *rb);
47+
48+
const void* ringbuf_head(const struct ringbuf_t *rb);
49+
50+
static uint8_t *ringbuf_nextp(ringbuf_t rb, const uint8_t *p);
51+
52+
size_t ringbuf_findchr(const struct ringbuf_t *rb, int c, size_t offset);
53+
54+
size_t ringbuf_memset(ringbuf_t dst, int c, size_t len);
55+
56+
void *ringbuf_memcpy_into(ringbuf_t dst, const void *src, size_t count);
57+
58+
void *ringbuf_memcpy_from(void *dst, ringbuf_t src, size_t count);
59+
60+
#endif /* RINGBUF_H_ */

0 commit comments

Comments
 (0)