mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-26 07:02:15 +03:00
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)
This commit is contained in:
committed by
Ivan Grokhotkov
parent
61787b23af
commit
ae13809c81
6
tools/sdk/lwip/src/core/dhcp.c
Normal file → Executable file
6
tools/sdk/lwip/src/core/dhcp.c
Normal file → Executable file
@ -1096,12 +1096,12 @@ dhcp_renew(struct netif *netif)
|
||||
}
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4);
|
||||
dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr));
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4);
|
||||
dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr));
|
||||
#endif
|
||||
@ -1159,7 +1159,7 @@ dhcp_rebind(struct netif *netif)
|
||||
}
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4);
|
||||
dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr));
|
||||
|
||||
|
14
tools/sdk/lwip/src/core/dns.c
Normal file → Executable file
14
tools/sdk/lwip/src/core/dns.c
Normal file → Executable file
@ -227,7 +227,7 @@ static ip_addr_t dns_servers[DNS_MAX_SERVERS];
|
||||
/** Contiguous buffer for processing responses */
|
||||
//static u8_t dns_payload_buffer[LWIP_MEM_ALIGN_BUFFER(DNS_MSG_SIZE)];
|
||||
static u8_t* dns_payload;
|
||||
static u8_t dns_random;
|
||||
static u16_t dns_random;
|
||||
/**
|
||||
* Initialize the resolver: set up the UDP pcb and configure the default server
|
||||
* (DNS_SERVER_ADDRESS).
|
||||
@ -570,7 +570,7 @@ dns_send(u8_t numdns, const char* name, u8_t id)
|
||||
char *query, *nptr;
|
||||
const char *pHostname;
|
||||
u8_t n;
|
||||
dns_random = os_random()%250;
|
||||
dns_random = os_random()>>16;
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n",
|
||||
(u16_t)(numdns), name));
|
||||
LWIP_ASSERT("dns server out of array", numdns < DNS_MAX_SERVERS);
|
||||
@ -698,7 +698,7 @@ dns_check_entry(u8_t i)
|
||||
|
||||
case DNS_STATE_DONE: {
|
||||
/* if the time to live is nul */
|
||||
if (--pEntry->ttl == 0) {
|
||||
if ((pEntry->ttl == 0) || (--pEntry->ttl == 0)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name));
|
||||
/* flush this entry */
|
||||
pEntry->state = DNS_STATE_UNUSED;
|
||||
@ -825,6 +825,13 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
|
||||
if (pEntry->found) {
|
||||
(*pEntry->found)(pEntry->name, &pEntry->ipaddr, pEntry->arg);
|
||||
}
|
||||
if (pEntry->ttl == 0) {
|
||||
/* RFC 883, page 29: "Zero values are
|
||||
interpreted to mean that the RR can only be used for the
|
||||
transaction in progress, and should not be cached."
|
||||
-> flush this entry now */
|
||||
goto flushentry;
|
||||
}
|
||||
/* deallocate memory and return */
|
||||
goto memerr;
|
||||
} else {
|
||||
@ -847,6 +854,7 @@ responseerr:
|
||||
if (pEntry->found) {
|
||||
(*pEntry->found)(pEntry->name, NULL, pEntry->arg);
|
||||
}
|
||||
flushentry:
|
||||
/* flush this entry */
|
||||
pEntry->state = DNS_STATE_UNUSED;
|
||||
pEntry->found = NULL;
|
||||
|
@ -149,7 +149,7 @@ static err_t igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
|
||||
static void igmp_send(struct igmp_group *group, u8_t type)ICACHE_FLASH_ATTR;
|
||||
|
||||
|
||||
static struct igmp_group* igmp_group_list;
|
||||
static struct igmp_group* igmp_group_list = NULL;
|
||||
static ip_addr_t allsystems;
|
||||
static ip_addr_t allrouters;
|
||||
|
||||
|
@ -486,6 +486,10 @@ void netif_set_up(struct netif *netif)
|
||||
*/
|
||||
void netif_set_down(struct netif *netif)
|
||||
{
|
||||
if (netif == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (netif->flags & NETIF_FLAG_UP) {
|
||||
netif->flags &= ~NETIF_FLAG_UP;
|
||||
#if LWIP_SNMP
|
||||
|
93
tools/sdk/lwip/src/core/sntp.c
Normal file → Executable file
93
tools/sdk/lwip/src/core/sntp.c
Normal file → Executable file
@ -51,7 +51,7 @@
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#include "lwip/app/time.h"
|
||||
//#include <string.h>
|
||||
#if LWIP_UDP
|
||||
|
||||
@ -148,14 +148,18 @@
|
||||
#endif
|
||||
|
||||
/** SNTP macro to change system time including microseconds */
|
||||
#ifdef SNTP_SET_SYSTEM_TIME_US
|
||||
#define SNTP_CALC_TIME_US 1
|
||||
#define SNTP_RECEIVE_TIME_SIZE 2
|
||||
#else
|
||||
#define SNTP_SET_SYSTEM_TIME_US(sec, us)
|
||||
#define SNTP_CALC_TIME_US 0
|
||||
#define SNTP_RECEIVE_TIME_SIZE 1
|
||||
#endif
|
||||
uint8 sntp_receive_time_size = 1;
|
||||
#define SNTP_RECEIVE_TIME_SIZE sntp_receive_time_size
|
||||
#define SNTP_SET_SYSTEM_TIME_US(sec, us) sntp_update_rtc(sec, us)
|
||||
//#ifdef SNTP_SET_SYSTEM_TIME_US
|
||||
//#define SNTP_SET_SYSTEM_TIME_US(sec, us) sntp_update_rtc(sec, us)
|
||||
//#define SNTP_CALC_TIME_US 1
|
||||
//#define SNTP_RECEIVE_TIME_SIZE 2
|
||||
//#else
|
||||
//#define SNTP_SET_SYSTEM_TIME_US(sec, us)
|
||||
//#define SNTP_CALC_TIME_US 0
|
||||
//#define SNTP_RECEIVE_TIME_SIZE sntp_receive_time_size
|
||||
//#endif
|
||||
|
||||
/** SNTP macro to get system time, used with SNTP_CHECK_RESPONSE >= 2
|
||||
* to send in request and compare in response.
|
||||
@ -295,10 +299,12 @@ static ip_addr_t sntp_last_server_address;
|
||||
* to compare against in response */
|
||||
static u32_t sntp_last_timestamp_sent[2];
|
||||
#endif /* SNTP_CHECK_RESPONSE >= 2 */
|
||||
typedef long time_t;
|
||||
|
||||
//uint32 current_stamp_1 = 0;
|
||||
//uint32 current_stamp_2 = 0;
|
||||
uint32 realtime_stamp = 0;
|
||||
static bool sntp_time_flag = false;
|
||||
static uint32 sntp_update_delay = SNTP_UPDATE_DELAY;
|
||||
static uint32 realtime_stamp = 0;
|
||||
LOCAL os_timer_t sntp_timer;
|
||||
/*****************************************/
|
||||
#define SECSPERMIN 60L
|
||||
@ -643,13 +649,24 @@ bool ICACHE_FLASH_ATTR
|
||||
sntp_set_timezone(sint8 timezone)
|
||||
{
|
||||
if(timezone >= -11 || timezone <= 13) {
|
||||
time_zone = timezone;
|
||||
if (sntp_get_timetype()){
|
||||
RTC_TZ_SET(time_zone);
|
||||
} else
|
||||
time_zone = timezone;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR sntp_set_daylight(int daylight)
|
||||
{
|
||||
if (sntp_get_timetype()){
|
||||
RTC_DST_SET(daylight);
|
||||
}
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
sntp_time_inc(void)
|
||||
{
|
||||
@ -665,7 +682,22 @@ sntp_process(u32_t *receive_timestamp)
|
||||
* @todo: if MSB is 1, SNTP time is 2036-based!
|
||||
*/
|
||||
time_t t = (ntohl(receive_timestamp[0]) - DIFF_SEC_1900_1970);
|
||||
|
||||
if (sntp_get_timetype()){
|
||||
u32_t us = ntohl(receive_timestamp[1]) / 4295;
|
||||
SNTP_SET_SYSTEM_TIME_US(t, us);
|
||||
/* display local time from GMT time */
|
||||
LWIP_DEBUGF(SNTP_DEBUG_TRACE, ("sntp_process: %s, %"U32_F" us", ctime(&t), us));
|
||||
} else{
|
||||
/* change system time and/or the update the RTC clock */
|
||||
SNTP_SET_SYSTEM_TIME(t);
|
||||
/* display local time from GMT time */
|
||||
t += time_zone * 60 * 60;// format GMT + time_zone TIME ZONE
|
||||
realtime_stamp = t;
|
||||
os_timer_disarm(&sntp_timer);
|
||||
os_timer_setfn(&sntp_timer, (os_timer_func_t *)sntp_time_inc, NULL);
|
||||
os_timer_arm(&sntp_timer, 1000, 1);
|
||||
}
|
||||
#if 0
|
||||
#if SNTP_CALC_TIME_US
|
||||
u32_t us = ntohl(receive_timestamp[1]) / 4295;
|
||||
SNTP_SET_SYSTEM_TIME_US(t, us);
|
||||
@ -682,10 +714,8 @@ sntp_process(u32_t *receive_timestamp)
|
||||
os_timer_disarm(&sntp_timer);
|
||||
os_timer_setfn(&sntp_timer, (os_timer_func_t *)sntp_time_inc, NULL);
|
||||
os_timer_arm(&sntp_timer, 1000, 1);
|
||||
os_printf("%s\n",sntp_asctime(sntp_localtime (&t)));
|
||||
// os_printf("%s\n",ctime(&t));
|
||||
// LWIP_DEBUGF(SNTP_DEBUG_TRACE, ("sntp_process: %s", ctime(&t)));
|
||||
#endif /* SNTP_CALC_TIME_US */
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -856,9 +886,9 @@ sntp_recv(void *arg, struct udp_pcb* pcb, struct pbuf *p, ip_addr_t *addr, u16_t
|
||||
sntp_process(receive_timestamp);
|
||||
|
||||
/* Set up timeout for next request */
|
||||
sys_timeout((u32_t)SNTP_UPDATE_DELAY, sntp_request, NULL);
|
||||
sys_timeout((u32_t)sntp_update_delay, sntp_request, NULL);
|
||||
LWIP_DEBUGF(SNTP_DEBUG_STATE, ("sntp_recv: Scheduled next time request: %"U32_F" ms\n",
|
||||
(u32_t)SNTP_UPDATE_DELAY));
|
||||
(u32_t)sntp_update_delay));
|
||||
} else if (err == SNTP_ERR_KOD) {
|
||||
/* Kiss-of-death packet. Use another server or increase UPDATE_DELAY. */
|
||||
sntp_try_next_server(NULL);
|
||||
@ -1125,4 +1155,31 @@ sntp_getservername(u8_t idx)
|
||||
}
|
||||
#endif /* SNTP_SERVER_DNS */
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
sntp_set_update_delay(uint32 ms)
|
||||
{
|
||||
sntp_update_delay = ms > 15000?ms:15000;
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
sntp_set_timetype(bool type)
|
||||
{
|
||||
// sntp_time_flag = type;
|
||||
}
|
||||
|
||||
bool sntp_get_timetype(void)
|
||||
{
|
||||
return sntp_time_flag;
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR
|
||||
sntp_set_receive_time_size(void)
|
||||
{
|
||||
if (sntp_get_timetype()){
|
||||
sntp_receive_time_size = 2;
|
||||
} else{
|
||||
sntp_receive_time_size = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LWIP_UDP */
|
||||
|
Reference in New Issue
Block a user