reduce static memory usage; misc fixes

This commit is contained in:
Thorsten von Eicken 2015-09-29 23:06:13 -07:00
parent fe8da89356
commit 81d7576894
4 changed files with 32 additions and 19 deletions

View File

@ -654,7 +654,11 @@ endif
ifdef DEBUG
#OPTIMIZEFLAGS=-Os -g
ifeq ($(FAMILY),ESP8266)
OPTIMIZEFLAGS=-g -Os
else
OPTIMIZEFLAGS=-g
endif
DEFINES+=-DDEBUG
endif
@ -1236,6 +1240,8 @@ ifdef NRF5X
endif #NRF5X
ifeq ($(FAMILY),ESP8266)
# move os_printf strings into flash to save RAM space
DEFINES += -DUSE_OPTIMIZE_PRINTF
ESP8266=1
LIBS += -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain
CFLAGS+= -fno-builtin -fno-strict-aliasing \
@ -1565,10 +1571,12 @@ $(USER1_BIN): $(USER1_ELF)
$(Q) rm -f eagle.app.v6.*.bin
$(Q) mv eagle.app.flash.bin $@
@echo "** user1.bin uses $$(stat -c '%s' $@) bytes of" $(ESP_FLASH_MAX) "available"
$(Q) if [ $$(stat -c '%s' $@) -gt $$(( $(ESP_FLASH_MAX) )) ]; then echo "$@ too big!"; false; fi
@if [ $$(stat -c '%s' $@) -gt $$(( $(ESP_FLASH_MAX) )) ]; then echo "$@ too big!"; false; fi
# generate binary image for user2, i.e. second OTA partition
$(USER2_BIN): $(USER2_ELF)
# we make this rule dependent on user1.bin in order to serialize the two rules because they use
# stupid static filenames (go blame the Espressif tool)
$(USER2_BIN): $(USER2_ELF) $(USER1_BIN)
$(Q)$(OBJCOPY) --only-section .text -O binary $(USER2_ELF) eagle.app.v6.text.bin
$(Q)$(OBJCOPY) --only-section .data -O binary $(USER2_ELF) eagle.app.v6.data.bin
$(Q)$(OBJCOPY) --only-section .rodata -O binary $(USER2_ELF) eagle.app.v6.rodata.bin

View File

@ -89,6 +89,7 @@ void jswrap_ESP8266WiFi_connect(JsVar *jsv_ssid, JsVar *jsv_password, JsVar *got
if (gotIpCallback != NULL) {
jsGotIpCallback = jsvLockAgainSafe(gotIpCallback);
}
os_printf("jsGotIpCallback=%p\n", jsGotIpCallback);
// Create strings from the JsVars for the ESP8266 API calls.
char ssid[33];
@ -119,6 +120,7 @@ void jswrap_ESP8266WiFi_connect(JsVar *jsv_ssid, JsVar *jsv_password, JsVar *got
wifi_set_event_handler_cb(wifiEventHandler);
wifi_station_connect();
wifi_set_event_handler_cb(wifiEventHandler);
} // End of jswrap_ESP8266WiFi_connect
@ -542,9 +544,17 @@ JsVar *jswrap_ESP8266WiFi_getRSSI() {
}*/
void jswrap_ESP8266WiFi_init() {
os_printf("> jswrap_ESP8266WiFi_init\n");
os_printf("Heap: %d\n", system_get_free_heap_size());
// register the state change handler so we get debug printout for sure
wifi_set_phy_mode(2);
wifi_set_event_handler_cb(wifiEventHandler);
os_printf("Wifi init, mode=%d\n", wifi_get_opmode());
wifi_station_set_hostname("espruino");
netInit_esp8266_board();
setupJsNetwork();
networkState = NETWORKSTATE_ONLINE;
os_printf("Heap: %d\n", system_get_free_heap_size());
os_printf("< jswrap_ESP8266WiFi_init\n");
} // End of jswrap_ESP8266WiFi_init
@ -818,7 +828,7 @@ static void scanCB(void *arg, STATUS status) {
bssInfo = (struct bss_info *)arg;
// skip the first in the chain … it is invalid
bssInfo = STAILQ_NEXT(bssInfo, next);
//bssInfo = STAILQ_NEXT(bssInfo, next); // this got fixed in SDK 1.4
while(bssInfo != NULL) {
// Add a new object to the JS array that will be passed as a parameter to
// the callback. The ESP8266 bssInfo structure contains the following:

View File

@ -36,22 +36,9 @@ void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg);
void ets_update_cpu_frequency(int freqmhz);
#ifdef SDK_DBG
#define DEBUG_SDK true
#else
#define DEBUG_SDK false
#endif
int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__((format(printf, 3, 4)));
int os_printf_plus(const char *format, ...) __attribute__((format(printf, 1, 2)));
#undef os_printf
#define os_printf(format, ...) do {\
system_set_os_print(true); \
os_printf_plus(format, ## __VA_ARGS__); \
system_set_os_print(DEBUG_SDK); \
} while(0)
// memory allocation functions are "different" due to memory debugging functionality
// added in SDK 1.4.0
void vPortFree(void *ptr, char * file, int line);

View File

@ -27,7 +27,7 @@ typedef long long int64_t;
#define TASK_QUEUE_LENGTH 10
// Should we introduce a ticker to say we are still alive?
//#define EPS8266_BOARD_HEARTBEAT
#define EPS8266_BOARD_HEARTBEAT
// --- Forward definitions
static void mainLoop();
@ -124,6 +124,7 @@ static void eventHandler(
} // End of eventHandler
#if 0
/**
* \brief A callback function to be invoked when a line has been entered on the telnet client.
* Here we want to pass that line to the JS parser for processing.
@ -146,7 +147,9 @@ static void telnetLineCB(char *line) {
static void gotIpCallback() {
telnet_startListening(telnetLineCB);
} // End of gotIpCallback
#endif
static uint32 lastTime = 0;
/**
* \brief Perform the main loop processing.
@ -162,7 +165,8 @@ static void mainLoop() {
#ifdef EPS8266_BOARD_HEARTBEAT
if (system_get_time() - lastTime > 1000 * 1000 * 5) {
lastTime = system_get_time();
os_printf("tick: %d\n", jshGetSystemTime());
os_printf("tick: %ld, heap: %ld\n",
(uint32)(jshGetSystemTime()), system_get_free_heap_size());
}
#endif
@ -178,6 +182,7 @@ static void mainLoop() {
*/
static void initDone() {
os_printf("initDone invoked\n");
os_printf("Heap: %d\n", system_get_free_heap_size());
// Discard any junk data in the input as this is a boot.
//uart_rx_discard();
@ -197,6 +202,7 @@ static void initDone() {
// Post the first event to get us going.
queueTaskMainLoop();
os_printf("Heap: %d\n", system_get_free_heap_size());
return;
} // End of initDone
@ -218,7 +224,9 @@ void user_init() {
// Initialize the UART devices
uart_init(BIT_RATE_115200, BIT_RATE_115200);
os_delay_us(10000); // give the uart a break
UART_SetPrintPort(0);
UART_SetPrintPort(1);
system_set_os_print(1);
os_printf("Heap: %d\n", system_get_free_heap_size());
// Dump the restart exception information.
dumpRestart();