Merge pull request #2 from brunnels/windows

Windows
pull/37/head
Benjamin Runnels 9 years ago
commit 319bb7f336
  1. 5
      .gitignore
  2. 35
      Makefile
  3. 22
      esp-link.sln
  4. 115
      esp-link.vcxproj
  5. 66
      espfs/espfs.c
  6. 4
      espfs/espfs.h
  7. 30
      espfs/heatshrink_config_custom.h
  8. 19
      espfs/heatshrink_decoder.c
  9. 26
      espfs/mkespfsimage/Makefile
  10. 4
      espfs/mkespfsimage/heatshrink_encoder.c
  11. 90
      espfs/mkespfsimage/main.c
  12. 48
      espfs/mkespfsimage/mman-win32/Makefile
  13. 11
      espfs/mkespfsimage/mman-win32/config.mak
  14. 157
      espfs/mkespfsimage/mman-win32/configure
  15. 180
      espfs/mkespfsimage/mman-win32/mman.c
  16. 55
      espfs/mkespfsimage/mman-win32/mman.h
  17. 235
      espfs/mkespfsimage/mman-win32/test.c
  18. 7
      espmake.cmd
  19. 5
      include/esp8266.h
  20. 10
      include/espmissingincludes.h
  21. 51
      serial/console.c
  22. 26
      serial/serbridge.c
  23. 4
      user/config.c
  24. 2
      user/config.h

5
.gitignore vendored

@ -10,7 +10,8 @@ html_compressed/
esp-link.tgz
tve-patch/
yui
.localhistory/
espfs/mkespfsimage/mman-win32/mman.o
esp-link.opensdf
esp-link.sdf
espfs/mkespfsimage/mman-win32/libmman.a
espfs/mkespfsimage/mman-win32/mman.o
.localhistory/

@ -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
@ -30,14 +31,14 @@ ESPBAUD ?= 460800
# --------------- 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
ESP_SPI_SIZE ?= 0 # 0->512KB (256KB+256KB)
ESP_FLASH_MODE ?= 0 # 0->QIO
ESP_FLASH_FREQ_DIV ?= 0 # 0->40Mhz
ESP_FLASH_MAX ?= 241664 # max bin file for 512KB flash: 236KB
ESP_FLASH_MODE ?= 0 # 0->QIO
ESP_FLASH_FREQ_DIV ?= 0 # 0->40Mhz
ESP_FLASH_MAX ?= 241664 # max bin file for 512KB flash: 236KB
ET_FS ?= 4m # 4Mbit flash size in esptool flash command
ET_FF ?= 40m # 40Mhz flash speed in esptool flash command
ET_BLANK ?= 0x7E000 # where to flash blank.bin to erase wireless settings
@ -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 -------------
@ -146,8 +142,8 @@ TARGET = httpd
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/
MODULES = espfs httpd user serial
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)
@ -331,11 +330,11 @@ ifeq ("$(FLASH_SIZE)","512KB")
build/eagle.esphttpd1.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.512.app1.ld
$(Q) sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4);' -e 'a *(.espfs)' -e '}' \
-e '/^ irom0_0_seg/ s/2B000/38000/' \
$(SDK_LDDIR)/eagle.app.v6.new.512.app1.ld >$@
$(SDK_LDDIR)/eagle.app.v6.new.512.app1.ld >$@
build/eagle.esphttpd2.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.512.app2.ld
$(Q) sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4);' -e 'a *(.espfs)' -e '}' \
-e '/^ irom0_0_seg/ s/2B000/38000/' \
$(SDK_LDDIR)/eagle.app.v6.new.512.app2.ld >$@
$(SDK_LDDIR)/eagle.app.v6.new.512.app2.ld >$@
else
build/eagle.esphttpd1.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.1024.app1.ld
$(Q) sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4);' -e 'a *(.espfs)' -e '}' \
@ -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

