From c586f38765e04fd5caa2e9936a0c7dbfd7ee8c2f Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Mon, 24 Aug 2015 15:48:12 -0500 Subject: [PATCH 1/7] swapped out for offsite web files --- Makefile | 6 +- cmd/cmd.h | 1 + esp-link.vcxproj | 2 +- html-old/console.html | 46 +++++++++++++++ {html => html-old}/console.js | 0 {html => html-old}/favicon.ico | Bin html-old/head- | 10 ++++ html-old/home.html | 87 ++++++++++++++++++++++++++++ {html => html-old}/jl-400x110.png- | Bin html-old/log.html | 48 ++++++++++++++++ {html => html-old}/pure.css | 0 {html => html-old}/style.css | 0 {html => html-old}/ui.js | 0 {html => html-old}/wifi/icons.png | Bin html-old/wifi/wifi.html | 84 +++++++++++++++++++++++++++ {html => html-old}/wifi/wifi.js | 0 html/console.html | 47 +-------------- html/head- | 10 ---- html/home.html | 88 +---------------------------- html/log.html | 49 +--------------- html/wifi/wifi.html | 85 +--------------------------- user/user_main.c | 59 ++++++++++--------- 22 files changed, 317 insertions(+), 305 deletions(-) create mode 100644 html-old/console.html rename {html => html-old}/console.js (100%) rename {html => html-old}/favicon.ico (100%) mode change 100755 => 100644 create mode 100644 html-old/head- create mode 100644 html-old/home.html rename {html => html-old}/jl-400x110.png- (100%) mode change 100755 => 100644 create mode 100644 html-old/log.html rename {html => html-old}/pure.css (100%) rename {html => html-old}/style.css (100%) rename {html => html-old}/ui.js (100%) rename {html => html-old}/wifi/icons.png (100%) create mode 100644 html-old/wifi/wifi.html rename {html => html-old}/wifi/wifi.js (100%) diff --git a/Makefile b/Makefile index 08f0dcd..a3df665 100644 --- a/Makefile +++ b/Makefile @@ -25,13 +25,13 @@ SDK_BASE ?= $(abspath ../esp_iot_sdk_v1.3.0) # Typically you'll use https://github.com/themadinventor/esptool # Windows users use the com port i.e: ESPPORT ?= com3 ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py) -ESPPORT ?= /dev/ttyUSB0 -ESPBAUD ?= 460800 +ESPPORT ?= com10 +ESPBAUD ?= 230400 # --------------- chipset configuration --------------- # Pick your flash size: "512KB", "1MB", or "4MB" -FLASH_SIZE ?= 4MB +FLASH_SIZE ?= 512KB ifeq ("$(FLASH_SIZE)","512KB") # Winbond 25Q40 512KB flash, typ for esp-01 thru esp-11 diff --git a/cmd/cmd.h b/cmd/cmd.h index 5a66bc7..23bd584 100644 --- a/cmd/cmd.h +++ b/cmd/cmd.h @@ -4,6 +4,7 @@ #ifndef CMD_H #define CMD_H +#include // Escape chars used by tuanpmt, dunno why he didn't use std ones... #define SLIP_START 0x7E diff --git a/esp-link.vcxproj b/esp-link.vcxproj index 1fc9e5c..2a774e9 100644 --- a/esp-link.vcxproj +++ b/esp-link.vcxproj @@ -28,7 +28,7 @@ __ets__;_STDINT_H;ICACHE_FLASH;__MINGW32__;__WIN32__ - .\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.3.0\include;C:\tools\mingw64\include + .\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.3.0\include;..\xtensa-lx106-elf\xtensa-lx106-elf\include;c:\tools\mingw64\x86_64-w64-mingw32\include;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include diff --git a/html-old/console.html b/html-old/console.html new file mode 100644 index 0000000..db4c0a6 --- /dev/null +++ b/html-old/console.html @@ -0,0 +1,46 @@ +
+
+

Microcontroller Console

+
+ +
+

The Microcontroller console shows the last 1024 characters + received from UART0, to which a microcontroller is typically attached. + The UART is configured for 8 bits, no parity, 1 stop bit (8N1).

+

+ Reset µC +  Baud: + +

+

+    
+
+ + + + + + diff --git a/html/console.js b/html-old/console.js similarity index 100% rename from html/console.js rename to html-old/console.js diff --git a/html/favicon.ico b/html-old/favicon.ico old mode 100755 new mode 100644 similarity index 100% rename from html/favicon.ico rename to html-old/favicon.ico diff --git a/html-old/head- b/html-old/head- new file mode 100644 index 0000000..514ff53 --- /dev/null +++ b/html-old/head- @@ -0,0 +1,10 @@ + + + esp-link + + + + + + +
diff --git a/html-old/home.html b/html-old/home.html new file mode 100644 index 0000000..46a984d --- /dev/null +++ b/html-old/home.html @@ -0,0 +1,87 @@ +
+
+
JEELABS
+

esp-link

+

+
+ +
+
+
+

The JeeLabs esp-link firmware bridges the ESP8266 serial port to Wifi and can + program microcontrollers over the serial port, in particular Arduinos, AVRs, and + NXP's LPC800 and other ARM processors.

+

Program an Arduino/AVR using avrdude using a command + line similar to:

+
/home/arduino-1.0.5/hardware/tools/avrdude \
+   -DV -patmega328p -Pnet:esp-link.local:23 -carduino -b115200 -U \
+   -C /home/arduino-1.0.5/hardware/tools/avrdude.conf flash:w:my_sketch.hex:i +
+

where -Pnet:esp-link.local:23 tells avrdude to connect to port 23 of esp-link. + You can substitute the IP address of your esp-link for esp-link.local if necessary.

+

Please refer to + the online README + for up-to-date help and to the forthcoming + JeeLabs blog for an intro to the codebase.

+
+
+
+
+
+

Wifi summary

+
+ + + + + + + + +
+
+

TCP client

+
+ TCP client support in esp-link +
+ + +
+
+ Grovestreams data push +
+ + +
+
+ + +
+ +
+
+
+
+

Pin assignment

+ Select one of the following signal/pin assignments to match your hardware +
+
+
+
+
+
+
+
+
+
+ + + diff --git a/html/jl-400x110.png- b/html-old/jl-400x110.png- old mode 100755 new mode 100644 similarity index 100% rename from html/jl-400x110.png- rename to html-old/jl-400x110.png- diff --git a/html-old/log.html b/html-old/log.html new file mode 100644 index 0000000..46ec785 --- /dev/null +++ b/html-old/log.html @@ -0,0 +1,48 @@ +
+
+

Debug Log

+
+ +
+

The debug log shows the most recent characters printed by the esp-link software itself to + its own debug log.

+
+

+ Refresh +

+

+ UART debug log: + auto + off + on +

+
+

+    
+
+ + + + + + diff --git a/html/pure.css b/html-old/pure.css similarity index 100% rename from html/pure.css rename to html-old/pure.css diff --git a/html/style.css b/html-old/style.css similarity index 100% rename from html/style.css rename to html-old/style.css diff --git a/html/ui.js b/html-old/ui.js similarity index 100% rename from html/ui.js rename to html-old/ui.js diff --git a/html/wifi/icons.png b/html-old/wifi/icons.png similarity index 100% rename from html/wifi/icons.png rename to html-old/wifi/icons.png diff --git a/html-old/wifi/wifi.html b/html-old/wifi/wifi.html new file mode 100644 index 0000000..b6c142b --- /dev/null +++ b/html-old/wifi/wifi.html @@ -0,0 +1,84 @@ +
+
+

Wifi Configuration

+
+ +
+
+
+

Wifi State

+
+ + + + + + + + + + + +
+
+

Wifi Association

+ +
+ To connect to a WiFi network, please select one of the detected networks, + enter the password, and hit the connect button... + +
Scanning...
+ + + +
+
+
+
+
+

Special Settings

+
+ Special settings, use with care! +
+ + +
+
+ + +
+
+ + + + + + +
+ +
+
+
+
+
+ + + + + + diff --git a/html/wifi/wifi.js b/html-old/wifi/wifi.js similarity index 100% rename from html/wifi/wifi.js rename to html-old/wifi/wifi.js diff --git a/html/console.html b/html/console.html index db4c0a6..549ae82 100644 --- a/html/console.html +++ b/html/console.html @@ -1,46 +1 @@ -
-
-

Microcontroller Console

-
- -
-

The Microcontroller console shows the last 1024 characters - received from UART0, to which a microcontroller is typically attached. - The UART is configured for 8 bits, no parity, 1 stop bit (8N1).

-

- Reset µC -  Baud: - -

-

-    
-
- - - - - - + diff --git a/html/head- b/html/head- index 514ff53..e69de29 100644 --- a/html/head- +++ b/html/head- @@ -1,10 +0,0 @@ - - - esp-link - - - - - - -
diff --git a/html/home.html b/html/home.html index 46a984d..2677264 100644 --- a/html/home.html +++ b/html/home.html @@ -1,87 +1 @@ -
-
-
JEELABS
-

