Skip to content

Commit a6d4f57

Browse files
author
Espressif Systems
committed
NEW VERSION: 1.0.4
1. memory optimize; 2. add irom version libm.a: libmirom.a; 3. more apis are supported in libcirom.a, such as sscanf, sprintf, etc; 4. add c++ support in Makefile; 5. put functions to iRAM default, don't need ICACHE_FLASH_ATTR anymore; 6. remove -O2 in Makefile; 7. fix some fatal exception bugs; 8. update smartconfig to version 2.4.7; 9. update some open source files and header files; 10.use os_printf can save memory; 11.add new apis: os_random and os_get_random; 12.bug fix in lwip/net80211/wpa modules; 13.other minor changes;
1 parent 76a22b4 commit a6d4f57

38 files changed

+99
-46
lines changed

Makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ifeq ($(COMPILE), gcc)
88
AR = xtensa-lx106-elf-ar
99
CC = xtensa-lx106-elf-gcc
1010
NM = xtensa-lx106-elf-nm
11-
CPP = xtensa-lx106-elf-cpp
11+
CPP = xtensa-lx106-elf-g++
1212
OBJCOPY = xtensa-lx106-elf-objcopy
1313
OBJDUMP = xtensa-lx106-elf-objdump
1414
else
@@ -162,6 +162,7 @@ else
162162
endif
163163

164164
CSRCS ?= $(wildcard *.c)
165+
CPPSRCS ?= $(wildcard *.cpp)
165166
ASRCs ?= $(wildcard *.s)
166167
ASRCS ?= $(wildcard *.S)
167168
SUBDIRS ?= $(patsubst %/,%,$(dir $(wildcard */Makefile)))
@@ -170,10 +171,12 @@ ODIR := .output
170171
OBJODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/obj
171172

172173
OBJS := $(CSRCS:%.c=$(OBJODIR)/%.o) \
174+
$(CPPSRCS:%.cpp=$(OBJODIR)/%.o) \
173175
$(ASRCs:%.s=$(OBJODIR)/%.o) \
174176
$(ASRCS:%.S=$(OBJODIR)/%.o)
175177

176178
DEPS := $(CSRCS:%.c=$(OBJODIR)/%.d) \
179+
$(CPPSRCS:%.cpp=$(OBJODIR)/%.d) \
177180
$(ASRCs:%.s=$(OBJODIR)/%.d) \
178181
$(ASRCS:%.S=$(OBJODIR)/%.d)
179182

@@ -188,15 +191,16 @@ OBINS := $(GEN_BINS:%=$(BINODIR)/%)
188191

189192
CCFLAGS += \
190193
-g \
191-
-O2 \
192194
-Wpointer-arith \
193195
-Wundef \
194196
-Werror \
195197
-Wl,-EL \
196198
-fno-inline-functions \
197199
-nostdlib \
198200
-mlongcalls \
199-
-mtext-section-literals
201+
-mtext-section-literals \
202+
-ffunction-sections \
203+
-fdata-sections
200204
# -Wall
201205

202206
CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(INCLUDES)
@@ -327,6 +331,18 @@ $(OBJODIR)/%.d: %.c
327331
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
328332
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
329333
rm -f $@.$$$$
334+
335+
$(OBJODIR)/%.o: %.cpp
336+
@mkdir -p $(OBJODIR);
337+
$(CPP) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
338+
339+
$(OBJODIR)/%.d: %.cpp
340+
@mkdir -p $(OBJODIR);
341+
@echo DEPEND: $(CPP) -M $(CFLAGS) $<
342+
@set -e; rm -f $@; \
343+
$(CPP) -M $(CFLAGS) $< > $@.$$$$; \
344+
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
345+
rm -f $@.$$$$
330346

331347
$(OBJODIR)/%.o: %.s
332348
@mkdir -p $(OBJODIR);

app/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ COMPONENTS_eagle.app.v6 = \
5050

5151
LINKFLAGS_eagle.app.v6 = \
5252
-L../lib \
53+
-Wl,--gc-sections \
5354
-nostdlib \
5455
-T$(LD_FILE) \
5556
-Wl,--no-check-sections \