@ -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

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A92F0CAA-F89B-4F78-AD2A-A042429BD87F}</ProjectGuid>
<Keyword>MakeFileProj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
<ConfigurationType>Makefile</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<NMakeOutput />
<NMakePreprocessorDefinitions>__ets__;_STDINT_H;ICACHE_FLASH;__MINGW32__;__WIN32__</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.3.0\include;c:\tools\mingw64\x86_64-w64-mingw32\include\c++\x86_64-w64-mingw32;c:\tools\mingw64\x86_64-w64-mingw32\include\c++\backward;c:\tools\mingw64\x86_64-w64-mingw32\include\c++;c:\tools\mingw64\x86_64-w64-mingw32\include;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include-fixed;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include</NMakeIncludeSearchPath>
<ExecutablePath />
<ReferencePath />
<LibraryPath />
<LibraryWPath />
<ExcludePath />
<NMakeOutput />
<OutDir>bin</OutDir>
<IntDir>build</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<NMakeBuildCommandLine>espmake flash</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>espmake clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>espmake clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<NMakeBuildCommandLine>espmake baseflash</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>espmake clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>espmake clean</NMakeCleanCommandLine>
</PropertyGroup>
<ItemDefinitionGroup>
<BuildLog>
<Path />
</BuildLog>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="espfs\mkespfsimage\Makefile" />
<None Include="espfs\mkespfsimage\mman-win32\config.mak" />
<None Include="espfs\mkespfsimage\mman-win32\configure" />
<None Include="espfs\mkespfsimage\mman-win32\Makefile" />
<None Include="espmake.cmd" />
<None Include="Makefile" />
<None Include="wiflash" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="espfs\espfs.c" />
<ClCompile Include="espfs\espfstest\main.c" />
<ClCompile Include="espfs\mkespfsimage\main.c" />
<ClCompile Include="espfs\mkespfsimage\mman-win32\mman.c" />
<ClCompile Include="espfs\mkespfsimage\mman-win32\test.c" />
<ClCompile Include="httpd\auth.c" />
<ClCompile Include="httpd\base64.c" />
<ClCompile Include="httpd\httpd.c" />
<ClCompile Include="httpd\httpdespfs.c" />
<ClCompile Include="serial\console.c" />
<ClCompile Include="serial\serbridge.c" />
<ClCompile Include="serial\serled.c" />
<ClCompile Include="serial\uart.c" />
<ClCompile Include="user\cgi.c" />
<ClCompile Include="user\cgiflash.c" />
<ClCompile Include="user\cgipins.c" />
<ClCompile Include="user\cgiwifi.c" />
<ClCompile Include="user\config.c" />
<ClCompile Include="user\log.c" />
<ClCompile Include="user\status.c" />
<ClCompile Include="user\user_main.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="espfs\espfs.h" />
<ClInclude Include="espfs\espfsformat.h" />
<ClInclude Include="espfs\mkespfsimage\mman-win32\mman.h" />
<ClInclude Include="httpd\auth.h" />
<ClInclude Include="httpd\base64.h" />
<ClInclude Include="httpd\httpd.h" />
<ClInclude Include="httpd\httpdespfs.h" />
<ClInclude Include="include\esp8266.h" />
<ClInclude Include="include\espmissingincludes.h" />
<ClInclude Include="include\uart_hw.h" />
<ClInclude Include="include\user_config.h" />
<ClInclude Include="serial\console.h" />
<ClInclude Include="serial\serbridge.h" />
<ClInclude Include="serial\serled.h" />
<ClInclude Include="serial\uart.h" />
<ClInclude Include="user\cgi.h" />
<ClInclude Include="user\cgiflash.h" />
<ClInclude Include="user\cgipins.h" />
<ClInclude Include="user\cgiwifi.h" />
<ClInclude Include="user\config.h" />
<ClInclude Include="user\log.h" />
<ClInclude Include="user\status.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -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(decoded<len) {
//Feed data into the decompressor
//ToDo: Check ret val of heatshrink fns for errors
elen=flen-(fh->posComp - 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);
}

@ -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,

@ -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

@ -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 <esp8266.h>
#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

@ -1,24 +1,24 @@
GZIP_COMPRESSION ?= no
USE_HEATSHRINK ?= yes
GZIP_COMPRESSION?=no
CFLAGS=-I.. -std=gnu99
CFLAGS=-I../../lib/heatshrink -I.. -std=gnu99
ifeq ("$(GZIP_COMPRESSION)","yes")
CFLAGS += -DESPFS_GZIP
LDFLAGS+=-lz
CFLAGS+=-DESPFS_GZIP
endif
ifeq ("$(USE_HEATSHRINK)","yes")
CFLAGS += -DESPFS_HEATSHRINK
ifeq ($(OS),Windows_NT)
CFLAGS+=-Imman-win32
LDFLAGS+=-Lmman-win32 -lmman
TARGET =mkespfsimage.exe
else
TARGET =mkespfsimage
endif
OBJS=main.o heatshrink_encoder.o
TARGET=mkespfsimage
OBJS=main.o
$(TARGET): $(OBJS)
ifeq ("$(GZIP_COMPRESSION)","yes")
$(CC) -o $@ $^ -lz
else
$(CC) -o $@ $^
endif
$(CC) -o $@ $^ $(LDFLAGS)
clean:
rm -f $(TARGET) $(OBJS)

@ -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

@ -5,27 +5,29 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <arpa/inet.h>
#include <string.h>
#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 <sys/mman.h>
#endif
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h>
#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 <zlib.h>
#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<argc; x++) {
if (strcmp(argv[x], "-c")==0 && argc>=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;

@ -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

@ -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

@ -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"

@ -0,0 +1,180 @@
#include <windows.h>
#include <errno.h>
#include <io.h>
#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;
}

@ -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 <sys/types.h>
#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_ */

@ -0,0 +1,235 @@
#include "mman.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#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;
}

@ -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

@ -13,7 +13,10 @@
#include <mem.h>
#include <osapi.h>
#include <upgrade.h>
#include <user_interface.h>
#include "espmissingincludes.h"
#include "uart_hw.h"
#ifdef __WIN32__
#include <_mingw.h>
#endif

@ -1,9 +1,8 @@
#ifndef ESPMISSINGINCLUDES_H
#define ESPMISSINGINCLUDES_H
#include <stdint.h>
#include <c_types.h>
#include <ets_sys.h>
#include <user_interface.h>
#include <eagle_soc.h>
//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