esp-link

-

-
- -
-
-
-

The JeeLabs esp-link firmware bridges the ESP8266 serial port to Wifi and can - program microcontrollers over the serial port, in particular Arduinos, AVRs, and - NXP's LPC800 and other ARM processors.

-

Program an Arduino/AVR using avrdude using a command - line similar to:

-
/home/arduino-1.0.5/hardware/tools/avrdude \
-   -DV -patmega328p -Pnet:esp-link.local:23 -carduino -b115200 -U \
-   -C /home/arduino-1.0.5/hardware/tools/avrdude.conf flash:w:my_sketch.hex:i -
-

where -Pnet:esp-link.local:23 tells avrdude to connect to port 23 of esp-link. - You can substitute the IP address of your esp-link for esp-link.local if necessary.

-

Please refer to - the online README - for up-to-date help and to the forthcoming - JeeLabs blog for an intro to the codebase.

-
-
-
-
-
-

Wifi summary

-
- - - - - - - - -
-
-

TCP client

-
- TCP client support in esp-link -
- - -
-
- Grovestreams data push -
- - -
-
- - -
- -
-
-
-
-

Pin assignment

- Select one of the following signal/pin assignments to match your hardware -
-
-
-
-
-
-
-
-
-
- - - + diff --git a/html/log.html b/html/log.html index 46ec785..7bec267 100644 --- a/html/log.html +++ b/html/log.html @@ -1,48 +1 @@ -
-
-

Debug Log

-
- -
-

The debug log shows the most recent characters printed by the esp-link software itself to - its own debug log.

-
-

- Refresh -

-

- UART debug log: - auto - off - on -

-
-

-    
-
- - - - - - + diff --git a/html/wifi/wifi.html b/html/wifi/wifi.html index b6c142b..a6dd616 100644 --- a/html/wifi/wifi.html +++ b/html/wifi/wifi.html @@ -1,84 +1 @@ -
-
-

Wifi Configuration

-
- -
-
-
-

Wifi State

-
- - - - - - - - - - - -
-
-

Wifi Association

- -
- To connect to a WiFi network, please select one of the detected networks, - enter the password, and hit the connect button... - -
Scanning...
- - - -
-
-
-
-
-

Special Settings

