Skip to content

Commit 6eb4f08

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) - Remove flash_gd25q32c_enable_QIO_mode from libmain.a:spi_flash.o (saves IRAM space) - Remove spi_flash_issi_enable_QIO_mode from libmain.a:spi_flash.o (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. - Remove espconn APIs. We can put them back, in theory, but we need to untie espconn_init from startup code (using objcopy --rename-symbol, for example)
1 parent b412660 commit 6eb4f08

38 files changed

+197
-3310
lines changed

cores/esp8266/core_esp8266_main.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ void init_done() {
152152
esp_schedule();
153153
}
154154

155-
156155
extern "C" void user_init(void) {
157156
struct rst_info *rtc_info_ptr = system_get_rst_info();
158157
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));

cores/esp8266/core_esp8266_phy.c

+32-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,18 @@ extern void __run_user_rf_pre_init(void)
278286
return; // default do noting
279287
}
280288

289+
290+
extern uint32_t _RFCAL_start;
291+
uint32_t user_rf_cal_sector_set(void)
292+
{
293+
spoof_init_data = true;
294+
return flashchip->chip_size/SPI_FLASH_SEC_SIZE - 4;
295+
}
296+
281297
void user_rf_pre_init()
282298
{
283299
// *((volatile uint32_t*) 0x60000710) = 0;
284-
300+
spoof_init_data = false;
285301
volatile uint32_t* rtc_reg = (volatile uint32_t*) 0x60001000;
286302
if((rtc_reg[24] >> 16) > 4) {
287303
rtc_reg[24] &= 0xFFFF;
@@ -295,3 +311,11 @@ void user_rf_pre_init()
295311
}
296312
__run_user_rf_pre_init();
297313
}
314+
315+
316+
void ICACHE_RAM_ATTR spi_flash_issi_enable_QIO_mode() {}
317+
318+
void ICACHE_RAM_ATTR flash_gd25q32c_enable_QIO_mode() {}
319+
320+
void espconn_init(){}
321+

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/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/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/libespnow.a

23.2 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_gcc.a

-203 KB
Binary file not shown.

tools/sdk/lib/libmain.a

26 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/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

tools/sdk/lwip/include/lwip/sntp.h

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
extern "C" {
99
#endif
1010

11+
typedef long time_t;
12+
1113
/** The maximum number of SNTP servers that can be set */
1214
#ifndef SNTP_MAX_SERVERS
1315
#define SNTP_MAX_SERVERS 3
@@ -24,6 +26,8 @@ extern "C" {
2426
#define SNTP_SERVER_DNS 1
2527
#endif
2628

29+
bool sntp_get_timetype(void);
30+
void sntp_set_receive_time_size(void);
2731
/** One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
2832
* #define SNTP_SERVER_ADDRESS "pool.ntp.org"
2933
*/

tools/sdk/lwip/src/app/dhcpserver.c

+21-3
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ void ICACHE_FLASH_ATTR node_remove_from_list(list_node **phead, list_node* pdele
9292
} else {
9393
if (plist == pdelete){
9494
*phead = plist->pnext;
95+
pdelete->pnext = NULL;
9596
} else {
9697
while (plist != NULL) {
9798
if (plist->pnext == pdelete){
9899
plist->pnext = pdelete->pnext;
100+
pdelete->pnext = NULL;
99101
}
100102
plist = plist->pnext;
101103
}
@@ -269,7 +271,10 @@ static void ICACHE_FLASH_ATTR create_msg(struct dhcps_msg *m)
269271
os_memset((char *) m->file, 0, sizeof(m->file));
270272

271273
os_memset((char *) m->options, 0, sizeof(m->options));
272-
os_memcpy((char *) m->options, &magic_cookie, sizeof(magic_cookie));
274+
275+
//For xiaomi crash bug
276+
uint32 magic_cookie1 = magic_cookie;
277+
os_memcpy((char *) m->options, &magic_cookie1, sizeof(magic_cookie1));
273278
}
274279
///////////////////////////////////////////////////////////////////////////////////
275280
/*
@@ -760,11 +765,18 @@ void ICACHE_FLASH_ATTR dhcps_stop(void)
760765
//udp_remove(pcb_dhcps);
761766
list_node *pnode = NULL;
762767
list_node *pback_node = NULL;
768+
struct dhcps_pool* dhcp_node = NULL;
769+
struct ip_addr ip_zero;
770+
771+
os_memset(&ip_zero,0x0,sizeof(ip_zero));
763772
pnode = plist;
764773
while (pnode != NULL) {
765774
pback_node = pnode;
766775
pnode = pback_node->pnext;
767776
node_remove_from_list(&plist, pback_node);
777+
dhcp_node = (struct dhcps_pool*)pback_node->pnode;
778+
//wifi_softap_dhcps_client_leave(dhcp_node->mac,&dhcp_node->ip,TRUE); // force to delete
779+
wifi_softap_set_station_info(dhcp_node->mac, &ip_zero);
768780
os_free(pback_node->pnode);
769781
pback_node->pnode = NULL;
770782
os_free(pback_node);
@@ -1077,10 +1089,10 @@ uint32 ICACHE_FLASH_ATTR wifi_softap_dhcps_client_update(u8 *bssid, struct ip_ad
10771089
return IPADDR_ANY;
10781090
}
10791091
} else {
1080-
if (start_ip == end_ip) {
1092+
if (start_ip > end_ip) {
10811093
return IPADDR_ANY;
10821094
}
1083-
start_ip = htonl((ntohl(start_ip) + 1));
1095+
//start_ip = htonl((ntohl(start_ip) + 1));
10841096
flag = TRUE;
10851097
}
10861098
}
@@ -1096,6 +1108,8 @@ uint32 ICACHE_FLASH_ATTR wifi_softap_dhcps_client_update(u8 *bssid, struct ip_ad
10961108

10971109
// mac exists and ip exists in other node,delete mac
10981110
node_remove_from_list(&plist,pmac_node);
1111+
os_free(pmac_node->pnode);
1112+
pmac_node->pnode = NULL;
10991113
os_free(pmac_node);
11001114
pmac_node = pip_node;
11011115
os_memcpy(pdhcps_pool->mac, bssid, sizeof(pdhcps_pool->mac));
@@ -1144,6 +1158,10 @@ uint32 ICACHE_FLASH_ATTR wifi_softap_dhcps_client_update(u8 *bssid, struct ip_ad
11441158
os_free(pdhcps_pool);
11451159
return IPADDR_ANY;
11461160
}
1161+
if (pdhcps_pool->ip.addr > end_ip) {
1162+
os_free(pdhcps_pool);
1163+
return IPADDR_ANY;
1164+
}
11471165
os_memcpy(pdhcps_pool->mac, bssid, sizeof(pdhcps_pool->mac));
11481166
pdhcps_pool->lease_timer = DHCPS_LEASE_TIMER;
11491167
pdhcps_pool->type = type;

0 commit comments

Comments
 (0)