@ -45,8 +45,13 @@ console_prev(void) {
void ICACHE_FLASH_ATTR
console_write_char(char c) {
<<<<<<< HEAD
//if (c == '\n' && console_prev() != '\r') console_write('\r'); // does more harm than good
console_write(c);
=======
//if (c == '\n' && console_prev() != '\r') console_write('\r'); // does more harm than good
console_write(c);
>>>>>>> master
}
int ICACHE_FLASH_ATTR
@ -83,6 +88,51 @@ ajaxConsoleBaud(HttpdConnData *connData) {
int ICACHE_FLASH_ATTR
ajaxConsole(HttpdConnData *connData) {
<<<<<<< HEAD
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
char buff[2048];
int len; // length of text in buff
int console_len = (console_wr+BUF_MAX-console_rd) % BUF_MAX; // num chars in console_buf
int start = 0; // offset onto console_wr to start sending out chars
jsonHeader(connData, 200);
// figure out where to start in buffer based on URI param
len = httpdFindArg(connData->getArgs, "start", buff, sizeof(buff));
if (len > 0) {
start = atoi(buff);
if (start < console_pos) {
start = 0;
} else if (start >= console_pos+console_len) {
start = console_len;
} else {
start = start - console_pos;
}
}
// start outputting
len = os_sprintf(buff, "{\"len\":%d, \"start\":%d, \"text\": \"",
console_len-start, console_pos+start);
int rd = (console_rd+start) % BUF_MAX;
while (len < 2040 && rd != console_wr) {
uint8_t c = console_buf[rd];
if (c == '\\' || c == '"') {
buff[len++] = '\\';
buff[len++] = c;
} else if (c == '\r') {
// this is crummy, but browsers display a newline for \r\n sequences
} else if (c < ' ') {
len += os_sprintf(buff+len, "\\u%04x", c);
} else {
buff[len++] = c;
}
rd = (rd + 1) % BUF_MAX;
}
os_strcpy(buff+len, "\"}"); len+=2;
httpdSend(connData, buff, len);
return HTTPD_CGI_DONE;
=======
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
char buff[2048];
int len; // length of text in buff
@ -126,6 +176,7 @@ ajaxConsole(HttpdConnData *connData) {
os_strcpy(buff+len, "\"}"); len+=2;
httpdSend(connData, buff, len);
return HTTPD_CGI_DONE;
>>>>>>> master
}
void ICACHE_FLASH_ATTR consoleInit() {

@ -334,6 +334,31 @@ static void ICACHE_FLASH_ATTR serbridgeConnectCb(void *arg) {
//===== Initialization
void ICACHE_FLASH_ATTR serbridgeInitPins() {
<<<<<<< HEAD
mcu_reset_pin = flashConfig.reset_pin;
mcu_isp_pin = flashConfig.isp_pin;
os_printf("Serbridge pins: reset=%d isp=%d swap=%d\n",
mcu_reset_pin, mcu_isp_pin, flashConfig.swap_uart);
if (flashConfig.swap_uart) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 4);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 4);
PIN_PULLUP_DIS(PERIPHS_IO_MUX_MTCK_U);
PIN_PULLUP_DIS(PERIPHS_IO_MUX_MTDO_U);
system_uart_swap();
} else {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, 0);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, 0);
system_uart_de_swap();
}
// set both pins to 1 before turning them on so we don't cause a reset
if (mcu_isp_pin >= 0) GPIO_OUTPUT_SET(mcu_isp_pin, 1);
if (mcu_reset_pin >= 0) GPIO_OUTPUT_SET(mcu_reset_pin, 1);
// switch pin mux to make these pins GPIO pins
if (mcu_reset_pin >= 0) makeGpio(mcu_reset_pin);
if (mcu_isp_pin >= 0) makeGpio(mcu_isp_pin);
=======
mcu_reset_pin = flashConfig.reset_pin;
mcu_isp_pin = flashConfig.isp_pin;
os_printf("Serbridge pins: reset=%d isp=%d swap=%d\n",
@ -357,6 +382,7 @@ void ICACHE_FLASH_ATTR serbridgeInitPins() {
// switch pin mux to make these pins GPIO pins
if (mcu_reset_pin >= 0) makeGpio(mcu_reset_pin);
if (mcu_isp_pin >= 0) makeGpio(mcu_isp_pin);
>>>>>>> master
}
// Start transparent serial bridge TCP server on specified port (typ. 23)

@ -17,9 +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)
1, 0, // tcp_enable, rssi_enable
"\0", // api_key
0, // swap uart (don't by default)
};
typedef union {

@ -14,8 +14,6 @@ typedef struct {
uint32_t staticip, netmask, gateway; // using DHCP if staticip==0
uint8_t log_mode; // UART log debug mode
uint8_t swap_uart; // swap uart0 to gpio 13&15
uint8_t tcp_enable, rssi_enable; // TCP client settings
char api_key[48]; // RSSI submission API key (Grovestreams for now)
} FlashConfig;
extern FlashConfig flashConfig;

Loading…
Cancel
Save