-
- Special settings, use with care! -
- - -
-
- - -
-
- - - - - - -
- -
-
-
-
-
- - - - - - + diff --git a/user/user_main.c b/user/user_main.c index 54ca59e..cf6d266 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -48,7 +48,6 @@ int myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pas return 0; } - /* This is the main url->function dispatching data struct. In short, it's a struct with various URLs plus their handlers. The handlers can @@ -95,7 +94,6 @@ HttpdBuiltInUrl builtInUrls[]={ {NULL, NULL, NULL} }; - //#define SHOW_HEAP_USE #ifdef SHOW_HEAP_USE @@ -106,7 +104,36 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) { } #endif +# define VERS_STR_STR(V) #V +# define VERS_STR(V) VERS_STR_STR(V) +char *esp_link_version = VERS_STR(VERSION); + void user_rf_pre_init(void) { + // get the flash config so we know how to init things + //configWipe(); // uncomment to reset the config for testing purposes + bool restoreOk = configRestore(); + + // init gpio pin registers + gpio_init(); + + // init UART + uart_init(flashConfig.baud_rate, 115200); + logInit(); // must come after init of uart + + // say hello (leave some time to cause break in TX after boot loader's msg + os_delay_us(10000L); + os_printf("\n\n** %s\n", esp_link_version); + os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); + + // Status LEDs + statusInit(); + serledInit(); + +#ifdef SHOW_HEAP_USE + os_timer_disarm(&prHeapTimer); + os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); + os_timer_arm(&prHeapTimer, 10000, 1); +#endif } // address of espfs binary blob @@ -116,43 +143,23 @@ static char *rst_codes[] = { "normal", "wdt reset", "exception", "soft wdt", "restart", "deep sleep", "external", }; -# define VERS_STR_STR(V) #V -# define VERS_STR(V) VERS_STR_STR(V) -char *esp_link_version = VERS_STR(VERSION); - //Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done. void user_init(void) { - // get the flash config so we know how to init things - //configWipe(); // uncomment to reset the config for testing purposes - bool restoreOk = configRestore(); - // init gpio pin registers - gpio_init(); - // init UART - uart_init(flashConfig.baud_rate, 115200); - logInit(); // must come after init of uart - // say hello (leave some time to cause break in TX after boot loader's msg - os_delay_us(10000L); - os_printf("\n\n** %s\n", esp_link_version); - os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); - // Status LEDs - statusInit(); - serledInit(); // Wifi wifiInit(); + // init the flash filesystem with the html stuff espFsInit(&_binary_espfs_img_start); + //EspFsInitResult res = espFsInit(&_binary_espfs_img_start); //os_printf("espFsInit %s\n", res?"ERR":"ok"); + // mount the http handlers httpdInit(builtInUrls, 80); + // init the wifi-serial transparent bridge (port 23) serbridgeInit(23); uart_add_recv_cb(&serbridgeUartCb); -#ifdef SHOW_HEAP_USE - os_timer_disarm(&prHeapTimer); - os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); - os_timer_arm(&prHeapTimer, 10000, 1); -#endif struct rst_info *rst_info = system_get_rst_info(); os_printf("Reset cause: %d=%s\n", rst_info->reason, rst_codes[rst_info->reason]); From 38922383883cd06a6b2cfd408de476dffbf8095c Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Fri, 28 Aug 2015 15:00:59 -0500 Subject: [PATCH 2/7] dynamic arduino callback support --- cmd/cmd.h | 24 +++-- cmd/handlers.c | 102 +++++++++++++++++-- {html-old => httpd/html-old}/console.html | 0 {html-old => httpd/html-old}/console.js | 0 {html-old => httpd/html-old}/favicon.ico | Bin {html-old => httpd/html-old}/head- | 0 {html-old => httpd/html-old}/home.html | 0 {html-old => httpd/html-old}/jl-400x110.png- | Bin {html-old => httpd/html-old}/log.html | 0 {html-old => httpd/html-old}/pure.css | 0 {html-old => httpd/html-old}/style.css | 0 {html-old => httpd/html-old}/ui.js | 0 {html-old => httpd/html-old}/wifi/icons.png | Bin {html-old => httpd/html-old}/wifi/wifi.html | 0 {html-old => httpd/html-old}/wifi/wifi.js | 0 15 files changed, 110 insertions(+), 16 deletions(-) rename {html-old => httpd/html-old}/console.html (100%) rename {html-old => httpd/html-old}/console.js (100%) rename {html-old => httpd/html-old}/favicon.ico (100%) rename {html-old => httpd/html-old}/head- (100%) rename {html-old => httpd/html-old}/home.html (100%) rename {html-old => httpd/html-old}/jl-400x110.png- (100%) rename {html-old => httpd/html-old}/log.html (100%) rename {html-old => httpd/html-old}/pure.css (100%) rename {html-old => httpd/html-old}/style.css (100%) rename {html-old => httpd/html-old}/ui.js (100%) rename {html-old => httpd/html-old}/wifi/icons.png (100%) rename {html-old => httpd/html-old}/wifi/wifi.html (100%) rename {html-old => httpd/html-old}/wifi/wifi.js (100%) diff --git a/cmd/cmd.h b/cmd/cmd.h index 23bd584..b489108 100644 --- a/cmd/cmd.h +++ b/cmd/cmd.h @@ -20,12 +20,12 @@ #define SLIP_ESC_ESC 0335 // ESC ESC_ESC means ESC data byte #endif -typedef struct __attribute((__packed__)) { +typedef struct __attribute__((__packed__)) { uint16_t len; // length of data uint8_t data[0]; // really data[len] } CmdArg; -typedef struct __attribute((__packed__)) { +typedef struct __attribute__((__packed__)) { uint16_t cmd; // command to perform, from CmdName enum uint32_t callback; // callback pointer to embed in response uint32_t _return; // return value to embed in response (?) @@ -54,7 +54,9 @@ typedef enum { CMD_REST_SETUP, // (11) CMD_REST_REQUEST, CMD_REST_SETHEADER, - CMD_REST_EVENTS + CMD_REST_EVENTS, + CMD_ADD_SENSOR, // 15 + CMD_SENSOR_EVENTS } CmdName; typedef uint32_t (*cmdfunc_t)(CmdPacket *cmd); @@ -64,18 +66,24 @@ typedef struct { cmdfunc_t sc_function; } CmdList; -void CMD_parse_packet(uint8_t *buf, short len); +typedef struct { + char name[16]; + uint32_t callback; +} cmdCallback; + +void ICACHE_FLASH_ATTR CMD_parse_packet(uint8_t *buf, short len); +cmdCallback* ICACHE_FLASH_ATTR CMD_GetCbByName(char* name); // Responses // Start a response, returns the partial CRC -uint16_t CMD_ResponseStart(uint16_t cmd, uint32_t callback, uint32_t _return, uint16_t argc); +uint16_t ICACHE_FLASH_ATTR CMD_ResponseStart(uint16_t cmd, uint32_t callback, uint32_t _return, uint16_t argc); // Adds data to a response, returns the partial CRC -uint16_t CMD_ResponseBody(uint16_t crc_in, uint8_t* data, short len); +uint16_t ICACHE_FLASH_ATTR CMD_ResponseBody(uint16_t crc_in, uint8_t* data, short len); // Ends a response -void CMD_ResponseEnd(uint16_t crc); +void ICACHE_FLASH_ATTR CMD_ResponseEnd(uint16_t crc); -void CMD_Response(uint16_t cmd, uint32_t callback, uint32_t _return, uint16_t argc, CmdArg* args[]); +//void ICACHE_FLASH_ATTR CMD_Response(uint16_t cmd, uint32_t callback, uint32_t _return, uint16_t argc, CmdArg* args[]); // Requests diff --git a/cmd/handlers.c b/cmd/handlers.c index 73370dd..8e6deb0 100644 --- a/cmd/handlers.c +++ b/cmd/handlers.c @@ -9,10 +9,14 @@ #include "serbridge.h" #include "uart.h" #include "cgiwifi.h" +#include static uint32_t ICACHE_FLASH_ATTR CMD_Null(CmdPacket *cmd); static uint32_t ICACHE_FLASH_ATTR CMD_IsReady(CmdPacket *cmd); static uint32_t ICACHE_FLASH_ATTR CMD_WifiConnect(CmdPacket *cmd); +static uint32_t ICACHE_FLASH_ATTR CMD_AddSensor(CmdPacket *cmd); + +static uint8_t lastWifiStatus = wifiIsDisconnected; // Command dispatch table for serial -> ESP commands const CmdList commands[] = { @@ -33,34 +37,83 @@ const CmdList commands[] = { {CMD_REST_SETUP, REST_Setup}, {CMD_REST_REQUEST, REST_Request}, {CMD_REST_SETHEADER, REST_SetHeader}, + + {CMD_ADD_SENSOR, CMD_AddSensor }, + {CMD_NULL, NULL} }; +// WifiCb plus 10 for sensors +cmdCallback callbacks[12] = { + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 }, + { { '\0' }, -1 } +}; + // Command handler for IsReady (healthcheck) command static uint32_t ICACHE_FLASH_ATTR CMD_IsReady(CmdPacket *cmd) { - os_printf("CMD: Check ready\n"); + os_printf("CMD_IsReady: Check ready\n"); return 1; } // Command handler for Null command static uint32_t ICACHE_FLASH_ATTR CMD_Null(CmdPacket *cmd) { - os_printf("CMD: NULL/unsupported command\n"); + os_printf("CMD_Null: NULL/unsupported command\n"); return 1; } -static uint8_t lastWifiStatus; -static uint32_t wifiCallback; +static void ICACHE_FLASH_ATTR +CMD_AddCb(char* name, uint32_t cb) { + char checkname[16]; + os_strncpy(checkname, name, sizeof(checkname)); + for (uint8_t i = 0; i < sizeof(commands); i++) { + os_printf("CMD_AddCb: index %d name=%s cb=%p\n", i, callbacks[i].name, (void *)callbacks[i].callback); + // find existing callback or add to the end + if (os_strcmp(callbacks[i].name, checkname) == 0 || callbacks[i].name[0] == '\0') { + os_strncpy(callbacks[i].name, checkname, sizeof(checkname)); + callbacks[i].callback = cb; + os_printf("CMD_AddCb: cb %s added at index %d\n", callbacks[i].name, i); + break; + } + } +} + +cmdCallback* ICACHE_FLASH_ATTR +CMD_GetCbByName(char* name) { + char checkname[16]; + os_strncpy(checkname, name, sizeof(checkname)); + for (uint8_t i = 0; i < sizeof(commands); i++) { + os_printf("CMD_GetCbByName: index %d name=%s cb=%p\n", i, callbacks[i].name, (void *)callbacks[i].callback); + // if callback doesn't exist or it's null + if (os_strcmp(callbacks[i].name, checkname) == 0) { + os_printf("CMD_GetCbByName: cb %s found at index %d\n", callbacks[i].name, i); + return &callbacks[i]; + } + } + os_printf("CMD_GetCbByName: cb %s not found\n", name); + return 0; +} // Callback from wifi subsystem to notify us of status changes static void ICACHE_FLASH_ATTR CMD_WifiCb(uint8_t wifiStatus) { if (wifiStatus != lastWifiStatus){ + os_printf("CMD_WifiCb: wifiStatus=%d\n", wifiStatus); lastWifiStatus = wifiStatus; - if (wifiCallback) { + cmdCallback *wifiCb = CMD_GetCbByName("wifiCb"); + if ((uint32_t)wifiCb->callback != -1) { uint8_t status = wifiStatus == wifiGotIP ? 5 : 1; - uint16_t crc = CMD_ResponseStart(CMD_WIFI_CONNECT, wifiCallback, 0, 1); + uint16_t crc = CMD_ResponseStart(CMD_WIFI_CONNECT, (uint32_t)wifiCb->callback, 0, 1); crc = CMD_ResponseBody(crc, (uint8_t*)&status, 1); CMD_ResponseEnd(crc); } @@ -70,10 +123,43 @@ CMD_WifiCb(uint8_t wifiStatus) { // Command handler for Wifi connect command static uint32_t ICACHE_FLASH_ATTR CMD_WifiConnect(CmdPacket *cmd) { + CmdRequest req; + CMD_Request(&req, cmd); + os_printf("CMD_WifiConnect: setup argc=%ld\n", CMD_GetArgc(&req)); if(cmd->argc != 2 || cmd->callback == 0) - return 0xFFFFFFFF; + return 0; wifiStatusCb = CMD_WifiCb; // register our callback with wifi subsystem - wifiCallback = cmd->callback; // save the MCU's callback + CMD_AddCb("wifiCb", (uint32_t)cmd->callback); // save the MCU's callback + lastWifiStatus = wifiIsDisconnected; + if (statusWifiState() != wifiIsDisconnected) { + CMD_WifiCb(statusWifiState()); + } + + return 1; +} + +// Command handler for Wifi connect command +static uint32_t ICACHE_FLASH_ATTR +CMD_AddSensor(CmdPacket *cmd) { + CmdRequest req; + CMD_Request(&req, cmd); + os_printf("CMD_AddSensor: setup argc=%ld\n", CMD_GetArgc(&req)); + if (cmd->argc != 1 || cmd->callback == 0) + return 0; + + uint8_t* name; + uint16_t len; + + // get the sensor name + len = CMD_ArgLen(&req); + os_printf("CMD_AddSensor: name len=%d\n", len); + if (len > 15) return 0; // max size of name is 15 characters + name = (uint8_t*)os_zalloc(len + 1); + if (CMD_PopArg(&req, name, len)) return 0; + name[len] = 0; + os_printf("CMD_AddSensor: name=%s\n", name); + + CMD_AddCb((char*)name, (uint32_t)cmd->callback); // save the sensor callback return 1; } diff --git a/html-old/console.html b/httpd/html-old/console.html similarity index 100% rename from html-old/console.html rename to httpd/html-old/console.html diff --git a/html-old/console.js b/httpd/html-old/console.js similarity index 100% rename from html-old/console.js rename to httpd/html-old/console.js diff --git a/html-old/favicon.ico b/httpd/html-old/favicon.ico similarity index 100% rename from html-old/favicon.ico rename to httpd/html-old/favicon.ico diff --git a/html-old/head- b/httpd/html-old/head- similarity index 100% rename from html-old/head- rename to httpd/html-old/head- diff --git a/html-old/home.html b/httpd/html-old/home.html similarity index 100% rename from html-old/home.html rename to httpd/html-old/home.html diff --git a/html-old/jl-400x110.png- b/httpd/html-old/jl-400x110.png- similarity index 100% rename from html-old/jl-400x110.png- rename to httpd/html-old/jl-400x110.png- diff --git a/html-old/log.html b/httpd/html-old/log.html similarity index 100% rename from html-old/log.html rename to httpd/html-old/log.html diff --git a/html-old/pure.css b/httpd/html-old/pure.css similarity index 100% rename from html-old/pure.css rename to httpd/html-old/pure.css diff --git a/html-old/style.css b/httpd/html-old/style.css similarity index 100% rename from html-old/style.css rename to httpd/html-old/style.css diff --git a/html-old/ui.js b/httpd/html-old/ui.js similarity index 100% rename from html-old/ui.js rename to httpd/html-old/ui.js diff --git a/html-old/wifi/icons.png b/httpd/html-old/wifi/icons.png similarity index 100% rename from html-old/wifi/icons.png rename to httpd/html-old/wifi/icons.png diff --git a/html-old/wifi/wifi.html b/httpd/html-old/wifi/wifi.html similarity index 100% rename from html-old/wifi/wifi.html rename to httpd/html-old/wifi/wifi.html diff --git a/html-old/wifi/wifi.js b/httpd/html-old/wifi/wifi.js similarity index 100% rename from html-old/wifi/wifi.js rename to httpd/html-old/wifi/wifi.js From 8e1516aacb3752f86a0bde967cc52cb387f22f07 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Fri, 28 Aug 2015 15:23:34 -0500 Subject: [PATCH 3/7] merge regressions --- cmd/handlers.c | 4 +--- esp-link.vcxproj | 2 +- user/status.c | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/handlers.c b/cmd/handlers.c index 3033e5c..28382dd 100644 --- a/cmd/handlers.c +++ b/cmd/handlers.c @@ -131,9 +131,7 @@ CMD_WifiConnect(CmdPacket *cmd) { wifiStatusCb = CMD_WifiCb; // register our callback with wifi subsystem CMD_AddCb("wifiCb", (uint32_t)cmd->callback); // save the MCU's callback lastWifiStatus = wifiIsDisconnected; - if (statusWifiState() != wifiIsDisconnected) { - CMD_WifiCb(statusWifiState()); - } + CMD_WifiCb(wifiState); return 1; } diff --git a/esp-link.vcxproj b/esp-link.vcxproj index 2a774e9..f8db9b3 100644 --- a/esp-link.vcxproj +++ b/esp-link.vcxproj @@ -44,7 +44,7 @@ espmake clean
- espmake baseflash + espmake all wiflash espmake clean all espmake clean diff --git a/user/status.c b/user/status.c index 50afb85..a6080fe 100644 --- a/user/status.c +++ b/user/status.c @@ -23,7 +23,6 @@ static void ICACHE_FLASH_ATTR setLed(int on) { } static uint8_t ledState = 0; -static uint8_t wifiState = 0; // Timer callback to update the LED static void ICACHE_FLASH_ATTR ledTimerCb(void *v) { From c286473be91d3cf04dd67237d81d93b8d35337e8 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Fri, 28 Aug 2015 15:37:50 -0500 Subject: [PATCH 4/7] no message --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8a769b0..6b40320 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,3 @@ esp-link.tgz tve-patch/ yui .localhistory/ -esp-link.sdf -espfs/mkespfsimage/mman-win32/libmman.a -espfs/mkespfsimage/mman-win32/mman.o From 059692dfad91e5ca6968ec7ea62b2b549a72c4e5 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Fri, 28 Aug 2015 19:23:16 -0500 Subject: [PATCH 5/7] Fixed mkespfsimage makefile and removed espfstest --- esp-link.vcxproj | 1 - espfs/espfstest/Makefile | 13 ------- espfs/espfstest/main.c | 67 ------------------------------------- espfs/mkespfsimage/Makefile | 53 +++++++++++++++++++++++------ 4 files changed, 42 insertions(+), 92 deletions(-) delete mode 100644 espfs/espfstest/Makefile delete mode 100644 espfs/espfstest/main.c diff --git a/esp-link.vcxproj b/esp-link.vcxproj index f8db9b3..c98faa5 100644 --- a/esp-link.vcxproj +++ b/esp-link.vcxproj @@ -68,7 +68,6 @@ - diff --git a/espfs/espfstest/Makefile b/espfs/espfstest/Makefile deleted file mode 100644 index f8296f4..0000000 --- a/espfs/espfstest/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -CFLAGS=-I../../lib/heatshrink -I.. -std=gnu99 -DESPFS_HEATSHRINK - -espfstest: main.o espfs.o heatshrink_decoder.o - $(CC) -o $@ $^ - -espfs.o: ../espfs.c - $(CC) $(CFLAGS) -c $^ -o $@ - -heatshrink_decoder.o: ../heatshrink_decoder.c - $(CC) $(CFLAGS) -c $^ -o $@ - -clean: - rm -f *.o espfstest diff --git a/espfs/espfstest/main.c b/espfs/espfstest/main.c deleted file mode 100644 index 16a6287..0000000 --- a/espfs/espfstest/main.c +++ /dev/null @@ -1,67 +0,0 @@ -/* -Simple and stupid file decompressor for an espfs image. Mostly used as a testbed for espfs.c and -the decompressors: code compiled natively is way easier to debug using gdb et all :) -*/ -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "espfs.h" - -char *espFsData; - -int main(int argc, char **argv) { - int f, out; - int len; - char buff[128]; - EspFsFile *ef; - off_t size; - EspFsInitResult ir; - - if (argc!=3) { - printf("Usage: %s espfs-image file\nExpands file from the espfs-image archive.\n", argv[0]); - exit(0); - } - - f=open(argv[1], O_RDONLY); - if (f<=0) { - perror(argv[1]); - exit(1); - } - size=lseek(f, 0, SEEK_END); - espFsData=mmap(NULL, size, PROT_READ, MAP_SHARED, f, 0); - if (espFsData==MAP_FAILED) { - perror("mmap"); - exit(1); - } - - ir=espFsInit(espFsData); - if (ir != ESPFS_INIT_RESULT_OK) { - printf("Couldn't init espfs filesystem (code %d)\n", ir); - exit(1); - } - - ef=espFsOpen(argv[2]); - if (ef==NULL) { - printf("Couldn't find %s in image.\n", argv[2]); - exit(1); - } - - out=open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0644); - if (out<=0) { - perror(argv[2]); - exit(1); - } - - while ((len=espFsRead(ef, buff, 128))!=0) { - write(out, buff, len); - } - espFsClose(ef); - //munmap, close, ... I can't be bothered. -} diff --git a/espfs/mkespfsimage/Makefile b/espfs/mkespfsimage/Makefile index b05d5b0..2980331 100644 --- a/espfs/mkespfsimage/Makefile +++ b/espfs/mkespfsimage/Makefile @@ -1,24 +1,55 @@ -GZIP_COMPRESSION?=no +GZIP_COMPRESSION ?= no -CFLAGS=-I.. -std=gnu99 +ifeq ($(OS),Windows_NT) + +TARGET = mkespfsimage.exe + +CC = gcc +LD = $(CC) +CFLAGS=-c -I.. -Imman-win32 -std=gnu99 +LDFLAGS=-Lmman-win32 -lmman ifeq ("$(GZIP_COMPRESSION)","yes") -LDFLAGS+=-lz -CFLAGS+=-DESPFS_GZIP +CFLAGS += -DESPFS_GZIP +LDFLAGS += -lz endif -ifeq ($(OS),Windows_NT) -CFLAGS+=-Imman-win32 -LDFLAGS+=-Lmman-win32 -lmman -TARGET =mkespfsimage.exe +OBJECTS = main.o + +all: libmman $(TARGET) + +libmman: + $(Q) make -C mman-win32 + +$(TARGET): $(OBJECTS) + $(LD) -o $@ $^ $(LDFLAGS) + +%.o: %.c + $(CC) $(CFLAGS) -o $@ $^ + +clean: + rm -f $(OBJECTS) $(TARGET) ./mman-win32/libmman.a ./mman-win32/mman.o + +.PHONY: all clean + else -TARGET =mkespfsimage + +CFLAGS=-I.. -std=gnu99 +ifeq ("$(GZIP_COMPRESSION)","yes") +CFLAGS += -DESPFS_GZIP endif OBJS=main.o +TARGET=mkespfsimage $(TARGET): $(OBJS) - $(CC) -o $@ $^ $(LDFLAGS) +ifeq ("$(GZIP_COMPRESSION)","yes") + $(CC) -o $@ $^ -lz +else + $(CC) -o $@ $^ +endif clean: - rm -f $(TARGET) $(OBJS) \ No newline at end of file + rm -f $(TARGET) $(OBJS) + +endif \ No newline at end of file From 31d308416b84e095e8399fb24fa91eb01cf0d1cb Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Sat, 29 Aug 2015 05:26:37 -0500 Subject: [PATCH 6/7] Merging --- .gitignore | 5 +- Makefile | 21 +- esp-link.sln | 22 +++ espfs/espfs.c | 66 ------- espfs/espfs.h | 4 - espfs/mkespfsimage/main.c | 90 ++------- espfs/mkespfsimage/mman-win32/Makefile | 48 +++++ espfs/mkespfsimage/mman-win32/config.mak | 11 ++ espfs/mkespfsimage/mman-win32/configure | 157 +++++++++++++++ espfs/mkespfsimage/mman-win32/mman.c | 180 +++++++++++++++++ espfs/mkespfsimage/mman-win32/mman.h | 55 ++++++ espfs/mkespfsimage/mman-win32/test.c | 235 +++++++++++++++++++++++ espmake.cmd | 7 + include/esp8266.h | 5 +- include/espmissingincludes.h | 10 +- user/config.c | 2 +- 16 files changed, 757 insertions(+), 161 deletions(-) create mode 100644 esp-link.sln create mode 100644 espfs/mkespfsimage/mman-win32/Makefile create mode 100644 espfs/mkespfsimage/mman-win32/config.mak create mode 100644 espfs/mkespfsimage/mman-win32/configure create mode 100644 espfs/mkespfsimage/mman-win32/mman.c create mode 100644 espfs/mkespfsimage/mman-win32/mman.h create mode 100644 espfs/mkespfsimage/mman-win32/test.c create mode 100644 espmake.cmd diff --git a/.gitignore b/.gitignore index 3364a8f..899b7c3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,8 @@ html_compressed/ esp-link.tgz tve-patch/ yui -.localhistory/ espfs/mkespfsimage/mman-win32/mman.o -espfs/mkespfsimage/mman-win32/libmman.a +esp-link.opensdf esp-link.sdf +espfs/mkespfsimage/mman-win32/libmman.a +.localhistory/ diff --git a/Makefile b/Makefile index 647ba20..08f0dcd 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ SDK_BASE ?= $(abspath ../esp_iot_sdk_v1.3.0) # Esptool.py path and port, only used for 1-time serial flashing # Typically you'll use https://github.com/themadinventor/esptool +# Windows users use the com port i.e: ESPPORT ?= com3 ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py) ESPPORT ?= /dev/ttyUSB0 ESPBAUD ?= 460800 @@ -108,7 +109,6 @@ CHANGE_TO_STA ?= yes # This could speed up the downloading of these files, but might break compatibility with older # web browsers not supporting gzip encoding because Accept-Encoding is simply ignored. # Enable this option if you have large static files to serve (for e.g. JQuery, Twitter bootstrap) -# By default only js, css and html files are compressed using heatshrink. # If you have text based static files with different extensions what you want to serve compressed # then you will need to add the extension to the following places: # - Add the extension to this Makefile at the webpages.espfs target to the find command @@ -127,10 +127,6 @@ GZIP_COMPRESSION ?= yes COMPRESS_W_YUI ?= yes YUI-COMPRESSOR ?= yuicompressor-2.4.8.jar -# If USE_HEATSHRINK is set to "yes" then the espfs files will be compressed with Heatshrink and -# decompressed on the fly while reading the file. -# Because the decompression is done in the esp8266, it does not require any support in the browser. -USE_HEATSHRINK ?= no # -------------- End of config options ------------- @@ -147,7 +143,7 @@ APPGEN_TOOL ?= gen_appbin.py # which modules (subdirectories) of the project to include in compiling MODULES = espfs httpd user serial cmd -EXTRA_INCDIR = include . # lib/heatshrink/ +EXTRA_INCDIR = include . # libraries used in this project, mainly provided by the SDK LIBS = c gcc hal phy pp net80211 wpa main lwip @@ -216,10 +212,6 @@ ifeq ("$(GZIP_COMPRESSION)","yes") CFLAGS += -DGZIP_COMPRESSION endif -ifeq ("$(USE_HEATSHRINK)","yes") -CFLAGS += -DESPFS_HEATSHRINK -endif - ifeq ("$(CHANGE_TO_STA)","yes") CFLAGS += -DCHANGE_TO_STA endif @@ -289,6 +281,9 @@ $(BUILD_DIR): wiflash: all ./wiflash $(ESP_HOSTNAME) $(FW_BASE)/user1.bin $(FW_BASE)/user2.bin +baseflash: all + $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x01000 $(FW_BASE)/user1.bin + flash: all $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) -fs $(ET_FS) -ff $(ET_FF) write_flash \ 0x00000 "$(SDK_BASE)/bin/boot_v1.4(b1).bin" 0x01000 $(FW_BASE)/user1.bin \ @@ -296,7 +291,11 @@ flash: all yui/$(YUI-COMPRESSOR): $(Q) mkdir -p yui + ifeq ($(OS),Windows_NT) + cd yui; wget --no-check-certificate https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI-COMPRESSOR) -O $(YUI-COMPRESSOR) + else cd yui; wget https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI-COMPRESSOR) + endif ifeq ("$(COMPRESS_W_YUI)","yes") $(BUILD_BASE)/espfs_img.o: yui/$(YUI-COMPRESSOR) @@ -348,7 +347,7 @@ build/eagle.esphttpd2.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.1024.app2.ld endif espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/ - $(Q) $(MAKE) -C espfs/mkespfsimage USE_HEATSHRINK="$(USE_HEATSHRINK)" GZIP_COMPRESSION="$(GZIP_COMPRESSION)" + $(Q) $(MAKE) -C espfs/mkespfsimage GZIP_COMPRESSION="$(GZIP_COMPRESSION)" release: all $(Q) rm -rf release; mkdir -p release/esp-link diff --git a/esp-link.sln b/esp-link.sln new file mode 100644 index 0000000..fb7b468 --- /dev/null +++ b/esp-link.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "esp-link", "esp-link.vcxproj", "{A92F0CAA-F89B-4F78-AD2A-A042429BD87F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Release|ARM = Release|ARM + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A92F0CAA-F89B-4F78-AD2A-A042429BD87F}.Debug|ARM.ActiveCfg = Debug|ARM + {A92F0CAA-F89B-4F78-AD2A-A042429BD87F}.Debug|ARM.Build.0 = Debug|ARM + {A92F0CAA-F89B-4F78-AD2A-A042429BD87F}.Release|ARM.ActiveCfg = Release|ARM + {A92F0CAA-F89B-4F78-AD2A-A042429BD87F}.Release|ARM.Build.0 = Release|ARM + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/espfs/espfs.c b/espfs/espfs.c index 3da6692..128ca29 100644 --- a/espfs/espfs.c +++ b/espfs/espfs.c @@ -40,11 +40,6 @@ It's written for use with httpd, but doesn't need to be used as such. #include "espfsformat.h" #include "espfs.h" -#ifdef ESPFS_HEATSHRINK -#include "heatshrink_config_custom.h" -#include "heatshrink_decoder.h" -#endif - static char* espFsData = NULL; struct EspFsFile { @@ -167,18 +162,6 @@ EspFsFile ICACHE_FLASH_ATTR *espFsOpen(char *fileName) { r->posDecomp=0; if (h.compression==COMPRESS_NONE) { r->decompData=NULL; -#ifdef ESPFS_HEATSHRINK - } else if (h.compression==COMPRESS_HEATSHRINK) { - //File is compressed with Heatshrink. - char parm; - heatshrink_decoder *dec; - //Decoder params are stored in 1st byte. - memcpyAligned(&parm, r->posComp, 1); - r->posComp++; - //os_printf("Heatshrink compressed file; decode parms = %x\n", parm); - dec=heatshrink_decoder_alloc(16, (parm>>4)&0xf, parm&0xf); - r->decompData=dec; -#endif } else { os_printf("Invalid compression: %d\n", h.compression); return NULL; @@ -209,48 +192,6 @@ int ICACHE_FLASH_ATTR espFsRead(EspFsFile *fh, char *buff, int len) { fh->posComp+=len; // os_printf("Done reading %d bytes, pos=%x\n", len, fh->posComp); return len; -#ifdef ESPFS_HEATSHRINK - } else if (fh->decompressor==COMPRESS_HEATSHRINK) { - int decoded=0; - size_t elen, rlen; - char ebuff[16]; - heatshrink_decoder *dec=(heatshrink_decoder *)fh->decompData; -// os_printf("Alloc %p\n", dec); - if (fh->posDecomp == fdlen) { - return 0; - } - - // We must ensure that whole file is decompressed and written to output buffer. - // This means even when there is no input data (elen==0) try to poll decoder until - // posDecomp equals decompressed file length - - while(decodedposComp - fh->posStart); - if (elen>0) { - memcpyAligned(ebuff, fh->posComp, 16); - heatshrink_decoder_sink(dec, (uint8_t *)ebuff, (elen>16)?16:elen, &rlen); - fh->posComp+=rlen; - } - //Grab decompressed data and put into buff - heatshrink_decoder_poll(dec, (uint8_t *)buff, len-decoded, &rlen); - fh->posDecomp+=rlen; - buff+=rlen; - decoded+=rlen; - -// os_printf("Elen %d rlen %d d %d pd %ld fdl %d\n",elen,rlen,decoded, fh->posDecomp, fdlen); - - if (elen == 0) { - if (fh->posDecomp == fdlen) { -// os_printf("Decoder finish\n"); - heatshrink_decoder_finish(dec); - } - return decoded; - } - } - return len; -#endif } return 0; } @@ -258,13 +199,6 @@ int ICACHE_FLASH_ATTR espFsRead(EspFsFile *fh, char *buff, int len) { //Close the file. void ICACHE_FLASH_ATTR espFsClose(EspFsFile *fh) { if (fh==NULL) return; -#ifdef ESPFS_HEATSHRINK - if (fh->decompressor==COMPRESS_HEATSHRINK) { - heatshrink_decoder *dec=(heatshrink_decoder *)fh->decompData; - heatshrink_decoder_free(dec); -// os_printf("Freed %p\n", dec); - } -#endif //os_printf("Freed %p\n", fh); os_free(fh); } diff --git a/espfs/espfs.h b/espfs/espfs.h index c41df0a..c8e13e7 100644 --- a/espfs/espfs.h +++ b/espfs/espfs.h @@ -1,10 +1,6 @@ #ifndef ESPFS_H #define ESPFS_H -// This define is done in Makefile. If you do not use default Makefile, uncomment -// to be able to use Heatshrink-compressed espfs images. -//#define ESPFS_HEATSHRINK - typedef enum { ESPFS_INIT_RESULT_OK, ESPFS_INIT_RESULT_NO_IMAGE, diff --git a/espfs/mkespfsimage/main.c b/espfs/mkespfsimage/main.c index 4d5da0d..be3aeb7 100644 --- a/espfs/mkespfsimage/main.c +++ b/espfs/mkespfsimage/main.c @@ -5,27 +5,29 @@ #include #include #include -#include -#include #include #include "espfs.h" -#include "espfsformat.h" - -//Heatshrink -#ifdef ESPFS_HEATSHRINK -#include "heatshrink_common.h" -#include "heatshrink_config.h" -#include "heatshrink_encoder.h" +#ifdef __MINGW32__ +#include "mman-win32/mman.h" +#else +#include +#endif +#ifdef __WIN32__ +#include +#else +#include #endif +#include "espfsformat.h" //Gzip #ifdef ESPFS_GZIP -// If compiler complains about missing header, try running "sudo apt-get install zlib1g-dev" +// If compiler complains about missing header, try running "sudo apt-get install zlib1g-dev" // to install missing package. #include #endif + //Routines to convert host format to the endianness used in the xtensa short htoxs(short in) { char r[2]; @@ -43,53 +45,6 @@ int htoxl(int in) { return *((int *)r); } -#ifdef ESPFS_HEATSHRINK -size_t compressHeatshrink(char *in, int insize, char *out, int outsize, int level) { - char *inp=in; - char *outp=out; - size_t len; - int ws[]={5, 6, 8, 11, 13}; - int ls[]={3, 3, 4, 4, 4}; - HSE_poll_res pres; - HSE_sink_res sres; - size_t r; - if (level==-1) level=8; - level=(level-1)/2; //level is now 0, 1, 2, 3, 4 - heatshrink_encoder *enc=heatshrink_encoder_alloc(ws[level], ls[level]); - if (enc==NULL) { - perror("allocating mem for heatshrink"); - exit(1); - } - //Save encoder parms as first byte - *outp=(ws[level]<<4)|ls[level]; - outp++; outsize--; - - r=1; - do { - if (insize>0) { - sres=heatshrink_encoder_sink(enc, inp, insize, &len); - if (sres!=HSER_SINK_OK) break; - inp+=len; insize-=len; - if (insize==0) heatshrink_encoder_finish(enc); - } - do { - pres=heatshrink_encoder_poll(enc, outp, outsize, &len); - if (pres!=HSER_POLL_MORE && pres!=HSER_POLL_EMPTY) break; - outp+=len; outsize-=len; - r+=len; - } while (pres==HSER_POLL_MORE); - } while (insize!=0); - - if (insize!=0) { - fprintf(stderr, "Heatshrink: Bug? insize is still %d. sres=%d pres=%d\n", insize, sres, pres); - exit(1); - } - - heatshrink_encoder_free(enc); - return r; -} -#endif - #ifdef ESPFS_GZIP size_t compressGzip(char *in, int insize, char *out, int outsize, int level) { z_stream stream; @@ -202,11 +157,6 @@ int handleFile(int f, char *name, int compression, int level, char **compName, o if (compression==COMPRESS_NONE) { csize=size; cdat=fdat; -#ifdef ESPFS_HEATSHRINK - } else if (compression==COMPRESS_HEATSHRINK) { - cdat=malloc(size*2); - csize=compressHeatshrink(fdat, size, cdat, size*2, level); -#endif } else { fprintf(stderr, "Unknown compression - %d\n", compression); exit(1); @@ -245,9 +195,7 @@ int handleFile(int f, char *name, int compression, int level, char **compName, o munmap(fdat, size); if (compName != NULL) { - if (h.compression==COMPRESS_HEATSHRINK) { - *compName = "heatshrink"; - } else if (h.compression==COMPRESS_NONE) { + if (h.compression==COMPRESS_NONE) { if (h.flags & FLAG_GZIP) { *compName = "gzip"; } else { @@ -284,11 +232,7 @@ int main(int argc, char **argv) { int compType; //default compression type - heatshrink int compLvl=-1; -#ifdef ESPFS_HEATSHRINK - compType = COMPRESS_HEATSHRINK; -#else compType = COMPRESS_NONE; -#endif for (x=1; x=x-2) { @@ -322,11 +266,7 @@ int main(int argc, char **argv) { #endif fprintf(stderr, "> out.espfs\n"); fprintf(stderr, "Compressors:\n"); -#ifdef ESPFS_HEATSHRINK - fprintf(stderr, "0 - None\n1 - Heatshrink(default)\n"); -#else fprintf(stderr, "0 - None(default)\n"); -#endif fprintf(stderr, "\nCompression level: 1 is worst but low RAM usage, higher is better compression \nbut uses more ram on decompression. -1 = compressors default.\n"); #ifdef ESPFS_GZIP fprintf(stderr, "\nGzipped extensions: list of comma separated, case sensitive file extensions \nthat will be gzipped. Defaults to 'html,css,js'\n"); @@ -334,6 +274,10 @@ int main(int argc, char **argv) { exit(0); } +#ifdef __WIN32__ + setmode(fileno(stdout), _O_BINARY); +#endif + while(fgets(fileName, sizeof(fileName), stdin)) { //Kill off '\n' at the end fileName[strlen(fileName)-1]=0; diff --git a/espfs/mkespfsimage/mman-win32/Makefile b/espfs/mkespfsimage/mman-win32/Makefile new file mode 100644 index 0000000..5624c1b --- /dev/null +++ b/espfs/mkespfsimage/mman-win32/Makefile @@ -0,0 +1,48 @@ +# +# mman-win32 (mingw32) Makefile +# +include config.mak + +ifeq ($(BUILD_STATIC),yes) + TARGETS+=libmman.a + INSTALL+=static-install +endif +ifeq ($(BUILD_MSVC),yes) + SHFLAGS+=-Wl,--output-def,libmman.def + INSTALL+=lib-install +endif + +all: $(TARGETS) + +mman.o: mman.c mman.h + $(CC) -o mman.o -c mman.c -Wall -O3 -fomit-frame-pointer + +libmman.a: mman.o + $(AR) cru libmman.a mman.o + $(RANLIB) libmman.a + +static-install: + mkdir -p $(DESTDIR)$(libdir) + cp libmman.a $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(incdir) + cp mman.h $(DESTDIR)$(incdir) + +lib-install: + mkdir -p $(DESTDIR)$(libdir) + cp libmman.lib $(DESTDIR)$(libdir) + +install: $(INSTALL) + +test.exe: test.c mman.c mman.h + $(CC) -o test.exe test.c -L. -lmman + +test: $(TARGETS) test.exe + test.exe + +clean:: + rm -f mman.o libmman.a libmman.def libmman.lib test.exe *.dat + +distclean: clean + rm -f config.mak + +.PHONY: clean distclean install test diff --git a/espfs/mkespfsimage/mman-win32/config.mak b/espfs/mkespfsimage/mman-win32/config.mak new file mode 100644 index 0000000..2d2ae1b --- /dev/null +++ b/espfs/mkespfsimage/mman-win32/config.mak @@ -0,0 +1,11 @@ +# Automatically generated by configure +PREFIX=/mingw +libdir=/mingw/lib +incdir=/mingw/include/sys +AR=ar +CC=gcc +RANLIB=ranlib +STRIP=strip +BUILD_STATIC=yes +BUILD_MSVC= +LIBCMD=echo ignoring lib diff --git a/espfs/mkespfsimage/mman-win32/configure b/espfs/mkespfsimage/mman-win32/configure new file mode 100644 index 0000000..c928f11 --- /dev/null +++ b/espfs/mkespfsimage/mman-win32/configure @@ -0,0 +1,157 @@ +#!/bin/sh +# mmap-win32 configure script +# +# Parts copied from FFmpeg's configure +# + +set_all(){ + value=$1 + shift + for var in $*; do + eval $var=$value + done +} + +enable(){ + set_all yes $* +} + +disable(){ + set_all no $* +} + +enabled(){ + eval test "x\$$1" = "xyes" +} + +disabled(){ + eval test "x\$$1" = "xno" +} + +show_help(){ + echo "Usage: configure [options]" + echo "Options: [defaults in brackets after descriptions]" + echo "All \"enable\" options have \"disable\" counterparts" + echo + echo " --help print this message" + echo " --prefix=PREFIX install in PREFIX [$PREFIX]" + echo " --libdir=DIR install libs in DIR [$PREFIX/lib]" + echo " --incdir=DIR install includes in DIR [$PREFIX/include]" + echo " --enable-static build static libraries [yes]" + echo " --enable-msvc create msvc-compatible import lib [auto]" + echo + echo " --cc=CC use C compiler CC [$cc_default]" + echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]" + exit 1 +} + +die_unknown(){ + echo "Unknown option \"$1\"." + echo "See $0 --help for available options." + exit 1 +} + +PREFIX="/mingw" +libdir="${PREFIX}/lib" +incdir="${PREFIX}/include/sys" +ar="ar" +cc_default="gcc" +ranlib="ranlib" +strip="strip" + +DEFAULT="msvc +" + +DEFAULT_YES="static + stripping +" + +CMDLINE_SELECT="$DEFAULT + $DEFAULT_NO + $DEFAULT_YES +" + +enable $DEFAULT_YES +disable $DEFAULT_NO + +for opt do + optval="${opt#*=}" + case "$opt" in + --help) + show_help + ;; + --prefix=*) + PREFIX="$optval" + ;; + --libdir=*) + libdir="$optval" + ;; + --incdir=*) + incdir="$optval" + ;; + --cc=*) + cc="$optval" + ;; + --cross-prefix=*) + cross_prefix="$optval" + ;; + --enable-?*|--disable-?*) + eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` + echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt + $action $option + ;; + *) + die_unknown $opt + ;; + esac +done + +ar="${cross_prefix}${ar}" +cc_default="${cross_prefix}${cc_default}" +ranlib="${cross_prefix}${ranlib}" +strip="${cross_prefix}${strip}" + +if ! test -z $cc; then + cc_default="${cc}" +fi +cc="${cc_default}" + +disabled static && { + echo "At least one library type must be set."; + exit 1; +} + +if enabled msvc; then + lib /? > /dev/null 2>&1 /dev/null || { + echo "MSVC's lib command not found." + echo "Make sure MSVC is installed and its bin folder is in your \$PATH." + exit 1 + } +fi + +if ! enabled stripping; then + strip="echo ignoring strip" +fi + +enabled msvc && libcmd="lib" || libcmd="echo ignoring lib" + +echo "# Automatically generated by configure" > config.mak +echo "PREFIX=$PREFIX" >> config.mak +echo "libdir=$libdir" >> config.mak +echo "incdir=$incdir" >> config.mak +echo "AR=$ar" >> config.mak +echo "CC=$cc" >> config.mak +echo "RANLIB=$ranlib" >> config.mak +echo "STRIP=$strip" >> config.mak +echo "BUILD_STATIC=$static" >> config.mak +echo "BUILD_MSVC=$msvc" >> config.mak +echo "LIBCMD=$libcmd" >> config.mak + +echo "prefix: $PREFIX" +echo "libdir: $libdir" +echo "incdir: $incdir" +echo "ar: $ar" +echo "cc: $cc" +echo "ranlib: $ranlib" +echo "strip: $strip" +echo "static: $static" diff --git a/espfs/mkespfsimage/mman-win32/mman.c b/espfs/mkespfsimage/mman-win32/mman.c new file mode 100644 index 0000000..486ed94 --- /dev/null +++ b/espfs/mkespfsimage/mman-win32/mman.c @@ -0,0 +1,180 @@ + +#include +#include +#include + +#include "mman.h" + +#ifndef FILE_MAP_EXECUTE +#define FILE_MAP_EXECUTE 0x0020 +#endif /* FILE_MAP_EXECUTE */ + +static int __map_mman_error(const DWORD err, const int deferr) +{ + if (err == 0) + return 0; + //TODO: implement + return err; +} + +static DWORD __map_mmap_prot_page(const int prot) +{ + DWORD protect = 0; + + if (prot == PROT_NONE) + return protect; + + if ((prot & PROT_EXEC) != 0) + { + protect = ((prot & PROT_WRITE) != 0) ? + PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ; + } + else + { + protect = ((prot & PROT_WRITE) != 0) ? + PAGE_READWRITE : PAGE_READONLY; + } + + return protect; +} + +static DWORD __map_mmap_prot_file(const int prot) +{ + DWORD desiredAccess = 0; + + if (prot == PROT_NONE) + return desiredAccess; + + if ((prot & PROT_READ) != 0) + desiredAccess |= FILE_MAP_READ; + if ((prot & PROT_WRITE) != 0) + desiredAccess |= FILE_MAP_WRITE; + if ((prot & PROT_EXEC) != 0) + desiredAccess |= FILE_MAP_EXECUTE; + + return desiredAccess; +} + +void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) +{ + HANDLE fm, h; + + void * map = MAP_FAILED; + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4293) +#endif + + const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ? + (DWORD)off : (DWORD)(off & 0xFFFFFFFFL); + const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ? + (DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL); + const DWORD protect = __map_mmap_prot_page(prot); + const DWORD desiredAccess = __map_mmap_prot_file(prot); + + const off_t maxSize = off + (off_t)len; + + const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ? + (DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL); + const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ? + (DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL); + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + errno = 0; + + if (len == 0 + /* Unsupported flag combinations */ + || (flags & MAP_FIXED) != 0 + /* Usupported protection combinations */ + || prot == PROT_EXEC) + { + errno = EINVAL; + return MAP_FAILED; + } + + h = ((flags & MAP_ANONYMOUS) == 0) ? + (HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE; + + if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE) + { + errno = EBADF; + return MAP_FAILED; + } + + fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL); + + if (fm == NULL) + { + errno = __map_mman_error(GetLastError(), EPERM); + return MAP_FAILED; + } + + map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); + + CloseHandle(fm); + + if (map == NULL) + { + errno = __map_mman_error(GetLastError(), EPERM); + return MAP_FAILED; + } + + return map; +} + +int munmap(void *addr, size_t len) +{ + if (UnmapViewOfFile(addr)) + return 0; + + errno = __map_mman_error(GetLastError(), EPERM); + + return -1; +} + +int mprotect(void *addr, size_t len, int prot) +{ + DWORD newProtect = __map_mmap_prot_page(prot); + DWORD oldProtect = 0; + + if (VirtualProtect(addr, len, newProtect, &oldProtect)) + return 0; + + errno = __map_mman_error(GetLastError(), EPERM); + + return -1; +} + +int msync(void *addr, size_t len, int flags) +{ + if (FlushViewOfFile(addr, len)) + return 0; + + errno = __map_mman_error(GetLastError(), EPERM); + + return -1; +} + +int mlock(const void *addr, size_t len) +{ + if (VirtualLock((LPVOID)addr, len)) + return 0; + + errno = __map_mman_error(GetLastError(), EPERM); + + return -1; +} + +int munlock(const void *addr, size_t len) +{ + if (VirtualUnlock((LPVOID)addr, len)) + return 0; + + errno = __map_mman_error(GetLastError(), EPERM); + + return -1; +} diff --git a/espfs/mkespfsimage/mman-win32/mman.h b/espfs/mkespfsimage/mman-win32/mman.h new file mode 100644 index 0000000..ffa3748 --- /dev/null +++ b/espfs/mkespfsimage/mman-win32/mman.h @@ -0,0 +1,55 @@ +/* + * sys/mman.h + * mman-win32 + */ + +#ifndef _SYS_MMAN_H_ +#define _SYS_MMAN_H_ + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +/* All the headers include this file. */ +#ifndef _MSC_VER +#include <_mingw.h> +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PROT_NONE 0 +#define PROT_READ 1 +#define PROT_WRITE 2 +#define PROT_EXEC 4 + +#define MAP_FILE 0 +#define MAP_SHARED 1 +#define MAP_PRIVATE 2 +#define MAP_TYPE 0xf +#define MAP_FIXED 0x10 +#define MAP_ANONYMOUS 0x20 +#define MAP_ANON MAP_ANONYMOUS + +#define MAP_FAILED ((void *)-1) + +/* Flags for msync. */ +#define MS_ASYNC 1 +#define MS_SYNC 2 +#define MS_INVALIDATE 4 + +void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off); +int munmap(void *addr, size_t len); +int mprotect(void *addr, size_t len, int prot); +int msync(void *addr, size_t len, int flags); +int mlock(const void *addr, size_t len); +int munlock(const void *addr, size_t len); + +#ifdef __cplusplus +}; +#endif + +#endif /* _SYS_MMAN_H_ */ diff --git a/espfs/mkespfsimage/mman-win32/test.c b/espfs/mkespfsimage/mman-win32/test.c new file mode 100644 index 0000000..9374b9f --- /dev/null +++ b/espfs/mkespfsimage/mman-win32/test.c @@ -0,0 +1,235 @@ + +#include "mman.h" + +#include +#include +#include + +#ifndef NULL +#define NULL (void*)0 +#endif + +const char* map_file_name = "map_file.dat"; + +int test_anon_map_readwrite() +{ + void* map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_READ | PROT_WRITE) returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_READ | PROT_WRITE) returned unexpected error: %d\n", errno); + + return result; +} + +int test_anon_map_readonly() +{ + void* map = mmap(NULL, 1024, PROT_READ, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + + return result; +} + +int test_anon_map_writeonly() +{ + void* map = mmap(NULL, 1024, PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_WRITE) returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_WRITE) returned unexpected error: %d\n", errno); + + return result; +} + +int test_anon_map_readonly_nowrite() +{ + void* map = mmap(NULL, 1024, PROT_READ, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + return -1; + } + + if (*((unsigned char*)map) != 0) + printf("test_anon_map_readonly_nowrite (MAP_ANONYMOUS, PROT_READ) returned unexpected value: %d\n", + (int)*((unsigned char*)map)); + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + + return result; +} + +int test_file_map_readwrite() +{ + mode_t mode = S_IRUSR | S_IWUSR; + int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode); + + void* map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0); + if (map == MAP_FAILED) + { + printf("mmap returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap returned unexpected error: %d\n", errno); + + close(o); + + /*TODO: get file info and content and compare it with the sources conditions */ + unlink(map_file_name); + + return result; +} + +int test_file_map_mlock_munlock() +{ + const size_t map_size = 1024; + + int result = 0; + mode_t mode = S_IRUSR | S_IWUSR; + int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode); + if (o == -1) + { + printf("unable to create file %s: %d\n", map_file_name, errno); + return -1; + } + + void* map = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0); + if (map == MAP_FAILED) + { + printf("mmap returned unexpected error: %d\n", errno); + result = -1; + goto done_close; + } + + if (mlock(map, map_size) != 0) + { + printf("mlock returned unexpected error: %d\n", errno); + result = -1; + goto done_munmap; + } + + *((unsigned char*)map) = 1; + + if (munlock(map, map_size) != 0) + { + printf("munlock returned unexpected error: %d\n", errno); + result = -1; + } + +done_munmap: + result = munmap(map, map_size); + + if (result != 0) + printf("munmap returned unexpected error: %d\n", errno); + +done_close: + close(o); + + unlink(map_file_name); +done: + return result; +} + +int test_file_map_msync() +{ + const size_t map_size = 1024; + + int result = 0; + mode_t mode = S_IRUSR | S_IWUSR; + int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode); + if (o == -1) + { + printf("unable to create file %s: %d\n", map_file_name, errno); + return -1; + } + + void* map = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0); + if (map == MAP_FAILED) + { + printf("mmap returned unexpected error: %d\n", errno); + result = -1; + goto done_close; + } + + *((unsigned char*)map) = 1; + + if (msync(map, map_size, MS_SYNC) != 0) + { + printf("msync returned unexpected error: %d\n", errno); + result = -1; + } + + result = munmap(map, map_size); + + if (result != 0) + printf("munmap returned unexpected error: %d\n", errno); + +done_close: + close(o); + + unlink(map_file_name); +done: + return result; +} + +#define EXEC_TEST(name) \ + if (name() != 0) { result = -1; printf( #name ": fail\n"); } \ + else { printf(#name ": pass\n"); } + +int main() +{ + int result = 0; + + EXEC_TEST(test_anon_map_readwrite); + //NOTE: this test must cause an access violation exception + //EXEC_TEST(test_anon_map_readonly); + EXEC_TEST(test_anon_map_readonly_nowrite); + EXEC_TEST(test_anon_map_writeonly); + + EXEC_TEST(test_file_map_readwrite); + EXEC_TEST(test_file_map_mlock_munlock); + EXEC_TEST(test_file_map_msync); + //TODO: EXEC_TEST(test_file_map_mprotect); + + return result; +} diff --git a/espmake.cmd b/espmake.cmd new file mode 100644 index 0000000..42e25a6 --- /dev/null +++ b/espmake.cmd @@ -0,0 +1,7 @@ +@echo off + +REM remove automatic created obj folder +rd obj /S /Q >nul 2>&1 + +PATH=%PATH%;C:\Espressif\xtensa-lx106-elf\bin;C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\espressif\git-bin;C:\espressif\java-bin;C:\Python27 +make -f Makefile %1 %2 %3 %4 %5 \ No newline at end of file diff --git a/include/esp8266.h b/include/esp8266.h index ce92455..96a7364 100644 --- a/include/esp8266.h +++ b/include/esp8266.h @@ -13,7 +13,10 @@ #include #include #include -#include #include "espmissingincludes.h" #include "uart_hw.h" + +#ifdef __WIN32__ +#include <_mingw.h> +#endif diff --git a/include/espmissingincludes.h b/include/espmissingincludes.h index c69b9fc..e5a20a0 100644 --- a/include/espmissingincludes.h +++ b/include/espmissingincludes.h @@ -1,9 +1,8 @@ #ifndef ESPMISSINGINCLUDES_H #define ESPMISSINGINCLUDES_H -#include -#include -#include +#include +#include //Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere. //MOST OF THESE ARE GUESSED! but they seem to work and shut up the compiler. @@ -54,6 +53,11 @@ int rand(void); void ets_bzero(void *s, size_t n); void ets_delay_us(int ms); +// Shortcuts for memory functions +#define os_malloc pvPortMalloc +#define os_free vPortFree +#define os_zalloc pvPortZalloc + // disappeared in SDK 1.1.0: #define os_timer_done ets_timer_done #define os_timer_handler_isr ets_timer_handler_isr diff --git a/user/config.c b/user/config.c index 835e74f..b44b329 100644 --- a/user/config.c +++ b/user/config.c @@ -17,7 +17,7 @@ FlashConfig flashDefault = { "esp-link\0 ", // hostname 0, 0x00ffffff, 0, // static ip, netmask, gateway 0, // log mode - 0, // swap_uart (don't by default) + 0, // swap uart (don't by default) 1, 0, // tcp_enable, rssi_enable "\0", // api_key }; From e74b9f5a0bc12aa9bc8d66aa96838269cfc62c79 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Sat, 29 Aug 2015 05:33:26 -0500 Subject: [PATCH 7/7] fixing merge problems --- esp-link.vcxproj | 2 +- espfs/heatshrink_config_custom.h | 30 ------------------------- espfs/heatshrink_decoder.c | 19 ---------------- espfs/mkespfsimage/heatshrink_encoder.c | 4 ---- 4 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 espfs/heatshrink_config_custom.h delete mode 100644 espfs/heatshrink_decoder.c delete mode 100644 espfs/mkespfsimage/heatshrink_encoder.c diff --git a/esp-link.vcxproj b/esp-link.vcxproj index c98faa5..918ed96 100644 --- a/esp-link.vcxproj +++ b/esp-link.vcxproj @@ -28,7 +28,7 @@ __ets__;_STDINT_H;ICACHE_FLASH;__MINGW32__;__WIN32__ - .\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.3.0\include;..\xtensa-lx106-elf\xtensa-lx106-elf\include;c:\tools\mingw64\x86_64-w64-mingw32\include;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include + .\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.3.0\include;C:\tools\mingw64\include diff --git a/espfs/heatshrink_config_custom.h b/espfs/heatshrink_config_custom.h deleted file mode 100644 index f885f87..0000000 --- a/espfs/heatshrink_config_custom.h +++ /dev/null @@ -1,30 +0,0 @@ -//Heatshrink config for the decompressor. -#ifndef HEATSHRINK_CONFIG_H -#define HEATSHRINK_CONFIG_H - -/* Should functionality assuming dynamic allocation be used? */ -#define HEATSHRINK_DYNAMIC_ALLOC 1 - -#if HEATSHRINK_DYNAMIC_ALLOC - /* Optional replacement of malloc/free */ - #ifdef __ets__ - #define HEATSHRINK_MALLOC(SZ) os_malloc(SZ) - #define HEATSHRINK_FREE(P, SZ) os_free(P) - #else - #define HEATSHRINK_MALLOC(SZ) malloc(SZ) - #define HEATSHRINK_FREE(P, SZ) free(P) - #endif -#else - /* Required parameters for static configuration */ - #define HEATSHRINK_STATIC_INPUT_BUFFER_SIZE 32 - #define HEATSHRINK_STATIC_WINDOW_BITS 8 - #define HEATSHRINK_STATIC_LOOKAHEAD_BITS 4 -#endif - -/* Turn on logging for debugging. */ -#define HEATSHRINK_DEBUGGING_LOGS 0 - -/* Use indexing for faster compression. (This requires additional space.) */ -#define HEATSHRINK_USE_INDEX 1 - -#endif diff --git a/espfs/heatshrink_decoder.c b/espfs/heatshrink_decoder.c deleted file mode 100644 index 522b560..0000000 --- a/espfs/heatshrink_decoder.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "espfs.h" -#ifdef ESPFS_HEATSHRINK -//Stupid wrapper so we don't have to move c-files around -//Also loads httpd-specific config. - -#ifdef __ets__ -//esp build - -#include - -#define memset(x,y,z) os_memset(x,y,z) -#define memcpy(x,y,z) os_memcpy(x,y,z) -#endif - -#include "heatshrink_config_custom.h" -#include "../lib/heatshrink/heatshrink_decoder.c" - - -#endif diff --git a/espfs/mkespfsimage/heatshrink_encoder.c b/espfs/mkespfsimage/heatshrink_encoder.c deleted file mode 100644 index b563970..0000000 --- a/espfs/mkespfsimage/heatshrink_encoder.c +++ /dev/null @@ -1,4 +0,0 @@ -//Stupid wraparound include to make sure object file doesn't end up in heatshrink dir -#ifdef ESPFS_HEATSHRINK -#include "../lib/heatshrink/heatshrink_encoder.c" -#endif \ No newline at end of file