app/user/user_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ void task3(void *pvParameters)
148148
* Parameters : none
149149
* Returns : none
150150
*******************************************************************************/
151-
void ICACHE_FLASH_ATTR
152-
user_init(void)
151+
void user_init(void)
153152
{
154153
printf("SDK version:%s\n", system_get_sdk_version());
155154

examples/smart_config/user/user_main.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#define server_ip "192.168.101.142"
2121
#define server_port 9669
2222

23-
sc_type SC_Type = 0;
24-
2523
void ICACHE_FLASH_ATTR
2624
smartconfig_done(sc_status status, void *pdata)
2725
{
@@ -34,6 +32,12 @@ smartconfig_done(sc_status status, void *pdata)
3432
break;
3533
case SC_STATUS_GETTING_SSID_PSWD:
3634
printf("SC_STATUS_GETTING_SSID_PSWD\n");
35+
sc_type *type = pdata;
36+
if (*type == SC_TYPE_ESPTOUCH) {
37+
printf("SC_TYPE:SC_TYPE_ESPTOUCH\n");
38+
} else {
39+
printf("SC_TYPE:SC_TYPE_AIRKISS\n");
40+
}
3741
break;
3842
case SC_STATUS_LINK:
3943
printf("SC_STATUS_LINK\n");
@@ -45,7 +49,7 @@ smartconfig_done(sc_status status, void *pdata)
4549
break;
4650
case SC_STATUS_LINK_OVER:
4751
printf("SC_STATUS_LINK_OVER\n");
48-
if (SC_Type == SC_TYPE_ESPTOUCH) {
52+
if (pdata != NULL) {
4953
uint8 phone_ip[4] = {0};
5054

5155
memcpy(phone_ip, (uint8*)pdata, 4);
@@ -60,10 +64,8 @@ smartconfig_done(sc_status status, void *pdata)
6064
void ICACHE_FLASH_ATTR
6165
smartconfig_task(void *pvParameters)
6266
{
63-
SC_Type = SC_TYPE_ESPTOUCH;
64-
65-
smartconfig_start(SC_Type, smartconfig_done);//SC_TYPE_AIRKISS
66-
67+
smartconfig_start(smartconfig_done);
68+
6769
vTaskDelete(NULL);
6870
}
6971

include/espressif/c_types.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ typedef enum {
7272
#define DMEM_ATTR __attribute__((section(".bss")))
7373
#define SHMEM_ATTR
7474

75-
#ifdef ICACHE_FLASH
76-
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
77-
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
78-
#else
75+
#define IRAM_ATTR __attribute__((section(".text")))
76+
7977
#define ICACHE_FLASH_ATTR
80-
#endif /* ICACHE_FLASH */
78+
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
79+
80+
#define STORE_ATTR __attribute__((aligned(4)))
8181

8282
#ifndef __cplusplus
8383
typedef unsigned char bool;

include/espressif/esp_libc.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ int printf(const char *format, ...);
3636
int sprintf(char *out, const char *format, ...);
3737
int snprintf(char *buf, unsigned int count, const char *format, ...);
3838
int puts(const char *str);
39-
int putchar(int c);
4039

4140
void *malloc(size_t n);
4241
void free(void *p);
@@ -47,16 +46,13 @@ void *realloc(void *p, size_t n);
4746
int atoi(const char *s);
4847
long atol(const char *s);
4948

50-
/* NOTE: don't use printf_opt in irq handler, for test */
51-
#define printf_opt(fmt, ...) do { \
52-
static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
53-
printf(flash_str, ##__VA_ARGS__); \
54-
} while(0)
49+
unsigned long os_random(void);
50+
int os_get_random(unsigned char *buf, size_t len);
5551

5652
/* NOTE: don't use printf_opt in irq handler, for test */
57-
#define sprintf_opt(out, fmt, ...) do { \
58-
static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
59-
sprintf(out, flash_str, ##__VA_ARGS__); \
53+
#define os_printf(fmt, ...) do { \
54+
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
55+
printf(flash_str, ##__VA_ARGS__); \
6056
} while(0)
6157

6258
#endif /* __LIBC_H__ */

include/espressif/smartconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef enum {
2222
typedef void (*sc_callback_t)(sc_status status, void *pdata);
2323

2424
const char *smartconfig_get_version(void);
25-
bool smartconfig_start(sc_type type, sc_callback_t cb, ...);
25+
bool smartconfig_start(sc_callback_t cb, ...);
2626
bool smartconfig_stop(void);
2727
bool esptouch_set_timeout(uint8 time_s);//15s~255s, offset:45s
2828

include/freertos/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#define configCPU_CLOCK_HZ ( ( unsigned long ) 80000000 )
8484
#define configTICK_RATE_HZ ( ( portTickType ) 100 )
8585
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 15 )
86-
#define configMINIMAL_STACK_SIZE ( ( unsigned short )156 )
86+
#define configMINIMAL_STACK_SIZE ( ( unsigned short )176 )
8787
//#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) )
8888
#define configMAX_TASK_NAME_LEN ( 16 )
8989
#define configUSE_TRACE_FACILITY 0

include/lwip/arch/cc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ typedef int sys_prot_t;
7373
//#define LWIP_DEBUG
7474

7575
#ifdef LWIP_DEBUG
76+
#include <stdio.h>
77+
78+
#define os_printf(fmt, ...) do { \
79+
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
80+
printf(flash_str, ##__VA_ARGS__); \
81+
} while(0)
82+
7683
#define LWIP_PLATFORM_DIAG(x) do {os_printf x;} while(0)
7784
#define LWIP_PLATFORM_ASSERT(x) do {os_printf(x); sys_arch_assert(__FILE__, __LINE__);} while(0)
7885
#else

include/lwip/lwip/dhcp.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ void dhcp_fine_tmr(void);
206206
#define DHCP_OPTION_TCP_TTL 37
207207
#define DHCP_OPTION_END 255
208208

209+
/**add options for support more router by liuHan**/
210+
#ifdef LWIP_ESP8266
211+
#define DHCP_OPTION_DOMAIN_NAME 15
212+
#define DHCP_OPTION_PRD 31
213+
#define DHCP_OPTION_STATIC_ROUTER 33
214+
#define DHCP_OPTION_VSN 43
215+
#define DHCP_OPTION_NB_TINS 44
216+
#define DHCP_OPTION_NB_TINT 46
217+
#define DHCP_OPTION_NB_TIS 47
218+
#define DHCP_OPTION_CLASSLESS_STATIC_ROUTER 121
219+
220+
#endif
209221
/** DHCP options */
210222
#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
211223
#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */

include/lwip/lwip/memp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ typedef enum {
7676
#endif /* MEM_USE_POOLS */
7777

7878
#if MEMP_MEM_MALLOC || MEM_USE_POOLS
79-
extern const u16_t memp_sizes[MEMP_MAX];
79+
extern const u32_t memp_sizes[MEMP_MAX];
8080
#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
8181

8282
#if MEMP_MEM_MALLOC

include/lwip/lwipopts.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@
250250
---------- Network Interfaces options ----------
251251
------------------------------------------------
252252
*/
253+
254+
/**
255+
* LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
256+
* field.
257+
*/
258+
#define LWIP_NETIF_HOSTNAME 1
259+
253260
/**
254261
* LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data
255262
* to be sent into one single pbuf. This is for compatibility with DMA-enabled
@@ -336,7 +343,7 @@
336343
* LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!)
337344
* Don't use it if you're not an active lwIP project member
338345
*/
339-
#define LWIP_TCPIP_CORE_LOCKING 1
346+
#define LWIP_TCPIP_CORE_LOCKING 0
340347

341348
/*
342349
------------------------------------

ld/eagle.app.v6.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

ld/eagle.app.v6.new.1024.app1.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

ld/eagle.app.v6.new.1024.app2.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

ld/eagle.app.v6.new.2048.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

ld/eagle.app.v6.new.512.app1.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

ld/eagle.app.v6.new.512.app2.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

ld/eagle.app.v6.old.1024.app1.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

ld/eagle.app.v6.old.1024.app2.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SECTIONS
188188
*(.entry.text)
189189
*(.init.literal)
190190
*(.init)
191-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
191+
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
192192
*(.fini.literal)
193193
*(.fini)
194194
*(.gnu.version)
@@ -209,6 +209,7 @@ SECTIONS
209209
{
210210
_irom0_text_start = ABSOLUTE(.);
211211
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
212+
*(.literal.* .text.*)
212213
_irom0_text_end = ABSOLUTE(.);
213214
} >irom0_0_seg :irom0_0_phdr
214215
}

0 commit comments

Comments
 (0)