Skip to content

Commit f12a430

Browse files
committed
Merge pull request #388 from Links2004/esp8266
fix compiler warnings and handle empty SSID paramater
2 parents 7f66a3a + 7c45873 commit f12a430

21 files changed

+80
-21
lines changed

cores/esp8266/core_esp8266_eboot_command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int eboot_command_read(struct eboot_command* cmd)
6060
}
6161

6262
uint32_t crc32 = eboot_command_calculate_crc32(cmd);
63-
if (cmd->magic & EBOOT_MAGIC_MASK != EBOOT_MAGIC ||
63+
if ((cmd->magic & EBOOT_MAGIC_MASK) != EBOOT_MAGIC ||
6464
cmd->crc32 != crc32) {
6565
return 1;
6666
}

cores/esp8266/core_esp8266_flash_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
3030
{
31-
if (start & (FLASH_SECTOR_SIZE - 1) != 0) {
31+
if ((start & (FLASH_SECTOR_SIZE - 1)) != 0) {
3232
return 1;
3333
}
3434

cores/esp8266/core_esp8266_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void user_init(void) {
129129
uart_div_modify(0, UART_CLK_FREQ / (74480));
130130

131131
system_rtc_mem_read(0, &resetInfo, sizeof(struct rst_info));
132-
if(resetInfo.reason == WDT_RST_FLAG || resetInfo.reason == EXCEPTION_RST_FLAG) {
132+
if(resetInfo.reason == REASON_WDT_RST || resetInfo.reason == REASON_EXCEPTION_RST) {
133133
os_printf("Last Reset:\n - flag=%d\n - Fatal exception (%d):\n - epc1=0x%08x,epc2=0x%08x,epc3=0x%08x,excvaddr=0x%08x,depc=0x%08x\n", resetInfo.reason, resetInfo.exccause, resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
134134
}
135135
struct rst_info info = { 0 };

cores/esp8266/spiffs/spiffs_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#define c_memset os_memset
2020

2121
typedef signed short file_t;
22-
typedef long int s32_t;
23-
typedef long unsigned int u32_t;
22+
typedef int32_t s32_t;
23+
typedef uint32_t u32_t;
2424
typedef int16_t s16_t;
2525
typedef uint16_t u16_t;
2626
typedef int8_t s8_t;

libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t ch
6969
mode(WIFI_STA);
7070
}
7171

72-
if(!ssid || strlen(ssid) > 31) {
72+
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
7373
// fail SSID to long or missing!
7474
return WL_CONNECT_FAILED;
7575
}
@@ -178,7 +178,7 @@ void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int chan
178178
mode(WIFI_AP);
179179
}
180180

181-
if(!ssid || strlen(ssid) > 31) {
181+
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
182182
// fail SSID to long or missing!
183183
return;
184184
}

libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "ESP8266WiFiMulti.h"
2727
#include <limits.h>
28+
#include <string.h>
2829

2930
ESP8266WiFiMulti::ESP8266WiFiMulti() {
3031
}
@@ -151,7 +152,7 @@ bool ESP8266WiFiMulti::APlistAdd(const char* ssid, const char *passphrase) {
151152

152153
WifiAPlist_t newAP;
153154

154-
if(!ssid || strlen(ssid) > 31) {
155+
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
155156
// fail SSID to long or missing!
156157
return false;
157158
}
@@ -161,21 +162,18 @@ bool ESP8266WiFiMulti::APlistAdd(const char* ssid, const char *passphrase) {
161162
return false;
162163
}
163164

164-
newAP.ssid = (char*) malloc((strlen(ssid) + 1));
165+
newAP.ssid = strdup(ssid);
165166

166167
if(!newAP.ssid) {
167168
return false;
168169
}
169170

170-
strcpy(newAP.ssid, ssid);
171-
172171
if(passphrase && *passphrase != 0x00) {
173-
newAP.passphrase = (char*) malloc((strlen(passphrase) + 1));
172+
newAP.passphrase = strdup(passphrase);
174173
if(!newAP.passphrase) {
175174
free(newAP.ssid);
176175
return false;
177176
}
178-
strcpy(newAP.passphrase, passphrase);
179177
}
180178

181179
APlist.push_back(newAP);

platform.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ compiler.sdk.path={runtime.platform.path}/tools/sdk/
1616
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include"
1717

1818
compiler.c.cmd=xtensa-lx106-elf-gcc
19-
compiler.c.flags=-c -Os -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=c99
19+
compiler.c.flags=-c -Os -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=c99 -pedantic
2020

2121
compiler.S.cmd=xtensa-lx106-elf-gcc
2222
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
@@ -26,7 +26,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc
2626
compiler.c.elf.libs=-lm -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp -lsmartconfig
2727

2828
compiler.cpp.cmd=xtensa-lx106-elf-g++
29-
compiler.cpp.flags=-c -Os -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD
29+
compiler.cpp.flags=-c -Os -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -pedantic
3030

3131
compiler.as.cmd=xtensa-lx106-elf-as
3232

tools/sdk/changelog.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,54 @@
1+
esp_iot_sdk_v1.1.1_15_06_05 Release Note
2+
-------------------------------------------
3+
4+
Resolved Issues(Bugs below are eligible for Bug Bounty Program):
5+
1.Too short timer which set by os_arm_timer_us may cause crash. [Tommy]
6+
2.Call os_malloc in low heap situation may cause crash. [MeneerThijs]
7+
3.Memory leak issue when SSL connection fail. [孙新虎]
8+
9+
Optimization:
10+
1.Update JSON parser to handle with illegal parameter and illegal calling progress.
11+
2.Add parameter of user_esp_platform_check_ip in user_websever.c which in IOT_Demo.
12+
3.Update UART driver to solve the problem that if send data through UART while ESP8266 startup may cause UART invalid.
13+
4.Update smartconfig to version 2.2, corresponding phone APP v0.3.2. And update the description and example of smartconfig_start in document "2C_ESP8266__Programming Guide"
14+
5.Update code in iram to solve the problem that space for text is not enough.
15+
6.Update PWM driver and provide libpwm.a in esp_iot_sdk, update PWM APIs in "2C_ESP8266__Programming Guide", more details in "Added APIs" below.
16+
7.Revised issue that multicast may fail in ESP8266 softAP mode.
17+
8.Update folder "driver",add folder "driver_lib" in \esp_iot_sdk\examples , add "hw_timer.c" about frc1 hardware timer.
18+
9.Remove useless driver code in IOT_Demo
19+
10.Update IOT_Demo to use the latest PWM driver in light demo.
20+
11.Provide liblwip_536.a of which MSS size is 536
21+
12.Revised issue that boot may fail when 80Mhz SPI clock selected
22+
13.Update esp_init_data_default.bin about RF option in \esp_iot_sdk\bin
23+
24+
Added APIs:
25+
1.PWM APIs:
26+
Updated: pwm_init,add parameter to set PWM channel and GPIO pin
27+
Added:
28+
(1)get_pwm_version:get version information of PWM driver
29+
(2)pwm_set_period:set PWM period
30+
(3)pwm_get_period:get PWM period
31+
Deleted:
32+
(1)pwm_set_freq:set PWM frequency
33+
(2)pwm_get_freq:get PWM frequency
34+
2.Read/write flash with protection
35+
(1)system_param_save_with_protect:write data into flash with backup protection
36+
(2)system_param_load:read data which saved into flash with backup protection
37+
3.system_get_rst_info:get information about current startup,it is a normal startup or watch dog reset
38+
4.at_response:set AT response
39+
5.at_register_response_func:register a callback for user-define AT response.
40+
6.Update document "2C_ESP8266__Programming Guide" to add description of interrupt definition in ets_sys.h
41+
42+
AT_v0.25 Release Note:
43+
Note: For AT firmware to support FOTA, flash size need to be 1024KB or more than that.
44+
Optimization:
45+
1.Add parameter about UDP local port in command "AT+SAVETRANSLINK"
46+
47+
Added AT command:
48+
1.AT+CIPDINFO:set configuration whether show remote IP and remote port with “+IPD” or not
49+
50+
51+
152
esp_iot_sdk_v1.1.0_15_05_27_p1 Release Note
253
-------------------------------------------
354

tools/sdk/include/ets_sys.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ inline uint32_t ETS_INTR_PENDING(void)
7474
#define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \
7575
ets_isr_attach(ETS_FRC_TIMER1_INUM, (int_handler_t)(func), (void *)(arg))
7676

77+
#define ETS_FRC_TIMER1_NMI_INTR_ATTACH(func) \
78+
NmiTimSetFunc(func)
79+
7780
#define ETS_GPIO_INTR_ATTACH(func, arg) \
7881
ets_isr_attach(ETS_GPIO_INUM, (int_handler_t)(func), (void *)(arg))
7982

tools/sdk/include/smartconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ typedef void (*sc_callback_t)(sc_status status, void *pdata);
2424
const char *smartconfig_get_version(void);
2525
bool smartconfig_start(sc_type type, sc_callback_t cb, ...);
2626
bool smartconfig_stop(void);
27+
bool esptouch_set_timeout(uint8 time_s); //15s~255s, offset:45s
2728

2829
#endif

0 commit comments

Comments
 (0)