diff --git a/.appveyor/build.cmd b/.appveyor/build.cmd index 0444f2ad0a..ecbadb88d4 100644 --- a/.appveyor/build.cmd +++ b/.appveyor/build.cmd @@ -1,37 +1,40 @@ REM Windows build script -SET SMING_HOME=%APPVEYOR_BUILD_FOLDER%\Sming +set SMING_HOME=%APPVEYOR_BUILD_FOLDER%\Sming -IF "%SMING_ARCH%" == "Esp8266" SET ESP_HOME=c:\Espressif +if "%SMING_ARCH%" == "Esp8266" set ESP_HOME=c:\Espressif cd %SMING_HOME% gcc -v +set MAKE_PARALLEL=make -j2 + +REM Move samples and tests into directory outside of the Sming repo. +set SMING_PROJECTS_DIR=%APPVEYOR_BUILD_FOLDER%\.. +move ../samples %SMING_PROJECTS_DIR% +move ../tests %SMING_PROJECTS_DIR% + +REM This will build the Basic_Blink application and most of the framework Components +cd %SMING_PROJECTS_DIR%/samples/Basic_Blink make help make list-config - -REM Compile the tools first -make tools V=1 || goto :error +%MAKE_PARALLEL% || goto :error cd %SMING_HOME% -make STRICT=1 || goto :error - if "%SMING_ARCH%" == "Host" ( REM Build a couple of basic applications - make Basic_Serial || goto :error - make Basic_ProgMem || goto :error - + %MAKE_PARALLEL% Basic_Serial Basic_ProgMem STRICT=1 V=1 || goto :error + REM Run basic tests - cd %SMING_HOME%\..\tests\HostTests - make flash || goto :error + set SMING_TARGET_OPTIONS="--flashfile=$(FLASH_BIN) --flashsize=$(SPI_SIZE)" + %MAKE_PARALLEL% tests || goto :error -) ELSE ( +) else ( - make Basic_Blink V=1 || goto :error - make Basic_Ssl || goto :error - make Basic_SmartConfig || goto :error + %MAKE_PARALLEL% Basic_Ssl || goto :error + %MAKE_PARALLEL% Basic_SmartConfig || goto :error ) diff --git a/.gitignore b/.gitignore index 310a9a3186..581028ed14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ # generated binaries out -Sming/Arch/**/Compiler/lib/**/lib*.a # generated documentation docs/api @@ -17,8 +16,6 @@ GPATH # Microsoft Visual SourceSafe files vssver2.scc - -.metadata -.submodule -/Sming/Arch/Host/Components/lwip/Windows/src -/Sming/Arch/Host/Components/lwip/Windows/tmp + +.metadata +.submodule diff --git a/.gitmodules b/.gitmodules index 8b76287fe2..ead8ed139a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = https://github.com/SmingHub/Sming.wiki.git ignore = dirty [submodule "spiffs"] - path = Sming/Components/spiffs + path = Sming/Components/spiffs/spiffs url = https://github.com/pellepl/spiffs.git ignore = dirty [submodule "http-parser"] @@ -28,7 +28,7 @@ url = https://github.com/raburton/rboot.git ignore = dirty [submodule "ESP8266.new-pwm"] - path = Sming/Arch/Esp8266/Components/pwm/new-pwm + path = Sming/Arch/Esp8266/Components/pwm_open/new-pwm url = https://github.com/StefanBruens/ESP8266_new_pwm.git ignore = dirty [submodule "ESP8266.axtls-8266"] @@ -49,11 +49,11 @@ ignore = dirty [submodule "ESP8266.Sdk"] - path = Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK + path = Sming/Arch/Esp8266/Components/esp8266/ESP8266_NONOS_SDK url = https://github.com/espressif/ESP8266_NONOS_SDK.git ignore = dirty [submodule "ESP8266.esptool2"] - path = Sming/Arch/Esp8266/Tools/esptool2 + path = Sming/Arch/Esp8266/Components/rboot/esptool2 url = https://github.com/raburton/esptool2.git ignore = dirty diff --git a/.travis/build.sh b/.travis/build.sh index c5795f49ab..e9934fb717 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -1,6 +1,9 @@ #!/bin/bash set -ex # exit with nonzero exit code if anything fails +# Build times benefit from parallel building +export MAKE_PARALLEL="make -j3" + env unset SPIFFY unset ESPTOOL2 @@ -25,24 +28,32 @@ fi # Full compile checks please export STRICT=1 -# Diagnostic info cd $SMING_HOME + +# Move samples and tests into directory outside of the Sming repo. +export SMING_PROJECTS_DIR=$HOME/projects +mkdir $SMING_PROJECTS_DIR +mv ../samples $SMING_PROJECTS_DIR +mv ../tests $SMING_PROJECTS_DIR + +# Diagnostic info +cd $SMING_PROJECTS_DIR/samples/Basic_Blink make help make list-config -# Build the framework -make +# This will build the Basic_Blink application and most of the framework Components +$MAKE_PARALLEL + +cd $SMING_HOME if [ "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]; then - make Basic_Blink Basic_DateTime Basic_Delegates Basic_Interrupts Basic_ProgMem Basic_Serial Basic_Servo LiveDebug DEBUG_VERBOSE_LEVEL=3 - cd ../tests/HostTests - make flash + $MAKE_PARALLEL Basic_DateTime Basic_Delegates Basic_Interrupts Basic_ProgMem Basic_Serial Basic_Servo LiveDebug DEBUG_VERBOSE_LEVEL=3 + # Build and run tests + export SMING_TARGET_OPTIONS='--flashfile=$(FLASH_BIN) --flashsize=$(SPI_SIZE)' + $MAKE_PARALLEL tests else - make samples + $MAKE_PARALLEL samples make clean samples-clean - make ENABLE_CUSTOM_HEAP=1 STRICT=1 - make Basic_Blink ENABLE_CUSTOM_HEAP=1 DEBUG_VERBOSE_LEVEL=3 - - make dist-clean - make HttpServer_ConfigNetwork ENABLE_CUSTOM_LWIP=2 STRICT=1 + $MAKE_PARALLEL Basic_Blink ENABLE_CUSTOM_HEAP=1 DEBUG_VERBOSE_LEVEL=3 + $MAKE_PARALLEL HttpServer_ConfigNetwork ENABLE_CUSTOM_LWIP=2 STRICT=1 fi diff --git a/.travis/tools/clang/format-pr.sh b/.travis/tools/clang/format-pr.sh index d264a4f3c8..4f4c644935 100755 --- a/.travis/tools/clang/format-pr.sh +++ b/.travis/tools/clang/format-pr.sh @@ -10,7 +10,8 @@ $CLANG_FORMAT --version cd $SMING_HOME/.. # Get list of modified files -files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^[^.]*[.]\(c\|cpp\|h\)$' | grep -e Sming/Core -e Sming/Platform -e Sming/Arch/.+/Core -e Sming/Arch/.+/Platform -e samples || true)" +files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^[^.]*[.]\(c\|cpp\|h\)$' | \ + grep -e Sming/Core -e Sming/Platform -e Sming/Arch/.+/Core -e Sming/Arch/.+/Platform -e samples -e tests || true)" for f in $files_to_lint; do diff --git a/Sming/Arch/Esp8266/Compiler/ld/common.ld b/Sming/Arch/Esp8266/Compiler/ld/common.ld index 65084f0892..d1028532db 100644 --- a/Sming/Arch/Esp8266/Compiler/ld/common.ld +++ b/Sming/Arch/Esp8266/Compiler/ld/common.ld @@ -88,10 +88,6 @@ SECTIONS *libsmartconfig.a:(.literal .text .literal.* .text.*) *libstdc++.a:(.literal .text .literal.* .text.*) - *liblwip_open.a:(.literal .text .literal.* .text.*) - *liblwip_full.a:(.literal .text .literal.* .text.*) - *liblwip2.a:(.literal .text .literal.* .text.*) - *libaxtls.a:(.literal .text .literal.* .text.*) *libat.a:(.literal.* .text.*) *libcrypto.a:(.literal.* .text.*) *libespnow.a:(.literal.* .text.*) @@ -110,12 +106,12 @@ SECTIONS *libm.a:(.literal .text .literal.* .text.*) - *(.rodata._ZTV*) /* C++ vtables */ + *(.rodata._ZTV*) /* C++ vtables */ *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text .irom.debug.*) - */app.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*) - *libsming.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*) - *libsmingssl.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*) - *libmqttc.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*) + + /* Generated libraries */ + *liblwip2.a:(.literal .text .literal.* .text.*) + */clib-*.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*) /* __FUNCTION__ locals */ *(.rodata._ZZ*__FUNCTION__) diff --git a/Sming/Arch/Esp8266/Compiler/lib/.gitignore b/Sming/Arch/Esp8266/Compiler/lib/.gitignore deleted file mode 100644 index e355bb09bd..0000000000 --- a/Sming/Arch/Esp8266/Compiler/lib/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -libsming.a - diff --git a/Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266.patch b/Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266.patch index 7dcaa105a9..b143110c93 100644 --- a/Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266.patch +++ b/Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266.patch @@ -30,59 +30,11 @@ diff -Nuar a/replacements/libc.c b/replacements/libc.c +int vprintf(const char * format, va_list arg) { + return ets_vprintf(ets_putc, format, arg); +} -diff --git a/Makefile b/Makefile -index e48e869..e632b44 100644 ---- a/Makefile -+++ b/Makefile -@@ -5,6 +5,9 @@ LD := $(TOOLCHAIN_PREFIX)gcc - OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy - - XTENSA_LIBS ?= $(shell $(CC) -print-sysroot) -+ifeq ($(XTENSA_LIBS),) -+ XTENSA_LIBS = $(ESP_HOME)/xtensa-lx106-elf/ -+endif - - TOOLCHAIN_DIR=$(shell cd $(XTENSA_LIBS)/../../; pwd) - -@@ -48,15 +51,24 @@ CFLAGS += -ffunction-sections -fdata-sections - - CFLAGS += -fdebug-prefix-map=$(PWD)= -fdebug-prefix-map=$(TOOLCHAIN_DIR)=xtensa-lx106-elf -gno-record-gcc-switches - --MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32) --ifneq ($(MFORCE32),) -- # If the compiler supports the -mforce-l32 flag, the compiler will generate correct code for loading -- # 16- and 8-bit constants from program memory. So in the code we can directly access the arrays -- # placed into program memory. -- CFLAGS += -mforce-l32 --else -- # Otherwise we need to use a helper function to load 16- and 8-bit constants from program memory. -- CFLAGS += -DWITH_PGM_READ_HELPER -+CFLAGS += $(CFLAGS_EXTRA) -+ -+WITH_PGM_READ_HELPER ?= 1 -+ -+ifeq ($(WITH_PGM_READ_HELPER), 0) -+ MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32) -+ ifneq ($(MFORCE32),) -+ # If the compiler supports the -mforce-l32 flag, the compiler will generate correct code for loading -+ # 16- and 8-bit constants from program memory. So in the code we can directly access the arrays -+ # placed into program memory. -+ CFLAGS += -mforce-l32 -+ else -+ WITH_PGM_READ_HELPER=1 -+ endif -+endif -+ -+ifeq ($(WITH_PGM_READ_HELPER), 1) -+ CFLAGS += -DWITH_PGM_READ_HELPER - endif - - BIN_DIR := bin diff --git a/replacements/time.c b/replacements/time.c -index 4972119..f6f44f8 100644 +index 4972119..1a79aac 100644 --- a/replacements/time.c +++ b/replacements/time.c -@@ -24,17 +24,19 @@ extern uint64_t system_mktime(uint32_t year, uint32_t mon, uint32_t day, uint32_ +@@ -24,20 +24,16 @@ extern uint64_t system_mktime(uint32_t year, uint32_t mon, uint32_t day, uint32_ static int errno_var = 0; @@ -95,17 +47,20 @@ index 4972119..f6f44f8 100644 } -unsigned long millis(void) -+unsigned long WEAK_ATTR millis(void) - { - return system_get_time() / 1000UL; - } +-{ +- return system_get_time() / 1000UL; +-} ++extern unsigned long millis(void); -unsigned long micros(void) -+unsigned long WEAK_ATTR micros(void) - { - return system_get_time(); - } -@@ -79,7 +81,7 @@ static void setServer(int id, const char* name_or_ip) +-{ +- return system_get_time(); +-} ++extern unsigned long micros(void); + + #ifndef _TIMEVAL_DEFINED + #define _TIMEVAL_DEFINED +@@ -79,7 +75,7 @@ static void setServer(int id, const char* name_or_ip) } } @@ -114,7 +69,7 @@ index 4972119..f6f44f8 100644 { sntp_stop(); -@@ -93,7 +95,7 @@ void configTime(int timezone, int daylightOffset_sec, const char* server1, const +@@ -93,7 +89,7 @@ void configTime(int timezone, int daylightOffset_sec, const char* server1, const sntp_init(); } @@ -123,7 +78,7 @@ index 4972119..f6f44f8 100644 { tp->tv_sec = millis() / 1000; tp->tv_nsec = micros() * 1000; -@@ -101,14 +103,14 @@ int clock_gettime(clockid_t unused, struct timespec *tp) +@@ -101,14 +97,14 @@ int clock_gettime(clockid_t unused, struct timespec *tp) } // seconds since 1970 @@ -140,7 +95,7 @@ index 4972119..f6f44f8 100644 { time_t seconds = sntp_get_current_timestamp(); if (t) -@@ -118,24 +120,24 @@ time_t time(time_t * t) +@@ -118,24 +114,24 @@ time_t time(time_t * t) return seconds; } @@ -170,30 +125,110 @@ index 4972119..f6f44f8 100644 if (tp) { diff --git a/ssl/os_port.h b/ssl/os_port.h -index e0b9e46..b039417 100644 +index e0b9e46..7d85ff1 100644 --- a/ssl/os_port.h +++ b/ssl/os_port.h -@@ -53,6 +53,8 @@ extern "C" { - #define EXP_FUNC +@@ -45,4 +45,5 @@ extern "C" { + #include "config.h" + #include ++#include + + #ifdef WIN32 +@@ -68,5 +69,5 @@ extern "C" { + #undef putc #endif +-#define putc(x, f) ets_putc(x) ++#define putc(x, f) m_putc(x) -+#ifndef SMING_INCLUDED -+ - #if defined(_WIN32_WCE) - #undef WIN32 - #define WIN32 -@@ -92,7 +94,8 @@ extern "C" { - #define be64toh(x) __bswap_constant_64(x) + #define SOCKET_READ(A,B,C) ax_port_read(A,B,C) +@@ -93,76 +94,30 @@ extern "C" { #endif -void ax_wdt_feed(); +- +-#ifndef PROGMEM +-#define PROGMEM __attribute__((aligned(4))) __attribute__((section(".irom.text"))) +-#endif +- +-#ifndef WITH_PGM_READ_HELPER +-#define ax_array_read_u8(x, y) x[y] +-#else +- +-static inline uint8_t pgm_read_byte(const void* addr) { +- register uint32_t res; +- __asm__("extui %0, %1, 0, 2\n" /* Extract offset within word (in bytes) */ +- "sub %1, %1, %0\n" /* Subtract offset from addr, yielding an aligned address */ +- "l32i.n %1, %1, 0x0\n" /* Load word from aligned address */ +- "slli %0, %0, 3\n" /* Multiply offset by 8, yielding an offset in bits */ +- "ssr %0\n" /* Prepare to shift by offset (in bits) */ +- "srl %0, %1\n" /* Shift right; now the requested byte is the first one */ +- :"=r"(res), "=r"(addr) +- :"1"(addr) +- :); +- return (uint8_t) res; /* This masks the lower byte from the returned word */ +-} +extern void system_soft_wdt_feed(void); +#define ax_wdt_feed system_soft_wdt_feed - #ifndef PROGMEM - #define PROGMEM __attribute__((aligned(4))) __attribute__((section(".irom.text"))) -@@ -162,8 +165,8 @@ extern int ets_printf(const char *format, ...) __attribute__ ((format (printf, - extern int ets_putc(int); + #define ax_array_read_u8(x, y) pgm_read_byte((x)+(y)) +-#endif //WITH_PGM_READ_HELPER + +-#ifdef printf +-#undef printf +-#endif +-//#define printf(...) ets_printf(__VA_ARGS__) +-#define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];})) +-#define PGM_VOID_P const void * +-static inline void* memcpy_P(void* dest, PGM_VOID_P src, size_t count) { +- const uint8_t* read = (const uint8_t*)(src); +- uint8_t* write = (uint8_t*)(dest); +- +- while (count) +- { +- *write++ = pgm_read_byte(read++); +- count--; +- } +- +- return dest; +-} +-static inline int strlen_P(const char *str) { +- int cnt = 0; +- while (pgm_read_byte(str++)) cnt++; +- return cnt; +-} +-static inline int memcmp_P(const void *a1, const void *b1, size_t len) { +- const uint8_t* a = (const uint8_t*)(a1); +- uint8_t* b = (uint8_t*)(b1); +- for (size_t i=0; i? - extern char *strdup(const char *orig); -@@ -260,6 +263,7 @@ EXP_FUNC int STDCALL getdomainname(char *buf, int buf_size); - #endif /* Not Win32 */ +@@ -261,4 +216,5 @@ EXP_FUNC int STDCALL getdomainname(char *buf, int buf_size); /* some functions to mutate the way these work */ +#ifndef ntohl inline uint32_t htonl(uint32_t n){ return ((n & 0xff) << 24) | - ((n & 0xff00) << 8) | -@@ -268,6 +272,7 @@ inline uint32_t htonl(uint32_t n){ - } +@@ -269,4 +225,5 @@ inline uint32_t htonl(uint32_t n){ #define ntohl htonl +#endif EXP_FUNC int STDCALL ax_open(const char *pathname, int flags); - -@@ -304,6 +309,8 @@ void exit_now(const char *format, ...); - #define PROGMEM - #endif - -+#endif /* SMING_INCLUDED */ -+ - #ifdef __cplusplus - } - #endif diff --git a/ssl/tls1.c b/ssl/tls1.c index 10b592c..10fe9d5 100644 --- a/ssl/tls1.c @@ -550,3 +571,17 @@ index c6de55b..6834f5f 100644 } memcpy(total_read_buffer + total_bytes, read_buffer, read_bytes); +diff --git a/compat/lwipr_compat.h b/compat/lwipr_compat.h +index 0916412..4bb7d07 100644 +--- a/compat/lwipr_compat.h ++++ b/compat/lwipr_compat.h +@@ -27,9 +27,6 @@ extern "C" { + #define ERR_AXL_INVALID_CLIENTFD_DATA -104 + #define ERR_AXL_INVALID_PBUF -105 + +-#define SOCKET_READ(A, B, C) ax_port_read(A, B, C) +-#define SOCKET_WRITE(A, B, C) ax_port_write(A, B, C) +- + /** + * Define watchdog function to be called during CPU intensive operations. + */ diff --git a/Sming/Arch/Esp8266/Components/axtls-8266/component.mk b/Sming/Arch/Esp8266/Components/axtls-8266/component.mk new file mode 100644 index 0000000000..61fd1cd0f6 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/axtls-8266/component.mk @@ -0,0 +1,32 @@ +COMPONENT_VARS := SSL_DEBUG +SSL_DEBUG ?= 0 + +COMPONENT_SUBMODULES := axtls-8266 + +COMPONENT_SRCDIRS := \ + axtls-8266/compat \ + axtls-8266/replacements \ + axtls-8266/crypto \ + axtls-8266/ssl + +COMPONENT_INCDIRS := \ + . \ + axtls-8266 \ + axtls-8266/ssl \ + axtls-8266/crypto + +GLOBAL_CFLAGS += -DLWIP_RAW=1 +COMPONENT_CFLAGS := -DWITH_PGM_READ_HELPER=1 -DAXTLS_BUILD +ifeq ($(SSL_DEBUG),1) + COMPONENT_CFLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 -DAXL_DEBUG=1 +endif + +# Application +CUSTOM_TARGETS += include/ssl/private_key.h + +AXTLS_PATH := $(COMPONENT_PATH)/axtls-8266 + +include/ssl/private_key.h: + $(info Generating unique certificate and key. This may take some time...) + $(Q) mkdir -p $(PROJECT_DIR)/include/ssl/ + AXDIR=$(PROJECT_DIR)/include/ssl/ $(AXTLS_PATH)/tools/make_certs.sh diff --git a/Sming/Arch/Esp8266/Components/custom_heap/component.mk b/Sming/Arch/Esp8266/Components/custom_heap/component.mk new file mode 100644 index 0000000000..5884c2bf90 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/custom_heap/component.mk @@ -0,0 +1,15 @@ +# umm_malloc (custom heap allocation) + +COMPONENT_SUBMODULES := umm_malloc +COMPONENT_SRCDIRS := . umm_malloc/src +COMPONENT_INCDIRS := umm_malloc/src umm_malloc/includes/c-helper-macros + +LIBMAIN = mainmm +LIBMAIN_SRC = $(COMPONENT_LIBDIR)/libmainmm.a +COMPONENT_TARGETS += $(LIBMAIN_SRC) + +# Make copy of libmain and remove mem_manager.o module +$(COMPONENT_RULE)$(LIBMAIN_SRC): $(SDK_LIBDIR)/libmain.a + $(info Enabling custom heap implementation) + $(Q) cp $^ $@ + $(Q) $(AR) -d $@ mem_manager.o diff --git a/Sming/Core/Data/Buffer/SerialBuffer.cpp b/Sming/Arch/Esp8266/Components/driver/SerialBuffer.cpp similarity index 100% rename from Sming/Core/Data/Buffer/SerialBuffer.cpp rename to Sming/Arch/Esp8266/Components/driver/SerialBuffer.cpp diff --git a/Sming/Core/Data/Buffer/SerialBuffer.h b/Sming/Arch/Esp8266/Components/driver/SerialBuffer.h similarity index 100% rename from Sming/Core/Data/Buffer/SerialBuffer.h rename to Sming/Arch/Esp8266/Components/driver/SerialBuffer.h diff --git a/Sming/Arch/Esp8266/Components/driver/uart.cpp b/Sming/Arch/Esp8266/Components/driver/uart.cpp index c0a873af06..37711cc6cc 100644 --- a/Sming/Arch/Esp8266/Components/driver/uart.cpp +++ b/Sming/Arch/Esp8266/Components/driver/uart.cpp @@ -49,7 +49,7 @@ #include "driver/uart.h" #include "espinc/peri.h" -#include "Data/Buffer/SerialBuffer.h" +#include "SerialBuffer.h" /* * Parameters relating to RX FIFO and buffer thresholds diff --git a/Sming/Arch/Esp8266/Components/esp-lwip/component.mk b/Sming/Arch/Esp8266/Components/esp-lwip/component.mk new file mode 100644 index 0000000000..bee0acf346 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/esp-lwip/component.mk @@ -0,0 +1,9 @@ +COMPONENT_LIBNAME := + +COMPONENT_INCDIRS += . + +ifeq ($(SMING_RELEASE),1) + COMPONENT_CFLAGS := -DLWIP_NOASSERT +endif + +EXTRA_LIBS := lwip diff --git a/Sming/Arch/Esp8266/Components/esp-lwip/mem_manager.h b/Sming/Arch/Esp8266/Components/esp-lwip/mem_manager.h index fc1153a51e..ccb70cc834 100644 --- a/Sming/Arch/Esp8266/Components/esp-lwip/mem_manager.h +++ b/Sming/Arch/Esp8266/Components/esp-lwip/mem_manager.h @@ -74,9 +74,9 @@ static xBlockLink xStart, *pxEnd = NULL; /*------------------------��������-----------------------------------*/ -static void prvInsertBlockIntoFreeList( xBlockLink *pxBlockToInsert ) ;//ICACHE_FLASH_ATTR; +//static void prvInsertBlockIntoFreeList( xBlockLink *pxBlockToInsert ) ;//ICACHE_FLASH_ATTR; -static void prvHeapInit( void ) ;//ICACHE_FLASH_ATTR; +//static void prvHeapInit( void ) ;//ICACHE_FLASH_ATTR; void vApplicationMallocFailedHook( void ) ;//ICACHE_FLASH_ATTR; diff --git a/Sming/Arch/Esp8266/Components/esp-open-lwip/component.mk b/Sming/Arch/Esp8266/Components/esp-open-lwip/component.mk new file mode 100644 index 0000000000..37b4b926aa --- /dev/null +++ b/Sming/Arch/Esp8266/Components/esp-open-lwip/component.mk @@ -0,0 +1,78 @@ +COMPONENT_VARS := ENABLE_LWIPDEBUG ENABLE_ESPCONN +ENABLE_LWIPDEBUG ?= 0 +ENABLE_ESPCONN ?= 0 + +COMPONENT_CFLAGS := \ + -DPBUF_RSV_FOR_WLAN \ + -DEBUF_LWIP -DLWIP_OPEN_SRC \ + -Wno-implicit-function-declaration \ + -Wno-address \ + -Wno-format \ + -Wno-switch \ + -Wno-pointer-sign \ + -Wno-unused-function + +ifeq ($(SMING_RELEASE),1) + COMPONENT_CFLAGS += -DLWIP_NOASSERT +endif + +ifeq ($(ENABLE_LWIPDEBUG), 1) + COMPONENT_CFLAGS += -DLWIP_DEBUG +endif + +COMPONENT_SUBMODULES := esp-open-lwip +COMPONENT_SRCDIRS := +COMPONENT_SRCFILES := \ + lwip/core/def.c \ + lwip/core/dhcp.c \ + lwip/core/dns.c \ + lwip/core/init.c \ + lwip/core/mem.c \ + lwip/core/memp.c \ + lwip/core/netif.c \ + lwip/core/pbuf.c \ + lwip/core/raw.c \ + lwip/core/sntp.c \ + lwip/core/stats.c \ + lwip/core/sys_arch.c \ + lwip/core/sys.c \ + lwip/core/tcp.c \ + lwip/core/tcp_in.c \ + lwip/core/tcp_out.c \ + lwip/core/timers.c \ + lwip/core/udp.c \ + lwip/core/ipv4/autoip.c \ + lwip/core/ipv4/icmp.c \ + lwip/core/ipv4/igmp.c \ + lwip/core/ipv4/inet.c \ + lwip/core/ipv4/inet_chksum.c \ + lwip/core/ipv4/ip_addr.c \ + lwip/core/ipv4/ip.c \ + lwip/core/ipv4/ip_frag.c \ + lwip/netif/etharp.c \ + \ + lwip/app/dhcpserver.c + +ifeq ($(ENABLE_ESPCONN),1) + COMPONENT_SRCFILES += \ + $(addprefix lwip/app/,\ + espconn.c \ + espconn_tcp.c \ + espconn_udp.c \ + espconn_mdns.c) \ + lwip/api/err.c \ + lwip/core/mdns.c +else + COMPONENT_SRCFILES += espconn_dummy.c +endif +COMPONENT_SRCFILES := $(addprefix esp-open-lwip/,$(COMPONENT_SRCFILES)) +COMPONENT_INCDIRS := esp-open-lwip/include + +# Fussy about include paths so override default +INCDIR := \ + $(COMPONENT_PATH)/esp-open-lwip/include \ + $(SDK_BASE)/include \ + $(SMING_HOME)/System/include \ + $(ARCH_SYS)/include \ + $(ARCH_COMPONENTS)/esp8266/include \ + $(SMING_HOME)/Wiring diff --git a/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch b/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch index 6634103f29..c50664a013 100644 --- a/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch +++ b/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch @@ -222,9 +222,16 @@ index 1e46ee5..cfc10f8 100644 ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \ ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \ diff --git a/lwip/app/dhcpserver.c b/lwip/app/dhcpserver.c -index ddb5984..546a072 100644 +index ddb5984..ed8f912 100644 --- a/lwip/app/dhcpserver.c +++ b/lwip/app/dhcpserver.c +@@ -1,5 +1,5 @@ + #include "lwip/inet.h" +-#include "lwip/err.h" ++#include "lwip/err.h" + #include "lwip/pbuf.h" + #include "lwip/udp.h" + #include "lwip/mem.h" @@ -13,6 +13,8 @@ #include "user_interface.h" @@ -234,9 +241,16 @@ index ddb5984..546a072 100644 #ifdef MEMLEAK_DEBUG static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__; #endif -@@ -133,21 +135,16 @@ static uint8_t* ICACHE_FLASH_ATTR add_offer_options(uint8_t *optptr) +@@ -131,23 +133,18 @@ static uint8_t* ICACHE_FLASH_ATTR add_offer_options(uint8_t *optptr) + { + struct ip_addr ipadd; - ipadd.addr = *( (uint32_t *) &server_address); +- ipadd.addr = *( (uint32_t *) &server_address); ++ ipadd.addr = server_address.addr; ++ ++ struct ip_info if_ip; ++ os_bzero(&if_ip, sizeof(struct ip_info)); ++ wifi_get_ip_info(SOFTAP_IF, &if_ip); -#ifdef USE_CLASS_B_NET - *optptr++ = DHCP_OPTION_SUBNET_MASK; @@ -246,10 +260,6 @@ index ddb5984..546a072 100644 - *optptr++ = 0; - *optptr++ = 0; -#else -+ struct ip_info if_ip; -+ os_bzero(&if_ip, sizeof(struct ip_info)); -+ wifi_get_ip_info(SOFTAP_IF, &if_ip); -+ *optptr++ = DHCP_OPTION_SUBNET_MASK; - *optptr++ = 4; - *optptr++ = 255; @@ -276,6 +286,33 @@ index ddb5984..546a072 100644 *optptr++ = DHCP_OPTION_ROUTER; *optptr++ = 4; *optptr++ = ip4_addr1( &if_ip.gw); +@@ -248,7 +241,7 @@ static void ICACHE_FLASH_ATTR create_msg(struct dhcps_msg *m) + { + struct ip_addr client; + +- client.addr = *( (uint32_t *) &client_address); ++ client.addr = client_address.addr; + + m->op = DHCP_REPLY; + m->htype = DHCP_HTYPE_ETHERNET; +@@ -485,7 +478,7 @@ static uint8_t ICACHE_FLASH_ATTR parse_options(uint8_t *optptr, sint16_t len) + bool is_dhcp_parse_end = false; + struct dhcps_state s; + +- client.addr = *( (uint32_t *) &client_address);// Ҫ�����DHCP�ͻ��˵�IP ++ client.addr = client_address.addr;// Ҫ�����DHCP�ͻ��˵�IP + + u8_t *end = optptr + len; + u16_t type = 0; +@@ -573,7 +566,7 @@ static uint8_t ICACHE_FLASH_ATTR parse_options(uint8_t *optptr, sint16_t len) + /////////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////////// + static sint16_t ICACHE_FLASH_ATTR parse_msg(struct dhcps_msg *m, u16_t len) +-{ ++{ + if(os_memcmp((char *)m->options, + &magic_cookie, + sizeof(magic_cookie)) == 0){ --- a/include/lwip/tcp_impl.h +++ b/include/lwip/tcp_impl.h @@ -130,7 +130,7 @@ u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb)ICACHE_FLASH_ATTR; @@ -457,3 +494,40 @@ index ee50ceb..75563e9 100644 #ifdef MEMLEAK_DEBUG static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__; #endif +diff --git a/lwip/app/espconn.c b/lwip/app/espconn.c +index 9032648..69797e5 100644 +--- a/lwip/app/espconn.c ++++ b/lwip/app/espconn.c +@@ -676,8 +676,7 @@ sint8 ICACHE_FLASH_ATTR espconn_tcp_set_buf_count(struct espconn *espconn, uint8 + } + } + +- if (plist == NULL) +- return ESPCONN_ARG; ++ return (plist == NULL) ? ESPCONN_ARG : ESPCONN_OK; + } + + /****************************************************************************** +diff --git a/lwip/app/espconn_tcp.c b/lwip/app/espconn_tcp.c +index 52cd0b0..0ea6ab0 100644 +--- a/lwip/app/espconn_tcp.c ++++ b/lwip/app/espconn_tcp.c +@@ -187,7 +187,8 @@ struct tcp_pcb *ICACHE_FLASH_ATTR espconn_find_current_pcb(espconn_msg *pcurrent + uint16 local_port = pcurrent_msg->pcommon.local_port; + uint32 local_ip = pcurrent_msg->pcommon.local_ip; + uint16 remote_port = pcurrent_msg->pcommon.remote_port; +- uint32 remote_ip = *((uint32*)&pcurrent_msg->pcommon.remote_ip); ++ uint32 remote_ip; ++ memcpy(&remote_ip, pcurrent_msg->pcommon.remote_ip, sizeof(remote_ip)); + struct tcp_pcb *find_pcb = NULL; + if (pcurrent_msg ->preverse == NULL){/*Find the server's TCP block*/ + if (local_ip == 0|| local_port == 0) return pcurrent_msg->pcommon.pcb; +@@ -1334,7 +1335,7 @@ espconn_tcp_server(struct espconn *espconn) + *******************************************************************************/ + sint8 ICACHE_FLASH_ATTR espconn_tcp_delete(struct espconn *pdeletecon) + { +- err_t err; ++ err_t err = ERR_OK; + remot_info *pinfo = NULL; + espconn_msg *pdelete_msg = NULL; + struct tcp_pcb *pcb = NULL; diff --git a/Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK b/Sming/Arch/Esp8266/Components/esp8266/ESP8266_NONOS_SDK similarity index 100% rename from Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK rename to Sming/Arch/Esp8266/Components/esp8266/ESP8266_NONOS_SDK diff --git a/Sming/Arch/Esp8266/Components/esp8266/component.mk b/Sming/Arch/Esp8266/Components/esp8266/component.mk new file mode 100644 index 0000000000..bc09f524d2 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/esp8266/component.mk @@ -0,0 +1,38 @@ +# base directory of the ESP8266 SDK package, absolute +COMPONENT_VARS := SDK_BASE + +ifeq ($(UNAME),Windows) +SDK_BASE ?= $(ESP_HOME)/ESP8266_SDK +SDK_TOOLS ?= $(ESP_HOME)/utils +else +SDK_BASE ?= $(ESP_HOME)/sdk +SDK_TOOLS ?= $(SDK_BASE)/tools +endif + +SDK_BASE := $(call FixPath,$(SDK_BASE)) + +# => 'Internal' SDK - for SDK Version 3+ as submodule in Sming repository +# SDK_BASE just needs to point into our repo as it's overridden with the correct submodule path +# This provides backward-compatiblity, so $(SMING)/third-party/ESP8266_NONOS_SDK) still works +DEBUG_VARS += SDK_INTERNAL +ifneq (,$(findstring $(SMING_HOME),$(SDK_BASE))) +GLOBAL_CFLAGS += -DSDK_INTERNAL=1 +SDK_INTERNAL := 1 +COMPONENT_SUBMODULES := ESP8266_NONOS_SDK +SDK_BASE := $(COMPONENT_PATH)/ESP8266_NONOS_SDK +COMPONENT_TARGETS := $(SDK_BASE)/bin/esp_init_data_default.bin + +$(COMPONENT_RULE)$(SDK_BASE)/bin/esp_init_data_default.bin: + $(Q) cp -f $(@D)/esp_init_data_default_v08.bin $@ +else +SDK_INTERNAL := 0 +endif + +DEBUG_VARS += SDK_LIBDIR SDK_INCDIR +SDK_LIBDIR := $(SDK_BASE)/lib +SDK_INCDIR := $(SDK_BASE)/include +COMPONENT_INCDIRS := include $(SDK_INCDIR) + +export SDK_INTERNAL +export SDK_LIBDIR +export SDK_INCDIR diff --git a/Sming/Arch/Esp8266/Components/esp_wifi/component.mk b/Sming/Arch/Esp8266/Components/esp_wifi/component.mk new file mode 100644 index 0000000000..1cf7f4f415 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/esp_wifi/component.mk @@ -0,0 +1,8 @@ +COMPONENT_LIBNAME := + +# => WPS +COMPONENT_VARS := ENABLE_WPS +ifeq ($(ENABLE_WPS), 1) + GLOBAL_CFLAGS += -DENABLE_WPS=1 + EXTRA_LIBS := wps +endif diff --git a/Sming/Arch/Esp8266/Components/esptool/component.mk b/Sming/Arch/Esp8266/Components/esptool/component.mk new file mode 100644 index 0000000000..08a35fa4d0 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/esptool/component.mk @@ -0,0 +1,79 @@ +COMPONENT_LIBNAME := + +CONFIG_VARS += SPI_SPEED SPI_MODE SPI_SIZE + +# SPI_SPEED = 40, 26, 20, 80 +SPI_SPEED ?= 40 +# SPI_MODE: qio, qout, dio, dout +SPI_MODE ?= qio +# SPI_SIZE: 512K, 256K, 1M, 2M, 4M +SPI_SIZE ?= 512K + +ifeq ($(SPI_SPEED), 26) + flashimageoptions := -ff 26m +else ifeq ($(SPI_SPEED), 20) + flashimageoptions := -ff 20m +else ifeq ($(SPI_SPEED), 80) + flashimageoptions := -ff 80m +else + flashimageoptions := -ff 40m +endif + +ifeq ($(SPI_MODE), qout) + flashimageoptions += -fm qout +else ifeq ($(SPI_MODE), dio) + flashimageoptions += -fm dio +else ifeq ($(SPI_MODE), dout) + flashimageoptions += -fm dout +else + flashimageoptions += -fm qio +endif + +ifeq ($(SPI_SIZE), 256K) + flashimageoptions += -fs 256KB +else ifeq ($(SPI_SIZE), 1M) + flashimageoptions += -fs 1MB + INIT_BIN_ADDR := 0x0fc000 + BLANK_BIN_ADDR := 0x0fe000 +else ifeq ($(SPI_SIZE), 2M) + flashimageoptions += -fs 2MB + INIT_BIN_ADDR := 0x1fc000 + BLANK_BIN_ADDR := 0x1fe000 +else ifeq ($(SPI_SIZE), 4M) + flashimageoptions += -fs 4MB + INIT_BIN_ADDR := 0x3fc000 + BLANK_BIN_ADDR := 0x3fe000 +else + flashimageoptions += -fs 512KB + INIT_BIN_ADDR := 0x07c000 + BLANK_BIN_ADDR := 0x04b000 +endif + +# +FLASH_INIT_CHUNKS += $(INIT_BIN_ADDR)=$(SDK_BASE)/bin/esp_init_data_default.bin +FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR)=$(SDK_BASE)/bin/blank.bin + +# Default COM port and speed used for flashing +CACHE_VARS += COM_PORT_ESPTOOL COM_SPEED_ESPTOOL +COM_PORT_ESPTOOL ?= $(COM_PORT) +COM_SPEED_ESPTOOL ?= $(COM_SPEED) + +ifeq ($(UNAME),Windows) +ESPTOOL ?= $(SDK_TOOLS)/esptool/esptool.py +else +ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py +endif + +ESPTOOL_CMDLINE := $(ESPTOOL) -p $(COM_PORT_ESPTOOL) -b $(COM_SPEED_ESPTOOL) + +# Write file contents to Flash +# $1 -> List of `Offset=File` chunks +define WriteFlash + $(info WriteFlash $1) + $(ESPTOOL_CMDLINE) write_flash $(flashimageoptions) $(subst =, ,$1) +endef + +# Erase flash memory contents +define EraseFlash + $(ESPTOOL_CMDLINE) erase_flash +endef diff --git a/Sming/Arch/Esp8266/Components/gdbstub/component.mk b/Sming/Arch/Esp8266/Components/gdbstub/component.mk new file mode 100644 index 0000000000..714dfe1d20 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/gdbstub/component.mk @@ -0,0 +1,25 @@ +COMPONENT_LIBNAME := + +COMPONENT_APPCODE := appcode +COMPONENT_INCDIRS := . $(ESP8266_COMPONENTS)/driver + +ifeq ($(ENABLE_GDB), 1) +COMPONENT_APPCODE += . +CUSTOM_TARGETS += gdb_symbols +SYMBOLS_SOURCEDIR := $(COMPONENT_PATH)/symbols + +# Copy symbols required by GDB into build directory +.PHONY: gdb_symbols +gdb_symbols: $(BUILD_BASE)/bootrom.elf + +$(BUILD_BASE)/%.elf: + $(Q) cp $(SYMBOLS_SOURCEDIR)/$(@F) $@ +endif + +CACHE_VARS += COM_PORT_GDB COM_SPEED_GDB +COM_PORT_GDB ?= $(COM_PORT) +COM_SPEED_GDB ?= $(COM_SPEED) + +# Full GDB command line +GDBSTUB_DIR := $(COMPONENT_PATH) +GDB_CMDLINE = trap '' INT; $(GDB) -x $(GDBSTUB_DIR)/gdbcmds -b $(COM_SPEED_GDB) -ex "target remote $(COM_PORT_GDB)" diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbcmds b/Sming/Arch/Esp8266/Components/gdbstub/gdbcmds index c50938fb94..3d9c7f9dbf 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbcmds +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbcmds @@ -23,11 +23,11 @@ mem 0x40140000 0x5fffffff ro cache mem 0x60000000 0x60001fff rw # The target object file so GDB knows where to get symbol information -file out/build/Esp8266/app_0.out +file out/Esp8266/debug/build/app_0.out # GDB needs to know about ROM functions in order to create a full stack trace # See https://github.com/jcmvbkbc/esp-elf-rom -add-symbol-file out/build/Esp8266/bootrom.elf 0x40000000 -readnow +add-symbol-file out/Esp8266/debug/build/bootrom.elf 0x40000000 -readnow # Useful for lower-level debugging to see the result of stepping through assembler code #set disassemble-next-line on diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp index e3751b2568..8588141842 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp @@ -13,7 +13,7 @@ #include "gdbuart.h" #include "GdbPacket.h" #include "driver/uart.h" -#include "Data/Buffer/SerialBuffer.h" +#include "driver/SerialBuffer.h" #include "Platform/System.h" #include "HardwareSerial.h" #include "HardwareTimer.h" diff --git a/Sming/Arch/Esp8266/Components/lwip2/component.mk b/Sming/Arch/Esp8266/Components/lwip2/component.mk new file mode 100644 index 0000000000..3601ddce63 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/lwip2/component.mk @@ -0,0 +1,41 @@ +# For now, build as a regular library using existing makefile (variants not supported) +COMPONENT_LIBNAME := + +ifeq ($(SMING_RELEASE),1) + COMPONENT_CFLAGS := \ + -DLWIP_NOASSERT \ + -Wno-implicit-function-declaration +endif + +COMPONENT_VARS := ENABLE_LWIPDEBUG ENABLE_ESPCONN +ENABLE_LWIPDEBUG ?= 0 +ENABLE_ESPCONN ?= 0 + +EXTRA_CFLAGS_LWIP := \ + -I$(SMING_HOME)/System/include \ + -I$(ARCH_SYS)/include \ + -I$(ARCH_COMPONENTS)/esp8266/include \ + -I$(SMING_HOME)/Wiring + +ifeq ($(ENABLE_LWIPDEBUG), 1) + EXTRA_CFLAGS_LWIP += -DLWIP_DEBUG +endif + +ifeq ($(ENABLE_ESPCONN), 1) +$(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) +endif + +COMPONENT_SUBMODULES := lwip2 +COMPONENT_INCDIRS := lwip2/glue-esp/include-esp lwip2/include + +LWIP2_PATH := $(COMPONENT_PATH)/lwip2 + +# Make is pretty complex for LWIP2, and mucks about with output sections so build as a regular library +LWIP2_LIB := $(COMPONENT_NAME) +LWIP2_TARGET := $(COMPONENT_LIBDIR)/lib$(LWIP2_LIB).a +COMPONENT_TARGETS := $(LWIP2_TARGET) +EXTRA_LIBS := $(LWIP2_LIB) + +$(COMPONENT_RULE)$(LWIP2_TARGET): + $(Q) $(MAKE) -C $(LWIP2_PATH) -f Makefile.sming BUILD=$(COMPONENT_BUILD_DIR) \ + USER_LIBDIR=$(COMPONENT_LIBDIR)/ CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" CC=$(CC) AR=$(AR) all diff --git a/Sming/Arch/Esp8266/Components/lwip2/lwip2.patch b/Sming/Arch/Esp8266/Components/lwip2/lwip2.patch index fc4cd17955..6d1e33ffe7 100644 --- a/Sming/Arch/Esp8266/Components/lwip2/lwip2.patch +++ b/Sming/Arch/Esp8266/Components/lwip2/lwip2.patch @@ -81,33 +81,61 @@ index 0e42073..2846506 100644 struct ip_addr; void wifi_softap_set_station_info (uint8_t* mac, struct ip_addr*); diff --git a/makefiles/Makefile.build-lwip2 b/makefiles/Makefile.build-lwip2 -index 928bb63..289d48f 100644 +index 928bb63..ccdbca7 100644 --- a/makefiles/Makefile.build-lwip2 +++ b/makefiles/Makefile.build-lwip2 -@@ -29,9 +29,9 @@ $(LWIP_LIB_RELEASE): $(LWIP_LIB) +@@ -14,24 +14,25 @@ IRAM += sys_timeout_LWIP2 + IRAM += sntp_time_inc sntp_get_current_timestamp + #################################### - .PHONY: $(LWIP_LIB) - $(LWIP_LIB): ++LWIP_LIB_BUILD = $(BUILD)/$(LWIP_LIB) ++ + all: $(LWIP_LIB_RELEASE) + +-$(LWIP_LIB_RELEASE): $(LWIP_LIB) ++$(LWIP_LIB_RELEASE): $(LWIP_LIB_BUILD) + @# according to eagle.app.v6.common.ld: + @# putting symbols into .gnu.linkonce.literal.* instead of (default:).text.* + @# will eventually move them in iram: section .text.* instead of .irom0.text.* + @# check this with xtensa-lx106-elf-objdump -t | grep +- @( [ ! -r $(LWIP_LIB_RELEASE) ] || [ $(LWIP_LIB) -nt $(LWIP_LIB_RELEASE) ] ) && cp $(LWIP_LIB) $(LWIP_LIB_RELEASE) && for i in $(IRAM); do \ ++ @( [ ! -r $@ ] || [ $< -nt $@ ] ) && cp $< $@ && for i in $(IRAM); do \ + echo "---- moving $$i in IRAM"; \ +- $(OC) --rename-section .text.$$i=.gnu.linkonce.literal.$$i $(LWIP_LIB_RELEASE); \ ++ $(OC) --rename-section .text.$$i=.gnu.linkonce.literal.$$i $@; \ + true; \ + done || true + +-.PHONY: $(LWIP_LIB) +-$(LWIP_LIB): - make -f makefiles/Makefile.glue-esp - make -f makefiles/Makefile.glue - make -C lwip2-src/src -f ../../makefiles/Makefile.lwip2 BUILD=../../$(BUILD) LWIP_LIB=../../$(LWIP_LIB) -+ make -f makefiles/Makefile.glue-esp SDK_INTERNAL=$(SDK_INTERNAL) -+ make -f makefiles/Makefile.glue SDK_INTERNAL=$(SDK_INTERNAL) -+ make -C lwip2-src/src -f ../../makefiles/Makefile.lwip2 BUILD=../../$(BUILD) LWIP_LIB=../../$(LWIP_LIB) SDK_INTERNAL=$(SDK_INTERNAL) ++$(LWIP_LIB_BUILD): ++ make -f makefiles/Makefile.glue-esp SDK_INTERNAL=$(SDK_INTERNAL) LWIP_LIB=$@ ++ make -f makefiles/Makefile.glue SDK_INTERNAL=$(SDK_INTERNAL) LWIP_LIB=$@ ++ make -C lwip2-src/src -f ../../makefiles/Makefile.lwip2 LWIP_LIB=$@ SDK_INTERNAL=$(SDK_INTERNAL) section-show: @for i in $(IRAM); do \ +@@ -53,4 +54,4 @@ install: $(LWIP_LIB_RELEASE) + touch $(LWIP_INCLUDES_RELEASE)/espconn.h + + clean: +- rm -rf build $(LWIP_LIB) ++ rm -rf $(BUILD) diff --git a/makefiles/Makefile.defs b/makefiles/Makefile.defs -index 7ab4f87..fb60baf 100644 +index 7ab4f87..025a23c 100644 --- a/makefiles/Makefile.defs +++ b/makefiles/Makefile.defs @@ -4,7 +4,9 @@ AR = $(TOOLS)ar OC = $(TOOLS)objcopy OD = $(TOOLS)objdump +-BUILD = build +SDK_INTERNAL ?= 0 + - BUILD = build ++BUILD ?= build BUILD_FLAGS = -Wall -Wextra -std=c99 -c -Os -g -Wpointer-arith -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections -BUILD_DEFINES = -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -DLWIP_OPEN_SRC -DLWIP_BUILD -DUSE_OPTIMIZE_PRINTF +BUILD_DEFINES = -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -DLWIP_OPEN_SRC -DLWIP_BUILD -DUSE_OPTIMIZE_PRINTF -DSDK_INTERNAL=$(SDK_INTERNAL) diff --git a/Sming/Arch/Esp8266/Components/pwm_open/component.mk b/Sming/Arch/Esp8266/Components/pwm_open/component.mk new file mode 100644 index 0000000000..114287be86 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/pwm_open/component.mk @@ -0,0 +1,4 @@ + +COMPONENT_SUBMODULES := new-pwm +COMPONENT_SRCDIRS := new-pwm +COMPONENT_CFLAGS := -DSDK_PWM_PERIOD_COMPAT_MODE=1 diff --git a/Sming/Arch/Esp8266/Components/pwm/new-pwm b/Sming/Arch/Esp8266/Components/pwm_open/new-pwm similarity index 100% rename from Sming/Arch/Esp8266/Components/pwm/new-pwm rename to Sming/Arch/Esp8266/Components/pwm_open/new-pwm diff --git a/Sming/Arch/Esp8266/Components/pwm/new-pwm.patch b/Sming/Arch/Esp8266/Components/pwm_open/new-pwm.patch similarity index 64% rename from Sming/Arch/Esp8266/Components/pwm/new-pwm.patch rename to Sming/Arch/Esp8266/Components/pwm_open/new-pwm.patch index c9c787688d..a3b04b305e 100644 --- a/Sming/Arch/Esp8266/Components/pwm/new-pwm.patch +++ b/Sming/Arch/Esp8266/Components/pwm_open/new-pwm.patch @@ -1,5 +1,5 @@ diff --git a/pwm.c b/pwm.c -index 6df21ac..b79002c 100644 +index 6df21ac..dfaf4d9 100644 --- a/pwm.c +++ b/pwm.c @@ -16,6 +16,8 @@ @@ -37,3 +37,21 @@ index 6df21ac..b79002c 100644 { if ((pwm_state.current_set[pwm_state.current_phase].off_mask == 0) && (pwm_state.current_set[pwm_state.current_phase].on_mask == 0)) { +@@ -120,7 +122,7 @@ pwm_intr_handler(void) + + do { + // force write to GPIO registers on each loop +- asm volatile ("" : : : "memory"); ++ __asm__ volatile ("" : : : "memory"); + + gpio->out_w1ts = (uint32_t)(pwm_state.current_set[pwm_state.current_phase].on_mask); + gpio->out_w1tc = (uint32_t)(pwm_state.current_set[pwm_state.current_phase].off_mask); +@@ -142,7 +144,7 @@ pwm_intr_handler(void) + do { + ticks -= 1; + // stop compiler from optimizing delay loop to noop +- asm volatile ("" : : : "memory"); ++ __asm__ volatile ("" : : : "memory"); + } while (ticks > 0); + } + diff --git a/Sming/Arch/Esp8266/Components/rboot/component.mk b/Sming/Arch/Esp8266/Components/rboot/component.mk new file mode 100644 index 0000000000..d246bfaa50 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/rboot/component.mk @@ -0,0 +1,133 @@ +COMPONENT_LIBNAME := + +COMPONENT_SUBMODULES := rboot esptool2 +COMPONENT_INCDIRS := rboot appcode rboot/appcode + +ESPTOOL2 := $(TOOLS_BASE)/esptool2$(TOOL_EXT) +COMPONENT_TARGETS := $(ESPTOOL2) +$(COMPONENT_RULE)$(ESPTOOL2): + $(call MakeTarget,esptool2/Makefile) + + +# => APP + +# rBoot options, overwrite them in the projects Makefile-user.mk +CONFIG_VARS += RBOOT_BIG_FLASH RBOOT_TWO_ROMS RBOOT_RTC_ENABLED RBOOT_GPIO_ENABLED RBOOT_GPIO_SKIP_ENABLED +RBOOT_BIG_FLASH ?= 1 +RBOOT_TWO_ROMS ?= 0 +RBOOT_RTC_ENABLED ?= 0 +RBOOT_GPIO_ENABLED ?= 0 +# RBOOT_GPIO_SKIP_ENABLED and RBOOT_GPIO_ENABLED cannot be used at the same time. +RBOOT_GPIO_SKIP_ENABLED ?= 0 + +ifeq ($(RBOOT_GPIO_ENABLED)$(RBOOT_GPIO_SKIP_ENABLED),11) +$(error "Cannot enable RBOOT_GPIO_ENABLED and RBOOT_GPIO_SKIP_ENABLED at the same time) +endif + +### ROM Addresses ### +# The parameter below specifies the location of the second rom. +# This parameter is used only when RBOOT_BIG_FLASH = 1 +# BOOT_ROM1_ADDR = 0x200000 + +# The parameter below specifies the location of the GPIO ROM. +# This parameter is used only when RBOOT_GPIO_ENABLED = 1 +# If you use two SPIFFS make sure that this address is minimum +# RBOOT_SPIFFS_1 + SPIFF_SIZE +# BOOT_ROM2_ADDR = 0x310000 + +CONFIG_VARS += RBOOT_SILENT +RBOOT_SILENT ?= 0 + +RELINK_VARS += RBOOT_ROM_0 RBOOT_ROM_1 RBOOT_LD_0 RBOOT_LD_1 +RBOOT_ROM_0 ?= rom0 +RBOOT_ROM_1 ?= rom1 +RBOOT_LD_0 ?= rboot.rom0.ld +RBOOT_LD_1 ?= rom1.ld + +# +CONFIG_VARS += RBOOT_SPIFFS_0 RBOOT_SPIFFS_1 +RBOOT_SPIFFS_0 ?= 0x100000 +RBOOT_SPIFFS_1 ?= 0x300000 +APP_CFLAGS += -DRBOOT_SPIFFS_0=$(RBOOT_SPIFFS_0) +APP_CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) + +# Fixed addresses +ROM_0_ADDR := 0x002000 + +# filenames and options for generating rBoot rom images with esptool2 +RBOOT_E2_SECTS ?= .text .data .rodata +RBOOT_E2_USER_ARGS ?= -quiet -bin -boot2 + +RBOOT_ROM_0_BIN := $(FW_BASE)/$(RBOOT_ROM_0).bin +RBOOT_ROM_1_BIN := $(FW_BASE)/$(RBOOT_ROM_1).bin + + +COMPONENT_APPCODE := appcode rboot/appcode +RBOOT_BIN := $(FW_BASE)/rboot.bin +CUSTOM_TARGETS += $(RBOOT_BIN) +APP_CFLAGS += -DRBOOT_INTEGRATION + +# these are exported for use by the rBoot Makefile +CONFIG_VARS += RBOOT_ROM1_ADDR RBOOT_ROM2_ADDR +export RBOOT_BUILD_BASE := $(abspath $(COMPONENT_BUILD_DIR)) +export RBOOT_FW_BASE := $(abspath $(FW_BASE)) +export ESPTOOL2 + +# multiple roms per 1mb block? +ifeq ($(RBOOT_TWO_ROMS),1) + # set a define so ota code can choose correct rom + APP_CFLAGS += -DRBOOT_TWO_ROMS +else + # eliminate the second rBoot target + RBOOT_ROM_1_BIN := +endif + +ifeq ($(RBOOT_RTC_ENABLED),1) + # enable the temporary switch to rom feature + APP_CFLAGS += -DBOOT_RTC_ENABLED +endif + +ifeq ($(RBOOT_GPIO_ENABLED),1) + APP_CFLAGS += -DBOOT_GPIO_ENABLED +endif + +ifeq ($(RBOOT_GPIO_SKIP_ENABLED),1) + APP_CFLAGS += -DBOOT_GPIO_SKIP_ENABLED +endif + +$(RBOOT_BIN): + $(MAKE) -C $(ARCH_COMPONENTS)/rboot/rboot + + +# rBoot big flash support requires a slightly modified version of libmain (just one symbol gets weakened) +# Note that LIBMAIN/LIBMAIN_SRC changes depends on whether we're using a custom heap allocator +LIBMAIN_RBOOT := $(LIBMAIN)-rboot +LIBMAIN_RBOOT_DST := $(APP_LIBDIR)/lib$(LIBMAIN_RBOOT).a +CUSTOM_TARGETS += $(LIBMAIN_RBOOT_DST) + +$(LIBMAIN_RBOOT_DST): $(LIBMAIN_SRC) + @echo "OC $@" + $(Q) $(OBJCOPY) -W Cache_Read_Enable_New $^ $@ + +ifeq ($(RBOOT_BIG_FLASH),1) +LIBMAIN := $(LIBMAIN_RBOOT) +APP_CFLAGS += -DBOOT_BIG_FLASH +endif + +# Define our flash chunks +FLASH_RBOOT_BOOT_CHUNKS := 0x00000=$(RBOOT_BIN) +FLASH_RBOOT_APP_CHUNKS := $(ROM_0_ADDR)=$(RBOOT_ROM_0_BIN) +FLASH_RBOOT_ERASE_CONFIG_CHUNKS := 0x01000=$(SDK_BASE)/bin/blank.bin + +# => Firmware images +CUSTOM_TARGETS += $(RBOOT_ROM_0_BIN) +$(RBOOT_ROM_0_BIN): $(TARGET_OUT_0) + $(info ESPTOOL2 $@) + $(Q) $(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $< $@ $(RBOOT_E2_SECTS) + $(Q) $(call WriteFirmwareConfigFile,$@) + +CUSTOM_TARGETS += $(RBOOT_ROM_1_BIN) +$(RBOOT_ROM_1_BIN): $(TARGET_OUT_1) + $(info ESPTOOL2 $@) + $(Q) $(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $< $@ $(RBOOT_E2_SECTS) + $(Q) $(call WriteFirmwareConfigFile,$@) diff --git a/Sming/Arch/Esp8266/Tools/esptool2 b/Sming/Arch/Esp8266/Components/rboot/esptool2 similarity index 100% rename from Sming/Arch/Esp8266/Tools/esptool2 rename to Sming/Arch/Esp8266/Components/rboot/esptool2 diff --git a/Sming/Arch/Esp8266/Tools/esptool2.patch b/Sming/Arch/Esp8266/Components/rboot/esptool2.patch similarity index 100% rename from Sming/Arch/Esp8266/Tools/esptool2.patch rename to Sming/Arch/Esp8266/Components/rboot/esptool2.patch diff --git a/Sming/Arch/Esp8266/Components/sming-arch/component.mk b/Sming/Arch/Esp8266/Components/sming-arch/component.mk new file mode 100644 index 0000000000..ff6104f692 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/sming-arch/component.mk @@ -0,0 +1,61 @@ +COMPONENT_SRCDIRS := \ + $(ARCH_CORE) $(call ListAllSubDirs,$(ARCH_CORE)) \ + $(ARCH_SYS) \ + $(ARCH_BASE)/Platform + +COMPONENT_INCDIRS := \ + $(ARCH_BASE) \ + $(ARCH_CORE) \ + $(ARCH_SYS)/include \ + $(ARCH_COMPONENTS) + +COMPONENT_DEPENDS := \ + esp8266 \ + driver \ + esp_wifi \ + esptool \ + fatfs \ + gdbstub \ + spi_flash + +# => SSL +ifeq ($(ENABLE_SSL),1) + COMPONENT_DEPENDS += axtls-8266 +endif + +# => Custom heap +RELINK_VARS += ENABLE_CUSTOM_HEAP +ENABLE_CUSTOM_HEAP ?= 0 +ifeq ($(ENABLE_CUSTOM_HEAP), 1) + COMPONENT_DEPENDS += custom_heap +else + LIBMAIN = main + LIBMAIN_SRC = $(SDK_LIBDIR)/libmain.a +endif + +# Must follow custom_heap +COMPONENT_DEPENDS += rboot + +# => LWIP +COMPONENT_VARS += ENABLE_CUSTOM_LWIP +ENABLE_CUSTOM_LWIP ?= 1 +ifeq ($(ENABLE_CUSTOM_LWIP), 0) + COMPONENT_DEPENDS += esp-lwip +else ifeq ($(ENABLE_CUSTOM_LWIP), 1) + COMPONENT_DEPENDS += esp-open-lwip +else ifeq ($(ENABLE_CUSTOM_LWIP), 2) + COMPONENT_DEPENDS += lwip2 +endif + +# => PWM +RELINK_VARS += ENABLE_CUSTOM_PWM +ENABLE_CUSTOM_PWM ?= 1 +ifeq ($(ENABLE_CUSTOM_PWM), 1) + COMPONENT_DEPENDS += pwm_open +else + LIBS += pwm +endif + +# rBoot creates ROM images from one or both of these targets +TARGET_OUT_0 := $(BUILD_BASE)/$(APP_NAME)_0.out +TARGET_OUT_1 := $(BUILD_BASE)/$(APP_NAME)_1.out diff --git a/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h b/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h deleted file mode 100644 index 8f7bd65ea2..0000000000 --- a/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h +++ /dev/null @@ -1,44 +0,0 @@ - -#pragma once - -#include -#include -#include -#include -#include -#if defined(_WIN32) || defined(__CYGWIN__) - // For compatibility with different OS & configurations - #if __WORDSIZE == 64 - # if !defined(__intptr_t_defined) && !defined(_INTPTR_T_DEFINED) - typedef long int intptr_t; - #define __intptr_t_defined - #define _INTPTR_T_DEFINED - # endif - #if !defined(__uintptr_t_defined) && !defined(_UINTPTR_T_DEFINED) - #define __uintptr_t_defined - #define _UINTPTR_T_DEFINED - #undef uintptr_t - typedef unsigned long int uintptr_t; - #endif /* _UINTPTR_T_DEFINED */ - #else - # if !defined(__intptr_t_defined) && !defined(_INTPTR_T_DEFINED) - typedef int intptr_t; - #define __intptr_t_defined - #define _INTPTR_T_DEFINED - # endif - #if !defined(__uintptr_t_defined) && !defined(_UINTPTR_T_DEFINED) - #define __uintptr_t_defined - #define _UINTPTR_T_DEFINED - #undef uintptr_t - typedef unsigned int uintptr_t; - #endif /* _UINTPTR_T_DEFINED */ - #endif -#else - #include -#endif -typedef signed int s32_t; -typedef unsigned int u32_t; -typedef signed short s16_t; -typedef unsigned short u16_t; -typedef signed char s8_t; -typedef unsigned char u8_t; diff --git a/Sming/Arch/Esp8266/Tools/spiffy/.gitignore b/Sming/Arch/Esp8266/Tools/spiffy/.gitignore deleted file mode 100644 index 89a1a7f5a8..0000000000 --- a/Sming/Arch/Esp8266/Tools/spiffy/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.o -spiffy -spiffy.exe diff --git a/Sming/Arch/Esp8266/app.mk b/Sming/Arch/Esp8266/app.mk index a9ba09926e..b5d1303bd3 100644 --- a/Sming/Arch/Esp8266/app.mk +++ b/Sming/Arch/Esp8266/app.mk @@ -4,302 +4,43 @@ # ### -##@Building - -.PHONY: all -all: libsming checkdirs app ##(default) Build application - -# rBoot options, overwrite them in the projects Makefile-user.mk -CONFIG_VARS += RBOOT_BIG_FLASH RBOOT_TWO_ROMS RBOOT_RTC_ENABLED RBOOT_GPIO_ENABLED RBOOT_GPIO_SKIP_ENABLED -RBOOT_BIG_FLASH ?= 1 -RBOOT_TWO_ROMS ?= 0 -RBOOT_RTC_ENABLED ?= 0 -RBOOT_GPIO_ENABLED ?= 0 -# RBOOT_GPIO_SKIP_ENABLED and RBOOT_GPIO_ENABLED cannot be used at the same time. -RBOOT_GPIO_SKIP_ENABLED ?= 0 - -ifeq ($(RBOOT_GPIO_ENABLED)$(RBOOT_GPIO_SKIP_ENABLED),11) - $(error "Cannot enable RBOOT_GPIO_ENABLED and RBOOT_GPIO_SKIP_ENABLED at the same time) -endif - -### ROM Addresses ### -# The parameter below specifies the location of the second rom. -# This parameter is used only when RBOOT_BIG_FLASH = 1 -# BOOT_ROM1_ADDR = 0x200000 - -# The parameter below specifies the location of the GPIO ROM. -# This parameter is used only when RBOOT_GPIO_ENABLED = 1 -# If you use two SPIFFS make sure that this address is minimum -# RBOOT_SPIFFS_1 + SPIFF_SIZE -# BOOT_ROM2_ADDR = 0x310000 - -CONFIG_VARS += RBOOT_SILENT RBOOT_ROM_0 RBOOT_ROM_1 RBOOT_LD_0 RBOOT_LD_1 -RBOOT_SILENT ?= 0 -RBOOT_ROM_0 ?= rom0 -RBOOT_ROM_1 ?= rom1 -RBOOT_LD_0 ?= rboot.rom0.ld -RBOOT_LD_1 ?= rom1.ld - # -CONFIG_VARS += RBOOT_SPIFFS_0 RBOOT_SPIFFS_1 -RBOOT_SPIFFS_0 ?= 0x100000 -RBOOT_SPIFFS_1 ?= 0x300000 - -# Fixed addresses -ROM_0_ADDR := 0x002000 -BLANK_BIN_ADDR := 0x04b000 -INIT_BIN_ADDR := 0x07c000 - -# filenames and options for generating rBoot rom images with esptool2 -RBOOT_E2_SECTS ?= .text .data .rodata -RBOOT_E2_USER_ARGS ?= -quiet -bin -boot2 - -RBOOT_ROM_0 := $(FW_BASE)/$(RBOOT_ROM_0).bin -RBOOT_ROM_1 := $(FW_BASE)/$(RBOOT_ROM_1).bin - -# Code compiled with application -APPCODE := - -EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp8266/include \ - $(SDK_INCDIR) \ - $(ARCH_COMPONENTS)/driver/include \ - $(ARCH_COMPONENTS)/spi_flash/include \ - $(ARCH_COMPONENTS)/esp_wifi/include - -# Macro to make an optional library -# $1 -> The library to make -# $2 -> List of options to add to make command line -define MakeLibrary - $(Q) $(MAKE) -C $(SMING_HOME) $(patsubst $(SMING_HOME)/%,%,$1) $2 -endef - -# => rBoot -RBOOT_BASE := $(ARCH_COMPONENTS)/rboot -APPCODE += $(RBOOT_BASE)/appcode $(RBOOT_BASE)/rboot/appcode -EXTRA_INCDIR += $(RBOOT_BASE)/rboot $(RBOOT_BASE)/appcode $(RBOOT_BASE)/rboot/appcode -RBOOT_BIN := $(FW_BASE)/rboot.bin -CUSTOM_TARGETS += $(RBOOT_BIN) -CFLAGS += -DRBOOT_INTEGRATION -# these are exported for use by the rBoot Makefile -export RBOOT_SILENT -export RBOOT_BIG_FLASH -export RBOOT_BUILD_BASE := $(abspath $(BUILD_BASE)) -export RBOOT_FW_BASE := $(abspath $(FW_BASE)) -export RBOOT_RTC_ENABLED -export RBOOT_GPIO_ENABLED -export RBOOT_GPIO_SKIP_ENABLED -export RBOOT_ROM1_ADDR -export RBOOT_ROM2_ADDR -export SPI_SIZE -export SPI_MODE -export SPI_SPEED -export ESPTOOL2 -# multiple roms per 1mb block? -ifeq ($(RBOOT_TWO_ROMS),1) - # set a define so ota code can choose correct rom - CFLAGS += -DRBOOT_TWO_ROMS -else - # eliminate the second rBoot target - RBOOT_ROM_1 := -endif -ifeq ($(RBOOT_RTC_ENABLED),1) - # enable the temporary switch to rom feature - CFLAGS += -DBOOT_RTC_ENABLED -endif -ifeq ($(RBOOT_GPIO_ENABLED),1) - CFLAGS += -DBOOT_GPIO_ENABLED -endif -ifeq ($(RBOOT_GPIO_SKIP_ENABLED),1) - CFLAGS += -DBOOT_GPIO_SKIP_ENABLED -endif -$(RBOOT_BIN): - $(MAKE) -C $(ARCH_COMPONENTS)/rboot/rboot - - -# => SPIFFS -CONFIG_VARS += DISABLE_SPIFFS SPIFF_BIN_OUT -DISABLE_SPIFFS ?= 0 -SPIFF_BIN_OUT ?= spiff_rom -SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin -EXTRA_INCDIR += $(ARCH_COMPONENTS)/spiffs $(COMPONENTS)/spiffs/src -CFLAGS += -DRBOOT_SPIFFS_0=$(RBOOT_SPIFFS_0) -CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) -CUSTOM_TARGETS += $(SPIFF_BIN_OUT) - -# => LWIP -CONFIG_VARS += ENABLE_CUSTOM_LWIP LIBLWIP -ENABLE_CUSTOM_LWIP ?= 1 -ifeq ($(ENABLE_CUSTOM_LWIP), 0) - LIBLWIP := lwip - LWIP_BASE := $(ARCH_COMPONENTS)/esp-lwip - EXTRA_INCDIR += $(LWIP_BASE)/include $(LWIP_BASE) -else ifeq ($(ENABLE_CUSTOM_LWIP), 1) - LIBLWIP := lwip_open - LWIP_BASE := $(ARCH_COMPONENTS)/esp-open-lwip/esp-open-lwip - EXTRA_INCDIR += $(LWIP_BASE)/include - ifeq ($(ENABLE_ESPCONN), 1) - LIBLWIP := lwip_full - endif -else ifeq ($(ENABLE_CUSTOM_LWIP), 2) - ifeq ($(ENABLE_ESPCONN), 1) - $(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) - endif - LIBLWIP := lwip2 - LWIP_BASE := $(ARCH_COMPONENTS)/lwip2/lwip2 - EXTRA_INCDIR += $(LWIP_BASE)/glue-esp/include-esp $(LWIP_BASE)/include -else - EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp-lwip/lwip/include -endif -LIBS += $(LIBLWIP) - -ifneq ($(ENABLE_CUSTOM_LWIP), 0) - LIBLWIP_DST := $(call UserLibPath,$(LIBLWIP)) - CUSTOM_TARGETS += $(LIBLWIP_DST) - -$(LIBLWIP_DST): - $(call MakeLibrary,$@,ENABLE_CUSTOM_LWIP=$(ENABLE_CUSTOM_LWIP) ENABLE_ESPCONN=$(ENABLE_ESPCONN)) -endif - -# => GDB -CONFIG_VARS += ENABLE_GDB -GDBSTUB_BASE := $(ARCH_COMPONENTS)/gdbstub -APPCODE += $(GDBSTUB_BASE)/appcode -EXTRA_INCDIR += $(GDBSTUB_BASE) -ifeq ($(ENABLE_GDB), 1) - APPCODE += $(GDBSTUB_BASE) - CUSTOM_TARGETS += gdb_symbols - -# Copy symbols required by GDB into build directory -.PHONY: gdb_symbols -gdb_symbols: $(BUILD_BASE)/bootrom.elf - -$(BUILD_BASE)/%.elf: - $(Q) cp $(ARCH_COMPONENTS)/gdbstub/symbols/$(notdir $@) $@ -endif - -# Full GDB command line -GDB := trap '' INT; $(GDB) -x $(ARCH_COMPONENTS)/gdbstub/gdbcmds -b $(COM_SPEED_SERIAL) -ex "target remote $(COM_PORT)" - - -# => WPS -CONFIG_VARS += ENABLE_WPS -ifeq ($(ENABLE_WPS),1) - CFLAGS += -DENABLE_WPS=1 - LIBS += wps -endif - -# => Custom heap -CONFIG_VARS += ENABLE_CUSTOM_HEAP -ENABLE_CUSTOM_HEAP ?= 0 -ifeq ($(ENABLE_CUSTOM_HEAP),1) - LIBMAIN := mainmm - LIBMAIN_SRC := $(call UserLibPath,$(LIBMAIN)) - CUSTOM_TARGETS += $(LIBMAIN_SRC) - -$(LIBMAIN_SRC): - $(call MakeLibrary,$@,ENABLE_CUSTOM_HEAP=1) -else - LIBMAIN := main - LIBMAIN_SRC := $(SDK_LIBDIR)/lib$(LIBMAIN).a -endif - -# libmain must be modified for rBoot big flash support (just one symbol gets weakened) -ifeq ($(RBOOT_BIG_FLASH),1) - LIBMAIN := main2 - CFLAGS += -DBOOT_BIG_FLASH - LIBMAIN_DST := $(BUILD_BASE)/lib$(LIBMAIN).a - CUSTOM_TARGETS += $(LIBMAIN_DST) - -$(LIBMAIN_DST): $(LIBMAIN_SRC) - @echo "OC $@" - $(Q) $(OBJCOPY) -W Cache_Read_Enable_New $^ $@ -endif - -LIBS += $(LIBMAIN) - - - -# SSL support using axTLS -CONFIG_VARS += ENABLE_SSL SSL_DEBUG -ifeq ($(ENABLE_SSL),1) - LIBAXTLS := axtls - LIBS += $(LIBAXTLS) - LIBAXTLS_DST := $(call UserLibPath,$(LIBAXTLS)) - AXTLS_BASE := $(ARCH_COMPONENTS)/axtls-8266/axtls-8266 - EXTRA_INCDIR += $(AXTLS_BASE)/.. $(AXTLS_BASE) $(AXTLS_BASE)/ssl $(AXTLS_BASE)/crypto - AXTLS_FLAGS := -DLWIP_RAW=1 -DENABLE_SSL=1 - ifeq ($(SSL_DEBUG),1) # - AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 - endif - - CUSTOM_TARGETS += $(LIBAXTLS_DST) include/ssl/private_key.h - CFLAGS += $(AXTLS_FLAGS) - -$(LIBAXTLS_DST): - $(call MakeLibrary,$@,ENABLE_SSL=1) - -include/ssl/private_key.h: - $(vecho) "Generating unique certificate and key. This may take some time" - $(Q) mkdir -p $(CURDIR)/include/ssl/ - AXDIR=$(CURDIR)/include/ssl/ $(ARCH_COMPONENTS)/axtls-8266/axtls-8266/tools/make_certs.sh -endif - - -# => PWM -CONFIG_VARS += ENABLE_CUSTOM_PWM -ENABLE_CUSTOM_PWM ?= 1 -ifeq ($(ENABLE_CUSTOM_PWM), 1) - LIBPWM := pwm_open - LIBPWM_DST := $(call UserLibPath,$(LIBPWM)) - CUSTOM_TARGETS += $(LIBPWM_DST) - -$(LIBPWM_DST): - $(call MakeLibrary,$@,ENABLE_CUSTOM_PWM=1) -else - LIBPWM := pwm -endif -LIBS += $(LIBPWM) - - -# -LIBS := microc microgcc hal phy pp net80211 wpa $(LIBSMING) crypto smartconfig $(EXTRA_LIBS) $(LIBS) +LIBS += \ + microc \ + microgcc \ + hal \ + phy \ + pp \ + net80211 \ + wpa \ + crypto \ + smartconfig \ + $(LIBMAIN) # linker flags used to generate the main object file -LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u custom_crash_callback \ - -Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local +LDFLAGS = -nostdlib \ + -u call_user_start \ + -u Cache_Read_Enable_New \ + -u custom_crash_callback \ + -Wl,-static \ + -Wl,--gc-sections \ + -Wl,-Map=$(basename $@).map \ + -Wl,-wrap,system_restart_local -include $(ARCH_BASE)/flash.mk -TARGET_OUT_0 := $(BUILD_BASE)/$(TARGET)_0.out -TARGET_OUT_1 := $(BUILD_BASE)/$(TARGET)_1.out - -############# -# -# Target definitions -# -############# +.PHONY: application +application: $(CUSTOM_TARGETS) $(FW_FILE_1) $(FW_FILE_2) -include $(SMING_HOME)/modules.mk +LIBDIRS += $(SDK_LIBDIR) -# Add APPCODE objects and targets -$(call ScanModules,$(APPCODE)) - -.PHONY: app -app: $(CUSTOM_TARGETS) $(RBOOT_ROM_0) $(RBOOT_ROM_1) $(FW_FILE_1) $(FW_FILE_2) - -# => Firmware images -$(RBOOT_ROM_0): $(TARGET_OUT_0) - $(vecho) "E2 $@" - $(Q) $(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $< $@ $(RBOOT_E2_SECTS) - -$(RBOOT_ROM_1): $(TARGET_OUT_1) - $(vecho) "E2 $@" - $(Q) $(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $< $@ $(RBOOT_E2_SECTS) +# $1 -> Linker script +define LinkTarget + $(info $(notdir $(PROJECT_DIR)): Linking $@) + $(Q) $(LD) $(addprefix -L,$(LIBDIRS)) -T$1 $(LDFLAGS) -Wl,--start-group $(COMPONENTS_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@ +endef -$(TARGET_OUT_0): $(APP_AR) - $(vecho) "LD $@" - $(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(ARCH_BASE)/Compiler/ld \ - -T$(RBOOT_LD_0) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@ +$(TARGET_OUT_0): $(COMPONENTS_AR) + $(call LinkTarget,$(RBOOT_LD_0)) $(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW) @@ -320,117 +61,51 @@ $(TARGET_OUT_0): $(APP_AR) fi -$(TARGET_OUT_1): $(APP_AR) - $(vecho) "LD $@" - $(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(ARCH_BASE)/Compiler/ld \ - -T$(RBOOT_LD_1) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@ - -# recreate it from 0, since you get into problems with same filenames -$(APP_AR): $(OBJ) - $(vecho) "AR $@" - $(Q) test ! -f $@ || rm $@ - $(Q) $(AR) rcsP $@ $^ +$(TARGET_OUT_1): $(COMPONENTS_AR) + $(call LinkTarget,$(RBOOT_LD_1)) -.PHONY: libsming -libsming: $(LIBSMING_DST) ##Build the Sming framework and user libraries -$(LIBSMING_DST): - $(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time" - $(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) - $(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) -.PHONY: rebuild -rebuild: clean all ##Re-build your application - - -.PHONY: checkdirs -checkdirs: | $(BUILD_DIR) $(FW_BASE) - -$(BUILD_DIR) $(FW_BASE): - $(Q) mkdir -p $@ - -.PHONY: spiff_update -spiff_update: spiff_clean $(SPIFF_BIN_OUT) ##Rebuild the SPIFFS filesystem image - -##@Cleaning - -.PHONY: spiff_clean -spiff_clean: ##Remove SPIFFS image file - $(vecho) "Cleaning $(SPIFF_BIN_OUT)" - $(Q) rm -rf $(SPIFF_BIN_OUT) +##@Flashing -# Generating spiffs_bin -$(SPIFF_BIN_OUT): -ifeq ($(DISABLE_SPIFFS), 1) - $(vecho) "(!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs." -else - $(vecho) "Checking for spiffs files" - $(Q) if [ -d "$(SPIFF_FILES)" ]; then \ - echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) $(SPIFF_FILES) $(SPIFF_BIN_OUT); \ - else \ - echo "No files found in ./$(SPIFF_FILES)."; \ - echo "Creating empty $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) dummy.dir $(SPIFF_BIN_OUT); \ - fi +# If enabled, add the SPIFFS image to the chunks to write +ifneq ($(DISABLE_SPIFFS), 1) +FLASH_SPIFFS_CHUNKS := $(RBOOT_SPIFFS_0)=$(SPIFF_BIN_OUT) +FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0)=$(ARCH_BASE)/Compiler/data/blankfs.bin endif - -##@Flashing - .PHONY: flashboot -flashboot: libsming $(RBOOT_BIN) ##Write just the rBoot boot sector - $(WRITE_FLASH) 0x00000 $(RBOOT_BIN) +flashboot: $(RBOOT_BIN) ##Write just the rBoot boot sector + $(call WriteFlash,$(FLASH_RBOOT_BOOT_CHUNKS)) .PHONY: flashconfig flashconfig: kill_term ##Erase the rBoot config sector - $(vecho) "Erasing rBoot config sector" - $(WRITE_FLASH) 0x01000 $(SDK_BASE)/bin/blank.bin + $(info Erasing rBoot config sector) + $(call WriteFlash,$(FLASH_RBOOT_ERASE_CONFIG_CHUNKS)) .PHONY: flashapp flashapp: all kill_term ##Write just the application image - $(WRITE_FLASH) $(ROM_0_ADDR) $(RBOOT_ROM_0) + $(call WriteFlash,$(FLASH_RBOOT_APP_CHUNKS)) .PHONY: flashfs -flashfs: libsming $(SPIFF_BIN_OUT) ##Write just the SPIFFS filesystem image +flashfs: $(SPIFF_BIN_OUT) ##Write just the SPIFFS filesystem image ifeq ($(DISABLE_SPIFFS), 1) - $(vecho) "SPIFFS are not enabled!" + $(info SPIFFS image creation disabled!) else - $(WRITE_FLASH) $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) -endif - -# flashes rboot and first rom -FLASH_CHUNKS := 0x00000 $(RBOOT_BIN) -FLASH_CHUNKS += $(ROM_0_ADDR) $(RBOOT_ROM_0) -ifneq ($(DISABLE_SPIFFS), 1) - FLASH_CHUNKS += $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) + $(call WriteFlash,$(FLASH_SPIFFS_CHUNKS)) endif .PHONY: flash flash: all kill_term ##Write the rBoot boot sector, application image and (if enabled) SPIFFS image - $(WRITE_FLASH) $(FLASH_CHUNKS) + $(call WriteFlash,$(FLASH_RBOOT_CHUNKS) $(FLASH_RBOOT_APP_CHUNKS) $(FLASH_SPIFFS_CHUNKS)) ifeq ($(ENABLE_GDB), 1) - $(GDB) + $(GDB_CMDLINE) else $(TERMINAL) endif -# Wipe flash -FLASH_INIT_CHUNKS := $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin -FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin -ifneq ($(DISABLE_SPIFFS), 1) - FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0) $(ARCH_BASE)/Compiler/data/blankfs.bin -endif - .PHONY: flashinit flashinit: ##Erase your device's flash memory and reset system configuration area to defaults - $(vecho) "Flash init data default and blank data." - $(vecho) "DISABLE_SPIFFS = $(DISABLE_SPIFFS)" - $(ERASE_FLASH) - $(WRITE_FLASH) $(FLASH_INIT_CHUNKS) - -##@Cleaning - -.PHONY: clean -clean: ##Remove all generated build files - $(Q) rm -rf $(BUILD_BASE) - $(Q) rm -rf $(FW_BASE) + $(info Flash init data default and blank data) + $(info DISABLE_SPIFFS = $(DISABLE_SPIFFS)) + $(EraseFlash) + $(call WriteFlash,$(FLASH_INIT_CHUNKS)) diff --git a/Sming/Arch/Esp8266/build.mk b/Sming/Arch/Esp8266/build.mk index e4436d0bc3..0536c53f8f 100644 --- a/Sming/Arch/Esp8266/build.mk +++ b/Sming/Arch/Esp8266/build.mk @@ -4,23 +4,20 @@ # ############## -CFLAGS += -DARCH_ESP8266 -CXXFLAGS += -fno-rtti -fno-exceptions - -ifndef ESP_HOME -$(error ESP_HOME variable is not set to a valid directory.) -endif +CFLAGS += -DARCH_ESP8266 +CXXFLAGS += -fno-rtti -fno-exceptions ## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk +DEBUG_VARS += ESP_HOME -CONFIG_VARS += ESP_HOME -ESP_HOME := $(call FixPath,$(ESP_HOME)) -export ESP_HOME +ifeq ($(UNAME),Windows) +ESP_HOME ?= c:/Espressif +else ifeq ($(UNAME),FreeBSD) +ESP_HOME ?= /usr/local/esp8266/esp-open-sdk +else +ESP_HOME ?= /opt/esp-open-sdk +endif +export ESP_HOME := $(call FixPath,$(ESP_HOME)) XTENSA_TOOLS_ROOT := $(ESP_HOME)/xtensa-lx106-elf/bin export PATH := $(XTENSA_TOOLS_ROOT):$(PATH) @@ -28,43 +25,40 @@ CONFIG_TOOLPREFIX := xtensa-lx106-elf- TOOLSPEC := $(XTENSA_TOOLS_ROOT)/$(CONFIG_TOOLPREFIX) # select which tools to use as assembler, compiler, librarian and linker -AS := $(TOOLSPEC)gcc -CC := $(TOOLSPEC)gcc -CXX := $(TOOLSPEC)g++ -AR := $(TOOLSPEC)ar -LD := $(TOOLSPEC)gcc -OBJCOPY := $(TOOLSPEC)objcopy -OBJDUMP := $(TOOLSPEC)objdump -GDB := $(TOOLSPEC)gdb +AS := $(TOOLSPEC)gcc +CC := $(TOOLSPEC)gcc +CXX := $(TOOLSPEC)g++ +AR := $(TOOLSPEC)ar +LD := $(TOOLSPEC)gcc +OBJCOPY := $(TOOLSPEC)objcopy +OBJDUMP := $(TOOLSPEC)objdump +GDB := $(TOOLSPEC)gdb -CFLAGS_COMMON += -nostdlib -mlongcalls -mtext-section-literals -CFLAGS += -D__ets__ -DICACHE_FLASH -DUSE_OPTIMIZE_PRINTF -DESP8266=1 +CFLAGS_COMMON += \ + -nostdlib \ + -mlongcalls \ + -mtext-section-literals -CONFIG_VARS += MFORCE32 -MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32) -ifneq ($(MFORCE32),) - CFLAGS += -DMFORCE32 -mforce-l32 -endif +CFLAGS += \ + -D__ets__ \ + -DICACHE_FLASH \ + -DUSE_OPTIMIZE_PRINTF \ + -DESP8266 -# => 'Internal' SDK - for SDK Version 3+ as submodule in Sming repository -# SDK_BASE just needs to point into our repo as it's overridden with the correct submodule path -# This provides backward-compatiblity, so $(SMING)/third-party/ESP8266_NONOS_SDK) still works -CONFIG_VARS += SDK_BASE SDK_INTERNAL -SDK_BASE := $(call FixPath,$(abspath $(SDK_BASE))) -ifneq (,$(findstring $(SMING_HOME),$(SDK_BASE))) - SDK_COMPONENT := $(ARCH_COMPONENTS)/Sdk/ESP8266_NONOS_SDK - SDK_BASE := $(SMING_HOME)/$(SDK_COMPONENT) - CFLAGS += -DSDK_INTERNAL - SDK_INTERNAL = 1 -else - SDK_INTERNAL = 0 +ifeq (,$(wildcard $(XTENSA_TOOLS_ROOT))) +$(error ESP_HOME not set correctly: "$(ESP_HOME)") endif -# various paths from the SDK used in this project -SDK_LIBDIR := $(SDK_BASE)/lib -SDK_INCDIR := $(SDK_BASE)/include +# Both flash and peripheral memories must be accessed on 4-byte word boundaries, +# otherwise behaviour can be unpredictable or cause a memory exception. +# The -mforce-l32 compiler option generates code to deal with reads of +# mis-aligned memory accesses. It is not a standard feature of GNU compilers, +# however, and is not always available. +DEBUG_VARS += MFORCE32 +MFORCE32 := $(firstword $(shell $(CC) --help=target | grep mforce-l32)) +ifneq ($(MFORCE32),) + CFLAGS += -DMFORCE32 -mforce-l32 +endif # => Tools -ESPTOOL2 = $(ARCH_TOOLS)/esptool2/esptool2$(TOOL_EXT) -SPIFFY = $(ARCH_TOOLS)/spiffy/spiffy$(TOOL_EXT) MEMANALYZER = python $(ARCH_TOOLS)/memanalyzer.py $(OBJDUMP)$(TOOL_EXT) diff --git a/Sming/Arch/Esp8266/flash.mk b/Sming/Arch/Esp8266/flash.mk deleted file mode 100644 index 7bab109c0b..0000000000 --- a/Sming/Arch/Esp8266/flash.mk +++ /dev/null @@ -1,57 +0,0 @@ -## Flash parameters - -# SPI_SPEED = 40, 26, 20, 80 -SPI_SPEED ?= 40 -# SPI_MODE: qio, qout, dio, dout -SPI_MODE ?= qio -# SPI_SIZE: 512K, 256K, 1M, 2M, 4M -SPI_SIZE ?= 512K - -ifeq ($(SPI_SPEED), 26) - flashimageoptions := -ff 26m -else ifeq ($(SPI_SPEED), 20) - flashimageoptions := -ff 20m -else ifeq ($(SPI_SPEED), 80) - flashimageoptions := -ff 80m -else - flashimageoptions := -ff 40m -endif - -ifeq ($(SPI_MODE), qout) - flashimageoptions += -fm qout -else ifeq ($(SPI_MODE), dio) - flashimageoptions += -fm dio -else ifeq ($(SPI_MODE), dout) - flashimageoptions += -fm dout -else - flashimageoptions += -fm qio -endif - -ifeq ($(SPI_SIZE), 256K) - flashimageoptions += -fs 2m - SPIFF_SIZE ?= 131072 #128K -else ifeq ($(SPI_SIZE), 1M) - flashimageoptions += -fs 8m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR := 0x0fc000 - BLANK_BIN_ADDR := 0x0fe000 -else ifeq ($(SPI_SIZE), 2M) - flashimageoptions += -fs 16m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR := 0x1fc000 - BLANK_BIN_ADDR := 0x1fe000 -else ifeq ($(SPI_SIZE), 4M) - flashimageoptions += -fs 32m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR := 0x3fc000 - BLANK_BIN_ADDR := 0x3fe000 -else - flashimageoptions += -fs 4m - SPIFF_SIZE ?= 196608 #192K -endif - -CFLAGS += -DSPIFF_SIZE=$(SPIFF_SIZE) - -ESPTOOL := $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) -WRITE_FLASH := $(ESPTOOL) write_flash $(flashimageoptions) -ERASE_FLASH := $(ESPTOOL) erase_flash diff --git a/Sming/Arch/Esp8266/sming.mk b/Sming/Arch/Esp8266/sming.mk deleted file mode 100644 index 294b4c1cc3..0000000000 --- a/Sming/Arch/Esp8266/sming.mk +++ /dev/null @@ -1,194 +0,0 @@ -# ESP8266 Sming framework - -# => SDK -ifeq ($(SDK_INTERNAL), 1) - SUBMODULES += $(SDK_COMPONENT) - CUSTOM_TARGETS += $(SDK_COMPONENT)/bin/esp_init_data_default.bin - -$(SDK_COMPONENT)/bin/esp_init_data_default.bin: - $(Q) cp -f $(dir $@)esp_init_data_default_v08.bin $@ -endif - -MODULES += $(ARCH_COMPONENTS)/esp8266 -EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp8266/include $(SDK_INCDIR) - -MODULES += $(ARCH_COMPONENTS)/spi_flash -EXTRA_INCDIR += $(ARCH_COMPONENTS)/spi_flash/include - -MODULES += $(ARCH_COMPONENTS)/driver -EXTRA_INCDIR += $(ARCH_COMPONENTS)/driver/include - -MODULES += $(ARCH_COMPONENTS)/esp_wifi -EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp_wifi/include - -MODULES += $(ARCH_COMPONENTS)/fatfs - -# => rboot -RBOOT_BASE := $(ARCH_COMPONENTS)/rboot/rboot -SUBMODULES += $(RBOOT_BASE) -EXTRA_INCDIR += $(RBOOT_BASE) $(RBOOT_BASE)/appcode - -# => SPIFFS -SPIFFS_SMING := $(ARCH_COMPONENTS)/spiffs -SPIFFS_BASE := $(COMPONENTS)/spiffs -SUBMODULES += $(SPIFFS_BASE) -MODULES += $(SPIFFS_SMING) $(SPIFFS_BASE)/src -EXTRA_INCDIR += $(SPIFFS_SMING) $(SPIFFS_BASE)/src - - -# => ESP8266_new_pwm -CONFIG_VARS += ENABLE_CUSTOM_PWM -ENABLE_CUSTOM_PWM ?= 1 -ifeq ($(ENABLE_CUSTOM_PWM), 1) - PWM_BASE := $(ARCH_COMPONENTS)/pwm/new-pwm - SUBMODULES += $(PWM_BASE) - CFLAGS += -DSDK_PWM_PERIOD_COMPAT_MODE=1 - LIBPWM := pwm_open - LIBS += $(LIBPWM) - CLEAN += pwm-clean - -$(call UserLibPath,$(LIBPWM)): | $(PWM_BASE)/.submodule - $(Q) $(CC) $(INCDIR) $(CFLAGS) -c $(PWM_BASE)/pwm.c -o $(PWM_BASE)/pwm.o - $(Q) $(AR) rcs $@ $(PWM_BASE)/pwm.o - -.PHONY: pwm-clean -pwm-clean: - -$(Q) rm -f $(PWM_BASE)/*.o -endif - - -# => umm_malloc (custom heap allocation) -CONFIG_VARS += ENABLE_CUSTOM_HEAP -ENABLE_CUSTOM_HEAP ?= 0 -ifeq ($(ENABLE_CUSTOM_HEAP), 1) - CUSTOM_HEAP_BASE := $(ARCH_COMPONENTS)/custom_heap - UMM_MALLOC_BASE := $(CUSTOM_HEAP_BASE)/umm_malloc - SUBMODULES += $(UMM_MALLOC_BASE) - MODULES += $(CUSTOM_HEAP_BASE) $(UMM_MALLOC_BASE)/src - EXTRA_INCDIR += $(UMM_MALLOC_BASE)/src $(UMM_MALLOC_BASE)/includes/c-helper-macros - LIBMAINMM := mainmm - LIBS += $(LIBMAINMM) - -# Make copy of libmain and remove mem_manager.o module -$(call UserLibPath,$(LIBMAINMM)): $(SDK_LIBDIR)/libmain.a | $(UMM_MALLOC_BASE)/.submodule - $(vecho) "Enabling custom heap implementation" - $(Q) cp $^ $@ - $(Q) $(AR) -d $@ mem_manager.o -endif - - -# => Open Source LWIP -CONFIG_VARS += ENABLE_CUSTOM_LWIP ENABLE_LWIP_DEBUG ENABLE_ESPCONN -ENABLE_CUSTOM_LWIP ?= 1 -ENABLE_ESPCONN ?= 0 -ifeq ($(ENABLE_CUSTOM_LWIP), 0) - LIBLWIP := lwip - LWIP_BASE := $(ARCH_COMPONENTS)/esp-lwip - EXTRA_INCDIR += $(LWIP_BASE)/include $(LWIP_BASE) -else - EXTRA_CFLAGS_LWIP := -I$(SMING_HOME)/System/include -I$(ARCH_SYS)/include -I$(ARCH_COMPONENTS)/esp8266/include -I$(SMING_HOME)/Wiring - ENABLE_LWIPDEBUG ?= 0 - ifeq ($(ENABLE_LWIPDEBUG), 1) - EXTRA_CFLAGS_LWIP += -DLWIP_DEBUG - endif - - ifeq ($(ENABLE_CUSTOM_LWIP), 1) - LWIP_BASE := $(ARCH_COMPONENTS)/esp-open-lwip/esp-open-lwip - SUBMODULES += $(LWIP_BASE) - EXTRA_INCDIR += $(LWIP_BASE)/include - ifeq ($(ENABLE_ESPCONN), 1) - LIBLWIP := lwip_full - else - LIBLWIP := lwip_open - endif - LWIP_BUILD = $(MAKE) -C $(LWIP_BASE) -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE=$(SDK_BASE) \ - USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP) $(CFLAGS_COMMON)" - else ifeq ($(ENABLE_CUSTOM_LWIP), 2) - ifeq ($(ENABLE_ESPCONN), 1) - $(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) - endif - LWIP_BASE := $(ARCH_COMPONENTS)/lwip2/lwip2 - SUBMODULES += $(LWIP_BASE) - EXTRA_INCDIR += $(LWIP_BASE)/glue-esp/include-esp $(LWIP_BASE)/include - LIBLWIP ?= lwip2 - LWIP_BUILD := $(MAKE) -C $(LWIP_BASE) -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) \ - SDK_BASE=$(SDK_BASE) SDK_INTERNAL=$(SDK_INTERNAL) \ - USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" - endif - LIBS += $(LIBLWIP) - CLEAN += lwip-clean - -$(call UserLibPath,lwip%): | $(LWIP_BASE)/.submodule - $(vecho) "Building $(notdir $@)..." - $(Q) $(LWIP_BUILD) CC=$(CC) AR=$(AR) all - -.PHONY: lwip-clean -lwip-clean: - -$(Q) -$(LWIP_BUILD) clean - -endif - -# => SSL support using axTLS -CONFIG_VARS += ENABLE_SSL SSL_DEBUG -ENABLE_SSL ?= 0 -ifeq ($(ENABLE_SSL),1) - AXTLS_BASE := $(ARCH_COMPONENTS)/axtls-8266/axtls-8266 - SUBMODULES += $(AXTLS_BASE) - LIBAXTLS := axtls - LIBS += $(LIBAXTLS) - MODULES += $(AXTLS_BASE)/compat $(AXTLS_BASE)/replacements - EXTRA_INCDIR += $(AXTLS_BASE)/.. $(AXTLS_BASE) $(AXTLS_BASE)/ssl $(AXTLS_BASE)/crypto - AXTLS_FLAGS = -DLWIP_RAW=1 -DENABLE_SSL=1 - ifeq ($(SSL_DEBUG),1) # - AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 -DAXL_DEBUG=1 - endif - CLEAN += axtls-clean - CFLAGS += $(AXTLS_FLAGS) - AXTLS_BUILD := $(MAKE) -C $(AXTLS_BASE) -e V=$(V) BIN_DIR="$(SMING_HOME)/$(USER_LIBDIR)" - -$(call UserLibPath,$(LIBAXTLS)): | $(AXTLS_BASE)/.submodule - $(Q) $(AXTLS_BUILD) all - -.PHONY: axtls-clean -axtls-clean: - -$(Q) $(AXTLS_BUILD) clean -endif - - -# Tools - -# -# $1 -> target -# $2 -> make directory -# $3 -> parameters -# -define make-tool - $(Q) mkdir -p $(BUILD_BASE)/$(2)/$(UNAME) - $(MAKE) --no-print-directory -C $2 TARGET=$(abspath $1) BUILD_DIR=$(abspath $(BUILD_BASE)/$(2)/$(UNAME)) V=$(V) $3 -endef - -# => spiffy -TOOLS += $(SPIFFY) -TOOLS_CLEAN += spiffy-clean - -SPIFFY_BASE := $(ARCH_TOOLS)/spiffy -$(SPIFFY): | $(COMPONENTS)/spiffs/.submodule - $(Q) $(call make-tool,$@,$(SPIFFY_BASE),SPIFFS_SMING=$(SMING_HOME)/$(SPIFFS_SMING) SPIFFS_BASE=$(SMING_HOME)/$(SPIFFS_BASE)) - -.PHONY: spiffy-clean -spiffy-clean: - -$(Q) -$(call make-tool,$(SPIFFY),$(SPIFFY_BASE),clean) - -# => esptool2 -TOOLS += $(ESPTOOL2) -TOOLS_CLEAN += esptool2-clean - -ESPTOOL2_BASE := $(ARCH_TOOLS)/esptool2 -SUBMODULES += $(ESPTOOL2_BASE) -$(ESPTOOL2): | $(ESPTOOL2_BASE)/.submodule - $(Q) $(call make-tool,$@,$(ESPTOOL2_BASE)) - -.PHONY: esptool2-clean -esptool2-clean: - -$(Q) -$(call make-tool,$(ESPTOOL2),$(ESPTOOL2_BASE),clean) - diff --git a/Sming/Arch/Host/Components/driver/component.mk b/Sming/Arch/Host/Components/driver/component.mk new file mode 100644 index 0000000000..e039beeab7 --- /dev/null +++ b/Sming/Arch/Host/Components/driver/component.mk @@ -0,0 +1,18 @@ +COMPONENT_SRCFILES := $(ESP8266_COMPONENTS)/driver/SerialBuffer.cpp +COMPONENT_INCDIRS += $(ESP8266_COMPONENTS)/driver $(ESP8266_COMPONENTS)/driver/include + +##@Tools + +DEBUG_VARS ?= UARTID +UARTID ?= 0 + +TELNET_CMDLINE = telnet localhost $$((10000 + $(UARTID))) + +.PHONY: telnet +telnet: ##Run telnet to connect to a virtual serial port, specified by UARTID +ifeq ($(UNAME),Windows) + start $(TELNET_CMDLINE) +else + $(TELNET_CMDLINE) & +endif + diff --git a/Sming/Arch/Host/Components/driver/uart.cpp b/Sming/Arch/Host/Components/driver/uart.cpp index 7e68f53613..9a215b3565 100644 --- a/Sming/Arch/Host/Components/driver/uart.cpp +++ b/Sming/Arch/Host/Components/driver/uart.cpp @@ -25,7 +25,7 @@ */ #include -#include +#include #include #include diff --git a/Sming/Arch/Host/Components/hostlib/uart_server.cpp b/Sming/Arch/Host/Components/driver/uart_server.cpp similarity index 87% rename from Sming/Arch/Host/Components/hostlib/uart_server.cpp rename to Sming/Arch/Host/Components/driver/uart_server.cpp index 2684971e77..7a4f95fcf6 100644 --- a/Sming/Arch/Host/Components/hostlib/uart_server.cpp +++ b/Sming/Arch/Host/Components/driver/uart_server.cpp @@ -20,7 +20,7 @@ #include "uart_server.h" #include -#include +#include #include const unsigned IDLE_SLEEP_MS = 100; @@ -29,6 +29,22 @@ unsigned CUartServer::portBase = 10000; static CUartServer* uartServers[UART_COUNT]; +// Redirect the main serial port to console output +static void redirectToConsole() +{ + auto onNotify = [](uart_t* uart, uart_notify_code_t code) { + if(code == UART_NOTIFY_AFTER_WRITE){ + size_t avail; + void* data; + while((avail = uart->tx_buffer->getReadData(data)) != 0) { + host_nputs(static_cast(data), avail); + uart->tx_buffer->skipRead(avail); + } + } + }; + uart_set_notify(UART0, onNotify); +} + void CUartServer::startup(const UartServerConfig& config) { if(config.portBase != 0) { @@ -53,6 +69,11 @@ void CUartServer::startup(const UartServerConfig& config) server = new CUartServer(i); server->execute(); } + + // If no ports have been enabled then redirect port 0 output to host console + if(config.enableMask == 0) { + redirectToConsole(); + } } void CUartServer::shutdown() diff --git a/Sming/Arch/Host/Components/hostlib/uart_server.h b/Sming/Arch/Host/Components/driver/uart_server.h similarity index 97% rename from Sming/Arch/Host/Components/hostlib/uart_server.h rename to Sming/Arch/Host/Components/driver/uart_server.h index 328da9f256..ca812486e4 100644 --- a/Sming/Arch/Host/Components/hostlib/uart_server.h +++ b/Sming/Arch/Host/Components/driver/uart_server.h @@ -20,8 +20,8 @@ #pragma once #include -#include "sockets.h" -#include "threads.h" +#include +#include #define UART_SOCKET_PORT_BASE 10000 ///< Port for UART0 diff --git a/Sming/Arch/Host/Components/esp_hal/component.mk b/Sming/Arch/Host/Components/esp_hal/component.mk new file mode 100644 index 0000000000..8be549e01b --- /dev/null +++ b/Sming/Arch/Host/Components/esp_hal/component.mk @@ -0,0 +1 @@ +COMPONENT_INCDIRS += $(ESP8266_COMPONENTS)/esp8266/include diff --git a/Sming/Arch/Host/Components/esp_wifi/component.mk b/Sming/Arch/Host/Components/esp_wifi/component.mk new file mode 100644 index 0000000000..bc24366412 --- /dev/null +++ b/Sming/Arch/Host/Components/esp_wifi/component.mk @@ -0,0 +1,5 @@ +COMPONENT_VARS := ENABLE_WPS +ifeq ($(ENABLE_WPS),1) + GLOBAL_CFLAGS += -DENABLE_WPS=1 + EXTRA_LIBS := wps +endif diff --git a/Sming/Arch/Host/Components/gdbstub/component.mk b/Sming/Arch/Host/Components/gdbstub/component.mk new file mode 100644 index 0000000000..2db5b9ac6c --- /dev/null +++ b/Sming/Arch/Host/Components/gdbstub/component.mk @@ -0,0 +1,3 @@ +# Full GDB command line +GDBSTUB_DIR := $(COMPONENT_PATH) +GDB_CMDLINE = trap '' INT; $(GDB) -x $(GDBSTUB_DIR)/gdbcmds --args $(TARGET_OUT_0) $(SMING_TARGET_OPTIONS) diff --git a/Sming/Arch/Host/Components/hostlib/component.mk b/Sming/Arch/Host/Components/hostlib/component.mk new file mode 100644 index 0000000000..d47686c5b0 --- /dev/null +++ b/Sming/Arch/Host/Components/hostlib/component.mk @@ -0,0 +1,5 @@ +EXTRA_LIBS := pthread + +ifeq ($(UNAME),Windows) + EXTRA_LIBS += wsock32 +endif diff --git a/Sming/Arch/Host/Components/hostlib/hostmsg.c b/Sming/Arch/Host/Components/hostlib/hostmsg.c index 9180e8d090..1ffe3f2d75 100644 --- a/Sming/Arch/Host/Components/hostlib/hostmsg.c +++ b/Sming/Arch/Host/Components/hostlib/hostmsg.c @@ -66,6 +66,11 @@ void host_printfp(const char* fmt, const char* pretty_function, ...) host_puts(buffer); } +size_t host_nputs(const char* str, size_t length) +{ + return fwrite(str, 1, length, stderr); +} + void host_puts(const char* str) { fputs(str, stderr); diff --git a/Sming/Arch/Host/Components/hostlib/hostmsg.h b/Sming/Arch/Host/Components/hostlib/hostmsg.h index 25366b9699..1fd6537dc4 100644 --- a/Sming/Arch/Host/Components/hostlib/hostmsg.h +++ b/Sming/Arch/Host/Components/hostlib/hostmsg.h @@ -19,12 +19,15 @@ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif void host_printf(const char* fmt, ...); void host_printfp(const char* fmt, const char* pretty_function, ...); +size_t host_nputs(const char* str, size_t length); void host_puts(const char* str); #ifdef __cplusplus diff --git a/Sming/Arch/Host/Components/hostlib/startup.cpp b/Sming/Arch/Host/Components/hostlib/startup.cpp index b382f1f503..cef78f22bc 100644 --- a/Sming/Arch/Host/Components/hostlib/startup.cpp +++ b/Sming/Arch/Host/Components/hostlib/startup.cpp @@ -23,8 +23,8 @@ #include "sockets.h" #include "except.h" #include "options.h" -#include "flashmem.h" -#include "uart_server.h" +#include +#include #include #include #include @@ -203,7 +203,8 @@ int main(int argc, char* argv[]) sockets_initialise(); CUartServer::startup(config.uart); - if(host_lwip_init(&config.lwip)) { + bool lwip_initialised = host_lwip_init(&config.lwip); + if(lwip_initialised) { host_wifi_lwip_init_complete(); } @@ -219,7 +220,9 @@ int main(int argc, char* argv[]) while(!done) { host_service_tasks(); host_service_timers(); - host_lwip_service(); + if(lwip_initialised) { + host_lwip_service(); + } system_soft_wdt_feed(); } diff --git a/Sming/Arch/Host/Components/lwip/Linux/CMakeLists.txt b/Sming/Arch/Host/Components/lwip/Linux/CMakeLists.txt index 58152d0579..98f0637927 100644 --- a/Sming/Arch/Host/Components/lwip/Linux/CMakeLists.txt +++ b/Sming/Arch/Host/Components/lwip/Linux/CMakeLists.txt @@ -36,7 +36,8 @@ add_library(lwip ) set_target_properties(lwip - PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${USER_LIBDIR}) + PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${USER_LIBDIR} PREFIX "clib-" OUTPUT_NAME "${LWIP_LIBNAME}" +) target_compile_options(lwip PRIVATE ${LWIP_COMPILER_FLAGS} -m32) target_compile_definitions(lwip PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS}) diff --git a/Sming/Arch/Host/Components/lwip/Windows/.gitignore b/Sming/Arch/Host/Components/lwip/Windows/.gitignore new file mode 100644 index 0000000000..7d1749e9de --- /dev/null +++ b/Sming/Arch/Host/Components/lwip/Windows/.gitignore @@ -0,0 +1,2 @@ +src +tmp diff --git a/Sming/Arch/Host/Components/lwip/Windows/CMakeLists.txt b/Sming/Arch/Host/Components/lwip/Windows/CMakeLists.txt index f3819e1f39..37e053b1b1 100644 --- a/Sming/Arch/Host/Components/lwip/Windows/CMakeLists.txt +++ b/Sming/Arch/Host/Components/lwip/Windows/CMakeLists.txt @@ -50,7 +50,7 @@ add_library(lwip add_dependencies(lwip npcap) set_target_properties(lwip - PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${USER_LIBDIR} + PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${USER_LIBDIR} PREFIX "clib-" OUTPUT_NAME "${LWIP_LIBNAME}" ) target_compile_options(lwip PRIVATE ${LWIP_COMPILER_FLAGS} -m32 -Wno-strict-aliasing) diff --git a/Sming/Arch/Host/Components/lwip/component.mk b/Sming/Arch/Host/Components/lwip/component.mk new file mode 100644 index 0000000000..317e198468 --- /dev/null +++ b/Sming/Arch/Host/Components/lwip/component.mk @@ -0,0 +1,35 @@ +# Uses cmake to build +CUSTOM_BUILD := 1 + +# => LWIP +ENABLE_CUSTOM_LWIP ?= 2 +ifneq ($(ENABLE_CUSTOM_LWIP), 2) +$(error Host only supports LWIP version 2) +endif + +COMPONENT_SUBMODULES := lwip +COMPONENT_INCDIRS := . lwip/src/include +COMPONENT_VARS += ENABLE_LWIPDEBUG +ENABLE_LWIPDEBUG ?= 0 +ifeq ($(ENABLE_LWIPDEBUG), 1) + CMAKE_OPTIONS := -DCMAKE_BUILD_TYPE=Debug +else + CMAKE_OPTIONS := -DCMAKE_BUILD_TYPE=Release +endif + +ifeq ($(SMING_RELEASE),1) + CMAKE_OPTIONS += -DLWIP_NOASSERT=1 +endif + +ifeq ($(UNAME),Windows) + COMPONENT_INCDIRS += lwip/contrib/ports/win32/include + CMAKE_OPTIONS += -G "MSYS Makefiles" +else + COMPONENT_INCDIRS += lwip/contrib/ports/unix/port/include +endif + +CMAKE_OPTIONS += -DLWIP_LIBNAME=$(COMPONENT_VARIANT) + +$(COMPONENT_RULE)$(COMPONENT_LIBPATH): + $(Q) $(CMAKE) -DUSER_LIBDIR=$(COMPONENT_LIBDIR) $(CMAKE_OPTIONS) $(COMPONENT_PATH)/$(UNAME) + $(Q) $(MAKE) diff --git a/Sming/Arch/Host/Components/sming-arch/component.mk b/Sming/Arch/Host/Components/sming-arch/component.mk new file mode 100644 index 0000000000..a2689b548c --- /dev/null +++ b/Sming/Arch/Host/Components/sming-arch/component.mk @@ -0,0 +1,38 @@ +# Some libraries won't build (and others won't work) on the Host +# +# These are the libraries which won't build. We don't need to explicitly exclude them any +# more because only those libraries specified by ARDUINO_LIBRARIES are built for a project. +# +# This list is kept for reference purposes if it is desirable, for example, to build all +# the libraries for testing or CI purposes. However, a better way to achieve that is to ensure +# that all libraries are referenced by at least one sample or test application. +# +# EXCLUDE_LIBRARIES := Adafruit_ILI9341 Adafruit_NeoPixel Adafruit_PCD8544 Adafruit_SSD1306 \ +# ArduCAM CapacitiveSensor IR MCP23S17 RF24 SDCard TFT_ILI9163C WS2812 + +# Eventually this will go, but for now we use some Esp8266 code +ESP8266_COMPONENTS := $(SMING_HOME)/Arch/Esp8266/Components +export ESP8266_COMPONENTS + +COMPONENT_SRCDIRS := \ + $(ARCH_CORE) $(call ListAllSubDirs,$(ARCH_CORE)) \ + $(ARCH_SYS) \ + $(ARCH_BASE)/Platform + +COMPONENT_INCDIRS := \ + $(ARCH_BASE) \ + $(ARCH_CORE) \ + $(ARCH_SYS)/include \ + $(ARCH_COMPONENTS) + +COMPONENT_DEPENDS := \ + driver \ + esp_hal \ + esp_wifi \ + gdbstub \ + heap \ + hostlib \ + libc \ + lwip \ + spi_flash \ + vflash diff --git a/Sming/Arch/Host/Components/spi_flash/component.mk b/Sming/Arch/Host/Components/spi_flash/component.mk new file mode 100644 index 0000000000..510aaa7e76 --- /dev/null +++ b/Sming/Arch/Host/Components/spi_flash/component.mk @@ -0,0 +1 @@ +COMPONENT_INCDIRS += $(ESP8266_COMPONENTS)/spi_flash/include diff --git a/Sming/Arch/Host/Components/hostlib/flashmem.cpp b/Sming/Arch/Host/Components/spi_flash/flashmem.cpp similarity index 100% rename from Sming/Arch/Host/Components/hostlib/flashmem.cpp rename to Sming/Arch/Host/Components/spi_flash/flashmem.cpp diff --git a/Sming/Arch/Host/Components/hostlib/flashmem.h b/Sming/Arch/Host/Components/spi_flash/flashmem.h similarity index 97% rename from Sming/Arch/Host/Components/hostlib/flashmem.h rename to Sming/Arch/Host/Components/spi_flash/flashmem.h index 7027d64337..5021c6d9c4 100644 --- a/Sming/Arch/Host/Components/hostlib/flashmem.h +++ b/Sming/Arch/Host/Components/spi_flash/flashmem.h @@ -19,7 +19,7 @@ #pragma once -#include "hostlib.h" +#include struct FlashmemConfig { const char* filename; ///< Path to flash backing file diff --git a/Sming/Arch/Host/Components/vflash/component.mk b/Sming/Arch/Host/Components/vflash/component.mk new file mode 100644 index 0000000000..17233e4892 --- /dev/null +++ b/Sming/Arch/Host/Components/vflash/component.mk @@ -0,0 +1,40 @@ +COMPONENT_LIBNAME := + +# spiffs_get_storage_config() +COMPONENT_APPCODE := $(ESP8266_COMPONENTS)/rboot/appcode +RBOOT_SPIFFS_0 ?= 0x100000 +RBOOT_SPIFFS_1 ?= 0x300000 +APP_CFLAGS += -DRBOOT_SPIFFS_0=$(RBOOT_SPIFFS_0) +APP_CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) + +# Use DD to update FLASH_BIN, which represents the entire flash device contents + +DD := dd + +CACHE_VARS += FLASH_BIN +FLASH_BIN ?= $(FW_BASE)/flash.bin + +CONFIG_VARS += SPI_SIZE +SPI_SIZE ?= 4M + +# Write data to flash +# $1 -> Start offset +# $2 -> File containing data to write +define WriteFlashChunk + $(info WriteFlash $1 -> $2) + $(Q) if [ ! -f $(FLASH_BIN) ]; then \ + $(EraseFlash); \ + fi + $(Q) $(DD) if=$2 of=$(FLASH_BIN) obs=1 seek=$$(($1)) conv=notrunc +endef + +# Write one or more chunks to flash +# $1 -> List of `Offset=File` chunks +define WriteFlash + $(foreach c,$1,$(call WriteFlashChunk,$(word 1,$(subst =, ,$c)),$(word 2,$(subst =, ,$c)))) +endef + +# Reset/create flash backing file +define EraseFlash + $(DD) if=/dev/zero ibs=1 count=$(SPI_SIZE) | tr "\000" "\377" > $(FLASH_BIN) +endef diff --git a/Sming/Arch/Host/app.mk b/Sming/Arch/Host/app.mk index 16d33417f3..50acfeb336 100644 --- a/Sming/Arch/Host/app.mk +++ b/Sming/Arch/Host/app.mk @@ -4,192 +4,65 @@ # ### -##@Building - -.PHONY: all -all: libsming checkdirs app ##(default) Build application - -# -CONFIG_VARS += RBOOT_SPIFFS_0 RBOOT_SPIFFS_1 -RBOOT_SPIFFS_0 ?= 0x100000 -RBOOT_SPIFFS_1 ?= 0x300000 - -# Code compiled with application -APPCODE := - -# Where to look for libraries -LIBDIRS := $(USER_LIBDIR) $(BUILD_BASE) $(ARCH_BASE)/Compiler/ld - -# Eventually this will go, but for now we use some Esp8266 code -ESP8266_COMPONENTS := $(SMING_HOME)/Arch/Esp8266/Components - -EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp_hal/include $(ESP8266_COMPONENTS)/esp8266/include \ - $(ARCH_COMPONENTS)/driver/include $(ESP8266_COMPONENTS)/driver/include \ - $(ARCH_COMPONENTS)/spi_flash/include $(ESP8266_COMPONENTS)/spi_flash/include \ - $(ARCH_COMPONENTS)/libc/include \ - $(ARCH_COMPONENTS)/heap/include \ - $(ARCH_COMPONENTS)/esp_wifi/include - -# Macro to make an optional library -# $1 -> The library to make -# $2 -> List of options to add to make command line -define MakeLibrary - $(Q) $(MAKE) -C $(SMING_HOME) $(patsubst $(SMING_HOME)/%,%,$1) $2 -endef - -# => SPIFFS -CONFIG_VARS += DISABLE_SPIFFS SPIFF_BIN_OUT -DISABLE_SPIFFS ?= 0 -SPIFF_BIN_OUT ?= spiff_rom -SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin -EXTRA_INCDIR += $(ESP8266_COMPONENTS)/spiffs $(COMPONENTS)/spiffs/src -CFLAGS += -DRBOOT_SPIFFS_0=$(RBOOT_SPIFFS_0) -CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) -CFLAGS += -D__WORDSIZE=32 # spiffy_host.h -CUSTOM_TARGETS += $(SPIFF_BIN_OUT) -APPCODE += $(ESP8266_COMPONENTS)/rboot/appcode - -# => LWIP -LWIP_BASE := $(ARCH_COMPONENTS)/lwip -LIBS += lwip -EXTRA_INCDIR += $(LWIP_BASE) $(LWIP_BASE)/lwip/src/include -ifeq ($(UNAME),Windows) -EXTRA_INCDIR += $(LWIP_BASE)/lwip/contrib/ports/win32/include -else -EXTRA_INCDIR += $(LWIP_BASE)/lwip/contrib/ports/unix/port/include -endif - -# => WPS -CONFIG_VARS += ENABLE_WPS -ifeq ($(ENABLE_WPS),1) - CFLAGS += -DENABLE_WPS=1 - LIBS += wps -endif - -# -LIBS := $(LIBSMING) $(EXTRA_LIBS) $(LIBS) pthread - -ifeq ($(UNAME),Windows) -LIBS += wsock32 -endif - # linker flags used to generate the main object file -LDFLAGS = -m32 -Wl,--gc-sections -Wl,-Map=$(basename $@).map - -include $(ARCH_BASE)/flash.mk +LDFLAGS = \ + -m32 \ + -Wl,--gc-sections \ + -Wl,-Map=$(basename $@).map # Executable -TARGET_OUT_0 := $(FW_BASE)/$(TARGET)$(TOOL_EXT) +TARGET_OUT_0 := $(FW_BASE)/$(APP_NAME)$(TOOL_EXT) # Command-line options passed to executable -CONFIG_VARS += SMING_TARGET_OPTIONS -SMING_TARGET_OPTIONS ?= --flashfile=$(FLASH_BIN) --uart=0 --uart=1 --pause=5 -SMING_TARGET_OPTIONS += --flashsize=$(SPI_SIZE) - -# Full GDB command line -GDB := trap '' INT; $(GDB) -x $(ARCH_COMPONENTS)/gdbstub/gdbcmds --args $(TARGET_OUT_0) $(SMING_TARGET_OPTIONS) +CACHE_VARS += SMING_TARGET_OPTIONS +SMING_TARGET_OPTIONS ?= \ + --flashfile=$(FLASH_BIN) \ + --flashsize=$(SPI_SIZE) \ + --uart=0 \ + --uart=1 \ + --pause=5 -############# -# # Target definitions -# -############# - -include $(SMING_HOME)/modules.mk - -# Add APPCODE objects and targets -$(call ScanModules,$(APPCODE)) - -.PHONY: app -app: $(CUSTOM_TARGETS) $(TARGET_OUT_0) -$(TARGET_OUT_0): $(APP_AR) - $(vecho) "LD $@" - $(Q) $(LD) $(addprefix -L,$(LIBDIRS)) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@ +.PHONY: application +application: $(CUSTOM_TARGETS) $(TARGET_OUT_0) +$(TARGET_OUT_0): $(COMPONENTS_AR) + $(info $(notdir $(PROJECT_DIR)): Linking $@) + $(Q) $(LD) $(addprefix -L,$(LIBDIRS)) $(LDFLAGS) -Wl,--start-group $(COMPONENTS_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@ + $(Q) $(call WriteFirmwareConfigFile,$@) $(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW) - $(Q) cat $(FW_MEMINFO_NEW) -# recreate it from 0, since you get into problems with same filenames -$(APP_AR): $(OBJ) - $(vecho) "AR $@" - $(Q) test ! -f $@ || rm $@ - $(Q) $(AR) rcsP $@ $^ - -.PHONY: libsming -libsming: $(LIBSMING_DST) ##Build the Sming framework and user libraries -$(LIBSMING_DST): - $(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time" - $(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) - $(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) - -.PHONY: rebuild -rebuild: clean all ##Re-build your application - - -.PHONY: checkdirs -checkdirs: | $(BUILD_DIR) $(FW_BASE) -$(BUILD_DIR) $(FW_BASE): - $(Q) mkdir -p $@ - -.PHONY: spiff_update -spiff_update: spiff_clean $(SPIFF_BIN_OUT) ##Rebuild the SPIFFS filesystem image - -##@Cleaning - -.PHONY: spiff_clean -spiff_clean: ##Remove SPIFFS image file - $(vecho) "Cleaning $(SPIFF_BIN_OUT)" - $(Q) rm -rf $(SPIFF_BIN_OUT) +##@Flashing -# Generating spiffs_bin -$(SPIFF_BIN_OUT): -ifeq ($(DISABLE_SPIFFS), 1) - $(vecho) "(!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs." -else - $(vecho) "Checking for spiffs files" - $(Q) if [ -d "$(SPIFF_FILES)" ]; then \ - echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) $(SPIFF_FILES) $(SPIFF_BIN_OUT); \ - else \ - echo "No files found in ./$(SPIFF_FILES)."; \ - echo "Creating empty $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) dummy.dir $(SPIFF_BIN_OUT); \ - fi +ifneq ($(DISABLE_SPIFFS), 1) +FLASH_SPIFFS_CHUNKS := $(RBOOT_SPIFFS_0)=$(SPIFF_BIN_OUT) endif - -##@Flashing - .PHONY: run run: all ##Run the application image $(TARGET_OUT_0) $(SMING_TARGET_OPTIONS) - + .PHONY: flashfs -flashfs: libsming $(SPIFF_BIN_OUT) ##Write just the SPIFFS filesystem image +flashfs: $(SPIFF_BIN_OUT) ##Write just the SPIFFS filesystem image ifeq ($(DISABLE_SPIFFS), 1) - $(vecho) "SPIFFS are not enabled!" + $(info SPIFFS image creation disabled!) else - $(call WriteFlashChunk,$(RBOOT_SPIFFS_0),$(SPIFF_BIN_OUT)) + $(call WriteFlash,$(FLASH_SPIFFS_CHUNKS)) endif .PHONY: flash flash: all flashfs ##Write the SPIFFS filesystem image then run the application ifeq ($(ENABLE_GDB), 1) - $(GDB) + $(GDB_CMDLINE) else $(TARGET_OUT_0) $(SMING_TARGET_OPTIONS) endif .PHONY: flashinit -flashinit: ##Erase all flash memory - $(vecho) "Erase flash (creates default flash backing file)" - $(ERASE_FLASH) +flashinit: | $(FW_BASE) ##Erase all flash memory + $(info Erasing flash (writing default flash backing file)) + $(Q) $(EraseFlash) -# Remove build artifacts -.PHONY: clean -clean: - $(Q) rm -rf $(BUILD_BASE) - $(Q) rm -rf $(FW_BASE) diff --git a/Sming/Arch/Host/build.mk b/Sming/Arch/Host/build.mk index 88d76dfb58..f26005b9f2 100644 --- a/Sming/Arch/Host/build.mk +++ b/Sming/Arch/Host/build.mk @@ -4,30 +4,25 @@ # ############## -CFLAGS += -DARCH_HOST +CFLAGS += -DARCH_HOST -TOOLSPEC := +TOOLSPEC := -AS := $(TOOLSPEC)gcc -CC := $(TOOLSPEC)gcc -CXX := $(TOOLSPEC)g++ -AR := $(TOOLSPEC)ar -LD := $(TOOLSPEC)g++ -OBJCOPY := $(TOOLSPEC)objcopy -OBJDUMP := $(TOOLSPEC)objdump -GDB := $(TOOLSPEC)gdb +AS := $(TOOLSPEC)gcc +CC := $(TOOLSPEC)gcc +CXX := $(TOOLSPEC)g++ +AR := $(TOOLSPEC)ar +LD := $(TOOLSPEC)g++ +OBJCOPY := $(TOOLSPEC)objcopy +OBJDUMP := $(TOOLSPEC)objdump +GDB := $(TOOLSPEC)gdb -CFLAGS += -m32 -Wno-deprecated-declarations +CFLAGS += \ + -m32 \ + -Wno-deprecated-declarations # Keep Windows/Linux object files separate to avoid conflict -BUILD_BASE := $(BUILD_BASE)/$(UNAME) -USER_LIBDIR = $(ARCH_BASE)/Compiler/lib/$(UNAME) +OUT_BASE := out/$(SMING_ARCH)/$(UNAME)/$(if $(SMING_RELEASE),release,debug) # => Tools -SPIFFY = $(ARCH_BASE)/../Esp8266/Tools/spiffy/spiffy$(TOOL_EXT) -MEMANALYZER = size - -Terminal = start telnet localhost $$((10000 + $1)) - -TERMINAL = $(call Terminal,$(COM_PORT)) -KILL_TERM := +MEMANALYZER = size diff --git a/Sming/Arch/Host/flash.mk b/Sming/Arch/Host/flash.mk deleted file mode 100644 index ff08f7fd7e..0000000000 --- a/Sming/Arch/Host/flash.mk +++ /dev/null @@ -1,43 +0,0 @@ -# -# Flash parameters -# - -# SPI_SIZE: 512K, 256K, 1M, 2M, 4M -CONFIG_VARS += SPI_SPEED SPI_MODE SPI_SIZE SPIFF_SIZE -SPI_SIZE ?= 512K - -ifeq ($(SPI_SIZE), 256K) - SPIFF_SIZE ?= 131072 #128K -else ifeq ($(SPI_SIZE), 1M) - SPIFF_SIZE ?= 524288 #512K -else ifeq ($(SPI_SIZE), 2M) - SPIFF_SIZE ?= 524288 #512K -else ifeq ($(SPI_SIZE), 4M) - SPIFF_SIZE ?= 524288 #512K -else - SPIFF_SIZE ?= 196608 #192K -endif - -CFLAGS += -DSPIFF_SIZE=$(SPIFF_SIZE) - - -# Use DD to update $(FW_BASE)/flash.bin - -DD := dd - -CONFIG_VARS += FLASH_BIN -FLASH_BIN ?= $(FW_BASE)/flash.bin - -# Write data to flash -# $1 -> Start offset -# $2 -> File containing data to write -define WriteFlashChunk - $(info WriteFlash $1 -> $2) - $(Q) if [ ! -f $(FLASH_BIN) ]; then \ - $(ERASE_FLASH); \ - fi - $(Q) $(DD) if=$2 of=$(FLASH_BIN) obs=1 seek=$$(($1)) conv=notrunc -endef - -# -ERASE_FLASH := $(DD) if=/dev/zero ibs=1 count=$(SPI_SIZE) | tr "\000" "\377" > $(FLASH_BIN) diff --git a/Sming/Arch/Host/sming.mk b/Sming/Arch/Host/sming.mk deleted file mode 100644 index 662fc5363c..0000000000 --- a/Sming/Arch/Host/sming.mk +++ /dev/null @@ -1,94 +0,0 @@ -# Makefile to build Sming framework under Host (Win32/Linux) environment - -EXCLUDE_LIBRARIES := Adafruit_ILI9341 Adafruit_NeoPixel Adafruit_PCD8544 Adafruit_SSD1306 \ - ArduCAM CapacitiveSensor IR MCP23S17 RF24 SDCard TFT_ILI9163C WS2812 - -ESP8266_COMPONENTS := Arch/Esp8266/Components - -# -MODULES += $(ARCH_COMPONENTS)/esp_hal -EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp_hal/include $(ESP8266_COMPONENTS)/esp8266/include - -# -MODULES += $(ARCH_COMPONENTS)/driver -EXTRA_INCDIR += $(ARCH_COMPONENTS)/driver/include $(ESP8266_COMPONENTS)/driver/include - -# -MODULES += $(ARCH_COMPONENTS)/libc -MODULES += $(ARCH_COMPONENTS)/hostlib - -# -EXTRA_INCDIR += $(ARCH_COMPONENTS)/spi_flash/include $(ESP8266_COMPONENTS)/spi_flash/include - -# -MODULES += $(ARCH_COMPONENTS)/heap -EXTRA_INCDIR += $(ARCH_COMPONENTS)/heap/include - -# -MODULES += $(ARCH_COMPONENTS)/gdbstub - -# -MODULES += $(ARCH_COMPONENTS)/esp_wifi -EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp_wifi/include - -# => LWIP -ENABLE_CUSTOM_LWIP ?= 2 -ifeq ($(ENABLE_CUSTOM_LWIP), 2) - LWIP_BASE := $(ARCH_COMPONENTS)/lwip - SUBMODULES += $(LWIP_BASE)/lwip - EXTRA_INCDIR += $(LWIP_BASE) $(LWIP_BASE)/lwip/src/include - LIBLWIP := lwip - LIBS += $(LIBLWIP) - ENABLE_LWIPDEBUG ?= 0 - ifeq ($(ENABLE_LWIPDEBUG), 1) - CMAKE_OPTIONS := -DCMAKE_BUILD_TYPE=Debug - else - CMAKE_OPTIONS := -DCMAKE_BUILD_TYPE=Release - endif - LWIP_BUILD_DIR := $(BUILD_BASE)/$(LWIP_BASE) - - ifeq ($(UNAME),Windows) - EXTRA_INCDIR += $(LWIP_BASE)/lwip/contrib/ports/win32/include - CMAKE_OPTIONS += -G "MSYS Makefiles" - else - EXTRA_INCDIR += $(LWIP_BASE)/lwip/contrib/ports/unix/port/include - endif - - CLEAN += lwip-clean - -$(call UserLibPath,lwip): $(LWIP_BUILD_DIR)/Makefile - $(vecho) "Building $(notdir $@)..." - $(Q) $(MAKE) -C $(LWIP_BUILD_DIR) - -$(LWIP_BUILD_DIR)/Makefile: $(LWIP_BASE)/lwip/.submodule | $(LWIP_BUILD_DIR) - $(Q) cd $(LWIP_BUILD_DIR); \ - $(CMAKE) -DUSER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)" $(CMAKE_OPTIONS) $(SMING_HOME)/$(LWIP_BASE)/$(UNAME) - -$(LWIP_BUILD_DIR): - mkdir -p $@ - -.PHONY: lwip-clean -lwip-clean: - -$(Q) rm -rf $(LWIP_BUILD_DIR) -endif - -# -SPIFFS_SMING := $(ESP8266_COMPONENTS)/spiffs -SPIFFS_BASE := $(COMPONENTS)/spiffs -SUBMODULES += $(SPIFFS_BASE) -MODULES += $(SPIFFS_SMING) $(SPIFFS_BASE)/src -CFLAGS += -D__WORDSIZE=32 # spiffy_host.h -EXTRA_INCDIR += $(SPIFFS_SMING) $(SPIFFS_BASE)/src -TOOLS += $(SPIFFY) -TOOLS_CLEAN += tools-clean-esp8266 - -$(SPIFFY): - $(MAKE) SMING_ARCH=Esp8266 tools - -.PHONY: tools-clean-esp8266 -tools-clean-esp8266: - $(MAKE) SMING_ARCH=Esp8266 tools-clean - - -# Not all libraries will compile (yet) -SMING_LIBRARIES := ArduinoJson diff --git a/Sming/Components/.patches/http-parser.patch b/Sming/Components/.patches/http-parser.patch index c9634509bd..eace68cbe4 100644 --- a/Sming/Components/.patches/http-parser.patch +++ b/Sming/Components/.patches/http-parser.patch @@ -1,137 +1,11 @@ -diff --git a/bench.c b/bench.c -deleted file mode 100644 -index 678f555..0000000 ---- a/bench.c -+++ /dev/null -@@ -1,128 +0,0 @@ --/* Copyright Fedor Indutny. All rights reserved. -- * -- * Permission is hereby granted, free of charge, to any person obtaining a copy -- * of this software and associated documentation files (the "Software"), to -- * deal in the Software without restriction, including without limitation the -- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- * sell copies of the Software, and to permit persons to whom the Software is -- * furnished to do so, subject to the following conditions: -- * -- * The above copyright notice and this permission notice shall be included in -- * all copies or substantial portions of the Software. -- * -- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -- * IN THE SOFTWARE. -- */ --#include "http_parser.h" --#include --#include --#include --#include --#include -- --/* 8 gb */ --static const int64_t kBytes = 8LL << 30; -- --static const char data[] = -- "POST /joyent/http-parser HTTP/1.1\r\n" -- "Host: github.com\r\n" -- "DNT: 1\r\n" -- "Accept-Encoding: gzip, deflate, sdch\r\n" -- "Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4\r\n" -- "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) " -- "AppleWebKit/537.36 (KHTML, like Gecko) " -- "Chrome/39.0.2171.65 Safari/537.36\r\n" -- "Accept: text/html,application/xhtml+xml,application/xml;q=0.9," -- "image/webp,*/*;q=0.8\r\n" -- "Referer: https://github.com/joyent/http-parser\r\n" -- "Connection: keep-alive\r\n" -- "Transfer-Encoding: chunked\r\n" -- "Cache-Control: max-age=0\r\n\r\nb\r\nhello world\r\n0\r\n"; --static const size_t data_len = sizeof(data) - 1; -- --static int on_info(http_parser* p) { -- return 0; --} -- -- --static int on_data(http_parser* p, const char *at, size_t length) { -- return 0; --} -- --static http_parser_settings settings = { -- .on_message_begin = on_info, -- .on_headers_complete = on_info, -- .on_message_complete = on_info, -- .on_header_field = on_data, -- .on_header_value = on_data, -- .on_url = on_data, -- .on_status = on_data, -- .on_body = on_data --}; -- --int bench(int iter_count, int silent) { -- struct http_parser parser; -- int i; -- int err; -- struct timeval start; -- struct timeval end; -- -- if (!silent) { -- err = gettimeofday(&start, NULL); -- assert(err == 0); -- } -- -- fprintf(stderr, "req_len=%d\n", (int) data_len); -- for (i = 0; i < iter_count; i++) { -- size_t parsed; -- http_parser_init(&parser, HTTP_REQUEST); -- -- parsed = http_parser_execute(&parser, &settings, data, data_len); -- assert(parsed == data_len); -- } -- -- if (!silent) { -- double elapsed; -- double bw; -- double total; -- -- err = gettimeofday(&end, NULL); -- assert(err == 0); -- -- fprintf(stdout, "Benchmark result:\n"); -- -- elapsed = (double) (end.tv_sec - start.tv_sec) + -- (end.tv_usec - start.tv_usec) * 1e-6f; -- -- total = (double) iter_count * data_len; -- bw = (double) total / elapsed; -- -- fprintf(stdout, "%.2f mb | %.2f mb/s | %.2f req/sec | %.2f s\n", -- (double) total / (1024 * 1024), -- bw / (1024 * 1024), -- (double) iter_count / elapsed, -- elapsed); -- -- fflush(stdout); -- } -- -- return 0; --} -- --int main(int argc, char** argv) { -- int64_t iterations; -- -- iterations = kBytes / (int64_t) data_len; -- if (argc == 2 && strcmp(argv[1], "infinite") == 0) { -- for (;;) -- bench(iterations, 1); -- return 0; -- } else { -- return bench(iterations, 0); -- } --} +diff --git a/component.mk b/component.mk +new file mode 100644 +index 0000000..12f0ff7 +--- /dev/null ++++ b/component.mk +@@ -0,0 +1,2 @@ ++COMPONENT_SRCDIRS := ++COMPONENT_SRCFILES := http_parser.c diff --git a/http_parser.c b/http_parser.c index 5b5657b..b523e35 100644 --- a/http_parser.c @@ -259,4465 +133,3 @@ index 5b5657b..b523e35 100644 static enum http_host_state http_parse_host_char(enum http_host_state s, const char ch) { switch(s) { -diff --git a/test.c b/test.c -deleted file mode 100644 -index bc4e664..0000000 ---- a/test.c -+++ /dev/null -@@ -1,4456 +0,0 @@ --/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. -- * -- * Permission is hereby granted, free of charge, to any person obtaining a copy -- * of this software and associated documentation files (the "Software"), to -- * deal in the Software without restriction, including without limitation the -- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- * sell copies of the Software, and to permit persons to whom the Software is -- * furnished to do so, subject to the following conditions: -- * -- * The above copyright notice and this permission notice shall be included in -- * all copies or substantial portions of the Software. -- * -- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -- * IN THE SOFTWARE. -- */ --#include "http_parser.h" --#include --#include --#include --#include /* rand */ --#include --#include -- --#if defined(__APPLE__) --# undef strlcat --# undef strlncpy --# undef strlcpy --#endif /* defined(__APPLE__) */ -- --#undef TRUE --#define TRUE 1 --#undef FALSE --#define FALSE 0 -- --#define MAX_HEADERS 13 --#define MAX_ELEMENT_SIZE 2048 --#define MAX_CHUNKS 16 -- --#define MIN(a,b) ((a) < (b) ? (a) : (b)) -- --static http_parser *parser; -- --struct message { -- const char *name; // for debugging purposes -- const char *raw; -- enum http_parser_type type; -- enum http_method method; -- int status_code; -- char response_status[MAX_ELEMENT_SIZE]; -- char request_path[MAX_ELEMENT_SIZE]; -- char request_url[MAX_ELEMENT_SIZE]; -- char fragment[MAX_ELEMENT_SIZE]; -- char query_string[MAX_ELEMENT_SIZE]; -- char body[MAX_ELEMENT_SIZE]; -- size_t body_size; -- const char *host; -- const char *userinfo; -- uint16_t port; -- int num_headers; -- enum { NONE=0, FIELD, VALUE } last_header_element; -- char headers [MAX_HEADERS][2][MAX_ELEMENT_SIZE]; -- int should_keep_alive; -- -- int num_chunks; -- int num_chunks_complete; -- int chunk_lengths[MAX_CHUNKS]; -- -- const char *upgrade; // upgraded body -- -- unsigned short http_major; -- unsigned short http_minor; -- -- int message_begin_cb_called; -- int headers_complete_cb_called; -- int message_complete_cb_called; -- int status_cb_called; -- int message_complete_on_eof; -- int body_is_final; --}; -- --static int currently_parsing_eof; -- --static struct message messages[5]; --static int num_messages; --static http_parser_settings *current_pause_parser; -- --/* * R E Q U E S T S * */ --const struct message requests[] = --#define CURL_GET 0 --{ {.name= "curl get" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /test HTTP/1.1\r\n" -- "User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\n" -- "Host: 0.0.0.0=5000\r\n" -- "Accept: */*\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/test" -- ,.request_url= "/test" -- ,.num_headers= 3 -- ,.headers= -- { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" } -- , { "Host", "0.0.0.0=5000" } -- , { "Accept", "*/*" } -- } -- ,.body= "" -- } -- --#define FIREFOX_GET 1 --, {.name= "firefox get" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /favicon.ico HTTP/1.1\r\n" -- "Host: 0.0.0.0=5000\r\n" -- "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\n" -- "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" -- "Accept-Language: en-us,en;q=0.5\r\n" -- "Accept-Encoding: gzip,deflate\r\n" -- "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" -- "Keep-Alive: 300\r\n" -- "Connection: keep-alive\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/favicon.ico" -- ,.request_url= "/favicon.ico" -- ,.num_headers= 8 -- ,.headers= -- { { "Host", "0.0.0.0=5000" } -- , { "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0" } -- , { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" } -- , { "Accept-Language", "en-us,en;q=0.5" } -- , { "Accept-Encoding", "gzip,deflate" } -- , { "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7" } -- , { "Keep-Alive", "300" } -- , { "Connection", "keep-alive" } -- } -- ,.body= "" -- } -- --#define DUMBFUCK 2 --, {.name= "dumbfuck" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /dumbfuck HTTP/1.1\r\n" -- "aaaaaaaaaaaaa:++++++++++\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/dumbfuck" -- ,.request_url= "/dumbfuck" -- ,.num_headers= 1 -- ,.headers= -- { { "aaaaaaaaaaaaa", "++++++++++" } -- } -- ,.body= "" -- } -- --#define FRAGMENT_IN_URI 3 --, {.name= "fragment in url" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "page=1" -- ,.fragment= "posts-17408" -- ,.request_path= "/forums/1/topics/2375" -- /* XXX request url does include fragment? */ -- ,.request_url= "/forums/1/topics/2375?page=1#posts-17408" -- ,.num_headers= 0 -- ,.body= "" -- } -- --#define GET_NO_HEADERS_NO_BODY 4 --, {.name= "get no headers no body" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /get_no_headers_no_body/world HTTP/1.1\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE /* would need Connection: close */ -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/get_no_headers_no_body/world" -- ,.request_url= "/get_no_headers_no_body/world" -- ,.num_headers= 0 -- ,.body= "" -- } -- --#define GET_ONE_HEADER_NO_BODY 5 --, {.name= "get one header no body" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /get_one_header_no_body HTTP/1.1\r\n" -- "Accept: */*\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE /* would need Connection: close */ -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/get_one_header_no_body" -- ,.request_url= "/get_one_header_no_body" -- ,.num_headers= 1 -- ,.headers= -- { { "Accept" , "*/*" } -- } -- ,.body= "" -- } -- --#define GET_FUNKY_CONTENT_LENGTH 6 --, {.name= "get funky content length body hello" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /get_funky_content_length_body_hello HTTP/1.0\r\n" -- "conTENT-Length: 5\r\n" -- "\r\n" -- "HELLO" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/get_funky_content_length_body_hello" -- ,.request_url= "/get_funky_content_length_body_hello" -- ,.num_headers= 1 -- ,.headers= -- { { "conTENT-Length" , "5" } -- } -- ,.body= "HELLO" -- } -- --#define POST_IDENTITY_BODY_WORLD 7 --, {.name= "post identity body world" -- ,.type= HTTP_REQUEST -- ,.raw= "POST /post_identity_body_world?q=search#hey HTTP/1.1\r\n" -- "Accept: */*\r\n" -- "Transfer-Encoding: identity\r\n" -- "Content-Length: 5\r\n" -- "\r\n" -- "World" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.query_string= "q=search" -- ,.fragment= "hey" -- ,.request_path= "/post_identity_body_world" -- ,.request_url= "/post_identity_body_world?q=search#hey" -- ,.num_headers= 3 -- ,.headers= -- { { "Accept", "*/*" } -- , { "Transfer-Encoding", "identity" } -- , { "Content-Length", "5" } -- } -- ,.body= "World" -- } -- --#define POST_CHUNKED_ALL_YOUR_BASE 8 --, {.name= "post - chunked body: all your base are belong to us" -- ,.type= HTTP_REQUEST -- ,.raw= "POST /post_chunked_all_your_base HTTP/1.1\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "1e\r\nall your base are belong to us\r\n" -- "0\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/post_chunked_all_your_base" -- ,.request_url= "/post_chunked_all_your_base" -- ,.num_headers= 1 -- ,.headers= -- { { "Transfer-Encoding" , "chunked" } -- } -- ,.body= "all your base are belong to us" -- ,.num_chunks_complete= 2 -- ,.chunk_lengths= { 0x1e } -- } -- --#define TWO_CHUNKS_MULT_ZERO_END 9 --, {.name= "two chunks ; triple zero ending" -- ,.type= HTTP_REQUEST -- ,.raw= "POST /two_chunks_mult_zero_end HTTP/1.1\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "5\r\nhello\r\n" -- "6\r\n world\r\n" -- "000\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/two_chunks_mult_zero_end" -- ,.request_url= "/two_chunks_mult_zero_end" -- ,.num_headers= 1 -- ,.headers= -- { { "Transfer-Encoding", "chunked" } -- } -- ,.body= "hello world" -- ,.num_chunks_complete= 3 -- ,.chunk_lengths= { 5, 6 } -- } -- --#define CHUNKED_W_TRAILING_HEADERS 10 --, {.name= "chunked with trailing headers. blech." -- ,.type= HTTP_REQUEST -- ,.raw= "POST /chunked_w_trailing_headers HTTP/1.1\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "5\r\nhello\r\n" -- "6\r\n world\r\n" -- "0\r\n" -- "Vary: *\r\n" -- "Content-Type: text/plain\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/chunked_w_trailing_headers" -- ,.request_url= "/chunked_w_trailing_headers" -- ,.num_headers= 3 -- ,.headers= -- { { "Transfer-Encoding", "chunked" } -- , { "Vary", "*" } -- , { "Content-Type", "text/plain" } -- } -- ,.body= "hello world" -- ,.num_chunks_complete= 3 -- ,.chunk_lengths= { 5, 6 } -- } -- --#define CHUNKED_W_BULLSHIT_AFTER_LENGTH 11 --, {.name= "with bullshit after the length" -- ,.type= HTTP_REQUEST -- ,.raw= "POST /chunked_w_bullshit_after_length HTTP/1.1\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "5; ihatew3;whatthefuck=aretheseparametersfor\r\nhello\r\n" -- "6; blahblah; blah\r\n world\r\n" -- "0\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/chunked_w_bullshit_after_length" -- ,.request_url= "/chunked_w_bullshit_after_length" -- ,.num_headers= 1 -- ,.headers= -- { { "Transfer-Encoding", "chunked" } -- } -- ,.body= "hello world" -- ,.num_chunks_complete= 3 -- ,.chunk_lengths= { 5, 6 } -- } -- --#define WITH_QUOTES 12 --, {.name= "with quotes" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "foo=\"bar\"" -- ,.fragment= "" -- ,.request_path= "/with_\"stupid\"_quotes" -- ,.request_url= "/with_\"stupid\"_quotes?foo=\"bar\"" -- ,.num_headers= 0 -- ,.headers= { } -- ,.body= "" -- } -- --#define APACHEBENCH_GET 13 --/* The server receiving this request SHOULD NOT wait for EOF -- * to know that content-length == 0. -- * How to represent this in a unit test? message_complete_on_eof -- * Compare with NO_CONTENT_LENGTH_RESPONSE. -- */ --, {.name = "apachebench get" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /test HTTP/1.0\r\n" -- "Host: 0.0.0.0:5000\r\n" -- "User-Agent: ApacheBench/2.3\r\n" -- "Accept: */*\r\n\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/test" -- ,.request_url= "/test" -- ,.num_headers= 3 -- ,.headers= { { "Host", "0.0.0.0:5000" } -- , { "User-Agent", "ApacheBench/2.3" } -- , { "Accept", "*/*" } -- } -- ,.body= "" -- } -- --#define QUERY_URL_WITH_QUESTION_MARK_GET 14 --/* Some clients include '?' characters in query strings. -- */ --, {.name = "query url with question mark" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "foo=bar?baz" -- ,.fragment= "" -- ,.request_path= "/test.cgi" -- ,.request_url= "/test.cgi?foo=bar?baz" -- ,.num_headers= 0 -- ,.headers= {} -- ,.body= "" -- } -- --#define PREFIX_NEWLINE_GET 15 --/* Some clients, especially after a POST in a keep-alive connection, -- * will send an extra CRLF before the next request -- */ --, {.name = "newline prefix get" -- ,.type= HTTP_REQUEST -- ,.raw= "\r\nGET /test HTTP/1.1\r\n\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/test" -- ,.request_url= "/test" -- ,.num_headers= 0 -- ,.headers= { } -- ,.body= "" -- } -- --#define UPGRADE_REQUEST 16 --, {.name = "upgrade request" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /demo HTTP/1.1\r\n" -- "Host: example.com\r\n" -- "Connection: Upgrade\r\n" -- "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" -- "Sec-WebSocket-Protocol: sample\r\n" -- "Upgrade: WebSocket\r\n" -- "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" -- "Origin: http://example.com\r\n" -- "\r\n" -- "Hot diggity dogg" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/demo" -- ,.request_url= "/demo" -- ,.num_headers= 7 -- ,.upgrade="Hot diggity dogg" -- ,.headers= { { "Host", "example.com" } -- , { "Connection", "Upgrade" } -- , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } -- , { "Sec-WebSocket-Protocol", "sample" } -- , { "Upgrade", "WebSocket" } -- , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } -- , { "Origin", "http://example.com" } -- } -- ,.body= "" -- } -- --#define CONNECT_REQUEST 17 --, {.name = "connect request" -- ,.type= HTTP_REQUEST -- ,.raw= "CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\n" -- "User-agent: Mozilla/1.1N\r\n" -- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" -- "\r\n" -- "some data\r\n" -- "and yet even more data" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.method= HTTP_CONNECT -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "" -- ,.request_url= "0-home0.netscape.com:443" -- ,.num_headers= 2 -- ,.upgrade="some data\r\nand yet even more data" -- ,.headers= { { "User-agent", "Mozilla/1.1N" } -- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } -- } -- ,.body= "" -- } -- --#define REPORT_REQ 18 --, {.name= "report request" -- ,.type= HTTP_REQUEST -- ,.raw= "REPORT /test HTTP/1.1\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_REPORT -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/test" -- ,.request_url= "/test" -- ,.num_headers= 0 -- ,.headers= {} -- ,.body= "" -- } -- --#define NO_HTTP_VERSION 19 --, {.name= "request with no http version" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 0 -- ,.http_minor= 9 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/" -- ,.request_url= "/" -- ,.num_headers= 0 -- ,.headers= {} -- ,.body= "" -- } -- --#define MSEARCH_REQ 20 --, {.name= "m-search request" -- ,.type= HTTP_REQUEST -- ,.raw= "M-SEARCH * HTTP/1.1\r\n" -- "HOST: 239.255.255.250:1900\r\n" -- "MAN: \"ssdp:discover\"\r\n" -- "ST: \"ssdp:all\"\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_MSEARCH -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "*" -- ,.request_url= "*" -- ,.num_headers= 3 -- ,.headers= { { "HOST", "239.255.255.250:1900" } -- , { "MAN", "\"ssdp:discover\"" } -- , { "ST", "\"ssdp:all\"" } -- } -- ,.body= "" -- } -- --#define LINE_FOLDING_IN_HEADER 21 --, {.name= "line folding in header value" -- ,.type= HTTP_REQUEST -- ,.raw= "GET / HTTP/1.1\r\n" -- "Line1: abc\r\n" -- "\tdef\r\n" -- " ghi\r\n" -- "\t\tjkl\r\n" -- " mno \r\n" -- "\t \tqrs\r\n" -- "Line2: \t line2\t\r\n" -- "Line3:\r\n" -- " line3\r\n" -- "Line4: \r\n" -- " \r\n" -- "Connection:\r\n" -- " close\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/" -- ,.request_url= "/" -- ,.num_headers= 5 -- ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" } -- , { "Line2", "line2\t" } -- , { "Line3", "line3" } -- , { "Line4", "" } -- , { "Connection", "close" }, -- } -- ,.body= "" -- } -- -- --#define QUERY_TERMINATED_HOST 22 --, {.name= "host terminated by a query string" -- ,.type= HTTP_REQUEST -- ,.raw= "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "hail=all" -- ,.fragment= "" -- ,.request_path= "" -- ,.request_url= "http://hypnotoad.org?hail=all" -- ,.host= "hypnotoad.org" -- ,.num_headers= 0 -- ,.headers= { } -- ,.body= "" -- } -- --#define QUERY_TERMINATED_HOSTPORT 23 --, {.name= "host:port terminated by a query string" -- ,.type= HTTP_REQUEST -- ,.raw= "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "hail=all" -- ,.fragment= "" -- ,.request_path= "" -- ,.request_url= "http://hypnotoad.org:1234?hail=all" -- ,.host= "hypnotoad.org" -- ,.port= 1234 -- ,.num_headers= 0 -- ,.headers= { } -- ,.body= "" -- } -- --#define SPACE_TERMINATED_HOSTPORT 24 --, {.name= "host:port terminated by a space" -- ,.type= HTTP_REQUEST -- ,.raw= "GET http://hypnotoad.org:1234 HTTP/1.1\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "" -- ,.request_url= "http://hypnotoad.org:1234" -- ,.host= "hypnotoad.org" -- ,.port= 1234 -- ,.num_headers= 0 -- ,.headers= { } -- ,.body= "" -- } -- --#define PATCH_REQ 25 --, {.name = "PATCH request" -- ,.type= HTTP_REQUEST -- ,.raw= "PATCH /file.txt HTTP/1.1\r\n" -- "Host: www.example.com\r\n" -- "Content-Type: application/example\r\n" -- "If-Match: \"e0023aa4e\"\r\n" -- "Content-Length: 10\r\n" -- "\r\n" -- "cccccccccc" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_PATCH -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/file.txt" -- ,.request_url= "/file.txt" -- ,.num_headers= 4 -- ,.headers= { { "Host", "www.example.com" } -- , { "Content-Type", "application/example" } -- , { "If-Match", "\"e0023aa4e\"" } -- , { "Content-Length", "10" } -- } -- ,.body= "cccccccccc" -- } -- --#define CONNECT_CAPS_REQUEST 26 --, {.name = "connect caps request" -- ,.type= HTTP_REQUEST -- ,.raw= "CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\n" -- "User-agent: Mozilla/1.1N\r\n" -- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.method= HTTP_CONNECT -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "" -- ,.request_url= "HOME0.NETSCAPE.COM:443" -- ,.num_headers= 2 -- ,.upgrade="" -- ,.headers= { { "User-agent", "Mozilla/1.1N" } -- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } -- } -- ,.body= "" -- } -- --#if !HTTP_PARSER_STRICT --#define UTF8_PATH_REQ 27 --, {.name= "utf-8 path request" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\n" -- "Host: github.com\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "q=1" -- ,.fragment= "narf" -- ,.request_path= "/δ¶/δt/pope" -- ,.request_url= "/δ¶/δt/pope?q=1#narf" -- ,.num_headers= 1 -- ,.headers= { {"Host", "github.com" } -- } -- ,.body= "" -- } -- --#define HOSTNAME_UNDERSCORE 28 --, {.name = "hostname underscore" -- ,.type= HTTP_REQUEST -- ,.raw= "CONNECT home_0.netscape.com:443 HTTP/1.0\r\n" -- "User-agent: Mozilla/1.1N\r\n" -- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.method= HTTP_CONNECT -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "" -- ,.request_url= "home_0.netscape.com:443" -- ,.num_headers= 2 -- ,.upgrade="" -- ,.headers= { { "User-agent", "Mozilla/1.1N" } -- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } -- } -- ,.body= "" -- } --#endif /* !HTTP_PARSER_STRICT */ -- --/* see https://github.com/ry/http-parser/issues/47 */ --#define EAT_TRAILING_CRLF_NO_CONNECTION_CLOSE 29 --, {.name = "eat CRLF between requests, no \"Connection: close\" header" -- ,.raw= "POST / HTTP/1.1\r\n" -- "Host: www.example.com\r\n" -- "Content-Type: application/x-www-form-urlencoded\r\n" -- "Content-Length: 4\r\n" -- "\r\n" -- "q=42\r\n" /* note the trailing CRLF */ -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/" -- ,.request_url= "/" -- ,.num_headers= 3 -- ,.upgrade= 0 -- ,.headers= { { "Host", "www.example.com" } -- , { "Content-Type", "application/x-www-form-urlencoded" } -- , { "Content-Length", "4" } -- } -- ,.body= "q=42" -- } -- --/* see https://github.com/ry/http-parser/issues/47 */ --#define EAT_TRAILING_CRLF_WITH_CONNECTION_CLOSE 30 --, {.name = "eat CRLF between requests even if \"Connection: close\" is set" -- ,.raw= "POST / HTTP/1.1\r\n" -- "Host: www.example.com\r\n" -- "Content-Type: application/x-www-form-urlencoded\r\n" -- "Content-Length: 4\r\n" -- "Connection: close\r\n" -- "\r\n" -- "q=42\r\n" /* note the trailing CRLF */ -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE /* input buffer isn't empty when on_message_complete is called */ -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/" -- ,.request_url= "/" -- ,.num_headers= 4 -- ,.upgrade= 0 -- ,.headers= { { "Host", "www.example.com" } -- , { "Content-Type", "application/x-www-form-urlencoded" } -- , { "Content-Length", "4" } -- , { "Connection", "close" } -- } -- ,.body= "q=42" -- } -- --#define PURGE_REQ 31 --, {.name = "PURGE request" -- ,.type= HTTP_REQUEST -- ,.raw= "PURGE /file.txt HTTP/1.1\r\n" -- "Host: www.example.com\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_PURGE -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/file.txt" -- ,.request_url= "/file.txt" -- ,.num_headers= 1 -- ,.headers= { { "Host", "www.example.com" } } -- ,.body= "" -- } -- --#define SEARCH_REQ 32 --, {.name = "SEARCH request" -- ,.type= HTTP_REQUEST -- ,.raw= "SEARCH / HTTP/1.1\r\n" -- "Host: www.example.com\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_SEARCH -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/" -- ,.request_url= "/" -- ,.num_headers= 1 -- ,.headers= { { "Host", "www.example.com" } } -- ,.body= "" -- } -- --#define PROXY_WITH_BASIC_AUTH 33 --, {.name= "host:port and basic_auth" -- ,.type= HTTP_REQUEST -- ,.raw= "GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.fragment= "" -- ,.request_path= "/toto" -- ,.request_url= "http://a%12:b!&*$@hypnotoad.org:1234/toto" -- ,.host= "hypnotoad.org" -- ,.userinfo= "a%12:b!&*$" -- ,.port= 1234 -- ,.num_headers= 0 -- ,.headers= { } -- ,.body= "" -- } -- --#define LINE_FOLDING_IN_HEADER_WITH_LF 34 --, {.name= "line folding in header value" -- ,.type= HTTP_REQUEST -- ,.raw= "GET / HTTP/1.1\n" -- "Line1: abc\n" -- "\tdef\n" -- " ghi\n" -- "\t\tjkl\n" -- " mno \n" -- "\t \tqrs\n" -- "Line2: \t line2\t\n" -- "Line3:\n" -- " line3\n" -- "Line4: \n" -- " \n" -- "Connection:\n" -- " close\n" -- "\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/" -- ,.request_url= "/" -- ,.num_headers= 5 -- ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" } -- , { "Line2", "line2\t" } -- , { "Line3", "line3" } -- , { "Line4", "" } -- , { "Connection", "close" }, -- } -- ,.body= "" -- } -- --#define CONNECTION_MULTI 35 --, {.name = "multiple connection header values with folding" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /demo HTTP/1.1\r\n" -- "Host: example.com\r\n" -- "Connection: Something,\r\n" -- " Upgrade, ,Keep-Alive\r\n" -- "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" -- "Sec-WebSocket-Protocol: sample\r\n" -- "Upgrade: WebSocket\r\n" -- "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" -- "Origin: http://example.com\r\n" -- "\r\n" -- "Hot diggity dogg" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/demo" -- ,.request_url= "/demo" -- ,.num_headers= 7 -- ,.upgrade="Hot diggity dogg" -- ,.headers= { { "Host", "example.com" } -- , { "Connection", "Something, Upgrade, ,Keep-Alive" } -- , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } -- , { "Sec-WebSocket-Protocol", "sample" } -- , { "Upgrade", "WebSocket" } -- , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } -- , { "Origin", "http://example.com" } -- } -- ,.body= "" -- } -- --#define CONNECTION_MULTI_LWS 36 --, {.name = "multiple connection header values with folding and lws" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /demo HTTP/1.1\r\n" -- "Connection: keep-alive, upgrade\r\n" -- "Upgrade: WebSocket\r\n" -- "\r\n" -- "Hot diggity dogg" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/demo" -- ,.request_url= "/demo" -- ,.num_headers= 2 -- ,.upgrade="Hot diggity dogg" -- ,.headers= { { "Connection", "keep-alive, upgrade" } -- , { "Upgrade", "WebSocket" } -- } -- ,.body= "" -- } -- --#define CONNECTION_MULTI_LWS_CRLF 37 --, {.name = "multiple connection header values with folding and lws" -- ,.type= HTTP_REQUEST -- ,.raw= "GET /demo HTTP/1.1\r\n" -- "Connection: keep-alive, \r\n upgrade\r\n" -- "Upgrade: WebSocket\r\n" -- "\r\n" -- "Hot diggity dogg" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_GET -- ,.query_string= "" -- ,.fragment= "" -- ,.request_path= "/demo" -- ,.request_url= "/demo" -- ,.num_headers= 2 -- ,.upgrade="Hot diggity dogg" -- ,.headers= { { "Connection", "keep-alive, upgrade" } -- , { "Upgrade", "WebSocket" } -- } -- ,.body= "" -- } -- --#define UPGRADE_POST_REQUEST 38 --, {.name = "upgrade post request" -- ,.type= HTTP_REQUEST -- ,.raw= "POST /demo HTTP/1.1\r\n" -- "Host: example.com\r\n" -- "Connection: Upgrade\r\n" -- "Upgrade: HTTP/2.0\r\n" -- "Content-Length: 15\r\n" -- "\r\n" -- "sweet post body" -- "Hot diggity dogg" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_POST -- ,.request_path= "/demo" -- ,.request_url= "/demo" -- ,.num_headers= 4 -- ,.upgrade="Hot diggity dogg" -- ,.headers= { { "Host", "example.com" } -- , { "Connection", "Upgrade" } -- , { "Upgrade", "HTTP/2.0" } -- , { "Content-Length", "15" } -- } -- ,.body= "sweet post body" -- } -- --#define CONNECT_WITH_BODY_REQUEST 39 --, {.name = "connect with body request" -- ,.type= HTTP_REQUEST -- ,.raw= "CONNECT foo.bar.com:443 HTTP/1.0\r\n" -- "User-agent: Mozilla/1.1N\r\n" -- "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" -- "Content-Length: 10\r\n" -- "\r\n" -- "blarfcicle" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.method= HTTP_CONNECT -- ,.request_url= "foo.bar.com:443" -- ,.num_headers= 3 -- ,.upgrade="blarfcicle" -- ,.headers= { { "User-agent", "Mozilla/1.1N" } -- , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } -- , { "Content-Length", "10" } -- } -- ,.body= "" -- } -- --/* Examples from the Internet draft for LINK/UNLINK methods: -- * https://tools.ietf.org/id/draft-snell-link-method-01.html#rfc.section.5 -- */ -- --#define LINK_REQUEST 40 --, {.name = "link request" -- ,.type= HTTP_REQUEST -- ,.raw= "LINK /images/my_dog.jpg HTTP/1.1\r\n" -- "Host: example.com\r\n" -- "Link: ; rel=\"tag\"\r\n" -- "Link: ; rel=\"tag\"\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_LINK -- ,.request_path= "/images/my_dog.jpg" -- ,.request_url= "/images/my_dog.jpg" -- ,.query_string= "" -- ,.fragment= "" -- ,.num_headers= 3 -- ,.headers= { { "Host", "example.com" } -- , { "Link", "; rel=\"tag\"" } -- , { "Link", "; rel=\"tag\"" } -- } -- ,.body= "" -- } -- --#define UNLINK_REQUEST 41 --, {.name = "unlink request" -- ,.type= HTTP_REQUEST -- ,.raw= "UNLINK /images/my_dog.jpg HTTP/1.1\r\n" -- "Host: example.com\r\n" -- "Link: ; rel=\"tag\"\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_UNLINK -- ,.request_path= "/images/my_dog.jpg" -- ,.request_url= "/images/my_dog.jpg" -- ,.query_string= "" -- ,.fragment= "" -- ,.num_headers= 2 -- ,.headers= { { "Host", "example.com" } -- , { "Link", "; rel=\"tag\"" } -- } -- ,.body= "" -- } -- --#define SOURCE_REQUEST 42 --, {.name = "source request" -- ,.type= HTTP_REQUEST -- ,.raw= "SOURCE /music/sweet/music HTTP/1.1\r\n" -- "Host: example.com\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.method= HTTP_SOURCE -- ,.request_path= "/music/sweet/music" -- ,.request_url= "/music/sweet/music" -- ,.query_string= "" -- ,.fragment= "" -- ,.num_headers= 1 -- ,.headers= { { "Host", "example.com" } } -- ,.body= "" -- } -- --, {.name= NULL } /* sentinel */ --}; -- --/* * R E S P O N S E S * */ --const struct message responses[] = --#define GOOGLE_301 0 --{ {.name= "google 301" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 301 Moved Permanently\r\n" -- "Location: http://www.google.com/\r\n" -- "Content-Type: text/html; charset=UTF-8\r\n" -- "Date: Sun, 26 Apr 2009 11:11:49 GMT\r\n" -- "Expires: Tue, 26 May 2009 11:11:49 GMT\r\n" -- "X-$PrototypeBI-Version: 1.6.0.3\r\n" /* $ char in header field */ -- "Cache-Control: public, max-age=2592000\r\n" -- "Server: gws\r\n" -- "Content-Length: 219 \r\n" -- "\r\n" -- "\n" -- "301 Moved\n" -- "

301 Moved

\n" -- "The document has moved\n" -- "here.\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 301 -- ,.response_status= "Moved Permanently" -- ,.num_headers= 8 -- ,.headers= -- { { "Location", "http://www.google.com/" } -- , { "Content-Type", "text/html; charset=UTF-8" } -- , { "Date", "Sun, 26 Apr 2009 11:11:49 GMT" } -- , { "Expires", "Tue, 26 May 2009 11:11:49 GMT" } -- , { "X-$PrototypeBI-Version", "1.6.0.3" } -- , { "Cache-Control", "public, max-age=2592000" } -- , { "Server", "gws" } -- , { "Content-Length", "219 " } -- } -- ,.body= "\n" -- "301 Moved\n" -- "

301 Moved

\n" -- "The document has moved\n" -- "here.\r\n" -- "\r\n" -- } -- --#define NO_CONTENT_LENGTH_RESPONSE 1 --/* The client should wait for the server's EOF. That is, when content-length -- * is not specified, and "Connection: close", the end of body is specified -- * by the EOF. -- * Compare with APACHEBENCH_GET -- */ --, {.name= "no content-length response" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Date: Tue, 04 Aug 2009 07:59:32 GMT\r\n" -- "Server: Apache\r\n" -- "X-Powered-By: Servlet/2.5 JSP/2.1\r\n" -- "Content-Type: text/xml; charset=utf-8\r\n" -- "Connection: close\r\n" -- "\r\n" -- "\n" -- "\n" -- " \n" -- " \n" -- " SOAP-ENV:Client\n" -- " Client Error\n" -- " \n" -- " \n" -- "" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 5 -- ,.headers= -- { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" } -- , { "Server", "Apache" } -- , { "X-Powered-By", "Servlet/2.5 JSP/2.1" } -- , { "Content-Type", "text/xml; charset=utf-8" } -- , { "Connection", "close" } -- } -- ,.body= "\n" -- "\n" -- " \n" -- " \n" -- " SOAP-ENV:Client\n" -- " Client Error\n" -- " \n" -- " \n" -- "" -- } -- --#define NO_HEADERS_NO_BODY_404 2 --, {.name= "404 no headers no body" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 404 Not Found\r\n\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 404 -- ,.response_status= "Not Found" -- ,.num_headers= 0 -- ,.headers= {} -- ,.body_size= 0 -- ,.body= "" -- } -- --#define NO_REASON_PHRASE 3 --, {.name= "301 no response phrase" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 301\r\n\r\n" -- ,.should_keep_alive = FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 301 -- ,.response_status= "" -- ,.num_headers= 0 -- ,.headers= {} -- ,.body= "" -- } -- --#define TRAILING_SPACE_ON_CHUNKED_BODY 4 --, {.name="200 trailing space on chunked body" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Content-Type: text/plain\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "25 \r\n" -- "This is the data in the first chunk\r\n" -- "\r\n" -- "1C\r\n" -- "and this is the second one\r\n" -- "\r\n" -- "0 \r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 2 -- ,.headers= -- { {"Content-Type", "text/plain" } -- , {"Transfer-Encoding", "chunked" } -- } -- ,.body_size = 37+28 -- ,.body = -- "This is the data in the first chunk\r\n" -- "and this is the second one\r\n" -- ,.num_chunks_complete= 3 -- ,.chunk_lengths= { 0x25, 0x1c } -- } -- --#define NO_CARRIAGE_RET 5 --, {.name="no carriage ret" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\n" -- "Content-Type: text/html; charset=utf-8\n" -- "Connection: close\n" -- "\n" -- "these headers are from http://news.ycombinator.com/" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 2 -- ,.headers= -- { {"Content-Type", "text/html; charset=utf-8" } -- , {"Connection", "close" } -- } -- ,.body= "these headers are from http://news.ycombinator.com/" -- } -- --#define PROXY_CONNECTION 6 --, {.name="proxy connection" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Content-Type: text/html; charset=UTF-8\r\n" -- "Content-Length: 11\r\n" -- "Proxy-Connection: close\r\n" -- "Date: Thu, 31 Dec 2009 20:55:48 +0000\r\n" -- "\r\n" -- "hello world" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 4 -- ,.headers= -- { {"Content-Type", "text/html; charset=UTF-8" } -- , {"Content-Length", "11" } -- , {"Proxy-Connection", "close" } -- , {"Date", "Thu, 31 Dec 2009 20:55:48 +0000"} -- } -- ,.body= "hello world" -- } -- --#define UNDERSTORE_HEADER_KEY 7 -- // shown by -- // curl -o /dev/null -v "http://ad.doubleclick.net/pfadx/DARTSHELLCONFIGXML;dcmt=text/xml;" --, {.name="underscore header key" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Server: DCLK-AdSvr\r\n" -- "Content-Type: text/xml\r\n" -- "Content-Length: 0\r\n" -- "DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 4 -- ,.headers= -- { {"Server", "DCLK-AdSvr" } -- , {"Content-Type", "text/xml" } -- , {"Content-Length", "0" } -- , {"DCLK_imp", "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o" } -- } -- ,.body= "" -- } -- --#define BONJOUR_MADAME_FR 8 --/* The client should not merge two headers fields when the first one doesn't -- * have a value. -- */ --, {.name= "bonjourmadame.fr" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.0 301 Moved Permanently\r\n" -- "Date: Thu, 03 Jun 2010 09:56:32 GMT\r\n" -- "Server: Apache/2.2.3 (Red Hat)\r\n" -- "Cache-Control: public\r\n" -- "Pragma: \r\n" -- "Location: http://www.bonjourmadame.fr/\r\n" -- "Vary: Accept-Encoding\r\n" -- "Content-Length: 0\r\n" -- "Content-Type: text/html; charset=UTF-8\r\n" -- "Connection: keep-alive\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.status_code= 301 -- ,.response_status= "Moved Permanently" -- ,.num_headers= 9 -- ,.headers= -- { { "Date", "Thu, 03 Jun 2010 09:56:32 GMT" } -- , { "Server", "Apache/2.2.3 (Red Hat)" } -- , { "Cache-Control", "public" } -- , { "Pragma", "" } -- , { "Location", "http://www.bonjourmadame.fr/" } -- , { "Vary", "Accept-Encoding" } -- , { "Content-Length", "0" } -- , { "Content-Type", "text/html; charset=UTF-8" } -- , { "Connection", "keep-alive" } -- } -- ,.body= "" -- } -- --#define RES_FIELD_UNDERSCORE 9 --/* Should handle spaces in header fields */ --, {.name= "field underscore" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Date: Tue, 28 Sep 2010 01:14:13 GMT\r\n" -- "Server: Apache\r\n" -- "Cache-Control: no-cache, must-revalidate\r\n" -- "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" -- ".et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\n" -- "Vary: Accept-Encoding\r\n" -- "_eep-Alive: timeout=45\r\n" /* semantic value ignored */ -- "_onnection: Keep-Alive\r\n" /* semantic value ignored */ -- "Transfer-Encoding: chunked\r\n" -- "Content-Type: text/html\r\n" -- "Connection: close\r\n" -- "\r\n" -- "0\r\n\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 11 -- ,.headers= -- { { "Date", "Tue, 28 Sep 2010 01:14:13 GMT" } -- , { "Server", "Apache" } -- , { "Cache-Control", "no-cache, must-revalidate" } -- , { "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" } -- , { ".et-Cookie", "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com" } -- , { "Vary", "Accept-Encoding" } -- , { "_eep-Alive", "timeout=45" } -- , { "_onnection", "Keep-Alive" } -- , { "Transfer-Encoding", "chunked" } -- , { "Content-Type", "text/html" } -- , { "Connection", "close" } -- } -- ,.body= "" -- ,.num_chunks_complete= 1 -- ,.chunk_lengths= {} -- } -- --#define NON_ASCII_IN_STATUS_LINE 10 --/* Should handle non-ASCII in status line */ --, {.name= "non-ASCII in status line" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 500 Oriëntatieprobleem\r\n" -- "Date: Fri, 5 Nov 2010 23:07:12 GMT+2\r\n" -- "Content-Length: 0\r\n" -- "Connection: close\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 500 -- ,.response_status= "Oriëntatieprobleem" -- ,.num_headers= 3 -- ,.headers= -- { { "Date", "Fri, 5 Nov 2010 23:07:12 GMT+2" } -- , { "Content-Length", "0" } -- , { "Connection", "close" } -- } -- ,.body= "" -- } -- --#define HTTP_VERSION_0_9 11 --/* Should handle HTTP/0.9 */ --, {.name= "http version 0.9" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/0.9 200 OK\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 0 -- ,.http_minor= 9 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 0 -- ,.headers= -- {} -- ,.body= "" -- } -- --#define NO_CONTENT_LENGTH_NO_TRANSFER_ENCODING_RESPONSE 12 --/* The client should wait for the server's EOF. That is, when neither -- * content-length nor transfer-encoding is specified, the end of body -- * is specified by the EOF. -- */ --, {.name= "neither content-length nor transfer-encoding response" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Content-Type: text/plain\r\n" -- "\r\n" -- "hello world" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 1 -- ,.headers= -- { { "Content-Type", "text/plain" } -- } -- ,.body= "hello world" -- } -- --#define NO_BODY_HTTP10_KA_200 13 --, {.name= "HTTP/1.0 with keep-alive and EOF-terminated 200 status" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.0 200 OK\r\n" -- "Connection: keep-alive\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 1 -- ,.headers= -- { { "Connection", "keep-alive" } -- } -- ,.body_size= 0 -- ,.body= "" -- } -- --#define NO_BODY_HTTP10_KA_204 14 --, {.name= "HTTP/1.0 with keep-alive and a 204 status" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.0 204 No content\r\n" -- "Connection: keep-alive\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.status_code= 204 -- ,.response_status= "No content" -- ,.num_headers= 1 -- ,.headers= -- { { "Connection", "keep-alive" } -- } -- ,.body_size= 0 -- ,.body= "" -- } -- --#define NO_BODY_HTTP11_KA_200 15 --, {.name= "HTTP/1.1 with an EOF-terminated 200 status" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 0 -- ,.headers={} -- ,.body_size= 0 -- ,.body= "" -- } -- --#define NO_BODY_HTTP11_KA_204 16 --, {.name= "HTTP/1.1 with a 204 status" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 204 No content\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 204 -- ,.response_status= "No content" -- ,.num_headers= 0 -- ,.headers={} -- ,.body_size= 0 -- ,.body= "" -- } -- --#define NO_BODY_HTTP11_NOKA_204 17 --, {.name= "HTTP/1.1 with a 204 status and keep-alive disabled" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 204 No content\r\n" -- "Connection: close\r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 204 -- ,.response_status= "No content" -- ,.num_headers= 1 -- ,.headers= -- { { "Connection", "close" } -- } -- ,.body_size= 0 -- ,.body= "" -- } -- --#define NO_BODY_HTTP11_KA_CHUNKED_200 18 --, {.name= "HTTP/1.1 with chunked endocing and a 200 response" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "0\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 1 -- ,.headers= -- { { "Transfer-Encoding", "chunked" } -- } -- ,.body_size= 0 -- ,.body= "" -- ,.num_chunks_complete= 1 -- } -- --#if !HTTP_PARSER_STRICT --#define SPACE_IN_FIELD_RES 19 --/* Should handle spaces in header fields */ --, {.name= "field space" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Server: Microsoft-IIS/6.0\r\n" -- "X-Powered-By: ASP.NET\r\n" -- "en-US Content-Type: text/xml\r\n" /* this is the problem */ -- "Content-Type: text/xml\r\n" -- "Content-Length: 16\r\n" -- "Date: Fri, 23 Jul 2010 18:45:38 GMT\r\n" -- "Connection: keep-alive\r\n" -- "\r\n" -- "hello" /* fake body */ -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 7 -- ,.headers= -- { { "Server", "Microsoft-IIS/6.0" } -- , { "X-Powered-By", "ASP.NET" } -- , { "en-US Content-Type", "text/xml" } -- , { "Content-Type", "text/xml" } -- , { "Content-Length", "16" } -- , { "Date", "Fri, 23 Jul 2010 18:45:38 GMT" } -- , { "Connection", "keep-alive" } -- } -- ,.body= "hello" -- } --#endif /* !HTTP_PARSER_STRICT */ -- --#define AMAZON_COM 20 --, {.name= "amazon.com" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 301 MovedPermanently\r\n" -- "Date: Wed, 15 May 2013 17:06:33 GMT\r\n" -- "Server: Server\r\n" -- "x-amz-id-1: 0GPHKXSJQ826RK7GZEB2\r\n" -- "p3p: policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"\r\n" -- "x-amz-id-2: STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD\r\n" -- "Location: http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846\r\n" -- "Vary: Accept-Encoding,User-Agent\r\n" -- "Content-Type: text/html; charset=ISO-8859-1\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "1\r\n" -- "\n\r\n" -- "0\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 301 -- ,.response_status= "MovedPermanently" -- ,.num_headers= 9 -- ,.headers= { { "Date", "Wed, 15 May 2013 17:06:33 GMT" } -- , { "Server", "Server" } -- , { "x-amz-id-1", "0GPHKXSJQ826RK7GZEB2" } -- , { "p3p", "policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"" } -- , { "x-amz-id-2", "STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD" } -- , { "Location", "http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846" } -- , { "Vary", "Accept-Encoding,User-Agent" } -- , { "Content-Type", "text/html; charset=ISO-8859-1" } -- , { "Transfer-Encoding", "chunked" } -- } -- ,.body= "\n" -- ,.num_chunks_complete= 2 -- ,.chunk_lengths= { 1 } -- } -- --#define EMPTY_REASON_PHRASE_AFTER_SPACE 20 --, {.name= "empty reason phrase after space" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 \r\n" -- "\r\n" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "" -- ,.num_headers= 0 -- ,.headers= {} -- ,.body= "" -- } -- --#define CONTENT_LENGTH_X 21 --, {.name= "Content-Length-X" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Content-Length-X: 0\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "2\r\n" -- "OK\r\n" -- "0\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 2 -- ,.headers= { { "Content-Length-X", "0" } -- , { "Transfer-Encoding", "chunked" } -- } -- ,.body= "OK" -- ,.num_chunks_complete= 2 -- ,.chunk_lengths= { 2 } -- } -- --#define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER 22 --, {.name= "HTTP 101 response with Upgrade header" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 101 Switching Protocols\r\n" -- "Connection: upgrade\r\n" -- "Upgrade: h2c\r\n" -- "\r\n" -- "proto" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 101 -- ,.response_status= "Switching Protocols" -- ,.upgrade= "proto" -- ,.num_headers= 2 -- ,.headers= -- { { "Connection", "upgrade" } -- , { "Upgrade", "h2c" } -- } -- } -- --#define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER_AND_CONTENT_LENGTH 23 --, {.name= "HTTP 101 response with Upgrade and Content-Length header" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 101 Switching Protocols\r\n" -- "Connection: upgrade\r\n" -- "Upgrade: h2c\r\n" -- "Content-Length: 4\r\n" -- "\r\n" -- "body" -- "proto" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 101 -- ,.response_status= "Switching Protocols" -- ,.body= "body" -- ,.upgrade= "proto" -- ,.num_headers= 3 -- ,.headers= -- { { "Connection", "upgrade" } -- , { "Upgrade", "h2c" } -- , { "Content-Length", "4" } -- } -- } -- --#define HTTP_101_RESPONSE_WITH_UPGRADE_HEADER_AND_TRANSFER_ENCODING 24 --, {.name= "HTTP 101 response with Upgrade and Transfer-Encoding header" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 101 Switching Protocols\r\n" -- "Connection: upgrade\r\n" -- "Upgrade: h2c\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "2\r\n" -- "bo\r\n" -- "2\r\n" -- "dy\r\n" -- "0\r\n" -- "\r\n" -- "proto" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 101 -- ,.response_status= "Switching Protocols" -- ,.body= "body" -- ,.upgrade= "proto" -- ,.num_headers= 3 -- ,.headers= -- { { "Connection", "upgrade" } -- , { "Upgrade", "h2c" } -- , { "Transfer-Encoding", "chunked" } -- } -- ,.num_chunks_complete= 3 -- ,.chunk_lengths= { 2, 2 } -- } -- --#define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER 25 --, {.name= "HTTP 200 response with Upgrade header" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Connection: upgrade\r\n" -- "Upgrade: h2c\r\n" -- "\r\n" -- "body" -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= TRUE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.body= "body" -- ,.upgrade= NULL -- ,.num_headers= 2 -- ,.headers= -- { { "Connection", "upgrade" } -- , { "Upgrade", "h2c" } -- } -- } -- --#define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER_AND_CONTENT_LENGTH 26 --, {.name= "HTTP 200 response with Upgrade and Content-Length header" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Connection: upgrade\r\n" -- "Upgrade: h2c\r\n" -- "Content-Length: 4\r\n" -- "\r\n" -- "body" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 3 -- ,.body= "body" -- ,.upgrade= NULL -- ,.headers= -- { { "Connection", "upgrade" } -- , { "Upgrade", "h2c" } -- , { "Content-Length", "4" } -- } -- } -- --#define HTTP_200_RESPONSE_WITH_UPGRADE_HEADER_AND_TRANSFER_ENCODING 27 --, {.name= "HTTP 200 response with Upgrade and Transfer-Encoding header" -- ,.type= HTTP_RESPONSE -- ,.raw= "HTTP/1.1 200 OK\r\n" -- "Connection: upgrade\r\n" -- "Upgrade: h2c\r\n" -- "Transfer-Encoding: chunked\r\n" -- "\r\n" -- "2\r\n" -- "bo\r\n" -- "2\r\n" -- "dy\r\n" -- "0\r\n" -- "\r\n" -- ,.should_keep_alive= TRUE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 1 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 3 -- ,.body= "body" -- ,.upgrade= NULL -- ,.headers= -- { { "Connection", "upgrade" } -- , { "Upgrade", "h2c" } -- , { "Transfer-Encoding", "chunked" } -- } -- ,.num_chunks_complete= 3 -- ,.chunk_lengths= { 2, 2 } -- } -- --, {.name= NULL } /* sentinel */ --}; -- --/* strnlen() is a POSIX.2008 addition. Can't rely on it being available so -- * define it ourselves. -- */ --size_t --strnlen(const char *s, size_t maxlen) --{ -- const char *p; -- -- p = memchr(s, '\0', maxlen); -- if (p == NULL) -- return maxlen; -- -- return p - s; --} -- --size_t --strlncat(char *dst, size_t len, const char *src, size_t n) --{ -- size_t slen; -- size_t dlen; -- size_t rlen; -- size_t ncpy; -- -- slen = strnlen(src, n); -- dlen = strnlen(dst, len); -- -- if (dlen < len) { -- rlen = len - dlen; -- ncpy = slen < rlen ? slen : (rlen - 1); -- memcpy(dst + dlen, src, ncpy); -- dst[dlen + ncpy] = '\0'; -- } -- -- assert(len > slen + dlen); -- return slen + dlen; --} -- --size_t --strlcat(char *dst, const char *src, size_t len) --{ -- return strlncat(dst, len, src, (size_t) -1); --} -- --size_t --strlncpy(char *dst, size_t len, const char *src, size_t n) --{ -- size_t slen; -- size_t ncpy; -- -- slen = strnlen(src, n); -- -- if (len > 0) { -- ncpy = slen < len ? slen : (len - 1); -- memcpy(dst, src, ncpy); -- dst[ncpy] = '\0'; -- } -- -- assert(len > slen); -- return slen; --} -- --size_t --strlcpy(char *dst, const char *src, size_t len) --{ -- return strlncpy(dst, len, src, (size_t) -1); --} -- --int --request_url_cb (http_parser *p, const char *buf, size_t len) --{ -- assert(p == parser); -- strlncat(messages[num_messages].request_url, -- sizeof(messages[num_messages].request_url), -- buf, -- len); -- return 0; --} -- --int --header_field_cb (http_parser *p, const char *buf, size_t len) --{ -- assert(p == parser); -- struct message *m = &messages[num_messages]; -- -- if (m->last_header_element != FIELD) -- m->num_headers++; -- -- strlncat(m->headers[m->num_headers-1][0], -- sizeof(m->headers[m->num_headers-1][0]), -- buf, -- len); -- -- m->last_header_element = FIELD; -- -- return 0; --} -- --int --header_value_cb (http_parser *p, const char *buf, size_t len) --{ -- assert(p == parser); -- struct message *m = &messages[num_messages]; -- -- strlncat(m->headers[m->num_headers-1][1], -- sizeof(m->headers[m->num_headers-1][1]), -- buf, -- len); -- -- m->last_header_element = VALUE; -- -- return 0; --} -- --void --check_body_is_final (const http_parser *p) --{ -- if (messages[num_messages].body_is_final) { -- fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " -- "on last on_body callback call " -- "but it doesn't! ***\n\n"); -- assert(0); -- abort(); -- } -- messages[num_messages].body_is_final = http_body_is_final(p); --} -- --int --body_cb (http_parser *p, const char *buf, size_t len) --{ -- assert(p == parser); -- strlncat(messages[num_messages].body, -- sizeof(messages[num_messages].body), -- buf, -- len); -- messages[num_messages].body_size += len; -- check_body_is_final(p); -- // printf("body_cb: '%s'\n", requests[num_messages].body); -- return 0; --} -- --int --count_body_cb (http_parser *p, const char *buf, size_t len) --{ -- assert(p == parser); -- assert(buf); -- messages[num_messages].body_size += len; -- check_body_is_final(p); -- return 0; --} -- --int --message_begin_cb (http_parser *p) --{ -- assert(p == parser); -- messages[num_messages].message_begin_cb_called = TRUE; -- return 0; --} -- --int --headers_complete_cb (http_parser *p) --{ -- assert(p == parser); -- messages[num_messages].method = parser->method; -- messages[num_messages].status_code = parser->status_code; -- messages[num_messages].http_major = parser->http_major; -- messages[num_messages].http_minor = parser->http_minor; -- messages[num_messages].headers_complete_cb_called = TRUE; -- messages[num_messages].should_keep_alive = http_should_keep_alive(parser); -- return 0; --} -- --int --message_complete_cb (http_parser *p) --{ -- assert(p == parser); -- if (messages[num_messages].should_keep_alive != http_should_keep_alive(parser)) -- { -- fprintf(stderr, "\n\n *** Error http_should_keep_alive() should have same " -- "value in both on_message_complete and on_headers_complete " -- "but it doesn't! ***\n\n"); -- assert(0); -- abort(); -- } -- -- if (messages[num_messages].body_size && -- http_body_is_final(p) && -- !messages[num_messages].body_is_final) -- { -- fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " -- "on last on_body callback call " -- "but it doesn't! ***\n\n"); -- assert(0); -- abort(); -- } -- -- messages[num_messages].message_complete_cb_called = TRUE; -- -- messages[num_messages].message_complete_on_eof = currently_parsing_eof; -- -- num_messages++; -- return 0; --} -- --int --response_status_cb (http_parser *p, const char *buf, size_t len) --{ -- assert(p == parser); -- -- messages[num_messages].status_cb_called = TRUE; -- -- strlncat(messages[num_messages].response_status, -- sizeof(messages[num_messages].response_status), -- buf, -- len); -- return 0; --} -- --int --chunk_header_cb (http_parser *p) --{ -- assert(p == parser); -- int chunk_idx = messages[num_messages].num_chunks; -- messages[num_messages].num_chunks++; -- if (chunk_idx < MAX_CHUNKS) { -- messages[num_messages].chunk_lengths[chunk_idx] = p->content_length; -- } -- -- return 0; --} -- --int --chunk_complete_cb (http_parser *p) --{ -- assert(p == parser); -- -- /* Here we want to verify that each chunk_header_cb is matched by a -- * chunk_complete_cb, so not only should the total number of calls to -- * both callbacks be the same, but they also should be interleaved -- * properly */ -- assert(messages[num_messages].num_chunks == -- messages[num_messages].num_chunks_complete + 1); -- -- messages[num_messages].num_chunks_complete++; -- return 0; --} -- --/* These dontcall_* callbacks exist so that we can verify that when we're -- * paused, no additional callbacks are invoked */ --int --dontcall_message_begin_cb (http_parser *p) --{ -- if (p) { } // gcc -- fprintf(stderr, "\n\n*** on_message_begin() called on paused parser ***\n\n"); -- abort(); --} -- --int --dontcall_header_field_cb (http_parser *p, const char *buf, size_t len) --{ -- if (p || buf || len) { } // gcc -- fprintf(stderr, "\n\n*** on_header_field() called on paused parser ***\n\n"); -- abort(); --} -- --int --dontcall_header_value_cb (http_parser *p, const char *buf, size_t len) --{ -- if (p || buf || len) { } // gcc -- fprintf(stderr, "\n\n*** on_header_value() called on paused parser ***\n\n"); -- abort(); --} -- --int --dontcall_request_url_cb (http_parser *p, const char *buf, size_t len) --{ -- if (p || buf || len) { } // gcc -- fprintf(stderr, "\n\n*** on_request_url() called on paused parser ***\n\n"); -- abort(); --} -- --int --dontcall_body_cb (http_parser *p, const char *buf, size_t len) --{ -- if (p || buf || len) { } // gcc -- fprintf(stderr, "\n\n*** on_body_cb() called on paused parser ***\n\n"); -- abort(); --} -- --int --dontcall_headers_complete_cb (http_parser *p) --{ -- if (p) { } // gcc -- fprintf(stderr, "\n\n*** on_headers_complete() called on paused " -- "parser ***\n\n"); -- abort(); --} -- --int --dontcall_message_complete_cb (http_parser *p) --{ -- if (p) { } // gcc -- fprintf(stderr, "\n\n*** on_message_complete() called on paused " -- "parser ***\n\n"); -- abort(); --} -- --int --dontcall_response_status_cb (http_parser *p, const char *buf, size_t len) --{ -- if (p || buf || len) { } // gcc -- fprintf(stderr, "\n\n*** on_status() called on paused parser ***\n\n"); -- abort(); --} -- --int --dontcall_chunk_header_cb (http_parser *p) --{ -- if (p) { } // gcc -- fprintf(stderr, "\n\n*** on_chunk_header() called on paused parser ***\n\n"); -- exit(1); --} -- --int --dontcall_chunk_complete_cb (http_parser *p) --{ -- if (p) { } // gcc -- fprintf(stderr, "\n\n*** on_chunk_complete() " -- "called on paused parser ***\n\n"); -- exit(1); --} -- --static http_parser_settings settings_dontcall = -- {.on_message_begin = dontcall_message_begin_cb -- ,.on_header_field = dontcall_header_field_cb -- ,.on_header_value = dontcall_header_value_cb -- ,.on_url = dontcall_request_url_cb -- ,.on_status = dontcall_response_status_cb -- ,.on_body = dontcall_body_cb -- ,.on_headers_complete = dontcall_headers_complete_cb -- ,.on_message_complete = dontcall_message_complete_cb -- ,.on_chunk_header = dontcall_chunk_header_cb -- ,.on_chunk_complete = dontcall_chunk_complete_cb -- }; -- --/* These pause_* callbacks always pause the parser and just invoke the regular -- * callback that tracks content. Before returning, we overwrite the parser -- * settings to point to the _dontcall variety so that we can verify that -- * the pause actually did, you know, pause. */ --int --pause_message_begin_cb (http_parser *p) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return message_begin_cb(p); --} -- --int --pause_header_field_cb (http_parser *p, const char *buf, size_t len) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return header_field_cb(p, buf, len); --} -- --int --pause_header_value_cb (http_parser *p, const char *buf, size_t len) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return header_value_cb(p, buf, len); --} -- --int --pause_request_url_cb (http_parser *p, const char *buf, size_t len) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return request_url_cb(p, buf, len); --} -- --int --pause_body_cb (http_parser *p, const char *buf, size_t len) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return body_cb(p, buf, len); --} -- --int --pause_headers_complete_cb (http_parser *p) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return headers_complete_cb(p); --} -- --int --pause_message_complete_cb (http_parser *p) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return message_complete_cb(p); --} -- --int --pause_response_status_cb (http_parser *p, const char *buf, size_t len) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return response_status_cb(p, buf, len); --} -- --int --pause_chunk_header_cb (http_parser *p) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return chunk_header_cb(p); --} -- --int --pause_chunk_complete_cb (http_parser *p) --{ -- http_parser_pause(p, 1); -- *current_pause_parser = settings_dontcall; -- return chunk_complete_cb(p); --} -- --int --connect_headers_complete_cb (http_parser *p) --{ -- headers_complete_cb(p); -- return 1; --} -- --int --connect_message_complete_cb (http_parser *p) --{ -- messages[num_messages].should_keep_alive = http_should_keep_alive(parser); -- return message_complete_cb(p); --} -- --static http_parser_settings settings_pause = -- {.on_message_begin = pause_message_begin_cb -- ,.on_header_field = pause_header_field_cb -- ,.on_header_value = pause_header_value_cb -- ,.on_url = pause_request_url_cb -- ,.on_status = pause_response_status_cb -- ,.on_body = pause_body_cb -- ,.on_headers_complete = pause_headers_complete_cb -- ,.on_message_complete = pause_message_complete_cb -- ,.on_chunk_header = pause_chunk_header_cb -- ,.on_chunk_complete = pause_chunk_complete_cb -- }; -- --static http_parser_settings settings = -- {.on_message_begin = message_begin_cb -- ,.on_header_field = header_field_cb -- ,.on_header_value = header_value_cb -- ,.on_url = request_url_cb -- ,.on_status = response_status_cb -- ,.on_body = body_cb -- ,.on_headers_complete = headers_complete_cb -- ,.on_message_complete = message_complete_cb -- ,.on_chunk_header = chunk_header_cb -- ,.on_chunk_complete = chunk_complete_cb -- }; -- --static http_parser_settings settings_count_body = -- {.on_message_begin = message_begin_cb -- ,.on_header_field = header_field_cb -- ,.on_header_value = header_value_cb -- ,.on_url = request_url_cb -- ,.on_status = response_status_cb -- ,.on_body = count_body_cb -- ,.on_headers_complete = headers_complete_cb -- ,.on_message_complete = message_complete_cb -- ,.on_chunk_header = chunk_header_cb -- ,.on_chunk_complete = chunk_complete_cb -- }; -- --static http_parser_settings settings_connect = -- {.on_message_begin = message_begin_cb -- ,.on_header_field = header_field_cb -- ,.on_header_value = header_value_cb -- ,.on_url = request_url_cb -- ,.on_status = response_status_cb -- ,.on_body = dontcall_body_cb -- ,.on_headers_complete = connect_headers_complete_cb -- ,.on_message_complete = connect_message_complete_cb -- ,.on_chunk_header = chunk_header_cb -- ,.on_chunk_complete = chunk_complete_cb -- }; -- --static http_parser_settings settings_null = -- {.on_message_begin = 0 -- ,.on_header_field = 0 -- ,.on_header_value = 0 -- ,.on_url = 0 -- ,.on_status = 0 -- ,.on_body = 0 -- ,.on_headers_complete = 0 -- ,.on_message_complete = 0 -- ,.on_chunk_header = 0 -- ,.on_chunk_complete = 0 -- }; -- --void --parser_init (enum http_parser_type type) --{ -- num_messages = 0; -- -- assert(parser == NULL); -- -- parser = malloc(sizeof(http_parser)); -- -- http_parser_init(parser, type); -- -- memset(&messages, 0, sizeof messages); -- --} -- --void --parser_free () --{ -- assert(parser); -- free(parser); -- parser = NULL; --} -- --size_t parse (const char *buf, size_t len) --{ -- size_t nparsed; -- currently_parsing_eof = (len == 0); -- nparsed = http_parser_execute(parser, &settings, buf, len); -- return nparsed; --} -- --size_t parse_count_body (const char *buf, size_t len) --{ -- size_t nparsed; -- currently_parsing_eof = (len == 0); -- nparsed = http_parser_execute(parser, &settings_count_body, buf, len); -- return nparsed; --} -- --size_t parse_pause (const char *buf, size_t len) --{ -- size_t nparsed; -- http_parser_settings s = settings_pause; -- -- currently_parsing_eof = (len == 0); -- current_pause_parser = &s; -- nparsed = http_parser_execute(parser, current_pause_parser, buf, len); -- return nparsed; --} -- --size_t parse_connect (const char *buf, size_t len) --{ -- size_t nparsed; -- currently_parsing_eof = (len == 0); -- nparsed = http_parser_execute(parser, &settings_connect, buf, len); -- return nparsed; --} -- --static inline int --check_str_eq (const struct message *m, -- const char *prop, -- const char *expected, -- const char *found) { -- if ((expected == NULL) != (found == NULL)) { -- printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); -- printf("expected %s\n", (expected == NULL) ? "NULL" : expected); -- printf(" found %s\n", (found == NULL) ? "NULL" : found); -- return 0; -- } -- if (expected != NULL && 0 != strcmp(expected, found)) { -- printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); -- printf("expected '%s'\n", expected); -- printf(" found '%s'\n", found); -- return 0; -- } -- return 1; --} -- --static inline int --check_num_eq (const struct message *m, -- const char *prop, -- int expected, -- int found) { -- if (expected != found) { -- printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); -- printf("expected %d\n", expected); -- printf(" found %d\n", found); -- return 0; -- } -- return 1; --} -- --#define MESSAGE_CHECK_STR_EQ(expected, found, prop) \ -- if (!check_str_eq(expected, #prop, expected->prop, found->prop)) return 0 -- --#define MESSAGE_CHECK_NUM_EQ(expected, found, prop) \ -- if (!check_num_eq(expected, #prop, expected->prop, found->prop)) return 0 -- --#define MESSAGE_CHECK_URL_EQ(u, expected, found, prop, fn) \ --do { \ -- char ubuf[256]; \ -- \ -- if ((u)->field_set & (1 << (fn))) { \ -- memcpy(ubuf, (found)->request_url + (u)->field_data[(fn)].off, \ -- (u)->field_data[(fn)].len); \ -- ubuf[(u)->field_data[(fn)].len] = '\0'; \ -- } else { \ -- ubuf[0] = '\0'; \ -- } \ -- \ -- check_str_eq(expected, #prop, expected->prop, ubuf); \ --} while(0) -- --int --message_eq (int index, int connect, const struct message *expected) --{ -- int i; -- struct message *m = &messages[index]; -- -- MESSAGE_CHECK_NUM_EQ(expected, m, http_major); -- MESSAGE_CHECK_NUM_EQ(expected, m, http_minor); -- -- if (expected->type == HTTP_REQUEST) { -- MESSAGE_CHECK_NUM_EQ(expected, m, method); -- } else { -- MESSAGE_CHECK_NUM_EQ(expected, m, status_code); -- MESSAGE_CHECK_STR_EQ(expected, m, response_status); -- assert(m->status_cb_called); -- } -- -- if (!connect) { -- MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); -- MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof); -- } -- -- assert(m->message_begin_cb_called); -- assert(m->headers_complete_cb_called); -- assert(m->message_complete_cb_called); -- -- -- MESSAGE_CHECK_STR_EQ(expected, m, request_url); -- -- /* Check URL components; we can't do this w/ CONNECT since it doesn't -- * send us a well-formed URL. -- */ -- if (*m->request_url && m->method != HTTP_CONNECT) { -- struct http_parser_url u; -- -- if (http_parser_parse_url(m->request_url, strlen(m->request_url), 0, &u)) { -- fprintf(stderr, "\n\n*** failed to parse URL %s ***\n\n", -- m->request_url); -- abort(); -- } -- -- if (expected->host) { -- MESSAGE_CHECK_URL_EQ(&u, expected, m, host, UF_HOST); -- } -- -- if (expected->userinfo) { -- MESSAGE_CHECK_URL_EQ(&u, expected, m, userinfo, UF_USERINFO); -- } -- -- m->port = (u.field_set & (1 << UF_PORT)) ? -- u.port : 0; -- -- MESSAGE_CHECK_URL_EQ(&u, expected, m, query_string, UF_QUERY); -- MESSAGE_CHECK_URL_EQ(&u, expected, m, fragment, UF_FRAGMENT); -- MESSAGE_CHECK_URL_EQ(&u, expected, m, request_path, UF_PATH); -- MESSAGE_CHECK_NUM_EQ(expected, m, port); -- } -- -- if (connect) { -- check_num_eq(m, "body_size", 0, m->body_size); -- } else if (expected->body_size) { -- MESSAGE_CHECK_NUM_EQ(expected, m, body_size); -- } else { -- MESSAGE_CHECK_STR_EQ(expected, m, body); -- } -- -- if (connect) { -- check_num_eq(m, "num_chunks_complete", 0, m->num_chunks_complete); -- } else { -- assert(m->num_chunks == m->num_chunks_complete); -- MESSAGE_CHECK_NUM_EQ(expected, m, num_chunks_complete); -- for (i = 0; i < m->num_chunks && i < MAX_CHUNKS; i++) { -- MESSAGE_CHECK_NUM_EQ(expected, m, chunk_lengths[i]); -- } -- } -- -- MESSAGE_CHECK_NUM_EQ(expected, m, num_headers); -- -- int r; -- for (i = 0; i < m->num_headers; i++) { -- r = check_str_eq(expected, "header field", expected->headers[i][0], m->headers[i][0]); -- if (!r) return 0; -- r = check_str_eq(expected, "header value", expected->headers[i][1], m->headers[i][1]); -- if (!r) return 0; -- } -- -- if (!connect) { -- MESSAGE_CHECK_STR_EQ(expected, m, upgrade); -- } -- -- return 1; --} -- --/* Given a sequence of varargs messages, return the number of them that the -- * parser should successfully parse, taking into account that upgraded -- * messages prevent all subsequent messages from being parsed. -- */ --size_t --count_parsed_messages(const size_t nmsgs, ...) { -- size_t i; -- va_list ap; -- -- va_start(ap, nmsgs); -- -- for (i = 0; i < nmsgs; i++) { -- struct message *m = va_arg(ap, struct message *); -- -- if (m->upgrade) { -- va_end(ap); -- return i + 1; -- } -- } -- -- va_end(ap); -- return nmsgs; --} -- --/* Given a sequence of bytes and the number of these that we were able to -- * parse, verify that upgrade bodies are correct. -- */ --void --upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { -- va_list ap; -- size_t i; -- size_t off = 0; -- -- va_start(ap, nmsgs); -- -- for (i = 0; i < nmsgs; i++) { -- struct message *m = va_arg(ap, struct message *); -- -- off += strlen(m->raw); -- -- if (m->upgrade) { -- off -= strlen(m->upgrade); -- -- /* Check the portion of the response after its specified upgrade */ -- if (!check_str_eq(m, "upgrade", body + off, body + nread)) { -- abort(); -- } -- -- /* Fix up the response so that message_eq() will verify the beginning -- * of the upgrade */ -- *(body + nread + strlen(m->upgrade)) = '\0'; -- messages[num_messages -1 ].upgrade = body + nread; -- -- va_end(ap); -- return; -- } -- } -- -- va_end(ap); -- printf("\n\n*** Error: expected a message with upgrade ***\n"); -- -- abort(); --} -- --static void --print_error (const char *raw, size_t error_location) --{ -- fprintf(stderr, "\n*** %s ***\n\n", -- http_errno_description(HTTP_PARSER_ERRNO(parser))); -- -- int this_line = 0, char_len = 0; -- size_t i, j, len = strlen(raw), error_location_line = 0; -- for (i = 0; i < len; i++) { -- if (i == error_location) this_line = 1; -- switch (raw[i]) { -- case '\r': -- char_len = 2; -- fprintf(stderr, "\\r"); -- break; -- -- case '\n': -- fprintf(stderr, "\\n\n"); -- -- if (this_line) goto print; -- -- error_location_line = 0; -- continue; -- -- default: -- char_len = 1; -- fputc(raw[i], stderr); -- break; -- } -- if (!this_line) error_location_line += char_len; -- } -- -- fprintf(stderr, "[eof]\n"); -- -- print: -- for (j = 0; j < error_location_line; j++) { -- fputc(' ', stderr); -- } -- fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location); --} -- --void --test_preserve_data (void) --{ -- char my_data[] = "application-specific data"; -- http_parser parser; -- parser.data = my_data; -- http_parser_init(&parser, HTTP_REQUEST); -- if (parser.data != my_data) { -- printf("\n*** parser.data not preserved accross http_parser_init ***\n\n"); -- abort(); -- } --} -- --struct url_test { -- const char *name; -- const char *url; -- int is_connect; -- struct http_parser_url u; -- int rv; --}; -- --const struct url_test url_tests[] = --{ {.name="proxy request" -- ,.url="http://hostname/" -- ,.is_connect=0 -- ,.u= -- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) -- ,.port=0 -- ,.field_data= -- {{ 0, 4 } /* UF_SCHEMA */ -- ,{ 7, 8 } /* UF_HOST */ -- ,{ 0, 0 } /* UF_PORT */ -- ,{ 15, 1 } /* UF_PATH */ -- ,{ 0, 0 } /* UF_QUERY */ -- ,{ 0, 0 } /* UF_FRAGMENT */ -- ,{ 0, 0 } /* UF_USERINFO */ -- } -- } -- ,.rv=0 -- } -- --, {.name="proxy request with port" -- ,.url="http://hostname:444/" -- ,.is_connect=0 -- ,.u= -- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) -- ,.port=444 -- ,.field_data= -- {{ 0, 4 } /* UF_SCHEMA */ -- ,{ 7, 8 } /* UF_HOST */ -- ,{ 16, 3 } /* UF_PORT */ -- ,{ 19, 1 } /* UF_PATH */ -- ,{ 0, 0 } /* UF_QUERY */ -- ,{ 0, 0 } /* UF_FRAGMENT */ -- ,{ 0, 0 } /* UF_USERINFO */ -- } -- } -- ,.rv=0 -- } -- --, {.name="CONNECT request" -- ,.url="hostname:443" -- ,.is_connect=1 -- ,.u= -- {.field_set=(1 << UF_HOST) | (1 << UF_PORT) -- ,.port=443 -- ,.field_data= -- {{ 0, 0 } /* UF_SCHEMA */ -- ,{ 0, 8 } /* UF_HOST */ -- ,{ 9, 3 } /* UF_PORT */ -- ,{ 0, 0 } /* UF_PATH */ -- ,{ 0, 0 } /* UF_QUERY */ -- ,{ 0, 0 } /* UF_FRAGMENT */ -- ,{ 0, 0 } /* UF_USERINFO */ -- } -- } -- ,.rv=0 -- } -- --, {.name="CONNECT request but not connect" -- ,.url="hostname:443" -- ,.is_connect=0 -- ,.rv=1 -- } -- --, {.name="proxy ipv6 request" -- ,.url="http://[1:2::3:4]/" -- ,.is_connect=0 -- ,.u= -- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) -- ,.port=0 -- ,.field_data= -- {{ 0, 4 } /* UF_SCHEMA */ -- ,{ 8, 8 } /* UF_HOST */ -- ,{ 0, 0 } /* UF_PORT */ -- ,{ 17, 1 } /* UF_PATH */ -- ,{ 0, 0 } /* UF_QUERY */ -- ,{ 0, 0 } /* UF_FRAGMENT */ -- ,{ 0, 0 } /* UF_USERINFO */ -- } -- } -- ,.rv=0 -- } -- --, {.name="proxy ipv6 request with port" -- ,.url="http://[1:2::3:4]:67/" -- ,.is_connect=0 -- ,.u= -- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) -- ,.port=67 -- ,.field_data= -- {{ 0, 4 } /* UF_SCHEMA */ -- ,{ 8, 8 } /* UF_HOST */ -- ,{ 18, 2 } /* UF_PORT */ -- ,{ 20, 1 } /* UF_PATH */ -- ,{ 0, 0 } /* UF_QUERY */ -- ,{ 0, 0 } /* UF_FRAGMENT */ -- ,{ 0, 0 } /* UF_USERINFO */ -- } -- } -- ,.rv=0 -- } -- --, {.name="CONNECT ipv6 address" -- ,.url="[1:2::3:4]:443" -- ,.is_connect=1 -- ,.u= -- {.field_set=(1 << UF_HOST) | (1 << UF_PORT) -- ,.port=443 -- ,.field_data= -- {{ 0, 0 } /* UF_SCHEMA */ -- ,{ 1, 8 } /* UF_HOST */ -- ,{ 11, 3 } /* UF_PORT */ -- ,{ 0, 0 } /* UF_PATH */ -- ,{ 0, 0 } /* UF_QUERY */ -- ,{ 0, 0 } /* UF_FRAGMENT */ -- ,{ 0, 0 } /* UF_USERINFO */ -- } -- } -- ,.rv=0 -- } -- --, {.name="ipv4 in ipv6 address" -- ,.url="http://[2001:0000:0000:0000:0000:0000:1.9.1.1]/" -- ,.is_connect=0 -- ,.u= -- {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) -- ,.port=0 -- ,.field_data= -- {{ 0, 4 } /* UF_SCHEMA */ -- ,{ 8, 37 } /* UF_HOST */ -- ,{ 0, 0 } /* UF_PORT */ -- ,{ 46, 1 } /* UF_PATH */ -- ,{ 0, 0 } /* UF_QUERY */ -- ,{ 0, 0 } /* UF_FRAGMENT */ -- ,{ 0, 0 } /* UF_USERINFO */ -- } -- } -- ,.rv=0 -- } -- --, {.name="extra ? in query string" -- ,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css," -- "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css," -- "fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css" -- ,.is_connect=0 -- ,.u= -- {.field_set=(1<field_set, u->port); -- for (i = 0; i < UF_MAX; i++) { -- if ((u->field_set & (1 << i)) == 0) { -- printf("\tfield_data[%u]: unset\n", i); -- continue; -- } -- -- printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n\"", -- i, -- u->field_data[i].off, -- u->field_data[i].len, -- u->field_data[i].len, -- url + u->field_data[i].off); -- } --} -- --void --test_parse_url (void) --{ -- struct http_parser_url u; -- const struct url_test *test; -- unsigned int i; -- int rv; -- -- for (i = 0; i < (sizeof(url_tests) / sizeof(url_tests[0])); i++) { -- test = &url_tests[i]; -- memset(&u, 0, sizeof(u)); -- -- rv = http_parser_parse_url(test->url, -- strlen(test->url), -- test->is_connect, -- &u); -- -- if (test->rv == 0) { -- if (rv != 0) { -- printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " -- "unexpected rv %d ***\n\n", test->url, test->name, rv); -- abort(); -- } -- -- if (memcmp(&u, &test->u, sizeof(u)) != 0) { -- printf("\n*** http_parser_parse_url(\"%s\") \"%s\" failed ***\n", -- test->url, test->name); -- -- printf("target http_parser_url:\n"); -- dump_url(test->url, &test->u); -- printf("result http_parser_url:\n"); -- dump_url(test->url, &u); -- -- abort(); -- } -- } else { -- /* test->rv != 0 */ -- if (rv == 0) { -- printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " -- "unexpected rv %d ***\n\n", test->url, test->name, rv); -- abort(); -- } -- } -- } --} -- --void --test_method_str (void) --{ -- assert(0 == strcmp("GET", http_method_str(HTTP_GET))); -- assert(0 == strcmp("", http_method_str(1337))); --} -- --void --test_message (const struct message *message) --{ -- size_t raw_len = strlen(message->raw); -- size_t msg1len; -- for (msg1len = 0; msg1len < raw_len; msg1len++) { -- parser_init(message->type); -- -- size_t read; -- const char *msg1 = message->raw; -- const char *msg2 = msg1 + msg1len; -- size_t msg2len = raw_len - msg1len; -- -- if (msg1len) { -- read = parse(msg1, msg1len); -- -- if (message->upgrade && parser->upgrade && num_messages > 0) { -- messages[num_messages - 1].upgrade = msg1 + read; -- goto test; -- } -- -- if (read != msg1len) { -- print_error(msg1, read); -- abort(); -- } -- } -- -- -- read = parse(msg2, msg2len); -- -- if (message->upgrade && parser->upgrade) { -- messages[num_messages - 1].upgrade = msg2 + read; -- goto test; -- } -- -- if (read != msg2len) { -- print_error(msg2, read); -- abort(); -- } -- -- read = parse(NULL, 0); -- -- if (read != 0) { -- print_error(message->raw, read); -- abort(); -- } -- -- test: -- -- if (num_messages != 1) { -- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); -- abort(); -- } -- -- if(!message_eq(0, 0, message)) abort(); -- -- parser_free(); -- } --} -- --void --test_message_count_body (const struct message *message) --{ -- parser_init(message->type); -- -- size_t read; -- size_t l = strlen(message->raw); -- size_t i, toread; -- size_t chunk = 4024; -- -- for (i = 0; i < l; i+= chunk) { -- toread = MIN(l-i, chunk); -- read = parse_count_body(message->raw + i, toread); -- if (read != toread) { -- print_error(message->raw, read); -- abort(); -- } -- } -- -- -- read = parse_count_body(NULL, 0); -- if (read != 0) { -- print_error(message->raw, read); -- abort(); -- } -- -- if (num_messages != 1) { -- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); -- abort(); -- } -- -- if(!message_eq(0, 0, message)) abort(); -- -- parser_free(); --} -- --void --test_simple_type (const char *buf, -- enum http_errno err_expected, -- enum http_parser_type type) --{ -- parser_init(type); -- -- enum http_errno err; -- -- parse(buf, strlen(buf)); -- err = HTTP_PARSER_ERRNO(parser); -- parse(NULL, 0); -- -- parser_free(); -- -- /* In strict mode, allow us to pass with an unexpected HPE_STRICT as -- * long as the caller isn't expecting success. -- */ --#if HTTP_PARSER_STRICT -- if (err_expected != err && err_expected != HPE_OK && err != HPE_STRICT) { --#else -- if (err_expected != err) { --#endif -- fprintf(stderr, "\n*** test_simple expected %s, but saw %s ***\n\n%s\n", -- http_errno_name(err_expected), http_errno_name(err), buf); -- abort(); -- } --} -- --void --test_simple (const char *buf, enum http_errno err_expected) --{ -- test_simple_type(buf, err_expected, HTTP_REQUEST); --} -- --void --test_invalid_header_content (int req, const char* str) --{ -- http_parser parser; -- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); -- size_t parsed; -- const char *buf; -- buf = req ? -- "GET / HTTP/1.1\r\n" : -- "HTTP/1.1 200 OK\r\n"; -- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); -- assert(parsed == strlen(buf)); -- -- buf = str; -- size_t buflen = strlen(buf); -- -- parsed = http_parser_execute(&parser, &settings_null, buf, buflen); -- if (parsed != buflen) { -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN); -- return; -- } -- -- fprintf(stderr, -- "\n*** Error expected but none in invalid header content test ***\n"); -- abort(); --} -- --void --test_invalid_header_field_content_error (int req) --{ -- test_invalid_header_content(req, "Foo: F\01ailure"); -- test_invalid_header_content(req, "Foo: B\02ar"); --} -- --void --test_invalid_header_field (int req, const char* str) --{ -- http_parser parser; -- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); -- size_t parsed; -- const char *buf; -- buf = req ? -- "GET / HTTP/1.1\r\n" : -- "HTTP/1.1 200 OK\r\n"; -- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); -- assert(parsed == strlen(buf)); -- -- buf = str; -- size_t buflen = strlen(buf); -- -- parsed = http_parser_execute(&parser, &settings_null, buf, buflen); -- if (parsed != buflen) { -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN); -- return; -- } -- -- fprintf(stderr, -- "\n*** Error expected but none in invalid header token test ***\n"); -- abort(); --} -- --void --test_invalid_header_field_token_error (int req) --{ -- test_invalid_header_field(req, "Fo@: Failure"); -- test_invalid_header_field(req, "Foo\01\test: Bar"); --} -- --void --test_double_content_length_error (int req) --{ -- http_parser parser; -- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); -- size_t parsed; -- const char *buf; -- buf = req ? -- "GET / HTTP/1.1\r\n" : -- "HTTP/1.1 200 OK\r\n"; -- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); -- assert(parsed == strlen(buf)); -- -- buf = "Content-Length: 0\r\nContent-Length: 1\r\n\r\n"; -- size_t buflen = strlen(buf); -- -- parsed = http_parser_execute(&parser, &settings_null, buf, buflen); -- if (parsed != buflen) { -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH); -- return; -- } -- -- fprintf(stderr, -- "\n*** Error expected but none in double content-length test ***\n"); -- abort(); --} -- --void --test_chunked_content_length_error (int req) --{ -- http_parser parser; -- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); -- size_t parsed; -- const char *buf; -- buf = req ? -- "GET / HTTP/1.1\r\n" : -- "HTTP/1.1 200 OK\r\n"; -- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); -- assert(parsed == strlen(buf)); -- -- buf = "Transfer-Encoding: chunked\r\nContent-Length: 1\r\n\r\n"; -- size_t buflen = strlen(buf); -- -- parsed = http_parser_execute(&parser, &settings_null, buf, buflen); -- if (parsed != buflen) { -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH); -- return; -- } -- -- fprintf(stderr, -- "\n*** Error expected but none in chunked content-length test ***\n"); -- abort(); --} -- --void --test_header_cr_no_lf_error (int req) --{ -- http_parser parser; -- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); -- size_t parsed; -- const char *buf; -- buf = req ? -- "GET / HTTP/1.1\r\n" : -- "HTTP/1.1 200 OK\r\n"; -- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); -- assert(parsed == strlen(buf)); -- -- buf = "Foo: 1\rBar: 1\r\n\r\n"; -- size_t buflen = strlen(buf); -- -- parsed = http_parser_execute(&parser, &settings_null, buf, buflen); -- if (parsed != buflen) { -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_LF_EXPECTED); -- return; -- } -- -- fprintf(stderr, -- "\n*** Error expected but none in header whitespace test ***\n"); -- abort(); --} -- --void --test_no_overflow_parse_url (void) --{ -- int rv; -- struct http_parser_url u; -- -- http_parser_url_init(&u); -- rv = http_parser_parse_url("http://example.com:8001", 22, 0, &u); -- -- if (rv != 0) { -- fprintf(stderr, -- "\n*** test_no_overflow_parse_url invalid return value=%d\n", -- rv); -- abort(); -- } -- -- if (u.port != 800) { -- fprintf(stderr, -- "\n*** test_no_overflow_parse_url invalid port number=%d\n", -- u.port); -- abort(); -- } --} -- --void --test_header_overflow_error (int req) --{ -- http_parser parser; -- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); -- size_t parsed; -- const char *buf; -- buf = req ? "GET / HTTP/1.1\r\n" : "HTTP/1.0 200 OK\r\n"; -- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); -- assert(parsed == strlen(buf)); -- -- buf = "header-key: header-value\r\n"; -- size_t buflen = strlen(buf); -- -- int i; -- for (i = 0; i < 10000; i++) { -- parsed = http_parser_execute(&parser, &settings_null, buf, buflen); -- if (parsed != buflen) { -- //fprintf(stderr, "error found on iter %d\n", i); -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_HEADER_OVERFLOW); -- return; -- } -- } -- -- fprintf(stderr, "\n*** Error expected but none in header overflow test ***\n"); -- abort(); --} -- -- --void --test_header_nread_value () --{ -- http_parser parser; -- http_parser_init(&parser, HTTP_REQUEST); -- size_t parsed; -- const char *buf; -- buf = "GET / HTTP/1.1\r\nheader: value\nhdr: value\r\n"; -- parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); -- assert(parsed == strlen(buf)); -- -- assert(parser.nread == strlen(buf)); --} -- -- --static void --test_content_length_overflow (const char *buf, size_t buflen, int expect_ok) --{ -- http_parser parser; -- http_parser_init(&parser, HTTP_RESPONSE); -- http_parser_execute(&parser, &settings_null, buf, buflen); -- -- if (expect_ok) -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_OK); -- else -- assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_CONTENT_LENGTH); --} -- --void --test_header_content_length_overflow_error (void) --{ --#define X(size) \ -- "HTTP/1.1 200 OK\r\n" \ -- "Content-Length: " #size "\r\n" \ -- "\r\n" -- const char a[] = X(1844674407370955160); /* 2^64 / 10 - 1 */ -- const char b[] = X(18446744073709551615); /* 2^64-1 */ -- const char c[] = X(18446744073709551616); /* 2^64 */ --#undef X -- test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ -- test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ -- test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ --} -- --void --test_chunk_content_length_overflow_error (void) --{ --#define X(size) \ -- "HTTP/1.1 200 OK\r\n" \ -- "Transfer-Encoding: chunked\r\n" \ -- "\r\n" \ -- #size "\r\n" \ -- "..." -- const char a[] = X(FFFFFFFFFFFFFFE); /* 2^64 / 16 - 1 */ -- const char b[] = X(FFFFFFFFFFFFFFFF); /* 2^64-1 */ -- const char c[] = X(10000000000000000); /* 2^64 */ --#undef X -- test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ -- test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ -- test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ --} -- --void --test_no_overflow_long_body (int req, size_t length) --{ -- http_parser parser; -- http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); -- size_t parsed; -- size_t i; -- char buf1[3000]; -- size_t buf1len = sprintf(buf1, "%s\r\nConnection: Keep-Alive\r\nContent-Length: %lu\r\n\r\n", -- req ? "POST / HTTP/1.0" : "HTTP/1.0 200 OK", (unsigned long)length); -- parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); -- if (parsed != buf1len) -- goto err; -- -- for (i = 0; i < length; i++) { -- char foo = 'a'; -- parsed = http_parser_execute(&parser, &settings_null, &foo, 1); -- if (parsed != 1) -- goto err; -- } -- -- parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); -- if (parsed != buf1len) goto err; -- return; -- -- err: -- fprintf(stderr, -- "\n*** error in test_no_overflow_long_body %s of length %lu ***\n", -- req ? "REQUEST" : "RESPONSE", -- (unsigned long)length); -- abort(); --} -- --void --test_multiple3 (const struct message *r1, const struct message *r2, const struct message *r3) --{ -- int message_count = count_parsed_messages(3, r1, r2, r3); -- -- char total[ strlen(r1->raw) -- + strlen(r2->raw) -- + strlen(r3->raw) -- + 1 -- ]; -- total[0] = '\0'; -- -- strcat(total, r1->raw); -- strcat(total, r2->raw); -- strcat(total, r3->raw); -- -- parser_init(r1->type); -- -- size_t read; -- -- read = parse(total, strlen(total)); -- -- if (parser->upgrade) { -- upgrade_message_fix(total, read, 3, r1, r2, r3); -- goto test; -- } -- -- if (read != strlen(total)) { -- print_error(total, read); -- abort(); -- } -- -- read = parse(NULL, 0); -- -- if (read != 0) { -- print_error(total, read); -- abort(); -- } -- --test: -- -- if (message_count != num_messages) { -- fprintf(stderr, "\n\n*** Parser didn't see 3 messages only %d *** \n", num_messages); -- abort(); -- } -- -- if (!message_eq(0, 0, r1)) abort(); -- if (message_count > 1 && !message_eq(1, 0, r2)) abort(); -- if (message_count > 2 && !message_eq(2, 0, r3)) abort(); -- -- parser_free(); --} -- --/* SCAN through every possible breaking to make sure the -- * parser can handle getting the content in any chunks that -- * might come from the socket -- */ --void --test_scan (const struct message *r1, const struct message *r2, const struct message *r3) --{ -- char total[80*1024] = "\0"; -- char buf1[80*1024] = "\0"; -- char buf2[80*1024] = "\0"; -- char buf3[80*1024] = "\0"; -- -- strcat(total, r1->raw); -- strcat(total, r2->raw); -- strcat(total, r3->raw); -- -- size_t read; -- -- int total_len = strlen(total); -- -- int total_ops = 2 * (total_len - 1) * (total_len - 2) / 2; -- int ops = 0 ; -- -- size_t buf1_len, buf2_len, buf3_len; -- int message_count = count_parsed_messages(3, r1, r2, r3); -- -- int i,j,type_both; -- for (type_both = 0; type_both < 2; type_both ++ ) { -- for (j = 2; j < total_len; j ++ ) { -- for (i = 1; i < j; i ++ ) { -- -- if (ops % 1000 == 0) { -- printf("\b\b\b\b%3.0f%%", 100 * (float)ops /(float)total_ops); -- fflush(stdout); -- } -- ops += 1; -- -- parser_init(type_both ? HTTP_BOTH : r1->type); -- -- buf1_len = i; -- strlncpy(buf1, sizeof(buf1), total, buf1_len); -- buf1[buf1_len] = 0; -- -- buf2_len = j - i; -- strlncpy(buf2, sizeof(buf1), total+i, buf2_len); -- buf2[buf2_len] = 0; -- -- buf3_len = total_len - j; -- strlncpy(buf3, sizeof(buf1), total+j, buf3_len); -- buf3[buf3_len] = 0; -- -- read = parse(buf1, buf1_len); -- -- if (parser->upgrade) goto test; -- -- if (read != buf1_len) { -- print_error(buf1, read); -- goto error; -- } -- -- read += parse(buf2, buf2_len); -- -- if (parser->upgrade) goto test; -- -- if (read != buf1_len + buf2_len) { -- print_error(buf2, read); -- goto error; -- } -- -- read += parse(buf3, buf3_len); -- -- if (parser->upgrade) goto test; -- -- if (read != buf1_len + buf2_len + buf3_len) { -- print_error(buf3, read); -- goto error; -- } -- -- parse(NULL, 0); -- --test: -- if (parser->upgrade) { -- upgrade_message_fix(total, read, 3, r1, r2, r3); -- } -- -- if (message_count != num_messages) { -- fprintf(stderr, "\n\nParser didn't see %d messages only %d\n", -- message_count, num_messages); -- goto error; -- } -- -- if (!message_eq(0, 0, r1)) { -- fprintf(stderr, "\n\nError matching messages[0] in test_scan.\n"); -- goto error; -- } -- -- if (message_count > 1 && !message_eq(1, 0, r2)) { -- fprintf(stderr, "\n\nError matching messages[1] in test_scan.\n"); -- goto error; -- } -- -- if (message_count > 2 && !message_eq(2, 0, r3)) { -- fprintf(stderr, "\n\nError matching messages[2] in test_scan.\n"); -- goto error; -- } -- -- parser_free(); -- } -- } -- } -- puts("\b\b\b\b100%"); -- return; -- -- error: -- fprintf(stderr, "i=%d j=%d\n", i, j); -- fprintf(stderr, "buf1 (%u) %s\n\n", (unsigned int)buf1_len, buf1); -- fprintf(stderr, "buf2 (%u) %s\n\n", (unsigned int)buf2_len , buf2); -- fprintf(stderr, "buf3 (%u) %s\n", (unsigned int)buf3_len, buf3); -- abort(); --} -- --// user required to free the result --// string terminated by \0 --char * --create_large_chunked_message (int body_size_in_kb, const char* headers) --{ -- int i; -- size_t wrote = 0; -- size_t headers_len = strlen(headers); -- size_t bufsize = headers_len + (5+1024+2)*body_size_in_kb + 6; -- char * buf = malloc(bufsize); -- -- memcpy(buf, headers, headers_len); -- wrote += headers_len; -- -- for (i = 0; i < body_size_in_kb; i++) { -- // write 1kb chunk into the body. -- memcpy(buf + wrote, "400\r\n", 5); -- wrote += 5; -- memset(buf + wrote, 'C', 1024); -- wrote += 1024; -- strcpy(buf + wrote, "\r\n"); -- wrote += 2; -- } -- -- memcpy(buf + wrote, "0\r\n\r\n", 6); -- wrote += 6; -- assert(wrote == bufsize); -- -- return buf; --} -- --/* Verify that we can pause parsing at any of the bytes in the -- * message and still get the result that we're expecting. */ --void --test_message_pause (const struct message *msg) --{ -- char *buf = (char*) msg->raw; -- size_t buflen = strlen(msg->raw); -- size_t nread; -- -- parser_init(msg->type); -- -- do { -- nread = parse_pause(buf, buflen); -- -- // We can only set the upgrade buffer once we've gotten our message -- // completion callback. -- if (messages[0].message_complete_cb_called && -- msg->upgrade && -- parser->upgrade) { -- messages[0].upgrade = buf + nread; -- goto test; -- } -- -- if (nread < buflen) { -- -- // Not much do to if we failed a strict-mode check -- if (HTTP_PARSER_ERRNO(parser) == HPE_STRICT) { -- parser_free(); -- return; -- } -- -- assert (HTTP_PARSER_ERRNO(parser) == HPE_PAUSED); -- } -- -- buf += nread; -- buflen -= nread; -- http_parser_pause(parser, 0); -- } while (buflen > 0); -- -- nread = parse_pause(NULL, 0); -- assert (nread == 0); -- --test: -- if (num_messages != 1) { -- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); -- abort(); -- } -- -- if(!message_eq(0, 0, msg)) abort(); -- -- parser_free(); --} -- --/* Verify that body and next message won't be parsed in responses to CONNECT */ --void --test_message_connect (const struct message *msg) --{ -- char *buf = (char*) msg->raw; -- size_t buflen = strlen(msg->raw); -- -- parser_init(msg->type); -- -- parse_connect(buf, buflen); -- -- if (num_messages != 1) { -- printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); -- abort(); -- } -- -- if(!message_eq(0, 1, msg)) abort(); -- -- parser_free(); --} -- --int --main (void) --{ -- parser = NULL; -- int i, j, k; -- int request_count; -- int response_count; -- unsigned long version; -- unsigned major; -- unsigned minor; -- unsigned patch; -- -- version = http_parser_version(); -- major = (version >> 16) & 255; -- minor = (version >> 8) & 255; -- patch = version & 255; -- printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version); -- -- printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser)); -- -- for (request_count = 0; requests[request_count].name; request_count++); -- for (response_count = 0; responses[response_count].name; response_count++); -- -- //// API -- test_preserve_data(); -- test_parse_url(); -- test_method_str(); -- -- //// NREAD -- test_header_nread_value(); -- -- //// OVERFLOW CONDITIONS -- test_no_overflow_parse_url(); -- -- test_header_overflow_error(HTTP_REQUEST); -- test_no_overflow_long_body(HTTP_REQUEST, 1000); -- test_no_overflow_long_body(HTTP_REQUEST, 100000); -- -- test_header_overflow_error(HTTP_RESPONSE); -- test_no_overflow_long_body(HTTP_RESPONSE, 1000); -- test_no_overflow_long_body(HTTP_RESPONSE, 100000); -- -- test_header_content_length_overflow_error(); -- test_chunk_content_length_overflow_error(); -- -- //// HEADER FIELD CONDITIONS -- test_double_content_length_error(HTTP_REQUEST); -- test_chunked_content_length_error(HTTP_REQUEST); -- test_header_cr_no_lf_error(HTTP_REQUEST); -- test_invalid_header_field_token_error(HTTP_REQUEST); -- test_invalid_header_field_content_error(HTTP_REQUEST); -- test_double_content_length_error(HTTP_RESPONSE); -- test_chunked_content_length_error(HTTP_RESPONSE); -- test_header_cr_no_lf_error(HTTP_RESPONSE); -- test_invalid_header_field_token_error(HTTP_RESPONSE); -- test_invalid_header_field_content_error(HTTP_RESPONSE); -- -- //// RESPONSES -- -- test_simple_type("HTP/1.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); -- test_simple_type("HTTP/01.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); -- test_simple_type("HTTP/11.1 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); -- test_simple_type("HTTP/1.01 200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); -- test_simple_type("HTTP/1.1\t200 OK\r\n\r\n", HPE_INVALID_VERSION, HTTP_RESPONSE); -- -- for (i = 0; i < response_count; i++) { -- test_message(&responses[i]); -- } -- -- for (i = 0; i < response_count; i++) { -- test_message_pause(&responses[i]); -- } -- -- for (i = 0; i < response_count; i++) { -- test_message_connect(&responses[i]); -- } -- -- for (i = 0; i < response_count; i++) { -- if (!responses[i].should_keep_alive) continue; -- for (j = 0; j < response_count; j++) { -- if (!responses[j].should_keep_alive) continue; -- for (k = 0; k < response_count; k++) { -- test_multiple3(&responses[i], &responses[j], &responses[k]); -- } -- } -- } -- -- test_message_count_body(&responses[NO_HEADERS_NO_BODY_404]); -- test_message_count_body(&responses[TRAILING_SPACE_ON_CHUNKED_BODY]); -- -- // test very large chunked response -- { -- char * msg = create_large_chunked_message(31337, -- "HTTP/1.0 200 OK\r\n" -- "Transfer-Encoding: chunked\r\n" -- "Content-Type: text/plain\r\n" -- "\r\n"); -- struct message large_chunked = -- {.name= "large chunked" -- ,.type= HTTP_RESPONSE -- ,.raw= msg -- ,.should_keep_alive= FALSE -- ,.message_complete_on_eof= FALSE -- ,.http_major= 1 -- ,.http_minor= 0 -- ,.status_code= 200 -- ,.response_status= "OK" -- ,.num_headers= 2 -- ,.headers= -- { { "Transfer-Encoding", "chunked" } -- , { "Content-Type", "text/plain" } -- } -- ,.body_size= 31337*1024 -- ,.num_chunks_complete= 31338 -- }; -- for (i = 0; i < MAX_CHUNKS; i++) { -- large_chunked.chunk_lengths[i] = 1024; -- } -- test_message_count_body(&large_chunked); -- free(msg); -- } -- -- -- -- printf("response scan 1/2 "); -- test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY] -- , &responses[NO_BODY_HTTP10_KA_204] -- , &responses[NO_REASON_PHRASE] -- ); -- -- printf("response scan 2/2 "); -- test_scan( &responses[BONJOUR_MADAME_FR] -- , &responses[UNDERSTORE_HEADER_KEY] -- , &responses[NO_CARRIAGE_RET] -- ); -- -- puts("responses okay"); -- -- -- /// REQUESTS -- -- test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION); -- test_simple("GET / HTTP/01.1\r\n\r\n", HPE_INVALID_VERSION); -- test_simple("GET / HTTP/11.1\r\n\r\n", HPE_INVALID_VERSION); -- test_simple("GET / HTTP/1.01\r\n\r\n", HPE_INVALID_VERSION); -- -- // Extended characters - see nodejs/test/parallel/test-http-headers-obstext.js -- test_simple("GET / HTTP/1.1\r\n" -- "Test: Düsseldorf\r\n", -- HPE_OK); -- -- // Well-formed but incomplete -- test_simple("GET / HTTP/1.1\r\n" -- "Content-Type: text/plain\r\n" -- "Content-Length: 6\r\n" -- "\r\n" -- "fooba", -- HPE_OK); -- -- static const char *all_methods[] = { -- "DELETE", -- "GET", -- "HEAD", -- "POST", -- "PUT", -- //"CONNECT", //CONNECT can't be tested like other methods, it's a tunnel -- "OPTIONS", -- "TRACE", -- "COPY", -- "LOCK", -- "MKCOL", -- "MOVE", -- "PROPFIND", -- "PROPPATCH", -- "SEARCH", -- "UNLOCK", -- "BIND", -- "REBIND", -- "UNBIND", -- "ACL", -- "REPORT", -- "MKACTIVITY", -- "CHECKOUT", -- "MERGE", -- "M-SEARCH", -- "NOTIFY", -- "SUBSCRIBE", -- "UNSUBSCRIBE", -- "PATCH", -- "PURGE", -- "MKCALENDAR", -- "LINK", -- "UNLINK", -- 0 }; -- const char **this_method; -- for (this_method = all_methods; *this_method; this_method++) { -- char buf[200]; -- sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); -- test_simple(buf, HPE_OK); -- } -- -- static const char *bad_methods[] = { -- "ASDF", -- "C******", -- "COLA", -- "GEM", -- "GETA", -- "M****", -- "MKCOLA", -- "PROPPATCHA", -- "PUN", -- "PX", -- "SA", -- "hello world", -- 0 }; -- for (this_method = bad_methods; *this_method; this_method++) { -- char buf[200]; -- sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); -- test_simple(buf, HPE_INVALID_METHOD); -- } -- -- // illegal header field name line folding -- test_simple("GET / HTTP/1.1\r\n" -- "name\r\n" -- " : value\r\n" -- "\r\n", -- HPE_INVALID_HEADER_TOKEN); -- -- const char *dumbfuck2 = -- "GET / HTTP/1.1\r\n" -- "X-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n" -- "\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n" -- "\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n" -- "\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n" -- "\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n" -- "\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n" -- "\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n" -- "\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n" -- "\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n" -- "\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n" -- "\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n" -- "\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\r\n" -- "\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\r\n" -- "\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgHTTPAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\r\n" -- "\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\r\n" -- "\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\r\n" -- "\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\r\n" -- "\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\r\n" -- "\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\r\n" -- "\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\r\n" -- "\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\r\n" -- "\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\r\n" -- "\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\r\n" -- "\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\r\n" -- "\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\r\n" -- "\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\r\n" -- "\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n" -- "\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n" -- "\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n" -- "\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n" -- "\tRA==\r\n" -- "\t-----END CERTIFICATE-----\r\n" -- "\r\n"; -- test_simple(dumbfuck2, HPE_OK); -- -- const char *corrupted_connection = -- "GET / HTTP/1.1\r\n" -- "Host: www.example.com\r\n" -- "Connection\r\033\065\325eep-Alive\r\n" -- "Accept-Encoding: gzip\r\n" -- "\r\n"; -- test_simple(corrupted_connection, HPE_INVALID_HEADER_TOKEN); -- -- const char *corrupted_header_name = -- "GET / HTTP/1.1\r\n" -- "Host: www.example.com\r\n" -- "X-Some-Header\r\033\065\325eep-Alive\r\n" -- "Accept-Encoding: gzip\r\n" -- "\r\n"; -- test_simple(corrupted_header_name, HPE_INVALID_HEADER_TOKEN); -- --#if 0 -- // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body -- // until EOF. -- // -- // no content-length -- // error if there is a body without content length -- const char *bad_get_no_headers_no_body = "GET /bad_get_no_headers_no_body/world HTTP/1.1\r\n" -- "Accept: */*\r\n" -- "\r\n" -- "HELLO"; -- test_simple(bad_get_no_headers_no_body, 0); --#endif -- /* TODO sending junk and large headers gets rejected */ -- -- -- /* check to make sure our predefined requests are okay */ -- for (i = 0; requests[i].name; i++) { -- test_message(&requests[i]); -- } -- -- for (i = 0; i < request_count; i++) { -- test_message_pause(&requests[i]); -- } -- -- for (i = 0; i < request_count; i++) { -- if (!requests[i].should_keep_alive) continue; -- for (j = 0; j < request_count; j++) { -- if (!requests[j].should_keep_alive) continue; -- for (k = 0; k < request_count; k++) { -- test_multiple3(&requests[i], &requests[j], &requests[k]); -- } -- } -- } -- -- printf("request scan 1/4 "); -- test_scan( &requests[GET_NO_HEADERS_NO_BODY] -- , &requests[GET_ONE_HEADER_NO_BODY] -- , &requests[GET_NO_HEADERS_NO_BODY] -- ); -- -- printf("request scan 2/4 "); -- test_scan( &requests[POST_CHUNKED_ALL_YOUR_BASE] -- , &requests[POST_IDENTITY_BODY_WORLD] -- , &requests[GET_FUNKY_CONTENT_LENGTH] -- ); -- -- printf("request scan 3/4 "); -- test_scan( &requests[TWO_CHUNKS_MULT_ZERO_END] -- , &requests[CHUNKED_W_TRAILING_HEADERS] -- , &requests[CHUNKED_W_BULLSHIT_AFTER_LENGTH] -- ); -- -- printf("request scan 4/4 "); -- test_scan( &requests[QUERY_URL_WITH_QUESTION_MARK_GET] -- , &requests[PREFIX_NEWLINE_GET ] -- , &requests[CONNECT_REQUEST] -- ); -- -- puts("requests okay"); -- -- return 0; --} diff --git a/Sming/Components/spiffs/component.mk b/Sming/Components/spiffs/component.mk new file mode 100644 index 0000000000..e3d1b3087f --- /dev/null +++ b/Sming/Components/spiffs/component.mk @@ -0,0 +1,68 @@ +## SPIFFS library +COMPONENT_SUBMODULES := spiffs +COMPONENT_SRCDIRS := . spiffs/src +COMPONENT_INCDIRS := . spiffs/src + + +## Spiffy tool + +SPIFFY := $(TOOLS_BASE)/spiffy$(TOOL_EXT) +COMPONENT_TARGETS += $(SPIFFY) +$(COMPONENT_RULE)$(SPIFFY): + $(call MakeTarget,spiffy/Makefile) + + +## Application + +# This controls filesystem generation, it doesn't actually disable SPIFFS support in the application +CACHE_VARS += DISABLE_SPIFFS +DISABLE_SPIFFS ?= 0 + +CACHE_VARS += SPIFF_FILES SPIFF_BIN +SPIFF_FILES ?= files +SPIFF_BIN ?= spiff_rom +SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN).bin +CUSTOM_TARGETS += $(SPIFF_BIN_OUT) + +CONFIG_VARS += SPIFF_SIZE +ifeq ($(SPI_SIZE), 256K) + SPIFF_SIZE ?= 131072 #128K +else ifeq ($(SPI_SIZE), 1M) + SPIFF_SIZE ?= 524288 #512K +else ifeq ($(SPI_SIZE), 2M) + SPIFF_SIZE ?= 524288 #512K +else ifeq ($(SPI_SIZE), 4M) + SPIFF_SIZE ?= 524288 #512K +else + SPIFF_SIZE ?= 196608 #192K +endif +APP_CFLAGS += -DSPIFF_SIZE=$(SPIFF_SIZE) + +##@Building + +.PHONY: spiffs-image-update +spiffs-image-update: spiffs-image-clean $(SPIFF_BIN_OUT) ##Rebuild the SPIFFS filesystem image + +##@Cleaning + +.PHONY: spiffs-image-clean +spiffs-image-clean: ##Remove SPIFFS image file + $(info Cleaning $(SPIFF_BIN_OUT)) + $(Q) rm -f $(SPIFF_BIN_OUT) + +# Generating spiffs_bin +$(SPIFF_BIN_OUT): $(SPIFFY) +ifeq ($(DISABLE_SPIFFS), 1) + $(info (!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs.) +else + $(Q) mkdir -p $(dir $(SPIFF_BIN_OUT)) + $(info Checking for spiffs files) + $(Q) if [ -d "$(SPIFF_FILES)" ]; then \ + echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \ + $(SPIFFY) $(SPIFF_SIZE) $(SPIFF_FILES) $(SPIFF_BIN_OUT); \ + else \ + echo "No files found in ./$(SPIFF_FILES)."; \ + echo "Creating empty $(SPIFF_BIN_OUT)"; \ + $(SPIFFY) $(SPIFF_SIZE) dummy.dir $(SPIFF_BIN_OUT); \ + fi +endif diff --git a/Sming/Components/spiffs b/Sming/Components/spiffs/spiffs similarity index 100% rename from Sming/Components/spiffs rename to Sming/Components/spiffs/spiffs diff --git a/Sming/Components/.patches/spiffs.patch b/Sming/Components/spiffs/spiffs.patch similarity index 100% rename from Sming/Components/.patches/spiffs.patch rename to Sming/Components/spiffs/spiffs.patch diff --git a/Sming/Arch/Esp8266/Components/spiffs/spiffs_config.h b/Sming/Components/spiffs/spiffs_config.h similarity index 100% rename from Sming/Arch/Esp8266/Components/spiffs/spiffs_config.h rename to Sming/Components/spiffs/spiffs_config.h diff --git a/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.c b/Sming/Components/spiffs/spiffs_sming.c similarity index 100% rename from Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.c rename to Sming/Components/spiffs/spiffs_sming.c diff --git a/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h b/Sming/Components/spiffs/spiffs_sming.h similarity index 100% rename from Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h rename to Sming/Components/spiffs/spiffs_sming.h diff --git a/Sming/Arch/Esp8266/Tools/spiffy/Makefile b/Sming/Components/spiffs/spiffy/Makefile similarity index 88% rename from Sming/Arch/Esp8266/Tools/spiffy/Makefile rename to Sming/Components/spiffs/spiffy/Makefile index e2a8bf7073..b830ed7ce4 100644 --- a/Sming/Arch/Esp8266/Tools/spiffy/Makefile +++ b/Sming/Components/spiffs/spiffy/Makefile @@ -7,7 +7,7 @@ HOST_CC ?= gcc HOST_LD ?= gcc -INCDIR := -I$(SPIFFS_SMING) -I$(SPIFFS_BASE)/src +INCDIR := -I.. -I../spiffs/src CFLAGS := -O2 -Wall -Wno-unused-value ifeq ("$(V)","1") @@ -25,7 +25,7 @@ OBJS := $(addprefix $(BUILD_DIR)/,spiffy.o spiffs_cache.o spiffs_nucleus.o spiff all: $(TARGET) -$(BUILD_DIR)/%.o: $(SPIFFS_BASE)/src/%.c +$(BUILD_DIR)/%.o: ../spiffs/src/%.c $(vecho) "CC $<" $(Q) $(HOST_CC) $(CFLAGS) $(INCDIR) -c $< -o $@ diff --git a/Sming/Arch/Esp8266/Tools/spiffy/spiffy.c b/Sming/Components/spiffs/spiffy/spiffy.c similarity index 95% rename from Sming/Arch/Esp8266/Tools/spiffy/spiffy.c rename to Sming/Components/spiffs/spiffy/spiffy.c index cfc25d3cf0..485e4a87c5 100644 --- a/Sming/Arch/Esp8266/Tools/spiffy/spiffy.c +++ b/Sming/Components/spiffs/spiffy/spiffy.c @@ -18,7 +18,7 @@ static u8_t spiffs_work_buf[LOG_PAGE_SIZE*2]; static u8_t spiffs_fds[32*4]; static u8_t spiffs_cache_buf[(LOG_PAGE_SIZE+32)*4]; -#define S_DBG +#define S_DBG(fmt, ...) //#define S_DBG printf static FILE *rom = 0; @@ -150,9 +150,8 @@ int my_spiffs_format() { int write_to_spiffs(char *fname, u8_t *data, int size) { int ret = 0; - spiffs_file fd = -1; - fd = SPIFFS_open(&fs, fname, SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0); + spiffs_file fd = SPIFFS_open(&fs, fname, SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0); if (fd < 0) { printf("Unable to open spiffs file '%s', error %d.\n", fname, fd); } else { @@ -174,7 +173,6 @@ int write_to_spiffs(char *fname, u8_t *data, int size) { int add_file(const char* fdir, char* fname) { int ret = 0; - int size; u8_t *buff = 0; FILE *fp = 0; char *path = 0; @@ -192,7 +190,7 @@ int add_file(const char* fdir, char* fname) { if (!fp) { S_DBG("Unable to open '%s'.\n", fname); } else { - size = (int)st.st_size; + int size = (int)st.st_size; buff = malloc(size); if (!buff) { printf("Unable to malloc %d bytes.\n", size); @@ -238,7 +236,7 @@ int main(int argc, char **argv) { const char *folder; const char *romfile; int romsize; - int res, ret = EXIT_SUCCESS; + int ret = EXIT_SUCCESS; if (argc == 1) { romsize = DEFAULT_ROM_SIZE; @@ -279,10 +277,11 @@ int main(int argc, char **argv) { my_spiffs_unmount(); } - if ((res = my_spiffs_format())) { + int res; + if ((res = my_spiffs_format()) != SPIFFS_OK) { printf("Failed to format spiffs, error %d.\n", res); ret = EXIT_FAILURE; - } else if ((res = my_spiffs_mount(romsize))) { + } else if ((res = my_spiffs_mount(romsize)) != SPIFFS_OK) { printf("Failed to mount spiffs, error %d.\n", res); ret = EXIT_FAILURE; } else { diff --git a/Sming/Components/spiffs/spiffy_host.h b/Sming/Components/spiffs/spiffy_host.h new file mode 100644 index 0000000000..f621ef6557 --- /dev/null +++ b/Sming/Components/spiffs/spiffy_host.h @@ -0,0 +1,16 @@ + +#pragma once + +#include +#include +#include +#include +#include +#include + +typedef signed int s32_t; +typedef unsigned int u32_t; +typedef signed short s16_t; +typedef unsigned short u16_t; +typedef signed char s8_t; +typedef unsigned char u8_t; diff --git a/Sming/Components/terminal/component.mk b/Sming/Components/terminal/component.mk new file mode 100644 index 0000000000..edd5263f04 --- /dev/null +++ b/Sming/Components/terminal/component.mk @@ -0,0 +1,34 @@ +COMPONENT_LIBNAME := + +# Default COM port +CACHE_VARS += COM_PORT +ifeq ($(UNAME),FreeBSD) +COM_PORT ?= /dev/cuaU0 +else ifeq ($(UNAME),MacOS) +COM_PORT ?= /dev/tty.usbserial +else ifeq ($(UNAME),Linux) +COM_PORT ?= /dev/ttyUSB0 +else ifeq ($(UNAME),Windows) +COM_PORT ?= COM3 +endif + + +# Universal python terminal application +KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 +TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) + +# Alternative for Windows +#KILL_TERM ?= taskkill.exe -f -im Terminal.exe || exit 0 +#TERMINAL ?= $(SDK_TOOLS)/Terminal.exe $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) + + +##@Tools + +.PHONY: kill_term +kill_term: + $(info Killing Terminal to free $(COM_PORT)) + -$(Q) $(KILL_TERM) + +.PHONY: terminal +terminal: kill_term ##Open the serial terminal + $(TERMINAL) diff --git a/Sming/Libraries/Adafruit_ILI9341/component.mk b/Sming/Libraries/Adafruit_ILI9341/component.mk new file mode 100644 index 0000000000..4425b0c79b --- /dev/null +++ b/Sming/Libraries/Adafruit_ILI9341/component.mk @@ -0,0 +1 @@ +COMPONENT_DEPENDS := Adafruit_GFX \ No newline at end of file diff --git a/Sming/Libraries/Adafruit_PCD8544/component.mk b/Sming/Libraries/Adafruit_PCD8544/component.mk new file mode 100644 index 0000000000..f2997c2408 --- /dev/null +++ b/Sming/Libraries/Adafruit_PCD8544/component.mk @@ -0,0 +1 @@ +COMPONENT_DEPENDS := Adafruit_GFX diff --git a/Sming/Libraries/DS18S20/component.mk b/Sming/Libraries/DS18S20/component.mk new file mode 100644 index 0000000000..c2b836534a --- /dev/null +++ b/Sming/Libraries/DS18S20/component.mk @@ -0,0 +1 @@ +COMPONENT_DEPENDS := OneWire diff --git a/Sming/Libraries/HMC5883L/component.mk b/Sming/Libraries/HMC5883L/component.mk new file mode 100644 index 0000000000..725f8abd75 --- /dev/null +++ b/Sming/Libraries/HMC5883L/component.mk @@ -0,0 +1 @@ +COMPONENT_DEPENDS := I2Cdev diff --git a/Sming/Libraries/TFT_ILI9163C/component.mk b/Sming/Libraries/TFT_ILI9163C/component.mk new file mode 100644 index 0000000000..f2997c2408 --- /dev/null +++ b/Sming/Libraries/TFT_ILI9163C/component.mk @@ -0,0 +1 @@ +COMPONENT_DEPENDS := Adafruit_GFX diff --git a/Sming/Libraries/components.mk b/Sming/Libraries/components.mk new file mode 100644 index 0000000000..aba8b774b7 --- /dev/null +++ b/Sming/Libraries/components.mk @@ -0,0 +1,6 @@ +# Define dependencies between Arduino Libraries which are submodules +CMP_Adafruit_BME280_Library_DEPENDS := Adafruit_Sensor +CMP_Adafruit_SSD1306_DEPENDS := Adafruit_GFX +CMP_Adafruit_ST7735_DEPENDS := Adafruit_GFX +CMP_HMC5883L_DEPENDS := I2Cdev +CMP_IR_DEPENDS := RingBufCPP diff --git a/Sming/Makefile b/Sming/Makefile index 4a50011ddf..26bb7ee471 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -7,158 +7,44 @@ # ############################################################# -ifndef SMING_HOME -$(error SMING_HOME variable is not set to a valid directory.) -endif - -## Defaults for Sming Core +.NOTPARALLEL: -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming +# Make sure we're not pointing into a different Sming repo +override SMING_HOME := $(CURDIR) -# MacOS / Linux -# SMING_HOME = /opt/esp-open-sdk - -##@Building +include build.mk .PHONY: all -all: checkdirs libsming tools ##(default) Build the Sming library, user libraries, Arduino libraries and tools - -include $(SMING_HOME)/build.mk - -# name for the target project -TARGET := lib$(LIBSMING) - -RELOAD_MKFILE = 0 - -# List of directories containing source code to build -MODULES := - -# List of dependent submodule directories which may require updating/patching -SUBMODULES := +all: + $(info Please run `make` from your project directory!) # -SAMPLES_DIRS := $(shell ls -1 ../samples) -DOXYGEN := $(shell command -v doxygen 2> /dev/null) - -# => WPS -CONFIG_VARS += ENABLE_WPS -ifeq ($(ENABLE_WPS), 1) - CFLAGS += -DENABLE_WPS=1 -endif - -# => http-parser -SUBMODULES += $(COMPONENTS)/http-parser -MODULES += $(COMPONENTS)/http-parser - -# => libb64 -MODULES += $(COMPONENTS)/libb64 - -# => websocket-parser -SUBMODULES += $(COMPONENTS)/ws_parser -MODULES += $(COMPONENTS)/ws_parser - -# => mqtt-codec -SUBMODULES += $(COMPONENTS)/mqtt-codec -MODULES += $(COMPONENTS)/mqtt-codec/src -EXTRA_INCDIR += $(COMPONENTS)/mqtt-codec/src - +DOXYGEN := $(shell command -v doxygen 2> /dev/null) -# => yuarel -SUBMODULES += $(COMPONENTS)/libyuarel -MODULES += $(COMPONENTS)/libyuarel - -include $(ARCH_BASE)/sming.mk - -# Get list of subdirectory paths -# $1 -> Root directory -define ScanModuleDirs - $(sort $(dir $(wildcard $1/*/ $1/*/*/ $1/*/*/*/))) -endef - -# If specified, restrict importing and building to a specific list of libraries -ARDUINO_LIBRARIES ?= $(patsubst Libraries/%,%,$(wildcard Libraries/*/)) -ARDUINO_LIBRARIES := $(ARDUINO_LIBRARIES:/=) - -# Optionally, apply library exclusion list (e.g. not compatible with architecture) -EXCLUDE_LIBRARIES := $(filter $(EXCLUDE_LIBRARIES),$(ARDUINO_LIBRARIES)) -ifneq (,$(EXCLUDE_LIBRARIES)) -ARDUINO_LIBRARIES := $(filter-out $(EXCLUDE_LIBRARIES),$(ARDUINO_LIBRARIES)) -ifeq ("$(V)","1") -$(warning Excluded libraries: $(EXCLUDE_LIBRARIES)) -endif -endif - -# Identify which libraries have submodules -LIBRARY_SUBMODULES := $(call ListSubmodules,Libraries) -LIBRARY_SUBMODULES := $(patsubst Libraries/%,%,$(LIBRARY_SUBMODULES)) -LIBRARY_SUBMODULES := $(filter $(LIBRARY_SUBMODULES), $(ARDUINO_LIBRARIES)) -# List of any Arduino library .submodule targets -LIBRARY_SUBMODULES := $(foreach lib,$(LIBRARY_SUBMODULES),Libraries/$(lib)/.submodule) - -# which modules (subdirectories) to include in compiling -SMING_MODULES := $(ARCH_CORE) $(ARCH_BASE)/Platform Platform Core -SMING_MODULES := $(foreach mod,$(SMING_MODULES),$(call ScanModuleDirs,$(mod))) -MODULES := $(ARCH_SYS) System Wiring $(SMING_MODULES) $(MODULES) -MODULES += $(wildcard Services/*/) -MODULES += $(foreach lib,$(ARDUINO_LIBRARIES),Libraries/$(lib) Libraries/$(lib)/src) -MODULES := $(MODULES:/=) - -EXTRA_INCDIR := $(ARCH_BASE) $(ARCH_CORE) $(ARCH_SYS)/include \ - $(ARCH_COMPONENTS) $(COMPONENTS) System/include Wiring Core \ - . $(EXTRA_INCDIR) - -include $(SMING_HOME)/modules.mk - - -CUSTOM_TARGETS += $(LIBS) - -# Define secondary pseudo-targets for all libraries -define UserLibrary -.PHONY $1: -$1: $(call UserLibPath,$1) -endef -$(foreach lib,$(LIBS),$(eval $(call UserLibrary,$(lib)))) - - -.PHONY: libsming -libsming: $(LIBSMING_DST) - -$(LIBSMING_DST): $(APP_AR) $(CUSTOM_TARGETS) ##Build the Sming framework and user libraries - $(vecho) "Installing '$(LIBSMING)' library" -ifeq ($(ENABLE_SSL), 1) - $(vecho) "+ SSL support is enabled" -else - $(vecho) "(!) SSL support is not enabled. To enable it type: 'make clean; make ENABLE_SSL=1'" -endif - $(Q) cp -r $(APP_AR) $(LIBSMING_DST) - $(vecho) "Done" - -$(APP_AR): $(OBJ) - $(vecho) "AR $@" - $(Q) $(AR) cr $@ $^ - -.PHONY: checkdirs -checkdirs: submodules reload | $(BUILD_DIR) $(USER_LIBDIR) - -$(BUILD_DIR) $(USER_LIBDIR): - $(Q) mkdir -p $@ ##@Cleaning .PHONY: dist-clean -dist-clean: clean submodules-clean tools-clean user-lib-clean samples-clean ##Clean everything +dist-clean: submodules-clean samples-clean ##Clean everything for all arch/build types + -$(Q) rm -rf out .PHONY: clean -clean: $(CLEAN) ##Remove all generated build files - $(Q) rm -f $(APP_AR) - $(Q) rm -rf $(BUILD_BASE) +clean: ##Remove all intermediate build files, but leave generated libraries and tools + -$(Q) rm -rf $(BUILD_BASE) + +.PHONY: components-clean +components-clean: ##Remove generated Component (user) libraries + @echo Cleaning all Component libraries + -$(Q) rm -f $(USER_LIBDIR)/* + -$(Q) rm -rf $(OUT_BASE) + +.PHONY: submodules-clean +submodules-clean: ##Reset state of all third-party submodules + @echo Cleaning all submodules... + -$(Q) rm -rf $(ListSubmodules) + -$(Q) rm -rf $(addprefix $(BUILD_BASE),$(ListSubmodules)) + $(Q) $(GIT) checkout $(ListSubmodules) -.PHONY: user-lib-clean -user-lib-clean: ##Remove generated user libraries - -$(Q) rm -f $(wildcard $(USER_LIBDIR)/lib*.a) $(APP_AR) - -$(Q) $(GIT) checkout $(USER_LIBDIR) ##@Building @@ -183,7 +69,7 @@ ifndef DOXYGEN $(error doxygen not found - not building API docs) endif $(Q) mkdir -p $(DOCS_DIR)/api - $(Q) cd $(DOCS_DIR); doxygen 2>api/stderr.log 1>api/doxygen.log + $(Q) cd $(DOCS_DIR) && doxygen 2>api/stderr.log 1>api/doxygen.log $(DOCS_DIR)/api/sming/index.html: $(DOCS_DIR)/api/error.log $(vecho) "Undocumented compounds: $(shell grep "Compound.*is not documented" $(DOCS_DIR)/api/error.log | wc -l)" @@ -192,105 +78,70 @@ $(DOCS_DIR)/api/sming/index.html: $(DOCS_DIR)/api/error.log $(vecho) "Open in your browser: file://$(abspath $@)" -# Apply patch to a submodule -# $1 -> patch file with relative path -define ApplyPatch - touch $1; \ - $(GIT) apply -v $1 --ignore-whitespace --whitespace=nowarn -endef +##@Building -# If there's a patch for this submodule, apply it -# We look for patch in .. and in ../.patches -# $1 -> submodule path -# $2 -> name of patch file -define TryApplyPatch - cd $1; \ - if [ -f ../$2 ]; then \ - $(call ApplyPatch,../$2); \ - elif [ -f ../.patches/$2 ]; then \ - $(call ApplyPatch,../.patches/$2); \ - fi -endef +# For integration testing both samples and tests are moved outside of the repo. +SMING_PROJECTS_DIR ?= $(abspath $(SMING_HOME)/..) +SAMPLES_DIR := $(call FixPath,$(SMING_PROJECTS_DIR)/samples) +TESTS_DIR := $(call FixPath,$(SMING_PROJECTS_DIR)/tests) -.PHONY: submodules submodules-clean -submodules: | $(LIBRARY_SUBMODULES) $(addsuffix /.submodule,$(SUBMODULES)) ##Fetch all third-party submodules (but do not build) +SAMPLE_NAMES = $(shell ls -1 $(SAMPLES_DIR)) -##@Cleaning -submodules-clean: ##Reset state of all third-party submodules - -$(Q) rm -rf $(call ListSubmodules) - -$(Q) rm -rf $(addprefix $(BUILD_BASE),$(call ListSubmodules)) - $(GIT) checkout $(call ListSubmodules) - $(GIT) checkout Libraries - -# Update and patch submodule -# Patch file is either in submodule parent directory itself or subdirectory .patches from there -%/.submodule: - $(vecho) "Fetching $(dir $@) ..." - $(Q) mkdir -p $(dir $@) - $(Q) $(GIT) submodule update --init --force --recursive $(dir $@) - $(Q) $(call TryApplyPatch,$(dir $@),$(notdir $(patsubst %/,%,$(dir $@))).patch) - $(Q) touch $@ - RELOAD_MKFILE=1 - - -# if the new submodule brings source code files that need to be compiled inside Sming -# then we need somehow to be able to "see" these new files. -# For now we solve this by "reloading" the makefile after fetching a module. -.PHONY: reload -reload: - $(Q) if [ $(RELOAD_MKFILE) -eq 1 ]; then \ - echo "Reloading..."; \ - $(MAKE) -C $(SMING_HOME) $(MAKECMDGOALS) RELOAD_MKFILE=0; \ - fi +.PHONY: samples $(SAMPLE_NAMES) +samples: | $(SAMPLE_NAMES) ##Build all sample applications -##@Building -.PHONY: samples $(SAMPLES_DIRS) samples-clean -samples: | $(SAMPLES_DIRS) ##Build all sample applications +$(SAMPLE_NAMES): + $(Q) $(MAKE) --no-print-directory -C $(SAMPLES_DIR)/$@ -$(SAMPLES_DIRS): - $(Q) $(MAKE) -C $(SMING_HOME)/../samples/$@ -##@Cleaning -samples-clean: ##Invoke 'clean' on all sample applications - -$(Q) for dir in $(SAMPLES_DIRS); do \ - $(MAKE) -C $(SMING_HOME)/../samples/$$dir clean; \ - done +TESTS_COMPLETED = $(addsuffix /.complete,$(call ListSubDirs,$(TESTS_DIR))) +PHONY: tests +tests: $(TESTS_COMPLETED) ##Build and run all test applications -##@Building -.PHONY: tools -tools: $(TOOLS) ##Build all required internal tools +$(TESTS_COMPLETED): + $(Q) $(MAKE) -C $(@D) execute + $(Q) touch $@ ##@Cleaning -.PHONY: tools-clean -tools-clean: $(TOOLS_CLEAN) ##@Cleaning Remove intermediate files created when building tools -##@Building -.PHONY: rebuild -rebuild: clean all ##Re-build the Sming libraries +.PHONY: samples-clean +samples-clean: ##Clean all sample applications (all arch/build types) + @echo Cleaning all samples... + -$(Q) cd $(SAMPLES_DIR) && rm -rf $(addsuffix /out,$(SAMPLE_NAMES)) -# Recursive wildcard search -# $1 -> directory -# $2 -> file extensions -rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) +CLEAN_TESTS := $(TESTS_COMPLETED:complete=clean) +.PHONY: tests-clean +tests-clean: $(CLEAN_TESTS) ##Clean all test applications (all arch/build types) + -$(Q) rm -f $(TESTS_COMPLETED) + +.PHONY: $(CLEAN_TESTS) +$(CLEAN_TESTS): + @echo Cleaning '$(@D)' + $(Q) $(MAKE) -C $(@D) clean -# Files that should follow our coding standards -CS_DIRS := Core Platform Arch/*/Core Arch/*/Platform ../samples -CS_FILES := $(call rwildcard,$(patsubst %,%/*,$(CS_DIRS)),*.cpp *.h *.c) ##@Developer +# Recursive wildcard search +# $1 -> list of directories +# $2 -> file extensions filters (using % as wildcard) +define rwildcard + $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $2,$d)) +endef + +# Files that should follow our coding standards +CS_DIRS = Core Platform Arch/*/Core Arch/*/Platform $(SAMPLES_DIR) $(TESTS_DIR) +CS_FILES = $(call rwildcard,$(CS_DIRS:=/*),%.cpp %.h %.c) + .PHONY: cs cs: ##Apply coding style to all core files - $(Q) for FILE in $(CS_FILES); do \ + $(if $(V),$(info Applying coding style to $(words $(CS_FILES)) files ...)) + @for FILE in $(CS_FILES); do \ clang-format -i -style=file $$FILE; \ done ##@Help -.PHONY: list-config -list-config: ##Print the contents of internal build variables - $(call ListConfig) - .PHONY: help help: ##Show this help summary - $(call PrintHelp) + $(PrintHelp) diff --git a/Sming/Makefile-app.mk b/Sming/Makefile-app.mk deleted file mode 100644 index 67c76117d3..0000000000 --- a/Sming/Makefile-app.mk +++ /dev/null @@ -1,119 +0,0 @@ -############################################################# -# -# Created by Espressif -# UDK modifications by CHERTS -# Cross platform compatability by kireevco -# -############################################################# - -### Defaults ### - -CONFIG_VARS += SERVER_OTA_PORT -SERVER_OTA_PORT ?= 9999 - -## COM port parameters -# Default COM port speed (generic) -COM_SPEED ?= 115200 - -# Default COM port speed (used for flashing) -COM_SPEED_ESPTOOL ?= $(COM_SPEED) - -# Default COM port speed (used in code) -COM_SPEED_SERIAL ?= $(COM_SPEED) - -include $(SMING_HOME)/build.mk - -# name for the target project -TARGET := app - -ARCH_BASE := $(SMING_HOME)/$(ARCH_BASE) -COMPONENTS := $(SMING_HOME)/$(COMPONENTS) - -CONFIG_VARS += CURDIR MAKE_VERSION SHELL - -# -CONFIG_VARS += SPIFF_FILES -SPIFF_FILES ?= files - -# Firmware memory layout info files -FW_MEMINFO_NEW := $(FW_BASE)/fwMeminfo.new -FW_MEMINFO_OLD := $(FW_BASE)/fwMeminfo.old -FW_MEMINFO_SAVED := out/fwMeminfo - -# which modules (subdirectories) of the project to include in compiling -# define your custom directories in the project's own Makefile before including this one -MODULES ?= app # default to app if not set by user -EXTRA_INCDIR ?= include # default to include if not set by user - -SMING_INCDIR := System/include Wiring Core - -EXTRA_INCDIR += $(SMING_HOME) $(ARCH_BASE) $(ARCH_CORE) $(ARCH_SYS)/include \ - $(ARCH_COMPONENTS) $(COMPONENTS) \ - $(addprefix $(SMING_HOME)/,$(SMING_INCDIR)) - -# we will use global WiFi settings from Eclipse Environment Variables, if possible -CONFIG_VARS += WIFI_SSID WIFI_PWD -WIFI_SSID ?= "" -WIFI_PWD ?= "" -ifneq ($(WIFI_SSID), "") - CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\" -endif -ifneq ($(WIFI_PWD), "") - CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\" -endif - -# -CONFIG_VARS += DISABLE_SPIFFS -ifeq ($(DISABLE_SPIFFS), 1) - CFLAGS += -DDISABLE_SPIFFS=1 -endif - -# => Serial -CONFIG_VARS += COM_SPEED_SERIAL -CFLAGS += -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) - -include $(ARCH_BASE)/app.mk - -# -.PHONY: kill_term -kill_term: - $(vecho) "Killing Terminal to free $(COM_PORT)" - -$(Q) $(KILL_TERM) - -##@Tools - -.PHONY: terminal -terminal: kill_term ##Open the serial terminal - $(TERMINAL) - -.PHONY: gdb -gdb: kill_term ##Run the debugger console - $(GDB) - -# Stack trace decoder -CONFIG_VARS += TRACE -TRACE ?= -.PHONY: decode-stacktrace -decode-stacktrace: ##Open the stack trace decoder ready to paste dump text. Alteratively, use `make decode-stacktrace TRACE=/path/to/crash.stack` - $(Q) if [ -z "$(TRACE)" ]; then \ - echo "Decode stack trace: Paste stack trace here"; \ - fi - $(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0) $(TRACE) - -##@Testing - -.PHONY: otaserver -otaserver: all ##Launch a simple python HTTP server for testing OTA updates - $(vecho) "Starting OTA server for TESTING" - $(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT) - -##@Help - -.PHONY: list-config -list-config: ##Print the contents of internal build variables - $(call ListConfig) - -# => Help -.PHONY: help -help: ##Show this help summary - $(call PrintHelp) diff --git a/Sming/Makefile-bsd.mk b/Sming/Makefile-bsd.mk deleted file mode 100644 index e41312f70a..0000000000 --- a/Sming/Makefile-bsd.mk +++ /dev/null @@ -1,15 +0,0 @@ -# ESP8266 sdk package home directory -ESP_HOME ?= /usr/local/esp8266/esp-open-sdk - -# Default COM port -COM_PORT ?= /dev/cuaU0 - -# base directory of the ESP8266 SDK package, absolute -SDK_BASE ?= $(ESP_HOME)/sdk -SDK_TOOLS ?= $(SDK_BASE)/tools - -# Other tools mappings -ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py -KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 -GET_FILESIZE ?= stat -f "%-15z" -TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) diff --git a/Sming/Makefile-linux.mk b/Sming/Makefile-linux.mk deleted file mode 100644 index af46b1ae05..0000000000 --- a/Sming/Makefile-linux.mk +++ /dev/null @@ -1,15 +0,0 @@ -# ESP8266 sdk package home directory -ESP_HOME ?= /opt/esp-open-sdk - -# Default COM port -COM_PORT ?= /dev/ttyUSB0 - -# base directory of the ESP8266 SDK package, absolute -SDK_BASE ?= $(ESP_HOME)/sdk -SDK_TOOLS ?= $(SDK_BASE)/tools - -# Other tools mappings -ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py -KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 -GET_FILESIZE ?= stat -c %s -TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) diff --git a/Sming/Makefile-macos.mk b/Sming/Makefile-macos.mk deleted file mode 100644 index b42b9cdbd9..0000000000 --- a/Sming/Makefile-macos.mk +++ /dev/null @@ -1,15 +0,0 @@ -# ESP8266 sdk package home directory -ESP_HOME ?= /opt/esp-open-sdk - -# Default COM port -COM_PORT ?= /dev/tty.usbserial - -# base directory of the ESP8266 SDK package, absolute -SDK_BASE ?= $(ESP_HOME)/sdk -SDK_TOOLS ?= $(SDK_BASE)/tools - -# Other tools mappings -ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py -KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 -GET_FILESIZE ?= stat -L -f%z -TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) diff --git a/Sming/Makefile-rboot.mk b/Sming/Makefile-rboot.mk index 7f77207ead..e0f7a0fc7d 100644 --- a/Sming/Makefile-rboot.mk +++ b/Sming/Makefile-rboot.mk @@ -1 +1 @@ -include $(SMING_HOME)/Makefile-app.mk \ No newline at end of file +include $(SMING_HOME)/project.mk \ No newline at end of file diff --git a/Sming/Makefile-windows.mk b/Sming/Makefile-windows.mk deleted file mode 100644 index a896aae0f6..0000000000 --- a/Sming/Makefile-windows.mk +++ /dev/null @@ -1,15 +0,0 @@ -# ESP8266 sdk package home directory -ESP_HOME ?= c:/Espressif - -# Default COM port -COM_PORT ?= COM3 - -# base directory of the ESP8266 SDK package, absolute -SDK_BASE ?= $(ESP_HOME)/ESP8266_SDK -SDK_TOOLS ?= $(ESP_HOME)/utils - -# Other tools mappings -ESPTOOL ?= $(SDK_TOOLS)/esptool/esptool.py -KILL_TERM ?= taskkill.exe -f -im Terminal.exe || exit 0 -GET_FILESIZE ?= stat --printf="%s" -TERMINAL ?= $(SDK_TOOLS)/Terminal.exe $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) diff --git a/Sming/Wiring/FakePgmSpace.cpp b/Sming/Wiring/FakePgmSpace.cpp index 974f3c8e44..d6fe3493bb 100644 --- a/Sming/Wiring/FakePgmSpace.cpp +++ b/Sming/Wiring/FakePgmSpace.cpp @@ -17,6 +17,19 @@ void *memcpy_P(void *dest, const void *src_P, size_t length) return dest; } +int memcmp_P(const void *a1, const void *b1, size_t len) +{ + auto a = static_cast(a1); + auto b = static_cast(b1); + for (size_t i = 0; i < len; i++, ++a, ++b) { + uint8_t d = pgm_read_byte(a) - pgm_read_byte(b); + if (d != 0) { + return d; + } + } + return 0; +} + size_t strlen_P(const char * src_P) { char val; diff --git a/Sming/Wiring/FakePgmSpace.h b/Sming/Wiring/FakePgmSpace.h index 23372f384f..03ed377ffb 100644 --- a/Sming/Wiring/FakePgmSpace.h +++ b/Sming/Wiring/FakePgmSpace.h @@ -100,6 +100,7 @@ extern "C" { #endif void *memcpy_P(void *dest, const void *src_P, size_t length); + int memcmp_P(const void *a1, const void *b1, size_t len); size_t strlen_P(const char * src_P); char *strcpy_P(char * dest, const char * src_P); char *strncpy_P(char * dest, const char * src_P, size_t size); diff --git a/Sming/Wiring/FlashString.h b/Sming/Wiring/FlashString.h index cad6946aba..3857554fab 100644 --- a/Sming/Wiring/FlashString.h +++ b/Sming/Wiring/FlashString.h @@ -51,7 +51,9 @@ * * IMPORT_FSTR(name, file) - binds a file into the firmware image as a FlashString object * This needs to be used at file scope, example: - * IMPORT_FSTR(myFlashData, "files/myFlashData.bin") + * IMPORT_FSTR(myFlashData, PROJECT_DIR "/files/myFlashData.bin") + * + * Note the use of PROJECT_DIR to locate the file using an absolute path. * * Both DEFINE_PSTR and PSTR_ARRAY load a PSTR into a stack buffer, but using sizeof() on that buffer will return * a larger value than the string itself because it's aligned. Calling sizeof() on the original flash data will @@ -157,9 +159,13 @@ LOAD_FSTR(_name, _##_name) /** @brief Define a FlashString containing data from an external file + * @param name Name to use for referencing the FlashString object in code + * @param file Path to the file to be included. This should be an absolute path. * @note This provides a more efficient way to read constant (read-only) file data. * The file content is bound into firmware image at link time. * @note The FlashString object must be referenced or the linker won't emit it. + * @note Use the PROJECT_DIR to locate files in your project's source tree. For example: + * IMPORT_FSTR(myFlashString, PROJECT_DIR "/files/my_flash_file.txt"); */ #ifdef __WIN32 #define IMPORT_FSTR(name, file) \ diff --git a/Sming/build.mk b/Sming/build.mk index e1db86e2ae..012af04ddc 100644 --- a/Sming/build.mk +++ b/Sming/build.mk @@ -1,90 +1,82 @@ # Build environment definitions -# Add configuration variable names to CONFIG_VARS as they are encountered (see ListConfig macro) -CONFIG_VARS := +# Add debug variable names to DEBUG_VARS so they can be easily inspected via `make list-config` +DEBUG_VARS := # -CONFIG_VARS += SMING_ARCH -SMING_ARCH ?= Esp8266 - -MAKECMDGOALS ?= all -$(info Invoking '$(MAKECMDGOALS)' for '$(SMING_ARCH)' architecture) +DEBUG_VARS += SMING_HOME SMING_ARCH +ifeq (,$(SMING_ARCH)) +override SMING_ARCH := Esp8266 +endif +export SMING_ARCH -LIBS ?= -CUSTOM_TARGETS ?= -CLEAN ?= -TOOLS ?= -TOOLS_CLEAN ?= +DEBUG_VARS += SMING_RELEASE +ifeq ($(SMING_RELEASE),1) + BUILD_TYPE := release +else + BUILD_TYPE := debug + # Simplifies logic if =0 + override SMING_RELEASE := +endif +export SMING_RELEASE # Detect OS and build environment -UNAME := $(shell uname -s) - -CONFIG_VARS += UNAME +TOOL_EXT := +DEBUG_VARS += UNAME +UNAME := $(shell uname -s) ifneq ($(filter MINGW32_NT%,$(UNAME)),) - UNAME := Windows + UNAME := Windows + TOOL_EXT := .exe else ifneq ($(filter CYGWIN%,$(UNAME)),) - # Cygwin Detected - UNAME := Linux + # Cygwin Detected + UNAME := Linux else ifneq ($(filter CYGWIN%WOW,$(UNAME)),) - #Cygwin32 - UNAME := Linux + #Cygwin32 + UNAME := Linux else ifneq ($(filter MSYS%WOW,$(UNAME)),) - #Msys32 - UNAME := Linux + #Msys32 + UNAME := Linux else ifeq ($(UNAME), Linux) - #Linux + #Linux else ifeq ($(UNAME), Darwin) - #OS X + #OS X else ifeq ($(UNAME), Freebsd) - #BSD + #BSD endif - # Convert Windows paths to POSIX paths -CONFIG_VARS += OS +DEBUG_VARS += OS ifeq ($(OS),Windows_NT) -FixPath = $(subst //,/,$(subst \,/,$(addprefix /,$(subst :,,$1)))) +FixPath = $(subst //,/,$(subst \,/,$(addprefix /,$(subst :,,$1)))) else -FixPath = $1 +FixPath = $1 endif -CONFIG_VARS += SMING_HOME -SMING_HOME := $(call FixPath,$(realpath $(SMING_HOME))) +SMING_HOME := $(patsubst %/,%,$(call FixPath,$(SMING_HOME))) -# OS specific configuration -ifeq ($(UNAME),Windows) - # Windows detected - include $(SMING_HOME)/Makefile-windows.mk - TOOL_EXT := .exe -else - ifeq ($(UNAME),Darwin) - # MacOS Detected - UNAME := MacOS - include $(SMING_HOME)/Makefile-macos.mk - else ifeq ($(UNAME),Linux) - # Linux Detected - include $(SMING_HOME)/Makefile-linux.mk - else ifeq ($(UNAME),FreeBSD) - # Freebsd Detected - include $(SMING_HOME)/Makefile-bsd.mk - endif +ifeq (,$(wildcard $(SMING_HOME)/Arch/$(SMING_ARCH)/build.mk)) +$(error Arch '$(SMING_ARCH)' not found) endif +MAKECMDGOALS ?= all + export SMING_HOME export COMPILE := gcc -CONFIG_VARS += ARCH_BASE USER_LIBDIR BUILD_BASE FW_BASE +DEBUG_VARS += ARCH_BASE USER_LIBDIR OUT_BASE BUILD_BASE FW_BASE TOOLS_BASE -ARCH_BASE := Arch/$(SMING_ARCH) +ARCH_BASE := $(SMING_HOME)/Arch/$(SMING_ARCH) ARCH_SYS = $(ARCH_BASE)/System ARCH_CORE = $(ARCH_BASE)/Core ARCH_TOOLS = $(ARCH_BASE)/Tools ARCH_COMPONENTS = $(ARCH_BASE)/Components -USER_LIBDIR = $(ARCH_BASE)/Compiler/lib -COMPONENTS := Components +ARCH_LIBDIR = $(ARCH_BASE)/Compiler/lib -BUILD_BASE := out/build/$(SMING_ARCH) -FW_BASE := out/firmware +OUT_BASE := out/$(SMING_ARCH)/$(BUILD_TYPE) +BUILD_BASE = $(OUT_BASE)/build +FW_BASE = $(OUT_BASE)/firmware +TOOLS_BASE = $(SMING_HOME)/$(OUT_BASE)/tools +USER_LIBDIR = $(SMING_HOME)/$(OUT_BASE)/lib # Git command GIT ?= git @@ -92,121 +84,114 @@ GIT ?= git # CMake command CMAKE ?= cmake -### Debug output parameters -# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 -CONFIG_VARS += DEBUG_PRINT_FILENAME_AND_LINE -DEBUG_PRINT_FILENAME_AND_LINE ?= 0 - -# Default debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 -CONFIG_VARS += DEBUG_VERBOSE_LEVEL -DEBUG_VERBOSE_LEVEL ?= 2 - -# Disable CommandExecutor functionality if not used and save some ROM and RAM -CONFIG_VARS += ENABLE_CMD_EXECUTOR -ENABLE_CMD_EXECUTOR ?= 1 V ?= $(VERBOSE) ifeq ("$(V)","1") -Q := -vecho := @true + Q := + vecho := @true else -Q := @ -vecho := @echo + Q := @ + vecho := @echo endif # Common flags passed to user libraries -CFLAGS_COMMON = -Wl,-EL -finline-functions -fdata-sections -ffunction-sections +CFLAGS_COMMON = \ + -Wl,-EL \ + -finline-functions \ + -fdata-sections \ + -ffunction-sections + # compiler flags using during compilation of source files. Add '-pg' for debugging -CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment $(CFLAGS_COMMON) \ - -DARDUINO=106 -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1 -CONFIG_VARS += STRICT +CFLAGS = \ + -Wall \ + -Wundef \ + -Wpointer-arith \ + -Wno-comment \ + $(CFLAGS_COMMON) \ + -DARDUINO=106 + +# If STRICT is enabled, show all warnings but don't treat as errors ifneq ($(STRICT),1) - CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing +CFLAGS += \ + -Werror \ + -Wno-sign-compare \ + -Wno-parentheses \ + -Wno-unused-variable \ + -Wno-unused-but-set-variable \ + -Wno-strict-aliasing endif -CONFIG_VARS += ENABLE_GDB -ifeq ($(ENABLE_GDB), 1) - CFLAGS += -ggdb -DENABLE_GDB=1 -endif - -CONFIG_VARS += SMING_RELEASE ifeq ($(SMING_RELEASE),1) # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html # for full list of optimization options - CFLAGS += -Os -DSMING_RELEASE=1 -DLWIP_NOASSERT + CFLAGS += -Os -DSMING_RELEASE=1 else ifeq ($(ENABLE_GDB), 1) - CFLAGS += -Og + CFLAGS += -Og else - CFLAGS += -Os -g + CFLAGS += -Os -g endif -# -CONFIG_VARS += USER_CFLAGS -CFLAGS += $(USER_CFLAGS) - -#Append debug options -CONFIG_VARS += SMING_RELEASE -CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) - CXXFLAGS = $(CFLAGS) -std=c++11 -felide-constructors + ifneq ($(STRICT),1) CXXFLAGS += -Wno-reorder endif -# => LOCALE -ifdef LOCALE - CFLAGS += -DLOCALE=$(LOCALE) -endif +include $(ARCH_BASE)/build.mk -include $(SMING_HOME)/$(ARCH_BASE)/build.mk +# Component (user) libraries have a special prefix so linker script can identify them +CLIB_PREFIX := clib- -# Declare target for user library -# $1 -> Name of library -define UserLibPath - $(USER_LIBDIR)/lib$1.a +# Fetch full path for submodules matching given pattern +# Note that scanning .gitmodules is considerably quicker than using GIT +# $1 -> Path to repo working directory +# $2 -> Path pattern to match +define ScanGitModules +$(patsubst %,$(abspath $1/%),$(subst path = ,,$(shell grep -o 'path = $2' '$1/.gitmodules'))) endef -# Fetch full path for submodules matching given pattern -# $1 -> Path pattern to match define ListSubmodules - $(shell git submodule status $1 | cut -c2- | cut -f2 -d ' ') +$(call ScanGitModules,$(SMING_HOME)/..,.*) +endef + +# List immediate sub-directories for a list of root directories +# Results are sorted and without trailing path separator +# $1 -> Root paths +define ListSubDirs +$(foreach d,$(dir $(wildcard $1/*/.)),$(d:/=)) +endef + +# List sub-directories recursively for a list of root directories +# Results are sorted and without trailing path separator +# $1 -> Root paths +define ListAllSubDirs +$(foreach d,$(dir $(wildcard $1/*/.)),$(d:/=) $(call ListAllSubDirs,$(d:/=))) endef # Display variable and list values, e.g. $(call PrintVariable,LIBS) # $1 -> Name of variable containing values define PrintVariable $(info $1) - $(foreach item,$(sort $($1)),$(info - $(item))) + $(foreach item,$($1),$(info - $(item))) endef -# Display list of variable references with their values e.g. $(call PrintVariableRefs,CONFIG_VARS) -# $1 -> Name of variable containing list of variable names -define PrintVariableRefs +define PrintVariableSorted $(info $1) - $(foreach item,$(sort $($1)),$(info - $(item) = $($(item))) ) + $(foreach item,$(sort $($1)),$(info - $(value item))) endef -# Display some internal configuration information -define ListConfig - $(info ) - $(info ** Sming internal build configuration **) - $(info ) - $(call PrintVariable,MAKEFILE_LIST) - $(call PrintVariable,CUSTOM_TARGETS) - $(call PrintVariable,LIBSMING) - $(call PrintVariable,LIBS) - $(call PrintVariable,ARDUINO_LIBRARIES) - $(call PrintVariable,SUBMODULES) - $(call PrintVariableRefs,CONFIG_VARS) - $(info ) - $(info ) +# Display list of variable references with their values e.g. $(call PrintVariableRefs,DEBUG_VARS) +# $1 -> Name of variable containing list of variable names +define PrintVariableRefs + $(info $1) + $(foreach item,$(sort $($1)),$(info - $(item) = $(value $(item))) ) endef # Extract commented target information from makefiles and display # Based on code from https://suva.sh/posts/well-documented-makefiles/ define PrintHelp - $(info ) - $(info Welcome to the Sming build system!) + @echo + @echo Welcome to the Sming build system! @awk 'BEGIN { \ FS = "(:.*##)|(##@)"; \ printf "Usage:\n make \033[1;36m\033[0m\n"; \ @@ -222,28 +207,28 @@ define PrintHelp for (t in targets) { \ split(t, sep, SUBSEP); \ if (sep[2] == g) \ - printf " \033[1;36m%-18s\033[0m %s\n", sep[1], targets[t] \ + printf " \033[1;36m%-20s\033[0m %s\n", sep[1], targets[t] \ } \ } \ } ' $(MAKEFILE_LIST) - $(info ) + @echo endef -# => Main Sming library -CONFIG_VARS += ENABLE_SSL -ifeq ($(ENABLE_SSL),1) - LIBSMING = smingssl - SMING_FEATURES = SSL -else - LIBSMING = sming - SMING_FEATURES = none -endif -LIBSMING_DST = $(call UserLibPath,$(LIBSMING)) +# Give relative or absolute source paths, convert them all to absolute +# $1 -> source root directory +# $2 -> file path(s) +define AbsoluteSourcePath +$(foreach f,$2,$(abspath $(if $(filter /%,$f),$f,$1/$f))) +endef -# => MQTT -# Flags for compatability with old versions (most of them should disappear with the next major release) -CONFIG_VARS += MQTT_NO_COMPAT -ifeq ($(MQTT_NO_COMPAT),1) - CFLAGS += -DMQTT_NO_COMPAT=1 -endif +# Write config variables to a file +# $1 -> Output filename +# $2 -> List of variable names to output +define WriteConfig +$(if $(V),$(info WriteConfig $1)) +$(shell mkdir -p $(dir $1); + echo '# Automatically generated file. Do not edit.' > $1; + echo >> $1; + $(foreach v,$2,echo '$v = $($v)' >> $1;) ) +endef diff --git a/Sming/building.md b/Sming/building.md index 417c15f077..2b3f6c5dc5 100644 --- a/Sming/building.md +++ b/Sming/building.md @@ -1,138 +1,374 @@ -# Sming makefiles +# Sming makefile build system ## Introduction -This guide is provided to assist with developing and modifying the build system. +This guide is provided to assist with understanding, developing and modifying the build system. -There are two main makefiles: +A Sming project is built from a set of static libraries (object archives). Typically the application code is one library, built from the user's source code, whilst the other libraries are common to all projects and stored in a separate, shared location. -> **Makefile** to build the Sming framework libraries +Until recently Sming itself has always been built as one large library, but this is now broken into a number of discrete Component libraries. The concept is borrowed from Espressif's ESP-IDF build system and whilst it there are similarities the two systems are completely independent. -> **Makefile-app.mk** to build an application +## Building applications -There are also specific makefiles for each supported host environment: +### Setup -> **Makefile-bsd.mk** +These are the main variables you need to be aware of: -> **Makefile-linux.mk** +`SMING_HOME` must be set to the full path of the `Sming` directory. -> **Makefile-macos.mk** +`SMING_ARCH` Defines the target architecture: -> **Makefile-windows.mk** +* **Esp8266** The default if not specified. `ESP_HOME` must also be provided to locate SDK & tools. -The following are internal makefiles containing shared script for both framework and application: +* **Esp32** {todo} -> **build.mk** Defines the build environment +* **Host** builds a version of the library for native host debugging on Linux or Windows -> **modules.mk** Parses defined MODULES, etc. and creates target rules +These variables are available for application use: -In addition, `Sming/Arch/$(ARCH)` must contain: +`PROJECT_DIR` Path to the project's root source directory, without trailing path separator. This variable is available within makefiles, but is also provided as a #defined C string to allow references to source files within application code, such as with the `IMPORT_FSTR` macro. -> **sming.mk** to define architecture-specific modules and libraries -> **app.mk** to build an application +### Converting existing projects -`SMING_ARCH` may be defined as +Instead of `Makefile-user.mk` a project should provide a `component.mk`. To convert to the new style: -> **Esp8266** +1. Copy `Makefile` and `component.mk` from the `Basic_Blink` sample project +2. Copy any customisations from `Makefile-user.mk` into `component.mk` file. (Or, rename `Makefile-user.mk` to `component.mk` then edit it.) +3. Delete `Makefile-user.mk` +4. If the project uses any Arduino libraries, set the `ARDUINO_LIBRARIES` variable -> **Esp32** {todo} +**Targets** You can add your own targets to component.mk as usual. It's a good idea to add a comment for the target, like this: -> **Host** {todo} builds a version of the library for native host debugging (e.g. Linux/Windows) +``` +##@Building + +.PHONY: mytarget +mytarget: ##This is my target +``` + +When you type `make help` it will appear in the list. + +If you need a target to be added as a dependency to the main application build, add it to `CUSTOM_TARGETS` - the `Basic_Serial` sample contains a simple example of this. + +**Arduino Libraries** If your project uses any Arduino libraries, you must set `ARDUINO_LIBRARIES` appropriately. + +**Source files** Use `COMPONENT_SRCDIRS` instead of `MODULES`. Use `COMPONENT_SRCFILES` to add individual files. + +**Include paths** Use `COMPONENT_INCDIRS` instead of `EXTRA_INCDIR`. + +See [component.mk](#component-configuration) for a full list of variables. + + +### Building + +You should normally work from the project directory. Examples: + +* Type `make` to build the project and any required Components. To speed things up, use parallel building, e.g. `make -j5` will build using a maximum of 5 concurrent jobs. The optimum value for this is usually (CPU CORES + 1). Using `make -j` will use unlimited jobs, but can cause problems in virtual environments. + +* Type `make help` from the project directory to get a list of available build targets. + +To switch to a different build architecture, for example: + +* Type `make SMING_ARCH=Host` to build the project for the host emulator +* Type `make flash` to copy any SPIFFS image (if enabled) to the virtual flash, and run the application. (Note that you don't need to set SMING_ARCH again, the value is cached.) + +To inspect the current build configuration, type `make list-config`. + + +### Configuration variables + +Configuration variables should be set in the project's component.mk file. If appropriate, they can also be set as environment variables. + +During development, the easiest way to change variables is on the `make` command line. These are cached so persist between make sessions, and will override any values set in your project's `component.mk` file. For example: + +* Type `make SPIFF_BIN=test-rom` to build the project and (if enabled) create a SPIFFS image file called `test-rom.bin` +* Type `make flash COM_PORT=COM4 SPI_MODE=dio SPI_SIZE=4M` to flash the project and `test-rom` SPIFFS image using the provided flash memory settings +* Next time you type `make flash`, the same settings will be used, no need to type them again + +A separate cache is maintained for each build type (arch + release/debug). For example: +* Type `make SMING_RELASE=1 list-config` to switch to release build and display the active configuration -## Directories +Type `make config-clean` to clear all caches and revert to defaults. + +For reference, a copy of all build variables are stored in a file with each firmware image created in the 'firmware' directory. + + +### Component repositories + +Placing Components in a common location allows them to be used by multiple projects. To set up your own Component repository, create a directory in a suitable location which will contain your Components and set `COMPONENT_SEARCH_DIRS` to the full path of that directory. For example: ``` -Directory Contents ---------- -------- - -Arch/ Architecture-specific makefiles and code - Esp8266/ - Compiler/ - Components/ - Core/ - out/ - Platform/ - System/ - Tools/ - Esp32/ - ... - Host/ - ... + export COMPONENT_SEARCH_DIRS=/opt/shared/Components + + |_ opt + |_ shared + |_ Components # The repository + |_ MyComponent + |_ AnotherComponent + |_ spiffs # Will be used instead of Sming version +``` -Components/ Framework support code, not to be used directly by applications +User repositories are searched first, which allows replacement of any Component for a project. In this example, our `spiffs` component will be selected instead of the one provided with Sming. -Core/ Main framework core -Libraries/ Arduino Libraries +## Directory layout -Platform/ System-level classes +The main Sming repo. is laid out like this: -Services/ Modules not considered as part of Core +``` +Directory/File Contents +--------- ----- -------- + +|_ sming + .appveyor.yml CI testing (Windows) + .travis.yml CI testing (Linux) + |_ .appveyor CI scripts (Windows) + |_ .travis CI scripts (Linux) + |_ docs Sming documentation + |_ samples Samples to demonstrate specific Sming features or libraries + |_ Sming + Makefile Builds documentation, performs global actions on the framework + project.mk Main makefile to build a project + build.mk Defines the build environment + component.mk Sming Component definition file + component-wrapper.mk Used to build each Component using a separate make instance + |_ Arch Architecture-specific makefiles and code + |_ Esp8266 + sming.mk Defines architecture-specific Components and libraries + app.mk Links the project, create output binaries and perform architecture-specific actions + build.mk Architecture-specific build definitions, such as compiler paths + |_ Compiler + |_ Components + |_ Core + |_ Platform + |_ System + |_ Tools Pre-compiled or scripted tools + |_ Esp32 + ... + |_ Host + ... + |_ Components Framework support code, not to be used directly by applications + |_ Core Main framework core + |_ Libraries Arduino Libraries + ... + |_ out All generated shared files are written here + |_ Esp8266 The Arch + |_ debug The build type + |_ build Intermediate object files + |_ Lib Generated libraries + |_ tools Generated tools + |_ release + ... + |_ Host + ... + |_ Platform System-level classes + ... + |_ Services Modules not considered as part of Core + ... + |_ System Common framework low-level system code + |_ include + |_ Wiring + ... + |_ tests Integration test applications + ... + +``` -System/ Common framework low-level system code - esp8266/ - include/ - -Wiring/ +A typical Project looks like this: ``` +|_ Basic_Blink + Makefile Just calls Makefile-app.mk + component.mk Project-specific definitions + |_ app Default application source directory + |_ include Default application include directory + |_ out All generated shared files are written here + |_ Esp8266 The Arch + |_ debug The build type + |_ build Intermediate object files + |_ firmware Target output files + |_ Lib Generated libraries + |_ tools Generated tools + |_ release + ... + |_ Host + ... +``` + + +## Components + +The purpose of a Component is to encapsulate related elements for selective inclusion in a project, for easy sharing and re-use: + +* **Shared Library** with associated header files +* **App Code** Source files to be compiled directly into the user's project +* **Header files** without any associated source or library +* **Build targets** to perform specific actions, such as flashing binary data to hardware + +By default, a Component is built into a shared library using any source files found in the base or `src` directories. All Arduino Libraries are built as Components. Note that the application is also built as a Component library, but the source directory defaults to `app` instead of `src`. + +Components are referred to simply by name, defined by the directory in which it is stored. The Component itself is located by looking in all the directories listed by `COMPONENT_SEARCH_DIRS`, which contains a list of repositories. (Every sub-directory of a repository is considered to be a Component.) If there are Components with the same name in different search directories, the first one found will be used. + +Components are customised by providing an optional `component.mk` file. + +You can see details of all Components used in a project using `make list-components`. Add `V=1` to get more details. + +Note that the application itself is also built as a Component, and may be configured in a similar way to any other Component. + +### Library variants +Libraries can often be built using different option settings, so a mechanism is required to ensure that libraries (including the application) are rebuilt if those settings change. This is handled using _variants_, which modifies the library name using a hash of the settings values. Each variant gets its own build sub-directory so incremental building works as usual. -## Environment Setup +There are several types of config variable: -You must provide `SMING_HOME` and any architecture-specific ones. For the Esp8266 you must define `ESP_HOME` for SDK & tools. +Variable type | Cached? | Rebuild Component? | Rebuild application? | Relink application +--- | --- | --- | --- | --- +COMPONENT | Y | Y | Y | Y +CONFIG | Y | N | Y | Y +RELINK | Y | N | N | Y +CACHE | Y | N | N | N +DEBUG | N | N | N | N -# Building the framework +Variables are usually defined in the context of a Component, in the component.mk file. All Components see the full configuration during building, not just their own variables. + +The type of a configuration variable is defined by adding its _name_ to one of the following lists: + +`CONFIG_VARS` The Application library derives its variant from these variables. Use this type if the Component doesn't require a rebuild, but the application does. + +`COMPONENT_VARS` A Component library derives its variant from these variables. Any variable which requires a rebuild of the Component library itself must be listed. For example, the `esp-open-lwip` Component defines this as `ENABLE_LWIPDEBUG ENABLE_ESPCONN`. The default values for these produces `ENABLE_LWIPDEBUG=0 ENABLE_ESPCONN=0`, which is hashed (using MD5) to produce `a46d8c208ee44b1ee06f8e69cfa06773`, which is appended to the library name. + +`RELINK_VARS` Code isn't re-compiled, but libraries are re-linked and firmware images re-generated if any of these variables are changed. For example, `make RBOOT_ROM_0=new-rom-file` rewrites the firmware image using the given filename. (Also, as the value is cached, if you then do `make flashapp` that same iamge gets flashed.) + +`CACHE_VARS` These variables have no effect on building, but are cached. Variables such as `COM_SPEED_ESPTOOL` fall into this category. + +`DEBUG_VARS` are generally for information only, and are not cached (except for `SMING_ARCH` and `SMING_RELEASE`). + + +### Dependencies + +`COMPONENT_DEPENDS` identifies a list of Components upon which this one depends. These are established as pre-requisites so will trigger a rebuild. In addition, all dependent `COMPONENT_VARS` are (recursively) used in creation of the library hash. + +For example, the `axtls-8266` Component declares `SSL_DEBUG` as a `COMPONENT_VAR`. Because `Sming` depends on `sming-arch`, which in turn depends on `axtls-8266`, all of these Components get rebuilt as different variants when `SSL_DEBUG` changes values. The project code (`App` Component) also gets rebuilt as it implicitly depends on `Sming`. + + +### Component configuration + +The `component.mk` is parsed twice, first from the top-level makefile and the second time from the sub-make which does the actual building. A number of variables are used to define behaviour. + +These values are for reference only and should not be modified. + +`COMPONENT_NAME` Name of the Component +`COMPONENT_PATH` Base directory path for Component, no trailing path separator +`COMPONENT_BUILD_DIR` The current directory. This should be used if the Component provides any application code or targets to ensure it is built in the correct directory (but not by this makefile). +`COMPONENT_LIBDIR` Location to store created Component (shared) libraries +`COMPONENT_VARIANT` Name of the library to build +`COMPONENT_LIBPATH` Full path to the library to be built + +These values may be used to customise Component behaviour and may be changed as required. + +`COMPONENT_LIBNAME` By default, the library has the same name as the Component but can be changed if required. Note that this will be used as the stem for any variants. +Set `COMPONENT_LIBNAME :=` if the Component doesn't create a library. If you don't do this, a default library will be built but will be empty if no source files are found. + +`COMPONENT_TARGETS` Set this to any additional targets to be built as part of the Component, prefixed with `$(COMPONENT_RULE)`. If targets should be built for each application, use `CUSTOM_TARGETS` instead. See `spiffs` for an example. + +`COMPONENT_RULE` This is a special value used to prefix any custom targets which are to be built as part of the Component. The target must be prefixed by `$(COMPONENT_RULE)` without any space between it and the target. This ensures the rule only gets invoked during a component build, and is ignored by the top-level make. + +`COMPONENT_SUBMODULES` Relative paths to dependent submodule directories for this Component. These will be fetched/patched automatically before building. The patch file should be located in the submodule's parent directory (usually the Component directory itself). If the Component is itself a submodule, then patch files must be placed in `../.patches`. A `.submodule` file is created once the submodule has been fetched and successfully patched. + +`COMPONENT_SRCDIRS` Locations for source code relative to COMPONENT_PATH (defaults to ". src") + +`COMPONENT_INCDIRS` Include directories available when building ALL Components (not just this one). Paths may be relative or absolute. + +`INCDIR` The resultant set of include directories used to build this Component. Will contain include directories specified by all other Components in the build. May be overridden if required. + +`COMPONENT_APPCODE` List of directories containing source code to be compiled directly with the application. (Ignore in the project.mk file - use `COMPONENT_SRCDIRS` instead). + +`CUSTOM_BUILD` Set to 1 if providing an alternative build method. See [Custom building](#custom-building) section. + +`EXTRA_OBJ` Absolute paths to any additional binary object files to be added to the Component archive library. + +`COMPONENT_DEPENDS` Set to the name(s) of any dependent Components. + +`EXTRA_LIBS` Set to names of any additional libraries to be linked. + + +These values are global so must only be appended to (with `+=`) , never overwritten. + +`CUSTOM_TARGETS` Identifies targets to be built along with the application. These will be invoked directly by the top-level make. + +`GLOBAL_CFLAGS` Use only if you need to provide additional compiler flags to be included when building all Components (including Application) and custom targets. + +`APP_CFLAGS` Used when building application and custom targets. + + +**IMPORTANT NOTE** + +During initial parsing, many of these variables (specifically, the `COMPONENT_xxx` ones) _do not_ keep their values. For this reason it is usually best to use simple variable assignment using `:=`. + +For example, in `Esp8266/Components/gdbstub` we define `GDB_CMDLINE`. It may be tempting to do this: + +``` +GDB_CMDLINE = trap '' INT; $(GDB) -x $(COMPONENT_PATH)/gdbcmds -b $(COM_SPEED_GDB) -ex "target remote $(COM_PORT_GDB)" +``` + +That won't work! By the time `GDB_CMDLINE` gets expanded, `COMPONENT_PATH` could contain anything. We need `GDB_CMDLINE` to be expanded only when used, so the solution is to take a simple copy of `COMPONENT_PATH` and use it instead, like this: + +``` +GDBSTUB_DIR := $(COMPONENT_PATH) +GDB_CMDLINE = trap '' INT; $(GDB) -x $(GDBSTUB_DIR)/gdbcmds -b $(COM_SPEED_GDB) -ex "target remote $(COM_PORT_GDB)" +``` -## Makefile -Flags: +### Building -> ** ARDUINO_LIBRARIES** Specify which Arduino Libraries are to be built. Default: unspecified, builds them all. Example: `make ARDUINO_LIBRARIES="ArduinoJson SI7021 BMP180"` -This can be set in the platform `sming.mk` file. +For faster builds use make with the `-j` (jobs) feature of make. It is usually necessary to specify a limit for the number of jobs, especially on virtual machines. There is usually no point in using a figure greater than (CPU cores + 1). The CI builds use `-j3`. -## GIT Submodules +Note that `Makefile-app.mk` enforces sequential building to ensure submodules are fetched and patched correctly. This also ensures that only one Component is built at a time which keeps the build logs quite clean and easy to follow. -These are used in various places throughout the framework. A single `%/.submodule` rule takes care of updating and optionally patching the code. -A patch file with the same name as the submodule must be present in `..` or `../.patches`. -After updating and patching, an `.submodule` file is created to confirm this has been done. +Components can be rebuilt and cleaned individually. For example: -# Building applications +* `make spiffs-build` runs the Component 'make' for spiffs, which contains the spiffs library and spiffy tool. +* `make spiffs-clean` removes all intermediate build files for the Component +* `make spiffs-rebuild` cleans and then re-builds the Component -## Makefile-app.mk +By default, a regular `make` performs an incremental build on the application, which invokes a separate (recursive) make for the `App` Component. All other Components only get built if any of their targets don't exist (e.g. variant library not yet built). This makes application building faster and less 'busy', which is generally preferable for regular application development. For Component development this behaviour can be changed using the `FULL_COMPONENT_BUILD` variable (which is cached). Examples: -This does not contain any targets, but sets up the common build environment, configures Sming variables then invokes the platform-specific makefile in `Platform$/$(PLATFORM)/app.mk`. +* `make FULL_COMPONENT_BUILD=lwip` will perform an incremental build on the `lwip` Component +* `make FULL_COMPONENT_BUILD=1` will incrementally build all Components -## Application Code (APPCODE) -Some code is recompiled for every application (e.g. `gdbstub`, `rboot`). -Code must be placed in a separate sub-directory of the corresponding module or component, then added to the `APPCODE` variable within the makefiles. -This mechanism is appropriate for files with multiple configurable options and avoids the need to rebuild the framework. +### Custom Building -# Known Issues +To use an external makefile or other build system (such as CMake) to create the Component library, or to add additional shared libraries or other targets, customise the `component.mk` file as follows: -## Parallel build +1. Set `CUSTOM_BUILD=1` +2. Define the custom rule, prefixed with `$(COMPONENT_RULE)`. Note that Components are built using a separate make instance with the current directory set to the build output directory, not the source directory. -i.e. Using `make -j` doesn't work for rules which pull in submodules from GIT, so this must be done as a first step: +It is important that the rule uses the provided values for `COMPONENT_LIBNAME`, `COMPONENT_LIBPATH` and `COMPONENT_LIBDIR` so that variant building, cleaning, etc. work correctly. See below under 'Building', and the Host `lwip` Component for an example. -`make submodules` +Components are built using a make instance with the current directory set to the build output directory, not the source directory. If any custom building is done then these variables must be obeyed to ensure variants, etc. work as expected: -then you can +`COMPONENT_LIBNAME` as provided by component.mk, defaults to component name, e.g. `Sming` +`COMPONENT_LIBHASH` hash of the component variables used to create unique library names, e.g. `13cd2ddef79fda79dae1644a33bf48bb` +`COMPONENT_VARIANT` name of the library to be built, including hash. e.g. `Sming-13cd2ddef79fda79dae1644a33bf48bb` +`COMPONENT_LIBDIR` directory where any generated libraries must be output, e.g. `/home/user/sming/Sming/out/Esp8266/debug/lib/` +`COMPONENT_LIBPATH` full path to the library to be created, e.g. `/home/user/sming/Sming/out/Esp8266/debug/lib/clib-Sming-13cd2ddef79fda79dae1644a33bf48bb.a` +`COMPONENT_BUILDDIR` where to write intermediate object files, e.g. `/home/user/sming/Sming/out/Esp8266/debug/build/Sming/Sming-13cd2ddef79fda79dae1644a33bf48bb` -`make -j` +### Porting existing libraries -to compile the framework or application. Ensure that any options (`ENABLE_SSL`, `ARDUINO_LIBRARIES`) are set identically for both. +to be completed -## Cleaning +## Known Issues -Optional libraries are not cleaned unless defined. e.g. `make axtls-clean` will fail unless you also specify `ENABLE_SSL=1`. +**Cleaning** Components are not cleaned unless defined. e.g. `make axtls-8266-clean` will fail unless you also specify `ENABLE_SSL=1`. +**Empty libraries** Components without any source code produce an empty library. This is because, for simplicity, we don't want to add a component.mk to every Arduino library. -## Custom heap +**Empty Component directories** Every sub-directory in the `COMPONENT_SEARCH_DIRS` is interpreted as a Component. For example, `spiffs` was moved out of Arch/Esp8266/Components but if an empty directory called 'spiffs' still remains then it will be picked up instead of the main one. These sorts of issues can be checked using `make list-components` to ensure the correct Component path has been selected. -Changing the heap allocator requires a rebuild of the framework. -TODO: Implement as separate user library. +**Components as submodules** All component.mk files must be available for parsing. If they are contained in a GIT submodule then that must be fetched first. Some settings may be specified in a components.mk file instead. diff --git a/Sming/component-wrapper.mk b/Sming/component-wrapper.mk new file mode 100644 index 0000000000..7a8a3b105a --- /dev/null +++ b/Sming/component-wrapper.mk @@ -0,0 +1,177 @@ +####################### +# +# This file is invoked as a separate MAKE instance to build each Component. +# (The idea was borrowed from Espressif's IDF, but is much simpler.) +# +# By default, a Component builds a single library. +# The working directory (CURDIR) is set to the Component build directory. +# All required submodules are pulled in and patched before this makefile is invoked. +# See `building.md` for further details. +# +####################### + +.PHONY: all +all: + $(error Internal makefile) + +include $(SMING_HOME)/build.mk + +# Makefile runs in the build directory +COMPONENT_BUILD_DIR := $(CURDIR) + +CFLAGS := $(CFLAGS) $(GLOBAL_CFLAGS) + +# +CUSTOM_BUILD := +COMPONENT_TARGETS := +EXTRA_OBJ := +COMPONENT_CFLAGS := +COMPONENT_CXXFLAGS := +COMPONENT_VARS := +COMPONENT_LIBNAME := $(COMPONENT_NAME) + +ifeq (,$(wildcard $(COMPONENT_PATH)/Makefile-user.mk)) +# Regular Component +ifeq (App,$(COMPONENT_NAME)) +COMPONENT_SRCDIRS := app +COMPONENT_INCDIRS := include +else +COMPONENT_SRCDIRS := . src +endif +COMPONENT_SRCFILES := +else +# Legacy project +MODULES := app +EXTRA_INCDIR := include +EXTRA_SRCFILES := +include $(COMPONENT_PATH)/Makefile-user.mk +COMPONENT_SRCDIRS := $(MODULES) +COMPONENT_SRCFILES := $(EXTRA_SRCFILES) +endif + +ifeq (App,$(COMPONENT_NAME)) +COMPONENT_SRCDIRS += $(APPCODE) +CFLAGS += $(APP_CFLAGS) +EXTRA_INCDIR := $(call AbsoluteSourcePath,$(COMPONENT_PATH),$(EXTRA_INCDIR) $(COMPONENT_INCDIRS)) +else ifneq ($(STRICT),1) +# Enforce strictest building for regular Components and treat as errors +CFLAGS := $(filter-out -Wno-sign-compare -Wno-strict-aliasing,$(CFLAGS)) -Werror +CXXFLAGS := $(filter-out -Wno-reorder,$(CXXFLAGS)) +endif + +INCDIR := $(EXTRA_INCDIR) $(COMPONENTS_EXTRA_INCDIR) + +# Build a Component target using MAKE +# The makefile should accept TARGET and BUILD_DIR variables +# $1 -> path to makefile, relative to Component path +# $2 -> parameters +define MakeTarget +$(Q) mkdir -p $(COMPONENT_BUILD_DIR)/$(basename $(@F)) $(@D) ++$(Q) $(MAKE) --no-print-directory -C $(dir $(COMPONENT_PATH)/$1) -f $(notdir $1) \ + TARGET=$@ BUILD_DIR=$(COMPONENT_BUILD_DIR)/$(basename $(@F)) V=$(V) $2 +endef + +# Define variables required for custom builds +COMPONENT_VARIANT := $(COMPONENT_LIBNAME)$(if $(COMPONENT_LIBHASH),-$(COMPONENT_LIBHASH)) +COMPONENT_LIBPATH := $(COMPONENT_LIBDIR)/$(CLIB_PREFIX)$(COMPONENT_VARIANT).a + +# component.mk is optional +-include $(COMPONENT_PATH)/component.mk + +# COMPONENT_LIBNAME gets undefined if Component doesn't create a library +ifneq (,$(COMPONENT_LIBNAME)) + +COMPONENT_TARGETS += $(COMPONENT_LIBPATH) + +# List of directories containing object files +BUILD_DIRS := + +ifeq (App,$(COMPONENT_NAME)) +$(eval $(call WriteConfig,$(COMPONENT_BUILD_DIR)/build.cfg,$(CONFIG_VARS))) +else ifneq (,$(COMPONENT_VARS)) +$(eval $(call WriteConfig,$(COMPONENT_BUILD_DIR)/build.cfg,$(COMPONENT_VARS))) +endif + +# Custom build means we don't need any of the regular build logic, that's all be done in component.mk +ifeq (,$(CUSTOM_BUILD)) + +CFLAGS += $(COMPONENT_CFLAGS) +CXXFLAGS += $(COMPONENT_CXXFLAGS) + +# $1 -> absolute source directory, no trailing path separator +# $2 -> relative output build directory, with trailing path separator +define GenerateCompileTargets +BUILD_DIRS += $2 +ifneq (,$(filter $1/%.s,$(SOURCE_FILES))) +$2%.o: $1/%.s + $(vecho) "AS $$<" + $(Q) $(AS) $(addprefix -I,$(INCDIR)) $(CFLAGS) -c $$< -o $$@ +endif +ifneq (,$(filter $1/%.S,$(SOURCE_FILES))) +$2%.o: $1/%.S + $(vecho) "AS $$<" + $(Q) $(AS) $(addprefix -I,$(INCDIR)) $(CFLAGS) -c $$< -o $$@ +endif +ifneq (,$(filter $1/%.c,$(SOURCE_FILES))) +$2%.o: $1/%.c $2%.c.d + $(vecho) "CC $$<" + $(Q) $(CC) $(addprefix -I,$(INCDIR)) $(CFLAGS) -std=c11 -c $$< -o $$@ +$2%.c.d: $1/%.c + $(Q) $(CC) $(addprefix -I,$(INCDIR)) $(CFLAGS) -std=c11 -MM -MT $2$$*.o $$< -MF $$@ +.PRECIOUS: $2%.c.d +endif +ifneq (,$(filter $1/%.cpp,$(SOURCE_FILES))) +$2%.o: $1/%.cpp $2%.cpp.d + $(vecho) "C+ $$<" + $(Q) $(CXX) $(addprefix -I,$(INCDIR)) $(CXXFLAGS) -c $$< -o $$@ +$2%.cpp.d: $1/%.cpp + $(Q) $(CXX) $(addprefix -I,$(INCDIR)) $(CXXFLAGS) -MM -MT $2$$*.o $$< -MF $$@ +.PRECIOUS: $2%.cpp.d +endif +endef + +# Resolve a source path to the corresponding build output object file +# $1 -> source root directory +# $2 -> file path(s) +define ResolveObjPath +$(foreach f,$2,$(patsubst $(SMING_HOME)/%,%,$(patsubst $1/%,%,$f))) +endef + +# All source files, absolute paths +SOURCE_FILES := $(call AbsoluteSourcePath,$(COMPONENT_PATH),$(COMPONENT_SRCFILES)) \ + $(foreach d,$(call AbsoluteSourcePath,$(COMPONENT_PATH),$(COMPONENT_SRCDIRS)),$(wildcard $d/*.s $d/*.S $d/*.c $d/*.cpp)) +# All unique source directories, absolute paths +SOURCE_DIRS := $(sort $(patsubst %/,%,$(dir $(SOURCE_FILES)))) +# Output object files +OBJ := $(call ResolveObjPath,$(COMPONENT_PATH),$(SOURCE_FILES)) +OBJ := $(OBJ:.s=.o) +OBJ := $(OBJ:.S=.o) +OBJ := $(OBJ:.c=.o) +OBJ := $(OBJ:.cpp=.o) +# Create implicit rules for each source directory, and update BUILD_DIRS +$(foreach d,$(SOURCE_DIRS),$(eval $(call GenerateCompileTargets,$d,$(call ResolveObjPath,$(COMPONENT_PATH),$d/)))) +BUILD_DIRS := $(sort $(BUILD_DIRS:/=)) +# Include any generated dependency files (these won't exist on first build) +ABS_BUILD_DIRS := $(sort $(COMPONENT_BUILD_DIR) $(BUILD_DIRS)) +include $(wildcard $(ABS_BUILD_DIRS:=/*.c.d)) +include $(wildcard $(ABS_BUILD_DIRS:=/*.cpp.d)) + +# Provide a target unless Component is custom built, in which case the component.mk will have defined this already +$(COMPONENT_LIBPATH): $(OBJ) $(EXTRA_OBJ) + $(vecho) "AR $@" + $(Q) test ! -f $@ || rm $@ + $(Q) $(AR) rcsP $@ $^ + +endif # ifeq (,$(CUSTOM_BUILD)) +endif # ifneq (,$(COMPONENT_LIBNAME)) + +TARGET_DIRS := $(sort $(patsubst %/,%,$(dir $(COMPONENT_TARGETS)))) + +# Targets +.PHONY: build +build: checkdirs $(COMPONENT_TARGETS) + +checkdirs: | $(BUILD_DIRS) $(TARGET_DIRS) + +$(BUILD_DIRS) $(TARGET_DIRS): + $(Q) mkdir -p $@ diff --git a/Sming/component.mk b/Sming/component.mk new file mode 100644 index 0000000000..732e78ab74 --- /dev/null +++ b/Sming/component.mk @@ -0,0 +1,103 @@ +COMPONENT_SRCDIRS := \ + Core $(call ListAllSubDirs,$(COMPONENT_PATH)/Core) \ + Platform \ + System \ + Wiring \ + Services/HexDump \ + Services/Yeelight + +COMPONENT_INCDIRS := \ + Components \ + System/include \ + Wiring Core \ + . + +COMPONENT_DEPENDS := \ + sming-arch \ + spiffs \ + http-parser \ + libb64 \ + ws_parser \ + mqtt-codec \ + libyuarel \ + ArduinoJson \ + terminal + +# => SSL +COMPONENT_VARS := ENABLE_SSL +ifeq ($(ENABLE_SSL),1) + SMING_FEATURES := SSL + GLOBAL_CFLAGS += -DENABLE_SSL=1 +else + SMING_FEATURES := none + COMPONENT_SRCDIRS := $(filter-out %/Ssl,$(COMPONENT_SRCDIRS)) +endif + +# Prints SSL status when App gets built +CUSTOM_TARGETS += check-ssl +.PHONY:check-ssl +check-ssl: +ifeq ($(ENABLE_SSL),1) + $(info + SSL support is enabled) +else + $(warning ! SSL support is not enabled. To enable it type: 'make clean; make ENABLE_SSL=1') +endif + +# => Disable CommandExecutor functionality if not used and save some ROM and RAM +COMPONENT_VARS += ENABLE_CMD_EXECUTOR +ENABLE_CMD_EXECUTOR ?= 1 +ifeq ($(ENABLE_CMD_EXECUTOR),1) +COMPONENT_SRCDIRS += Services/CommandProcessing +endif +GLOBAL_CFLAGS += -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) + +# => MQTT +# Flags for compatability with old versions (most of them should disappear with the next major release) +COMPONENT_VARS += MQTT_NO_COMPAT +ifeq ($(MQTT_NO_COMPAT),1) + GLOBAL_CFLAGS += -DMQTT_NO_COMPAT=1 +endif + +# WiFi settings may be provide via Environment variables +CONFIG_VARS += WIFI_SSID WIFI_PWD +ifdef WIFI_SSID + APP_CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\" +endif +ifdef WIFI_PWD + APP_CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\" +endif + +# => LOCALE +COMPONENT_VARS += LOCALE +ifdef LOCALE + GLOBAL_CFLAGS += -DLOCALE=$(LOCALE) +endif + +### Debug output parameters + +# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 +CONFIG_VARS += DEBUG_PRINT_FILENAME_AND_LINE +DEBUG_PRINT_FILENAME_AND_LINE ?= 0 +GLOBAL_CFLAGS += -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) +# When rules are created make will see '$*' so substitute the filename +GLOBAL_CFLAGS += -DCUST_FILE_BASE=$$* + +# Default debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 +CONFIG_VARS += DEBUG_VERBOSE_LEVEL +DEBUG_VERBOSE_LEVEL ?= 2 +GLOBAL_CFLAGS += -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) + +CONFIG_VARS += ENABLE_GDB +ifeq ($(ENABLE_GDB), 1) + GLOBAL_CFLAGS += -ggdb -DENABLE_GDB=1 +endif + +# Default COM port speed (generic) +CACHE_VARS += COM_SPEED +COM_SPEED ?= 115200 + +# Default COM port speed used in code +CONFIG_VARS += COM_SPEED_SERIAL +COM_SPEED_SERIAL ?= $(COM_SPEED) +APP_CFLAGS += -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) + diff --git a/Sming/modules.mk b/Sming/modules.mk deleted file mode 100644 index 6b5fe38830..0000000000 --- a/Sming/modules.mk +++ /dev/null @@ -1,71 +0,0 @@ -##### -# -# Module support -# -# Both Sming and Application makefiles include this once all modules, libs, etc. have been defined -# -##### - -# List of directories containing object files -BUILD_DIR := - -# List of object files -OBJ := - -# Intermediate linker target -APP_AR := $(BUILD_BASE)/$(TARGET).a - -INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) - -# $1 -> directory containing source files -# $2 -> output build directory -define GenerateCompileTargets -$2/%.o: $1/%.s - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(CFLAGS) -c $$< -o $$@ -$2/%.o: $1/%.S - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(CFLAGS) -c $$< -o $$@ -$2/%.o: $1/%.c $2/%.c.d - $(vecho) "CC $$<" - $(Q) $(CC) $(INCDIR) $(CFLAGS) -std=c11 -c $$< -o $$@ -$2/%.o: $1/%.cpp $2/%.cpp.d - $(vecho) "C+ $$<" - $(Q) $(CXX) $(INCDIR) $(CXXFLAGS) -c $$< -o $$@ -$2/%.c.d: $1/%.c - $(Q) $(CC) $(INCDIR) $(CFLAGS) -std=c11 -MM -MT $2/$$*.o $$< -o $$@ -$2/%.cpp.d: $1/%.cpp - $(Q) $(CXX) $(INCDIR) $(CXXFLAGS) -MM -MT $2/$$*.o $$< -o $$@ - -.PRECIOUS: $2/%.c.d $2/%.cpp.d -endef - - -# Append target object file paths to OBJ -# $1 -> directory containing source files -# $2 -> output build directory -# $3 -> file extension -define ScanObjectFiles - OBJ += $(addprefix $2/,$(patsubst $(SMING_HOME)/%,%,$(patsubst %$3,%.o,$(wildcard $1/*$3)))) -endef - -# Generate all the compile target patterns and update object list for all source files in a module directory -# $1 -> directory containing source files -# $2 -> output build directory -define ScanModule - $(if $(V), $(info Scan $1)) - BUILD_DIR += $2/$(patsubst $(SMING_HOME)/%,%,$1) - $(eval $(call ScanObjectFiles,$1,$2,.s)) - $(eval $(call ScanObjectFiles,$1,$2,.S)) - $(eval $(call ScanObjectFiles,$1,$2,.c)) - $(eval $(call ScanObjectFiles,$1,$2,.cpp)) - $(eval $(call GenerateCompileTargets,$1,$(BUILD_BASE)/$(patsubst $(SMING_HOME)/%,%,$1))) -endef - -# $1 -> directory containing source files -define ScanModules - $(foreach sdir,$1,$(eval $(call ScanModule,$(sdir),$(BUILD_BASE)))) -endef - -# Generate all the compile target patterns and object references -$(call ScanModules,$(MODULES)) diff --git a/Sming/project.mk b/Sming/project.mk new file mode 100644 index 0000000000..3a9ab82214 --- /dev/null +++ b/Sming/project.mk @@ -0,0 +1,546 @@ +############################################################# +# +# Created by Espressif +# UDK modifications by CHERTS +# Cross platform compatability by kireevco +# +# This makefile is invoked in the application's directory +# +############################################################# + +ifndef SMING_HOME +$(error SMING_HOME variable is not set to a valid directory.) +endif + +# Don't bother with implicit checks +.SUFFIXES: + +.PHONY: all +all: checkdirs components application ##(default) Build all Component libraries + +# Load current build type from file +BUILD_TYPE_FILE := out/build-type.mk +-include $(BUILD_TYPE_FILE) + +# +include $(SMING_HOME)/build.mk + +# +# The build system supports several types of configuration variable. The name of the variable needs to be +# added to only one of the xxx_VARS lists below, depending on the required behaviour. +# + +# CONFIG_VARS controls when the `App` Component gets rebuilt. +# The values of all these variables are used to create a hash string, which is appended to the library name +# to create a unique variant. +# Components usually add their config variables to COMPONENT_VARS, which also controls variant creation for +# the Component itself. If the variable only affects the application build, not the Component, then it should +# be appended to CONFIG_VARS instead. +# The values of all CONFIG_VARS are cached after a successful build. A separate cache is maintained for +# each build type (SMING_ARCH, SMING_RELEASE). +CONFIG_VARS := + +# RELINK_VARS controls when a re-link is required, but no rebuilding is necessary. +# The values of all RELINK_VARS are cached after a successful build. +RELINK_VARS := + +# CACHE_VARS is a list of variable names which do not affect Component or application building or linking, +# but whose values are cached. +CACHE_VARS := + +# Use PROJECT_DIR to identify the project source directory, from where this makefile must be included +CONFIG_VARS += PROJECT_DIR +PROJECT_DIR := $(CURDIR) + +$(info ) +$(info $(notdir $(PROJECT_DIR)): Invoking '$(MAKECMDGOALS)' for $(SMING_ARCH) ($(BUILD_TYPE)) architecture) + +# CFLAGS used for application and any custom targets +DEBUG_VARS += APP_CFLAGS +APP_CFLAGS = +CFLAGS += $(APP_CFLAGS) + +# Changing USER_CFLAGS will cause an App rebuild automatically, but other Components must be rebuilt manually +CONFIG_VARS += USER_CFLAGS + +# CFLAGS exported for every Component to use whilst building, including any CUSTOM_TARGETS +DEBUG_VARS += GLOBAL_CFLAGS +GLOBAL_CFLAGS = $(USER_CFLAGS) -DPROJECT_DIR=\"$(PROJECT_DIR)\" -DSMING_HOME=\"$(SMING_HOME)\" +CFLAGS += $(GLOBAL_CFLAGS) + +# Targets to be added as dependencies of the application, built directly in this make instance +CUSTOM_TARGETS := + +# Application libraries will be written here +DEBUG_VARS += APP_LIBDIR +APP_LIBDIR := $(OUT_BASE)/lib + +# Tells linker where to find libraries and scripts +LIBDIRS := $(APP_LIBDIR) $(USER_LIBDIR) $(ARCH_BASE)/Compiler/lib $(ARCH_BASE)/Compiler/ld + +# Standard libraries that will be linked with application (Component libraries are defined separately) +LIBS := $(EXTRA_LIBS) + +# Name of the application to use for link output targets +APP_NAME := app + +# Firmware memory layout info files +FW_MEMINFO_NEW := $(FW_BASE)/fwMeminfo.new +FW_MEMINFO_OLD := $(FW_BASE)/fwMeminfo.old +FW_MEMINFO_SAVED := out/fwMeminfo + +# Enable extra warnings but don't stop on error +CACHE_VARS += STRICT + +# Set to 1 to enable some legacy building behaviour +CACHE_VARS += ENABLE_LEGACY_BUILD +ENABLE_LEGACY_BUILD ?= 0 + +# List of Components we're going to parse, with duplicate libraries removed +COMPONENTS := Sming + +# For identifying Components which are themselves submodules +ALL_SUBMODULES = $(ListSubmodules) + +# +# Component parsing +# + +# Names of Components containing buildable targets, and the full list of targets +BUILDABLE_COMPONENTS := +ALL_COMPONENT_TARGETS := + +# Prevent rules for custom targets being triggered +COMPONENT_RULE := __no_build__ + +# Component archives (object libraries) to be linked +COMPONENTS_AR := + +# The set of submodules required by Components +SUBMODULES := + +# Tracks Components which have been parsed +PARSED_COMPONENTS := + +# Full list of include directories obtained from all Components (except App) +COMPONENTS_EXTRA_INCDIR := + +# Components may specify directories containing source code to be compiled with application +APPCODE := + +# +# This macro sets the default component variables before including the (optional) component.mk file. +# +# $1 -> Component name +# $2 -> Component path +# $3 -> Build directory +# $4 -> Output library directory +define ParseComponent +$(if $V,$(info -- Parsing $1)) +$(if $2,,$(error Component '$1' not found)) +SUBMODULES += $(filter $2,$(ALL_SUBMODULES)) +CMP_$1_PATH := $2 +CMP_$1_LIBDIR := $4 +COMPONENT_LIBDIR := $$(CMP_$1_LIBDIR) +COMPONENT_INCDIRS := include +COMPONENT_NAME := $1 +COMPONENT_LIBNAME := $1 +CMP_$1_BUILD_BASE := $3/$1 +COMPONENT_BUILD_DIR := $$(CMP_$1_BUILD_BASE) +COMPONENT_VARS := +COMPONENT_TARGETS := +EXTRA_LIBS := +# Process any component.mk file (optional) +ifneq (,$(wildcard $2/component.mk)) +COMPONENT_PATH := $2 +COMPONENT_SUBMODULES := +COMPONENT_DEPENDS := +COMPONENT_APPCODE := +include $2/component.mk +CMP_$1_SUBMODULES := $$(addprefix $2/,$$(COMPONENT_SUBMODULES)) +SUBMODULES += $$(CMP_$1_SUBMODULES) +CMP_$1_DEPENDS := $$(COMPONENT_DEPENDS) +CMP_$1_VARS := $$(sort $$(COMPONENT_VARS)) +CMP_$1_APPCODE := $$(COMPONENT_APPCODE) +LIBS += $$(EXTRA_LIBS) +endif +CMP_$1_TARGETS := $$(COMPONENT_TARGETS) +CMP_$1_BUILD_DIR := $$(COMPONENT_BUILD_DIR) +CMP_$1_LIBNAME := $$(COMPONENT_LIBNAME) +CMP_$1_INCDIRS := $$(COMPONENT_INCDIRS) +# Variables including those inherited from dependencies (will be recursively expanded when required) +CMP_$1_DEPVARS = $$(CMP_$1_VARS) $$(foreach c,$$(CMP_$1_DEPENDS),$$(CMP_$$c_DEPVARS)) +CONFIG_VARS += $$(CMP_$1_VARS) +APPCODE += $$(call AbsoluteSourcePath,$2,$$(CMP_$1_APPCODE)) +PARSED_COMPONENTS += $1 +COMPONENTS += $$(filter-out $$(COMPONENTS),$$(CMP_$1_DEPENDS)) +ifneq (App,$1) +COMPONENTS_EXTRA_INCDIR += $$(call AbsoluteSourcePath,$2,$$(CMP_$1_INCDIRS)) +# Recursively parse any dependencies +DEPENDENCIES := $$(filter-out $$(PARSED_COMPONENTS),$$(CMP_$1_DEPENDS)) +ifneq (,$$(DEPENDENCIES)) +$$(call ParseComponentList,$$(DEPENDENCIES)) +endif +endif # App +endef # ParseComponent + +# Build a list of all available Components +ALL_COMPONENT_DIRS = $(foreach d,$(COMPONENT_SEARCH_DIRS),$(call ListSubDirs,$d)) + +# Lookup Component directory from a name +# $1 -> Component name +define FindComponentDir +$(if $(subst Sming,,$1),$(firstword $(filter %/$1,$(ALL_COMPONENT_DIRS))),$(SMING_HOME)) +endef + +# Parse a list of Components +# $1 -> List of Component names +define ParseComponentList +$(foreach c,$1,$(eval $(call ParseComponent,$c,$(call FindComponentDir,$c),$(SMING_HOME)/$(BUILD_BASE),$(USER_LIBDIR)))) +endef + +# Must parse the Application Component first to get project dependencies +$(eval $(call ParseComponent,App,$(CURDIR),$(BUILD_BASE),$(abspath $(APP_LIBDIR)))) + +# Load cached configuration variables. On first run this file won't exist, so all values +# will be as specified by defaults or in project's component.mk file. +# Values may be overriden via command line to update the cache. +# If file has become corrupted it will prevent cleaning, so make this conditional. +CONFIG_CACHE_FILE := $(OUT_BASE)/config.mk +ifeq (,$(findstring clean,$(MAKECMDGOALS))) +-include $(CONFIG_CACHE_FILE) +endif + +# Append standard search directories to any defined by the application +COMPONENT_SEARCH_DIRS := $(call FixPath,$(COMPONENT_SEARCH_DIRS)) +COMPONENTS_EXTRA_INCDIR += $(COMPONENT_SEARCH_DIRS) +COMPONENT_SEARCH_DIRS += $(ARCH_COMPONENTS) $(SMING_HOME)/Components $(SMING_HOME)/Libraries + +# And add in any requested Arduino libraries +COMPONENTS += $(sort $(ARDUINO_LIBRARIES)) + +# Each Component search directory can have an optional 'components.mk' file. +# This is primarily for defining dependencies for Arduino Libraries; many of these are submodules, +# so we can establish dependencies without resorting to elaborate recursive fetch/scan strategies. +$(foreach d,$(COMPONENT_SEARCH_DIRS),$(eval -include $d/components.mk)) + +# Pull in all Component definitions +$(eval $(call ParseComponentList,$(COMPONENTS))) + +# This macro assigns a library and build path based on a hash of the component variables +# $1 -> Component name +define ParseComponentLibs +CMP_$1_DEPVARS := $$(sort $$(CMP_$1_DEPVARS)) +ifneq (,$$(CMP_$1_LIBNAME)) +ifeq (,$$(CMP_$1_VARS)) +CMP_$1_LIBHASH := +COMPONENT_VARIANT := $$(CMP_$1_LIBNAME) +else +COMPONENT_VARIABLES := $$(foreach $$v,$$(CMP_$1_DEPVARS),$$($$v)=$$($$($$v))) +CMP_$1_LIBHASH := $$(firstword $$(shell echo -n $$(COMPONENT_VARIABLES) | md5sum -t)) +COMPONENT_VARIANT := $$(CMP_$1_LIBNAME)-$$(CMP_$1_LIBHASH) +endif +ifneq ($$(COMPONENT_VARIANT),$1) +CMP_$1_BUILD_DIR := $$(CMP_$1_BUILD_DIR)/$$(COMPONENT_VARIANT) +endif +COMPONENT_LIBPATH := $$(CMP_$1_LIBDIR)/$(CLIB_PREFIX)$$(COMPONENT_VARIANT).a +CMP_$1_TARGETS += $$(COMPONENT_LIBPATH) +COMPONENTS_AR += $$(COMPONENT_LIBPATH) +endif +ifneq (,$$(CMP_$1_TARGETS)) +BUILDABLE_COMPONENTS += $1 +ALL_COMPONENT_TARGETS += $$(CMP_$1_TARGETS) +endif +endef + +# Order unimportant so sort for ease of reading and remove duplicates +CONFIG_VARS := $(sort $(CONFIG_VARS)) + +# Always build App last, using a variant based on all config variables +# Note that a link step is always performed, so nothing needs to be done with RELINK_VARS +COMPONENTS += App +CMP_App_VARS := $(CONFIG_VARS) +$(foreach c,$(COMPONENTS),$(eval $(call ParseComponentLibs,$c))) + +export COMPONENTS_EXTRA_INCDIR +export APPCODE +export APP_CFLAGS +export GLOBAL_CFLAGS +export CONFIG_VARS + +# Export all config variables +$(foreach v,$(CONFIG_VARS) $(CACHE_VARS),$(eval export $v)) + + +##@Building + +# Apply patch to a submodule +# $1 -> patch file with relative path +define ApplyPatch + $(GIT) apply -v $1 --ignore-whitespace --whitespace=nowarn +endef + +# If there's a patch for this submodule, apply it +# We look for patch in .. and in ../.patches +# $1 -> submodule path +# $2 -> name of patch file +define TryApplyPatch + cd $1 && if [ -f ../$2 ]; then \ + $(call ApplyPatch,../$2); \ + elif [ -f ../.patches/$2 ]; then \ + $(call ApplyPatch,../.patches/$2); \ + fi +endef + +# Update and patch submodule +# Patch file is either in submodule parent directory itself or subdirectory .patches from there +.NOTPARALLEL: %/.submodule +%/.submodule: + $(info ) + $(info Fetching submodule '$*' ...) + $(Q) cd $*/.. && $(GIT) submodule update --init --force --recursive $(*F) + $(Q) $(call TryApplyPatch,$*,$(*F).patch) + $(Q) touch $@ + + +# Define target for building a component library +# We add a pseudo-target for each Component (using its name) to (re)build all contained targets +# e.g. spiffs: libspiffs.a spiffy.exe +# $1 -> Component name +define GenerateComponentTargets + +.PHONY: $1-build +$1-build: $(addsuffix -build,$(filter $(CMP_$1_DEPENDS),$(BUILDABLE_COMPONENTS))) | $(CMP_$1_BUILD_DIR) $(CMP_$1_SUBMODULES:=/.submodule) + @echo + @echo Building $(CMP_$1_TARGETS) + +$(Q) $(MAKE) -r -R --no-print-directory -C $(CMP_$1_BUILD_DIR) -f $(SMING_HOME)/component-wrapper.mk \ + COMPONENT_NAME=$1 \ + COMPONENT_PATH=$(CMP_$1_PATH) \ + COMPONENT_LIBDIR=$(CMP_$1_LIBDIR) \ + COMPONENT_LIBNAME=$(CMP_$1_LIBNAME) \ + COMPONENT_LIBHASH=$(CMP_$1_LIBHASH) \ + $(SUBMAKE_FLAGS) \ + build + +$(CMP_$1_BUILD_DIR): + $(Q) mkdir -p $$@ + +.PHONY: $1-rebuild +$1-rebuild: $1-clean $1-build + +.PHONY: $1-remove-targets +$1-remove-targets: + -$(Q) rm -f $(CMP_$1_TARGETS) + +.PHONY: $1-clean +$1-clean: $1-remove-targets + -$(Q) rm -rf $(CMP_$1_BUILD_BASE) + +$(foreach t,$(CMP_$1_TARGETS),$(eval $(call GenerateComponentTargetRule,$1,$t))) + +endef # GenerateComponentTargets + +# By default, the sub-make for all Components (except App) is invoked only if any of the declared targets don't exist +# This means if a file changes in the Component, it won't get rebuilt automatically. +# When working on a Component, add its name to FULL_COMPONENT_BUILD so it always gets checked. +# To add all Components, set `FULL_COMPONENT_BUILD=$(COMPONENTS)` +CACHE_VARS += FULL_COMPONENT_BUILD +FULL_COMPONENT_BUILD ?= +ifeq ($(FULL_COMPONENT_BUILD),1) + FULL_COMPONENT_BUILD = $(COMPONENTS) +endif + +# Each Component's real target is built using the phony -build target above, which we define here as a pre-requisite +# but only for the `App` Component and for any targets which don't actually exist. +# Components may always be explicitly (re)built using the -build or -rebuild targets. +# Note that if we don't touch the target then make won't know it's been updated and won't re-link the firmware +# until its next run. The side-effect of this is that a link will always happen, even if it's not required. +# $1 -> Component name +# $2 -> target +define GenerateComponentTargetRule +ifeq (App,$1) +$2: $1-build + $(Q) touch $$@ +else ifeq (,$(wildcard $2)) +$2: $1-build + $(Q) touch $$@ +else ifneq (,$(filter $1,$(FULL_COMPONENT_BUILD))) +$2: $1-build + $(Q) touch $$@ +endif +endef + + +# Create rules for all Components +$(foreach c,$(BUILDABLE_COMPONENTS),$(eval $(call GenerateComponentTargets,$c))) + +# The arch-specific targets, including link and firmware image creation +include $(ARCH_BASE)/app.mk + +.PHONY: rebuild +rebuild: clean all ##Re-build application + +.PHONY: checkdirs +checkdirs: | $(BUILD_DIRS) $(FW_BASE) $(TOOLS_BASE) $(APP_LIBDIR) $(USER_LIBDIR) + +$(BUILD_DIRS) $(FW_BASE) $(TOOLS_BASE) $(APP_LIBDIR) $(USER_LIBDIR): + $(Q) mkdir -p $@ + +# Build all Component (user) libraries +.PHONY: components +components: $(SUBMODULES:=/.submodule) $(ALL_COMPONENT_TARGETS) $(CUSTOM_TARGETS) + +# Pull in all submodules, regardless of whether they're used or not +.PHONY: all-submodules +all-submodules: $(ALL_SUBMODULES:=/.submodule) ##Fetch all third-party submodules (but do not build) + + +##@Cleaning + +SMING_MAKE := $(Q) $(MAKE) --no-print-directory -C $(SMING_HOME) + +.PHONY: dist-clean +dist-clean: ##Clean everything (all arch/build types) + $(SMING_MAKE) $@ + +.PHONY: submodules-clean +submodules-clean: ##Reset state of all third-party submodules + $(SMING_MAKE) $@ + +.PHONY: components-clean +components-clean: ##Remove generated Component libraries + $(SMING_MAKE) $@ + +.PHONY: config-clean +config-clean: ##Clear build configuration, so next make will use original defaults + @echo Cleaning build configuration + -$(Q) rm -f $(BUILD_TYPE_FILE) $(CONFIG_CACHE_FILE) + +.PHONY: clean +clean: ##Remove all generated build files (but leave build config intact) + @echo Cleaning application... + -$(Q) rm -rf $(BUILD_BASE) $(FW_BASE) $(APP_LIBDIR) + + +##@Tools + +.PHONY: gdb +gdb: kill_term ##Run the debugger console + $(GDB_CMDLINE) + + +# Stack trace decoder +CACHE_VARS += TRACE +TRACE ?= +.PHONY: decode-stacktrace +decode-stacktrace: ##Open the stack trace decoder ready to paste dump text. Alteratively, use `make decode-stacktrace TRACE=/path/to/crash.stack` + $(Q) if [ -z "$(TRACE)" ]; then \ + echo "Decode stack trace: Paste stack trace here"; \ + fi + $(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0) $(TRACE) + + +##@Testing + +# OTA Server +CACHE_VARS += SERVER_OTA_PORT +SERVER_OTA_PORT ?= 9999 +.PHONY: otaserver +otaserver: all ##Launch a simple python HTTP server for testing OTA updates + $(info Starting OTA server for TESTING) + $(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT) + +##@Help + +.PHONY: list-config +list-config: ##Print the contents of build variables + $(info ) + $(info ** Sming build configuration **) + $(info ) + $(if $(V),$(call PrintVariable,MAKEFILE_LIST)) + $(call PrintVariableSorted,CUSTOM_TARGETS) + $(call PrintVariableSorted,LIBS) + $(call PrintVariableSorted,ARDUINO_LIBRARIES) + $(call PrintVariableSorted,SUBMODULES) + $(if $(V),$(call PrintVariableSorted,ALL_SUBMODULES)) + $(call PrintVariableRefs,CONFIG_VARS) + $(call PrintVariableRefs,CACHE_VARS) + $(call PrintVariableRefs,RELINK_VARS) + $(call PrintVariableRefs,DEBUG_VARS) + $(info ) + $(info ) + +nullstr := + +# Print component information +# $1 -> Component name +define PrintComponentInfo + $(info > $1: $(CMP_$1_PATH)) + $(if $(V), + $(if $(CMP_$1_SUBMODULES),$(info $(nullstr) Submodules: $(notdir $(CMP_$1_SUBMODULES)))) + $(if $(CMP_$1_DEPENDS),$(info $(nullstr) Depends: $(CMP_$1_DEPENDS))) + $(if $(CMP_$1_APPCODE),$(info $(nullstr) Appcode: $(CMP_$1_APPCODE))) + $(if $(CMP_$1_TARGETS),$(info $(nullstr) Targets: $(notdir $(CMP_$1_TARGETS)))) + $(if $(CMP_$1_DEPVARS),\ + $(info $(nullstr) Variables:)\ + $(foreach v,$(CMP_$1_DEPVARS),$(info $(nullstr) $(if $(filter $v,$(CMP_$1_VARS)), ,i) $v=$($v)) )) ) +endef + +.PHONY: list-components +list-components: ##Print details of all Components for this project + $(call PrintVariable,COMPONENT_SEARCH_DIRS) + $(if $(V),$(call PrintVariable,ALL_COMPONENT_DIRS)) + $(info Components:) + $(foreach c,$(sort $(COMPONENTS)),$(eval $(call PrintComponentInfo,$c))) + +# => Help +.PHONY: help +help: ##Show this help summary + $(PrintHelp) +ifneq (,$V) + @echo 'Each Component also has the following targets:' + @echo ' cmp-build' + @echo ' cmp-clean' + @echo ' cmp-rebuild' +endif + + +# Update build type cache +$(shell mkdir -p $(dir $(BUILD_TYPE_FILE)); \ + echo '# Automatically generated file. Do not edit.' > $(BUILD_TYPE_FILE); \ + echo >> $(BUILD_TYPE_FILE); \ + echo 'SMING_ARCH := $(SMING_ARCH)' >> $(BUILD_TYPE_FILE); \ + echo 'SMING_RELEASE := $(SMING_RELEASE)' >> $(BUILD_TYPE_FILE); ) + + +# Called at final output stage to write a copy of config variables used for the build +# $1 -> Name of output file +define WriteFirmwareConfigFile +$(call WriteConfig,$1.cfg,$(CONFIG_VARS) $(RELINK_VARS) $(CACHE_VARS)) +endef + +# Write config variables to a cache file +# $1 -> Output filename +# $2 -> List of variable names to output +define WriteCacheValues +$(shell mkdir -p $(dir $1); + echo '# Automatically generated file. Do not edit.' > $1; + echo >> $1; + $(foreach v,$2,echo '$v = $(value $v)' >> $1;) ) +endef + +# Update config cache file +# We store the list of variable names to ensure that any not actively in use don't get lost +# $1 -> Output filename +# $2 -> Name of variable which contains list of names +define WriteConfigCache +$(call WriteCacheValues,$1,$($2)) +$(shell echo >> $1; + echo '$2 := $($2)' >> $1 ) +endef + +# Update variable cache for all operations except cleaning +ifeq (,$(findstring clean,$(MAKECMDGOALS))) +CACHED_VAR_NAMES := $(sort $(CACHED_VAR_NAMES) $(CONFIG_VARS) $(RELINK_VARS) $(CACHE_VARS)) +$(eval $(call WriteConfigCache,$(CONFIG_CACHE_FILE),CACHED_VAR_NAMES)) +endif diff --git a/samples/.gitignore b/samples/.gitignore deleted file mode 100644 index 003e406d3d..0000000000 --- a/samples/.gitignore +++ /dev/null @@ -1 +0,0 @@ -**/ld/standalone.rom.ld diff --git a/samples/Accelerometer_MMA7455/Makefile b/samples/Accelerometer_MMA7455/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Accelerometer_MMA7455/Makefile +++ b/samples/Accelerometer_MMA7455/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Accelerometer_MMA7455/Makefile-user.mk b/samples/Accelerometer_MMA7455/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Accelerometer_MMA7455/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Accelerometer_MMA7455/component.mk b/samples/Accelerometer_MMA7455/component.mk new file mode 100644 index 0000000000..ce1725567a --- /dev/null +++ b/samples/Accelerometer_MMA7455/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := MMA_7455 + +DISABLE_SPIFFS = 1 diff --git a/samples/Arducam/Makefile b/samples/Arducam/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Arducam/Makefile +++ b/samples/Arducam/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Arducam/Makefile-user.mk b/samples/Arducam/Makefile-user.mk deleted file mode 100644 index 9dc9f7faee..0000000000 --- a/samples/Arducam/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -#DISABLE_SPIFFS = 1 -SPIFF_FILES = web/build - diff --git a/samples/Arducam/component.mk b/samples/Arducam/component.mk new file mode 100644 index 0000000000..3d7a1074ba --- /dev/null +++ b/samples/Arducam/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := ArduCAM + +SPIFF_FILES = web/build diff --git a/samples/Basic_APA102/Makefile b/samples/Basic_APA102/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_APA102/Makefile +++ b/samples/Basic_APA102/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_APA102/Makefile-user.mk b/samples/Basic_APA102/Makefile-user.mk deleted file mode 100644 index 69060f38bf..0000000000 --- a/samples/Basic_APA102/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/ttyUSB0 - -## Com port speed -#COM_SPEED = 230400 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_APA102/component.mk b/samples/Basic_APA102/component.mk new file mode 100644 index 0000000000..75ebf23720 --- /dev/null +++ b/samples/Basic_APA102/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := APA102 + +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_Blink/Makefile b/samples/Basic_Blink/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Blink/Makefile +++ b/samples/Basic_Blink/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Blink/Makefile-user.mk b/samples/Basic_Blink/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_Blink/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_Blink/component.mk b/samples/Basic_Blink/component.mk new file mode 100644 index 0000000000..47a8bdfb2b --- /dev/null +++ b/samples/Basic_Blink/component.mk @@ -0,0 +1,39 @@ +## Application Component configuration +## Parameters configured here will override default and ENV values +## Uncomment and change examples: + +## Add your source directories here separated by space +# COMPONENT_SRCDIRS := app +# COMPONENT_SRCFILES := +# COMPONENT_INCDIRS := include + +## If you require any Arduino Libraries list them here +# ARDUINO_LIBRARIES := + +## List the names of any additional Components required for this project +# COMPONENT_DEPENDS := + +## Set paths for any GIT submodules your application uses +# COMPONENT_SUBMODULES := + +## Append any targets to be built as dependencies of the project, such as generation of additional binary files +# CUSTOM_TARGETS += + +## Additional object files to be included with the application library +# EXTRA_OBJ := + +## Additional libraries to be linked into the project +# EXTRA_LIBS := + +## Update any additional compiler flags +# CFLAGS += +# CXXFLAGS += + +## Configure flash parameters (for ESP12-E and other new boards): +# SPI_MODE := dio + +## SPIFFS options +DISABLE_SPIFFS := 1 +# SPIFF_FILES = files + +## Refer to Basic_rBoot sample for options relating to rBoot diff --git a/samples/Basic_Capsense/Makefile b/samples/Basic_Capsense/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Capsense/Makefile +++ b/samples/Basic_Capsense/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Capsense/Makefile-user.mk b/samples/Basic_Capsense/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_Capsense/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_Capsense/component.mk b/samples/Basic_Capsense/component.mk new file mode 100644 index 0000000000..4652678d1e --- /dev/null +++ b/samples/Basic_Capsense/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := CapacitiveSensor + +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_DateTime/Makefile b/samples/Basic_DateTime/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_DateTime/Makefile +++ b/samples/Basic_DateTime/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_DateTime/Makefile-user.mk b/samples/Basic_DateTime/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_DateTime/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_DateTime/component.mk b/samples/Basic_DateTime/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Basic_DateTime/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_Delegates/Makefile b/samples/Basic_Delegates/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Delegates/Makefile +++ b/samples/Basic_Delegates/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Delegates/Makefile-user.mk b/samples/Basic_Delegates/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_Delegates/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_Delegates/component.mk b/samples/Basic_Delegates/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Basic_Delegates/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_HwPWM/Makefile b/samples/Basic_HwPWM/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_HwPWM/Makefile +++ b/samples/Basic_HwPWM/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_HwPWM/Makefile-user.mk b/samples/Basic_HwPWM/Makefile-user.mk deleted file mode 100644 index 5f6b20bd94..0000000000 --- a/samples/Basic_HwPWM/Makefile-user.mk +++ /dev/null @@ -1,41 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - -# Uncomment the line below if you want to Espressif's PWM library. -#ENABLE_CUSTOM_PWM=0 diff --git a/samples/Basic_HwPWM/component.mk b/samples/Basic_HwPWM/component.mk new file mode 100644 index 0000000000..5794c096f3 --- /dev/null +++ b/samples/Basic_HwPWM/component.mk @@ -0,0 +1,4 @@ +DISABLE_SPIFFS = 1 + +# Uncomment the line below if you want to use Espressif's PWM library. +#ENABLE_CUSTOM_PWM=0 diff --git a/samples/Basic_Interrupts/Makefile b/samples/Basic_Interrupts/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Interrupts/Makefile +++ b/samples/Basic_Interrupts/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Interrupts/Makefile-user.mk b/samples/Basic_Interrupts/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_Interrupts/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_Interrupts/component.mk b/samples/Basic_Interrupts/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Basic_Interrupts/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_NFC/Makefile b/samples/Basic_NFC/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_NFC/Makefile +++ b/samples/Basic_NFC/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_NFC/Makefile-user.mk b/samples/Basic_NFC/Makefile-user.mk deleted file mode 100644 index 613df2baee..0000000000 --- a/samples/Basic_NFC/Makefile-user.mk +++ /dev/null @@ -1,38 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files \ No newline at end of file diff --git a/samples/Basic_NFC/component.mk b/samples/Basic_NFC/component.mk new file mode 100644 index 0000000000..6de711f481 --- /dev/null +++ b/samples/Basic_NFC/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := MFRC522 + +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_Neopixel/Makefile b/samples/Basic_Neopixel/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Neopixel/Makefile +++ b/samples/Basic_Neopixel/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Neopixel/Makefile-user.mk b/samples/Basic_Neopixel/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_Neopixel/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_Neopixel/component.mk b/samples/Basic_Neopixel/component.mk new file mode 100644 index 0000000000..7728b3185e --- /dev/null +++ b/samples/Basic_Neopixel/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := Adafruit_NeoPixel + +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_ProgMem/Makefile b/samples/Basic_ProgMem/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_ProgMem/Makefile +++ b/samples/Basic_ProgMem/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_ProgMem/Makefile-user.mk b/samples/Basic_ProgMem/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_ProgMem/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_ProgMem/component.mk b/samples/Basic_ProgMem/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Basic_ProgMem/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_ScannerI2C/Makefile b/samples/Basic_ScannerI2C/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_ScannerI2C/Makefile +++ b/samples/Basic_ScannerI2C/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_ScannerI2C/Makefile-user.mk b/samples/Basic_ScannerI2C/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_ScannerI2C/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_ScannerI2C/component.mk b/samples/Basic_ScannerI2C/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Basic_ScannerI2C/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_Serial/Makefile b/samples/Basic_Serial/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Serial/Makefile +++ b/samples/Basic_Serial/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Serial/Makefile-user.mk b/samples/Basic_Serial/Makefile-user.mk deleted file mode 100644 index 1c15e3569c..0000000000 --- a/samples/Basic_Serial/Makefile-user.mk +++ /dev/null @@ -1,48 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -SPIFF_FILES = files -SPIFF_SIZE ?= 65536 - -all_plus_files: files files/Readme.md all - -files: - $(Q) mkdir files - -# Large text file for demo purposes -files/Readme.md: $(SMING_HOME)/../Readme.md - $(Q) cp $< $@ diff --git a/samples/Basic_Serial/component.mk b/samples/Basic_Serial/component.mk new file mode 100644 index 0000000000..8b304d5876 --- /dev/null +++ b/samples/Basic_Serial/component.mk @@ -0,0 +1,8 @@ +SPIFF_SIZE ?= 65536 + +CUSTOM_TARGETS := files/Readme.md + +# Large text file for demo purposes +files/Readme.md: $(SMING_HOME)/../Readme.md + $(Q) mkdir -p $(@D) + $(Q) cp $< $@ diff --git a/samples/Basic_Servo/Makefile b/samples/Basic_Servo/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Servo/Makefile +++ b/samples/Basic_Servo/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Servo/Makefile-user.mk b/samples/Basic_Servo/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_Servo/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_Servo/component.mk b/samples/Basic_Servo/component.mk new file mode 100644 index 0000000000..08990693e8 --- /dev/null +++ b/samples/Basic_Servo/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := Servo + +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_SmartConfig/Makefile b/samples/Basic_SmartConfig/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_SmartConfig/Makefile +++ b/samples/Basic_SmartConfig/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_SmartConfig/Makefile-user.mk b/samples/Basic_SmartConfig/Makefile-user.mk deleted file mode 100644 index 3622c2d308..0000000000 --- a/samples/Basic_SmartConfig/Makefile-user.mk +++ /dev/null @@ -1,41 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - -# If you use custom LWIP compilation make sure to enable espconn because libsmartconfig uses it -ENABLE_ESPCONN = 1 diff --git a/samples/Basic_SmartConfig/component.mk b/samples/Basic_SmartConfig/component.mk new file mode 100644 index 0000000000..a80021bea5 --- /dev/null +++ b/samples/Basic_SmartConfig/component.mk @@ -0,0 +1,4 @@ +DISABLE_SPIFFS = 1 + +# If you use custom LWIP compilation make sure to enable espconn because libsmartconfig uses it +ENABLE_ESPCONN = 1 diff --git a/samples/Basic_Ssl/Makefile b/samples/Basic_Ssl/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_Ssl/Makefile +++ b/samples/Basic_Ssl/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_Ssl/Makefile-user.mk b/samples/Basic_Ssl/Makefile-user.mk deleted file mode 100644 index 3901e89699..0000000000 --- a/samples/Basic_Ssl/Makefile-user.mk +++ /dev/null @@ -1,51 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -#Add your source directories here separated by space -MODULES = app - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -#ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -# Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - -# We need rBoot in order to be able to run bigger Flash roms. - -#### overridable rBoot options #### -## use rboot build mode -RBOOT_ENABLED ?= 1 -## enable big flash support (for multiple roms, each in separate 1mb block of flash) -RBOOT_BIG_FLASH ?= 1 -## two rom mode (where two roms sit in the same 1mb block of flash) -#RBOOT_TWO_ROMS ?= 1 -## size of the flash chip -SPI_SIZE ?= 4M - -ENABLE_SSL=1 diff --git a/samples/Basic_Ssl/app/application.cpp b/samples/Basic_Ssl/app/application.cpp index a10e914953..d388700509 100644 --- a/samples/Basic_Ssl/app/application.cpp +++ b/samples/Basic_Ssl/app/application.cpp @@ -1,12 +1,3 @@ -/** - * Please, note, that in order to run this sample you should recompile Sming with ENABLE_SSL=1. - * The following three commands should be enough: - * - * cd Sming/Sming - * make clean - * make ENABLE_SSL=1 - */ - #include #include "Data/HexString.h" diff --git a/samples/Basic_Ssl/component.mk b/samples/Basic_Ssl/component.mk new file mode 100644 index 0000000000..1e5eedd2a0 --- /dev/null +++ b/samples/Basic_Ssl/component.mk @@ -0,0 +1,6 @@ +DISABLE_SPIFFS = 1 + +## size of the flash chip +SPI_SIZE ?= 4M + +ENABLE_SSL = 1 diff --git a/samples/Basic_WebSkeletonApp/Makefile b/samples/Basic_WebSkeletonApp/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_WebSkeletonApp/Makefile +++ b/samples/Basic_WebSkeletonApp/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_WebSkeletonApp/Makefile-user.mk b/samples/Basic_WebSkeletonApp/Makefile-user.mk deleted file mode 100644 index 265efd479c..0000000000 --- a/samples/Basic_WebSkeletonApp/Makefile-user.mk +++ /dev/null @@ -1,29 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -#ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -# Com port speed -# COM_SPEED = 115200 - -SPIFF_SIZE = 196608 diff --git a/samples/Basic_WebSkeletonApp/component.mk b/samples/Basic_WebSkeletonApp/component.mk new file mode 100644 index 0000000000..d7a21475da --- /dev/null +++ b/samples/Basic_WebSkeletonApp/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := OneWire + +SPIFF_SIZE ?= 196608 diff --git a/samples/Basic_WiFi/Makefile b/samples/Basic_WiFi/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_WiFi/Makefile +++ b/samples/Basic_WiFi/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_WiFi/Makefile-user.mk b/samples/Basic_WiFi/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Basic_WiFi/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Basic_WiFi/component.mk b/samples/Basic_WiFi/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Basic_WiFi/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Basic_rBoot/Makefile b/samples/Basic_rBoot/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Basic_rBoot/Makefile +++ b/samples/Basic_rBoot/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Basic_rBoot/Makefile-user.mk b/samples/Basic_rBoot/Makefile-user.mk deleted file mode 100644 index fcc217a89e..0000000000 --- a/samples/Basic_rBoot/Makefile-user.mk +++ /dev/null @@ -1,66 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -SPIFF_FILES = files - -#### overridable rBoot options #### -## use rboot build mode -RBOOT_ENABLED ?= 1 -## enable big flash support (for multiple roms, each in separate 1mb block of flash) -RBOOT_BIG_FLASH ?= 1 -## two rom mode (where two roms sit in the same 1mb block of flash) -#RBOOT_TWO_ROMS ?= 1 -## size of the flash chip -SPI_SIZE ?= 4M -## output file for first rom (.bin will be appended) -#RBOOT_ROM_0 ?= rom0 -## input linker file for first rom -#RBOOT_LD_0 ?= rom0.ld -## these next options only needed when using two rom mode -#RBOOT_ROM_1 ?= rom1 -#RBOOT_LD_1 ?= rom1.ld -## size of the spiffs to create -SPIFF_SIZE ?= 65536 -## option to completely disable spiffs -#DISABLE_SPIFFS = 1 -## flash offsets for spiffs, set if using two rom mode or not on a 4mb flash -## (spiffs location defaults to the mb after the rom slot on 4mb flash) -#RBOOT_SPIFFS_0 ?= 0x100000 -#RBOOT_SPIFFS_1 ?= 0x300000 -## esptool2 path -#ESPTOOL2 ?= esptool2 - diff --git a/samples/Basic_rBoot/component.mk b/samples/Basic_rBoot/component.mk new file mode 100644 index 0000000000..f606ea3444 --- /dev/null +++ b/samples/Basic_rBoot/component.mk @@ -0,0 +1,34 @@ +#### overridable rBoot options #### + +## use rboot build mode +RBOOT_ENABLED ?= 1 + +## enable big flash support (for multiple roms, each in separate 1mb block of flash) +RBOOT_BIG_FLASH ?= 1 + +## two rom mode (where two roms sit in the same 1mb block of flash) +#RBOOT_TWO_ROMS ?= 1 + +## size of the flash chip +SPI_SIZE ?= 4M + +## output file for first rom (.bin will be appended) +#RBOOT_ROM_0 ?= rom0 + +## input linker file for first rom +#RBOOT_LD_0 ?= rom0.ld + +## these next options only needed when using two rom mode +#RBOOT_ROM_1 ?= rom1 +#RBOOT_LD_1 ?= rom1.ld + +## size of the spiffs to create +SPIFF_SIZE ?= 65536 + +## option to completely disable spiffs +#DISABLE_SPIFFS ?= 1 + +## flash offsets for spiffs, set if using two rom mode or not on a 4mb flash +## (spiffs location defaults to the mb after the rom slot on 4mb flash) +#RBOOT_SPIFFS_0 ?= 0x100000 +#RBOOT_SPIFFS_1 ?= 0x300000 diff --git a/samples/CommandProcessing_Debug/Makefile b/samples/CommandProcessing_Debug/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/CommandProcessing_Debug/Makefile +++ b/samples/CommandProcessing_Debug/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/CommandProcessing_Debug/Makefile-user.mk b/samples/CommandProcessing_Debug/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/CommandProcessing_Debug/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/CommandProcessing_Debug/component.mk b/samples/CommandProcessing_Debug/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/CommandProcessing_Debug/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Compass_HMC5883L/Makefile b/samples/Compass_HMC5883L/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Compass_HMC5883L/Makefile +++ b/samples/Compass_HMC5883L/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Compass_HMC5883L/Makefile-user.mk b/samples/Compass_HMC5883L/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Compass_HMC5883L/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Compass_HMC5883L/component.mk b/samples/Compass_HMC5883L/component.mk new file mode 100644 index 0000000000..17af62653a --- /dev/null +++ b/samples/Compass_HMC5883L/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := HMC5883L I2Cdev + +DISABLE_SPIFFS = 1 diff --git a/samples/DFPlayerMini/.cproject b/samples/DFPlayerMini/.cproject new file mode 100644 index 0000000000..7ce192f4a7 --- /dev/null +++ b/samples/DFPlayerMini/.cproject @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/DFPlayerMini/.project b/samples/DFPlayerMini/.project new file mode 100644 index 0000000000..e11aea2617 --- /dev/null +++ b/samples/DFPlayerMini/.project @@ -0,0 +1,27 @@ + + + DFPlayerMini + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/samples/DFPlayerMini/Makefile b/samples/DFPlayerMini/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/DFPlayerMini/Makefile +++ b/samples/DFPlayerMini/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/DFPlayerMini/Makefile-user.mk b/samples/DFPlayerMini/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/DFPlayerMini/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/DFPlayerMini/component.mk b/samples/DFPlayerMini/component.mk new file mode 100644 index 0000000000..ccda75fa45 --- /dev/null +++ b/samples/DFPlayerMini/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := DFRobotDFPlayerMini + +DISABLE_SPIFFS = 1 diff --git a/samples/DNSCaptivePortal/Makefile b/samples/DNSCaptivePortal/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/DNSCaptivePortal/Makefile +++ b/samples/DNSCaptivePortal/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/DNSCaptivePortal/Makefile-user.mk b/samples/DNSCaptivePortal/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/DNSCaptivePortal/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/DNSCaptivePortal/component.mk b/samples/DNSCaptivePortal/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/DNSCaptivePortal/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/DS3232RTC_NTP_Setter/Makefile b/samples/DS3232RTC_NTP_Setter/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/DS3232RTC_NTP_Setter/Makefile +++ b/samples/DS3232RTC_NTP_Setter/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/DS3232RTC_NTP_Setter/Makefile-user.mk b/samples/DS3232RTC_NTP_Setter/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/DS3232RTC_NTP_Setter/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/DS3232RTC_NTP_Setter/component.mk b/samples/DS3232RTC_NTP_Setter/component.mk new file mode 100644 index 0000000000..4534b60e67 --- /dev/null +++ b/samples/DS3232RTC_NTP_Setter/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := DS3232RTC + +DISABLE_SPIFFS = 1 diff --git a/samples/Display_TM1637/.cproject b/samples/Display_TM1637/.cproject new file mode 100644 index 0000000000..bc7ccf404a --- /dev/null +++ b/samples/Display_TM1637/.cproject @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Display_TM1637/.project b/samples/Display_TM1637/.project new file mode 100644 index 0000000000..6ade25eec3 --- /dev/null +++ b/samples/Display_TM1637/.project @@ -0,0 +1,27 @@ + + + Display_TM1637 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/samples/Display_TM1637/Makefile b/samples/Display_TM1637/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Display_TM1637/Makefile +++ b/samples/Display_TM1637/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Display_TM1637/Makefile-user.mk b/samples/Display_TM1637/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Display_TM1637/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Display_TM1637/component.mk b/samples/Display_TM1637/component.mk new file mode 100644 index 0000000000..1f36cbd482 --- /dev/null +++ b/samples/Display_TM1637/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := TM1637 + +DISABLE_SPIFFS = 1 diff --git a/samples/Echo_Ssl/Makefile b/samples/Echo_Ssl/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Echo_Ssl/Makefile +++ b/samples/Echo_Ssl/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Echo_Ssl/Makefile-user.mk b/samples/Echo_Ssl/Makefile-user.mk deleted file mode 100644 index 3901e89699..0000000000 --- a/samples/Echo_Ssl/Makefile-user.mk +++ /dev/null @@ -1,51 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -#Add your source directories here separated by space -MODULES = app - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -#ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -# Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - -# We need rBoot in order to be able to run bigger Flash roms. - -#### overridable rBoot options #### -## use rboot build mode -RBOOT_ENABLED ?= 1 -## enable big flash support (for multiple roms, each in separate 1mb block of flash) -RBOOT_BIG_FLASH ?= 1 -## two rom mode (where two roms sit in the same 1mb block of flash) -#RBOOT_TWO_ROMS ?= 1 -## size of the flash chip -SPI_SIZE ?= 4M - -ENABLE_SSL=1 diff --git a/samples/Echo_Ssl/app/application.cpp b/samples/Echo_Ssl/app/application.cpp index 62362e0519..ca74a64861 100644 --- a/samples/Echo_Ssl/app/application.cpp +++ b/samples/Echo_Ssl/app/application.cpp @@ -1,11 +1,4 @@ /** - * Please, note, that in order to run this sample you should recompile Sming with ENABLE_SSL=1. - * The following three commands should be enough: - * - * cd Sming/Sming - * make clean - * make ENABLE_SSL=1 - * * * This example talks to SSL enabled TCP server. If you do not have such you can use ncat (from the nmap package) and run something like this * diff --git a/samples/Echo_Ssl/component.mk b/samples/Echo_Ssl/component.mk new file mode 100644 index 0000000000..1e5eedd2a0 --- /dev/null +++ b/samples/Echo_Ssl/component.mk @@ -0,0 +1,6 @@ +DISABLE_SPIFFS = 1 + +## size of the flash chip +SPI_SIZE ?= 4M + +ENABLE_SSL = 1 diff --git a/samples/FtpServer_Files/Makefile b/samples/FtpServer_Files/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/FtpServer_Files/Makefile +++ b/samples/FtpServer_Files/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/FtpServer_Files/Makefile-user.mk b/samples/FtpServer_Files/Makefile-user.mk deleted file mode 100644 index 1bad3ee5c5..0000000000 --- a/samples/FtpServer_Files/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -SPIFF_FILES = files - diff --git a/samples/Gesture_APDS-9960/Makefile b/samples/Gesture_APDS-9960/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Gesture_APDS-9960/Makefile +++ b/samples/Gesture_APDS-9960/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Gesture_APDS-9960/Makefile-user.mk b/samples/Gesture_APDS-9960/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Gesture_APDS-9960/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Gesture_APDS-9960/component.mk b/samples/Gesture_APDS-9960/component.mk new file mode 100644 index 0000000000..29be2f65a4 --- /dev/null +++ b/samples/Gesture_APDS-9960/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := SparkFun_APDS9960 + +DISABLE_SPIFFS = 1 diff --git a/samples/HttpClient/Makefile b/samples/HttpClient/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/HttpClient/Makefile +++ b/samples/HttpClient/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/HttpClient/Makefile-user.mk b/samples/HttpClient/Makefile-user.mk deleted file mode 100644 index 079d48ffed..0000000000 --- a/samples/HttpClient/Makefile-user.mk +++ /dev/null @@ -1,51 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -#Add your source directories here separated by space -MODULES = app - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -#ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -# Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - -# We need rBoot in order to be able to run bigger Flash roms. - -#### overridable rBoot options #### -## use rboot build mode -RBOOT_ENABLED ?= 1 -## enable big flash support (for multiple roms, each in separate 1mb block of flash) -RBOOT_BIG_FLASH ?= 1 -## two rom mode (where two roms sit in the same 1mb block of flash) -#RBOOT_TWO_ROMS ?= 1 -## size of the flash chip -SPI_SIZE ?= 4M - -ENABLE_SSL=1 diff --git a/samples/HttpClient/app/application.cpp b/samples/HttpClient/app/application.cpp index 729055d159..794a2f3350 100644 --- a/samples/HttpClient/app/application.cpp +++ b/samples/HttpClient/app/application.cpp @@ -1,12 +1,3 @@ -/** - * Please, note, that in order to run this sample you should recompile Sming with ENABLE_SSL=1. - * The following three commands should be enough: - * - * cd Sming/Sming - * make clean - * make ENABLE_SSL=1 - */ - #include #include "Network/HttpClient.h" diff --git a/samples/HttpClient/component.mk b/samples/HttpClient/component.mk new file mode 100644 index 0000000000..86d95cddcb --- /dev/null +++ b/samples/HttpClient/component.mk @@ -0,0 +1,4 @@ +## size of the flash chip +SPI_SIZE ?= 4M + +ENABLE_SSL = 1 diff --git a/samples/HttpClient_Instapush/Makefile b/samples/HttpClient_Instapush/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/HttpClient_Instapush/Makefile +++ b/samples/HttpClient_Instapush/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/HttpClient_Instapush/Makefile-user.mk b/samples/HttpClient_Instapush/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/HttpClient_Instapush/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/HttpClient_Instapush/component.mk b/samples/HttpClient_Instapush/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/HttpClient_Instapush/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/HttpClient_ThingSpeak/Makefile b/samples/HttpClient_ThingSpeak/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/HttpClient_ThingSpeak/Makefile +++ b/samples/HttpClient_ThingSpeak/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/HttpClient_ThingSpeak/Makefile-user.mk b/samples/HttpClient_ThingSpeak/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/HttpClient_ThingSpeak/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/HttpClient_ThingSpeak/component.mk b/samples/HttpClient_ThingSpeak/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/HttpClient_ThingSpeak/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/HttpServer_AJAX/Makefile b/samples/HttpServer_AJAX/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/HttpServer_AJAX/Makefile +++ b/samples/HttpServer_AJAX/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/HttpServer_AJAX/Makefile-user.mk b/samples/HttpServer_AJAX/Makefile-user.mk deleted file mode 100644 index 7c272dd4b5..0000000000 --- a/samples/HttpServer_AJAX/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -SPIFF_FILES = web/build - diff --git a/samples/HttpServer_AJAX/component.mk b/samples/HttpServer_AJAX/component.mk new file mode 100644 index 0000000000..c3b952901f --- /dev/null +++ b/samples/HttpServer_AJAX/component.mk @@ -0,0 +1 @@ +SPIFF_FILES = web/build diff --git a/samples/HttpServer_Bootstrap/Makefile b/samples/HttpServer_Bootstrap/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/HttpServer_Bootstrap/Makefile +++ b/samples/HttpServer_Bootstrap/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/HttpServer_Bootstrap/Makefile-user.mk b/samples/HttpServer_Bootstrap/Makefile-user.mk deleted file mode 100644 index c9aa278c11..0000000000 --- a/samples/HttpServer_Bootstrap/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/HttpServer_ConfigNetwork/Makefile b/samples/HttpServer_ConfigNetwork/Makefile index 44cf61f49e..ff51b6c3a7 100644 --- a/samples/HttpServer_ConfigNetwork/Makefile +++ b/samples/HttpServer_ConfigNetwork/Makefile @@ -1,13 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/HttpServer_ConfigNetwork/Makefile-user.mk b/samples/HttpServer_ConfigNetwork/Makefile-user.mk deleted file mode 100644 index 28ed73fa25..0000000000 --- a/samples/HttpServer_ConfigNetwork/Makefile-user.mk +++ /dev/null @@ -1,47 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -SPIFF_FILES = web/build - -all: - -web-pack: - $(Q) gulp - $(Q) date +'%a, %d %b %Y %H:%M:%S GMT' -u > web/build/.lastModified - -web-upload: web-pack spiff_update - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(SPIFF_START_OFFSET) $(SPIFF_BIN_OUT) diff --git a/samples/HttpServer_ConfigNetwork/app/application.cpp b/samples/HttpServer_ConfigNetwork/app/application.cpp index 6d150b053e..7598e73aed 100644 --- a/samples/HttpServer_ConfigNetwork/app/application.cpp +++ b/samples/HttpServer_ConfigNetwork/app/application.cpp @@ -12,7 +12,7 @@ Timer connectionTimer; String lastModified; // Instead of using a SPIFFS file, here we demonstrate usage of imported Flash Strings -IMPORT_FSTR(flashSettings, "web/build/settings.html") +IMPORT_FSTR(flashSettings, PROJECT_DIR "/web/build/settings.html") void onIndex(HttpRequest& request, HttpResponse& response) { diff --git a/samples/HttpServer_ConfigNetwork/component.mk b/samples/HttpServer_ConfigNetwork/component.mk new file mode 100644 index 0000000000..9877a2b893 --- /dev/null +++ b/samples/HttpServer_ConfigNetwork/component.mk @@ -0,0 +1,8 @@ +SPIFF_FILES = web/build + +web-pack: + $(Q) gulp + $(Q) date +'%a, %d %b %Y %H:%M:%S GMT' -u > web/build/.lastModified + +web-upload: web-pack spiff_update + $(call WriteFlash,$(SPIFF_START_OFFSET)=$(SPIFF_BIN_OUT)) diff --git a/samples/HttpServer_WebSockets/Makefile b/samples/HttpServer_WebSockets/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/HttpServer_WebSockets/Makefile +++ b/samples/HttpServer_WebSockets/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/HttpServer_WebSockets/Makefile-user.mk b/samples/HttpServer_WebSockets/Makefile-user.mk deleted file mode 100644 index 48064da273..0000000000 --- a/samples/HttpServer_WebSockets/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -#DISABLE_SPIFFS = 1 -SPIFF_FILES = files - diff --git a/samples/Humidity_AM2321/Makefile b/samples/Humidity_AM2321/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Humidity_AM2321/Makefile +++ b/samples/Humidity_AM2321/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Humidity_AM2321/Makefile-user.mk b/samples/Humidity_AM2321/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Humidity_AM2321/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Humidity_AM2321/component.mk b/samples/Humidity_AM2321/component.mk new file mode 100644 index 0000000000..ed804579fb --- /dev/null +++ b/samples/Humidity_AM2321/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := AM2321 + +DISABLE_SPIFFS = 1 diff --git a/samples/Humidity_DHT22/Makefile b/samples/Humidity_DHT22/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Humidity_DHT22/Makefile +++ b/samples/Humidity_DHT22/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Humidity_DHT22/Makefile-user.mk b/samples/Humidity_DHT22/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Humidity_DHT22/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Humidity_DHT22/component.mk b/samples/Humidity_DHT22/component.mk new file mode 100644 index 0000000000..da47456b52 --- /dev/null +++ b/samples/Humidity_DHT22/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := DHTesp + +DISABLE_SPIFFS = 1 diff --git a/samples/Humidity_SI7021/Makefile b/samples/Humidity_SI7021/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Humidity_SI7021/Makefile +++ b/samples/Humidity_SI7021/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Humidity_SI7021/Makefile-user.mk b/samples/Humidity_SI7021/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Humidity_SI7021/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Humidity_SI7021/component.mk b/samples/Humidity_SI7021/component.mk new file mode 100644 index 0000000000..e01c1c0c49 --- /dev/null +++ b/samples/Humidity_SI7021/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := SI7021 + +DISABLE_SPIFFS = 1 diff --git a/samples/IR_lib/Makefile b/samples/IR_lib/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/IR_lib/Makefile +++ b/samples/IR_lib/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/IR_lib/Makefile-user.mk b/samples/IR_lib/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/IR_lib/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/IR_lib/component.mk b/samples/IR_lib/component.mk new file mode 100644 index 0000000000..10e306665b --- /dev/null +++ b/samples/IR_lib/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := IR + +DISABLE_SPIFFS = 1 diff --git a/samples/LED_WS2812/Makefile b/samples/LED_WS2812/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/LED_WS2812/Makefile +++ b/samples/LED_WS2812/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/LED_WS2812/Makefile-user.mk b/samples/LED_WS2812/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/LED_WS2812/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/LED_WS2812/component.mk b/samples/LED_WS2812/component.mk new file mode 100644 index 0000000000..c3b9fd7313 --- /dev/null +++ b/samples/LED_WS2812/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := WS2812 + +DISABLE_SPIFFS = 1 diff --git a/samples/LED_YeelightBulb/Makefile b/samples/LED_YeelightBulb/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/LED_YeelightBulb/Makefile +++ b/samples/LED_YeelightBulb/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/LED_YeelightBulb/Makefile-user.mk b/samples/LED_YeelightBulb/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/LED_YeelightBulb/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/LED_YeelightBulb/component.mk b/samples/LED_YeelightBulb/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/LED_YeelightBulb/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Light_BH1750/Makefile b/samples/Light_BH1750/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Light_BH1750/Makefile +++ b/samples/Light_BH1750/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Light_BH1750/Makefile-user.mk b/samples/Light_BH1750/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Light_BH1750/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Light_BH1750/component.mk b/samples/Light_BH1750/component.mk new file mode 100644 index 0000000000..0ff62be148 --- /dev/null +++ b/samples/Light_BH1750/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := BH1750FVI + +DISABLE_SPIFFS = 1 diff --git a/samples/LiquidCrystal_44780/Makefile b/samples/LiquidCrystal_44780/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/LiquidCrystal_44780/Makefile +++ b/samples/LiquidCrystal_44780/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/LiquidCrystal_44780/Makefile-user.mk b/samples/LiquidCrystal_44780/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/LiquidCrystal_44780/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/LiquidCrystal_44780/component.mk b/samples/LiquidCrystal_44780/component.mk new file mode 100644 index 0000000000..2eaa53c03c --- /dev/null +++ b/samples/LiquidCrystal_44780/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := LiquidCrystal + +DISABLE_SPIFFS = 1 diff --git a/samples/LiveDebug/Makefile b/samples/LiveDebug/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/LiveDebug/Makefile +++ b/samples/LiveDebug/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/LiveDebug/Makefile-user.mk b/samples/LiveDebug/Makefile-user.mk deleted file mode 100644 index 224faac795..0000000000 --- a/samples/LiveDebug/Makefile-user.mk +++ /dev/null @@ -1,49 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -#Add your source directories here separated by space -MODULES = app - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -#ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -DISABLE_SPIFFS = 1 - -# Com port speed -# COM_SPEED = 115200 -ENABLE_GDB=1 - -export ENABLE_GDB - -ENABLE_GDB_CONSOLE ?= 1 - -ifeq ($(ENABLE_GDB_CONSOLE), 1) - USER_CFLAGS += -DGDBSTUB_ENABLE_SYSCALL -endif - -ifeq ($(ENABLE_GDB_CONSOLE), 1) -all: - $(warning WARNING! Enabling the GDB console may interfere with visual debuggers, like eclipse) - $(warning If required, please build with `make ENABLE_GDB_CONSOLE=0`) -endif - -export USER_CFLAGS diff --git a/samples/LiveDebug/component.mk b/samples/LiveDebug/component.mk new file mode 100644 index 0000000000..f2576c6518 --- /dev/null +++ b/samples/LiveDebug/component.mk @@ -0,0 +1,13 @@ +DISABLE_SPIFFS = 1 + +ENABLE_GDB = 1 + +ENABLE_GDB_CONSOLE ?= 1 + +ifeq ($(ENABLE_GDB_CONSOLE), 1) +USER_CFLAGS := -DGDBSTUB_ENABLE_SYSCALL + +all: + $(warning WARNING! Enabling the GDB console may interfere with visual debuggers, like eclipse) + $(warning If required, please build with `make ENABLE_GDB_CONSOLE=0`) +endif diff --git a/samples/MeteoControl/Makefile b/samples/MeteoControl/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/MeteoControl/Makefile +++ b/samples/MeteoControl/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/MeteoControl/Makefile-user.mk b/samples/MeteoControl/Makefile-user.mk deleted file mode 100644 index 3ebad88935..0000000000 --- a/samples/MeteoControl/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -# DISABLE_SPIFFS = 1 -SPIFF_FILES = web - diff --git a/samples/MeteoControl/component.mk b/samples/MeteoControl/component.mk new file mode 100644 index 0000000000..c1b02863ea --- /dev/null +++ b/samples/MeteoControl/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := LiquidCrystal DHTesp + +SPIFF_FILES = web diff --git a/samples/MeteoControl_mqtt/Makefile b/samples/MeteoControl_mqtt/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/MeteoControl_mqtt/Makefile +++ b/samples/MeteoControl_mqtt/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/MeteoControl_mqtt/Makefile-user.mk b/samples/MeteoControl_mqtt/Makefile-user.mk deleted file mode 100644 index efb9fe956a..0000000000 --- a/samples/MeteoControl_mqtt/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -#SPIFF_FILES = web - diff --git a/samples/MeteoControl_mqtt/component.mk b/samples/MeteoControl_mqtt/component.mk new file mode 100644 index 0000000000..bdb4b87fa1 --- /dev/null +++ b/samples/MeteoControl_mqtt/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := BMP180 SI7021 + +DISABLE_SPIFFS = 1 diff --git a/samples/MqttClient_Hello/Makefile b/samples/MqttClient_Hello/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/MqttClient_Hello/Makefile +++ b/samples/MqttClient_Hello/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/MqttClient_Hello/Makefile-user.mk b/samples/MqttClient_Hello/Makefile-user.mk deleted file mode 100644 index d4b2482acd..0000000000 --- a/samples/MqttClient_Hello/Makefile-user.mk +++ /dev/null @@ -1,57 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 -# COM_SPEED_ESPTOOL = 921600 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files -# we will use global WiFi settings from Eclipse Environment Variables, if possible - -ifdef MQTT_URL - USER_CFLAGS += -DMQTT_URL=\"$(MQTT_URL)\" -endif - -# We need rBoot in order to be able to run bigger Flash roms. - -#### overridable rBoot options #### -## use rboot build mode -RBOOT_ENABLED ?= 1 -## enable big flash support (for multiple roms, each in separate 1mb block of flash) -RBOOT_BIG_FLASH ?= 1 -## two rom mode (where two roms sit in the same 1mb block of flash) -#RBOOT_TWO_ROMS ?= 1 -## size of the flash chip -SPI_SIZE ?= 4M - diff --git a/samples/MqttClient_Hello/component.mk b/samples/MqttClient_Hello/component.mk new file mode 100644 index 0000000000..0b3208d9a7 --- /dev/null +++ b/samples/MqttClient_Hello/component.mk @@ -0,0 +1,8 @@ +DISABLE_SPIFFS = 1 + +ifdef MQTT_URL + USER_CFLAGS += -DMQTT_URL=\"$(MQTT_URL)\" +endif + +## size of the flash chip +SPI_SIZE ?= 4M diff --git a/samples/Nextion_Button/.cproject b/samples/Nextion_Button/.cproject new file mode 100644 index 0000000000..39bd845a67 --- /dev/null +++ b/samples/Nextion_Button/.cproject @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Nextion_Button/.project b/samples/Nextion_Button/.project new file mode 100644 index 0000000000..9b712daf01 --- /dev/null +++ b/samples/Nextion_Button/.project @@ -0,0 +1,27 @@ + + + Nextion_Button + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/samples/Nextion_Button/Makefile b/samples/Nextion_Button/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Nextion_Button/Makefile +++ b/samples/Nextion_Button/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Nextion_Button/Makefile-user.mk b/samples/Nextion_Button/Makefile-user.mk deleted file mode 100644 index 58bc76d381..0000000000 --- a/samples/Nextion_Button/Makefile-user.mk +++ /dev/null @@ -1,40 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - -ENABLE_NEXTION = 1 diff --git a/samples/Nextion_Button/component.mk b/samples/Nextion_Button/component.mk new file mode 100644 index 0000000000..c7cc0b302c --- /dev/null +++ b/samples/Nextion_Button/component.mk @@ -0,0 +1,5 @@ +ARDUINO_LIBRARIES := ITEADLIB_Arduino_Nextion + +DISABLE_SPIFFS = 1 + +ENABLE_NEXTION = 1 diff --git a/samples/PortExpander_MCP23017/Makefile b/samples/PortExpander_MCP23017/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/PortExpander_MCP23017/Makefile +++ b/samples/PortExpander_MCP23017/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/PortExpander_MCP23017/Makefile-user.mk b/samples/PortExpander_MCP23017/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/PortExpander_MCP23017/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/PortExpander_MCP23017/component.mk b/samples/PortExpander_MCP23017/component.mk new file mode 100644 index 0000000000..e59988fa90 --- /dev/null +++ b/samples/PortExpander_MCP23017/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := MCP23017 + +DISABLE_SPIFFS = 1 diff --git a/samples/PortExpander_MCP23S17/Makefile b/samples/PortExpander_MCP23S17/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/PortExpander_MCP23S17/Makefile +++ b/samples/PortExpander_MCP23S17/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/PortExpander_MCP23S17/Makefile-user.mk b/samples/PortExpander_MCP23S17/Makefile-user.mk deleted file mode 100644 index bc53275f5b..0000000000 --- a/samples/PortExpander_MCP23S17/Makefile-user.mk +++ /dev/null @@ -1,30 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -#Add your source directories here separated by space -MODULES = app - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -#ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -# Com port speed -# COM_SPEED = 115200 \ No newline at end of file diff --git a/samples/PortExpander_MCP23S17/component.mk b/samples/PortExpander_MCP23S17/component.mk new file mode 100644 index 0000000000..05753ccf86 --- /dev/null +++ b/samples/PortExpander_MCP23S17/component.mk @@ -0,0 +1 @@ +ARDUINO_LIBRARIES := MCP23S17 diff --git a/samples/Pressure_BMP180/Makefile b/samples/Pressure_BMP180/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Pressure_BMP180/Makefile +++ b/samples/Pressure_BMP180/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Pressure_BMP180/Makefile-user.mk b/samples/Pressure_BMP180/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Pressure_BMP180/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Pressure_BMP180/component.mk b/samples/Pressure_BMP180/component.mk new file mode 100644 index 0000000000..edad90d026 --- /dev/null +++ b/samples/Pressure_BMP180/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := BMP180 + +DISABLE_SPIFFS = 1 diff --git a/samples/Radio_RCSwitch/Makefile b/samples/Radio_RCSwitch/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Radio_RCSwitch/Makefile +++ b/samples/Radio_RCSwitch/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Radio_RCSwitch/Makefile-user.mk b/samples/Radio_RCSwitch/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Radio_RCSwitch/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Radio_RCSwitch/component.mk b/samples/Radio_RCSwitch/component.mk new file mode 100644 index 0000000000..664aaee609 --- /dev/null +++ b/samples/Radio_RCSwitch/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := RCSwitch + +DISABLE_SPIFFS = 1 diff --git a/samples/Radio_nRF24L01/Makefile b/samples/Radio_nRF24L01/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Radio_nRF24L01/Makefile +++ b/samples/Radio_nRF24L01/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Radio_nRF24L01/Makefile-user.mk b/samples/Radio_nRF24L01/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Radio_nRF24L01/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Radio_nRF24L01/component.mk b/samples/Radio_nRF24L01/component.mk new file mode 100644 index 0000000000..8102404c63 --- /dev/null +++ b/samples/Radio_nRF24L01/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := TFT_ILI9163C RF24 + +DISABLE_SPIFFS = 1 diff --git a/samples/Radio_si4432/Makefile b/samples/Radio_si4432/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Radio_si4432/Makefile +++ b/samples/Radio_si4432/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Radio_si4432/Makefile-user.mk b/samples/Radio_si4432/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Radio_si4432/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Radio_si4432/component.mk b/samples/Radio_si4432/component.mk new file mode 100644 index 0000000000..2ad241b2cc --- /dev/null +++ b/samples/Radio_si4432/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := si4432 + +DISABLE_SPIFFS = 1 diff --git a/samples/SDCard/Makefile b/samples/SDCard/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/SDCard/Makefile +++ b/samples/SDCard/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/SDCard/Makefile-user.mk b/samples/SDCard/Makefile-user.mk deleted file mode 100644 index 48064da273..0000000000 --- a/samples/SDCard/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -#DISABLE_SPIFFS = 1 -SPIFF_FILES = files - diff --git a/samples/SDCard/component.mk b/samples/SDCard/component.mk new file mode 100644 index 0000000000..e93d57393d --- /dev/null +++ b/samples/SDCard/component.mk @@ -0,0 +1 @@ +ARDUINO_LIBRARIES := SDCard diff --git a/samples/ScreenLCD_5110/Makefile b/samples/ScreenLCD_5110/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/ScreenLCD_5110/Makefile +++ b/samples/ScreenLCD_5110/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/ScreenLCD_5110/Makefile-user.mk b/samples/ScreenLCD_5110/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/ScreenLCD_5110/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/ScreenLCD_5110/component.mk b/samples/ScreenLCD_5110/component.mk new file mode 100644 index 0000000000..9e06efca69 --- /dev/null +++ b/samples/ScreenLCD_5110/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := Adafruit_PCD8544 + +DISABLE_SPIFFS = 1 diff --git a/samples/ScreenOLED_SSD1306/Makefile b/samples/ScreenOLED_SSD1306/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/ScreenOLED_SSD1306/Makefile +++ b/samples/ScreenOLED_SSD1306/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/ScreenOLED_SSD1306/Makefile-user.mk b/samples/ScreenOLED_SSD1306/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/ScreenOLED_SSD1306/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/ScreenOLED_SSD1306/component.mk b/samples/ScreenOLED_SSD1306/component.mk new file mode 100644 index 0000000000..c30fac01ee --- /dev/null +++ b/samples/ScreenOLED_SSD1306/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := Adafruit_SSD1306 + +DISABLE_SPIFFS = 1 diff --git a/samples/ScreenTFT_ILI9163C/Makefile b/samples/ScreenTFT_ILI9163C/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/ScreenTFT_ILI9163C/Makefile +++ b/samples/ScreenTFT_ILI9163C/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/ScreenTFT_ILI9163C/Makefile-user.mk b/samples/ScreenTFT_ILI9163C/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/ScreenTFT_ILI9163C/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/ScreenTFT_ILI9163C/component.mk b/samples/ScreenTFT_ILI9163C/component.mk new file mode 100644 index 0000000000..9494698445 --- /dev/null +++ b/samples/ScreenTFT_ILI9163C/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := TFT_ILI9163C + +DISABLE_SPIFFS = 1 diff --git a/samples/ScreenTFT_ILI9340-ILI9341/Makefile b/samples/ScreenTFT_ILI9340-ILI9341/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/ScreenTFT_ILI9340-ILI9341/Makefile +++ b/samples/ScreenTFT_ILI9340-ILI9341/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/ScreenTFT_ILI9340-ILI9341/Makefile-user.mk b/samples/ScreenTFT_ILI9340-ILI9341/Makefile-user.mk deleted file mode 100644 index 48064da273..0000000000 --- a/samples/ScreenTFT_ILI9340-ILI9341/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -#DISABLE_SPIFFS = 1 -SPIFF_FILES = files - diff --git a/samples/ScreenTFT_ILI9340-ILI9341/component.mk b/samples/ScreenTFT_ILI9340-ILI9341/component.mk new file mode 100644 index 0000000000..77706c8ff2 --- /dev/null +++ b/samples/ScreenTFT_ILI9340-ILI9341/component.mk @@ -0,0 +1 @@ +ARDUINO_LIBRARIES := Adafruit_ILI9341 diff --git a/samples/ScreenTFT_ST7735/Makefile b/samples/ScreenTFT_ST7735/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/ScreenTFT_ST7735/Makefile +++ b/samples/ScreenTFT_ST7735/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/ScreenTFT_ST7735/Makefile-user.mk b/samples/ScreenTFT_ST7735/Makefile-user.mk deleted file mode 100644 index 48064da273..0000000000 --- a/samples/ScreenTFT_ST7735/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -#DISABLE_SPIFFS = 1 -SPIFF_FILES = files - diff --git a/samples/ScreenTFT_ST7735/component.mk b/samples/ScreenTFT_ST7735/component.mk new file mode 100644 index 0000000000..444739bbdd --- /dev/null +++ b/samples/ScreenTFT_ST7735/component.mk @@ -0,0 +1 @@ +ARDUINO_LIBRARIES := Adafruit_ST7735 diff --git a/samples/SmtpClient/Makefile b/samples/SmtpClient/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/SmtpClient/Makefile +++ b/samples/SmtpClient/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/SmtpClient/Makefile-user.mk b/samples/SmtpClient/Makefile-user.mk deleted file mode 100644 index e55a31e327..0000000000 --- a/samples/SmtpClient/Makefile-user.mk +++ /dev/null @@ -1,43 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app - -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM6 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -COM_SPEED = 115200 - -## SPIFFS options -#DISABLE_SPIFFS = 1 -SPIFF_FILES = files - -ENABLE_SSL ?= 1 - -ifneq ($(ENABLE_SSL),1) -# Needed for hmac_md5, etc. - EXTRA_LIBS += ssl -endif diff --git a/samples/SmtpClient/component.mk b/samples/SmtpClient/component.mk new file mode 100644 index 0000000000..21bccd4b0a --- /dev/null +++ b/samples/SmtpClient/component.mk @@ -0,0 +1,5 @@ +ENABLE_SSL ?= 1 +ifneq ($(ENABLE_SSL),1) +# Needed for hmac_md5, etc. + EXTRA_LIBS := ssl +endif diff --git a/samples/SystemClock_NTP/Makefile b/samples/SystemClock_NTP/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/SystemClock_NTP/Makefile +++ b/samples/SystemClock_NTP/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/SystemClock_NTP/Makefile-user.mk b/samples/SystemClock_NTP/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/SystemClock_NTP/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/SystemClock_NTP/component.mk b/samples/SystemClock_NTP/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/SystemClock_NTP/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/TcpClient_NarodMon/Makefile b/samples/TcpClient_NarodMon/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/TcpClient_NarodMon/Makefile +++ b/samples/TcpClient_NarodMon/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/TcpClient_NarodMon/Makefile-user.mk b/samples/TcpClient_NarodMon/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/TcpClient_NarodMon/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/TcpClient_NarodMon/component.mk b/samples/TcpClient_NarodMon/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/TcpClient_NarodMon/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Telnet_TCPServer_TCPClient/Makefile b/samples/Telnet_TCPServer_TCPClient/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Telnet_TCPServer_TCPClient/Makefile +++ b/samples/Telnet_TCPServer_TCPClient/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Telnet_TCPServer_TCPClient/Makefile-user.mk b/samples/Telnet_TCPServer_TCPClient/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Telnet_TCPServer_TCPClient/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Telnet_TCPServer_TCPClient/component.mk b/samples/Telnet_TCPServer_TCPClient/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Telnet_TCPServer_TCPClient/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/Temperature_DS1820/Makefile b/samples/Temperature_DS1820/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Temperature_DS1820/Makefile +++ b/samples/Temperature_DS1820/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Temperature_DS1820/Makefile-user.mk b/samples/Temperature_DS1820/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Temperature_DS1820/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Temperature_DS1820/component.mk b/samples/Temperature_DS1820/component.mk new file mode 100644 index 0000000000..087c1b4647 --- /dev/null +++ b/samples/Temperature_DS1820/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := DS18S20 + +DISABLE_SPIFFS = 1 diff --git a/samples/UdpServer_Echo/Makefile b/samples/UdpServer_Echo/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/UdpServer_Echo/Makefile +++ b/samples/UdpServer_Echo/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/UdpServer_Echo/Makefile-user.mk b/samples/UdpServer_Echo/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/UdpServer_Echo/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/UdpServer_Echo/component.mk b/samples/UdpServer_Echo/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/UdpServer_Echo/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/samples/UdpServer_mDNS/Makefile b/samples/UdpServer_mDNS/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/UdpServer_mDNS/Makefile +++ b/samples/UdpServer_mDNS/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/UdpServer_mDNS/Makefile-user.mk b/samples/UdpServer_mDNS/Makefile-user.mk deleted file mode 100644 index faa1d5cdf4..0000000000 --- a/samples/UdpServer_mDNS/Makefile-user.mk +++ /dev/null @@ -1,41 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - -# If you use custom LWIP compilation make sure to enable espconn because this sample uses espconn_mdns_* functions -ENABLE_ESPCONN = 1 diff --git a/samples/UdpServer_mDNS/component.mk b/samples/UdpServer_mDNS/component.mk new file mode 100644 index 0000000000..fe54e3c24b --- /dev/null +++ b/samples/UdpServer_mDNS/component.mk @@ -0,0 +1,4 @@ +DISABLE_SPIFFS = 1 + +# If you use custom LWIP compilation make sure to enable espconn because this sample uses espconn_mdns_* functions +ENABLE_ESPCONN = 1 diff --git a/samples/Ultrasonic_HCSR04/Makefile b/samples/Ultrasonic_HCSR04/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Ultrasonic_HCSR04/Makefile +++ b/samples/Ultrasonic_HCSR04/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Ultrasonic_HCSR04/Makefile-user.mk b/samples/Ultrasonic_HCSR04/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Ultrasonic_HCSR04/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Ultrasonic_HCSR04/component.mk b/samples/Ultrasonic_HCSR04/component.mk new file mode 100644 index 0000000000..c21f2d42fa --- /dev/null +++ b/samples/Ultrasonic_HCSR04/component.mk @@ -0,0 +1,3 @@ +ARDUINO_LIBRARIES := Ultrasonic + +DISABLE_SPIFFS = 1 diff --git a/samples/Websocket_Client/Makefile b/samples/Websocket_Client/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Websocket_Client/Makefile +++ b/samples/Websocket_Client/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Websocket_Client/Makefile-user.mk b/samples/Websocket_Client/Makefile-user.mk deleted file mode 100644 index 1013ff4324..0000000000 --- a/samples/Websocket_Client/Makefile-user.mk +++ /dev/null @@ -1,52 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 - -# Uncomment the option below if you do not want to have SSL support. -ENABLE_SSL=1 - -# We need rBoot in order to be able to run bigger Flash roms. - -#### overridable rBoot options #### -## use rboot build mode -RBOOT_ENABLED ?= 1 -## enable big flash support (for multiple roms, each in separate 1mb block of flash) -RBOOT_BIG_FLASH ?= 1 -## two rom mode (where two roms sit in the same 1mb block of flash) -#RBOOT_TWO_ROMS ?= 1 -## size of the flash chip -SPI_SIZE ?= 4M diff --git a/samples/Websocket_Client/component.mk b/samples/Websocket_Client/component.mk new file mode 100644 index 0000000000..24bb214eb1 --- /dev/null +++ b/samples/Websocket_Client/component.mk @@ -0,0 +1,7 @@ +DISABLE_SPIFFS = 1 + +# Uncomment the option below if you do not want to have SSL support. +ENABLE_SSL=1 + +## size of the flash chip +SPI_SIZE ?= 4M diff --git a/samples/Wifi_Sniffer/Makefile b/samples/Wifi_Sniffer/Makefile index da292733cd..ff51b6c3a7 100644 --- a/samples/Wifi_Sniffer/Makefile +++ b/samples/Wifi_Sniffer/Makefile @@ -1,17 +1,9 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME -$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +$(error SMING_HOME is not set: please configure it as an environment variable) endif -# Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/samples/Wifi_Sniffer/Makefile-user.mk b/samples/Wifi_Sniffer/Makefile-user.mk deleted file mode 100644 index bd088ca354..0000000000 --- a/samples/Wifi_Sniffer/Makefile-user.mk +++ /dev/null @@ -1,39 +0,0 @@ -## Local build configuration -## Parameters configured here will override default and ENV values. -## Uncomment and change examples: - -## Add your source directories here separated by space -# MODULES = app -# EXTRA_INCDIR = include - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -## MacOS / Linux -# SMING_HOME = /opt/sming/Sming - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -## MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -## Com port speed -# COM_SPEED = 115200 - -## Configure flash parameters (for ESP12-E and other new boards): -# SPI_MODE = dio - -## SPIFFS options -DISABLE_SPIFFS = 1 -# SPIFF_FILES = files - diff --git a/samples/Wifi_Sniffer/component.mk b/samples/Wifi_Sniffer/component.mk new file mode 100644 index 0000000000..973dfe71cf --- /dev/null +++ b/samples/Wifi_Sniffer/component.mk @@ -0,0 +1 @@ +DISABLE_SPIFFS = 1 diff --git a/tests/HostTests/Makefile b/tests/HostTests/Makefile index da292733cd..9fd0ed9bbc 100644 --- a/tests/HostTests/Makefile +++ b/tests/HostTests/Makefile @@ -1,17 +1,10 @@ ##################################################################### -#### Please don't change this file. Use Makefile-user.mk instead #### +#### Please don't change this file. Use component.mk instead #### ##################################################################### -# Including user Makefile. -# Should be used to set project-specific parameters -include ./Makefile-user.mk -# Important parameters check. -# We need to make sure SMING_HOME is set. -# You can use Makefile-user.mk in each project or use enviromental variables to set it globally. - ifndef SMING_HOME $(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) endif # Include application Makefile -include $(SMING_HOME)/Makefile-app.mk +include $(SMING_HOME)/project.mk diff --git a/tests/HostTests/app/common.h b/tests/HostTests/app/common.h index 82f4e83562..d46bc82bd4 100644 --- a/tests/HostTests/app/common.h +++ b/tests/HostTests/app/common.h @@ -2,14 +2,8 @@ #include -#ifdef ARCH_HOST -#include -#else -#define hostmsg debug_i -#endif - #define startTest(str) \ do { \ m_puts("\r\n"); \ - hostmsg(">> %s", PSTR(str)); \ + m_printf(_F(">> %s\r\n"), PSTR(str)); \ } while(0) diff --git a/tests/HostTests/app/test-files.cpp b/tests/HostTests/app/test-files.cpp index 55cfbd3ba0..02d5058982 100644 --- a/tests/HostTests/app/test-files.cpp +++ b/tests/HostTests/app/test-files.cpp @@ -1,6 +1,6 @@ #include "common.h" -IMPORT_FSTR(testContent, "../../Readme.md"); +IMPORT_FSTR(testContent, SMING_HOME "/../Readme.md"); void test_files() { diff --git a/tests/HostTests/component.mk b/tests/HostTests/component.mk new file mode 100644 index 0000000000..1d4f46211a --- /dev/null +++ b/tests/HostTests/component.mk @@ -0,0 +1,6 @@ +DISABLE_SPIFFS = 1 +DEBUG_VERBOSE_LEVEL = 3 +SPI_SIZE = 4M + +.PHONY: execute +execute: flash diff --git a/tests/SharedComponent/Makefile b/tests/SharedComponent/Makefile new file mode 100644 index 0000000000..c6160b3706 --- /dev/null +++ b/tests/SharedComponent/Makefile @@ -0,0 +1,70 @@ +# +# This example demonstrates use of a shared Component in a repository (directory) outside of Sming or the +# project which uses it. +# +# Placing Components in a common location allows them to be used by multiple projects. Just add the +# name to `COMPONENT_DEPENDS` in your project's component.mk file. +# +# Here's our example: +# +# |_ Project The example Sming project +# |_ print-test.repo The GIT repository containing the source for our submodule +# This is where Sming will pull the submodule from when our Project is built +# |_ shared/Components The Component repository +# |_ shared-test The example Component +# |_ print-test The submodule +# +# Note that Components don't need to be in a GIT repo, just set up a directory somewhere and add +# its full path to COMPONENT_SEARCH_DIRS. +# +# However, if the Component uses submodules then of course it needs to be in a GIT repo. This makefile +# does all that before building the example project. +# + +ifeq ($(V),1) +Q := +else +Q := @ +endif + +REPO_DIR := print-test.repo +SUBMODULE_NAME := print-test +COMPONENT_NAME := shared-test +SHARED_COMPONENT_DIR := shared/Components + +# Tell Sming where our repository is - absolute path required +export COMPONENT_SEARCH_DIRS := $(CURDIR)/$(SHARED_COMPONENT_DIR) + +.PHONY: execute +execute: setup run + +.PHONY: run +run: + $(MAKE) -C Project run + +.NOTPARALLEL: +.PHONY: setup +setup: | $(REPO_DIR)/.git $(SHARED_COMPONENT_DIR)/.gitmodules + +clean: + $(Q) $(MAKE) -C Project clean + $(Q) rm -rf $(REPO_DIR)/.git $(SHARED_COMPONENT_DIR)/.git $(SHARED_COMPONENT_DIR)/.gitmodules $(SHARED_COMPONENT_DIR)/$(COMPONENT_NAME)/$(SUBMODULE_NAME) + +# Create GIT repository and commit files to it +$(REPO_DIR)/.git: + $(Q) cd $(@D) && \ + git init && \ + git add . && \ + git config --add user.email 'test@sming.dev' && \ + git config --add user.name 'test' && \ + git commit -m 'Initial Commit' + + +# Add shared-test.repo as a submodule to the shared-test Component, but leave it un-initialised +$(SHARED_COMPONENT_DIR)/.gitmodules: | $(SHARED_COMPONENT_DIR)/.git + $(Q) cd $(@D)/$(COMPONENT_NAME) && \ + git submodule add $(CURDIR)/$(REPO_DIR) $(SUBMODULE_NAME) && \ + git submodule deinit $(SUBMODULE_NAME) -f + +$(SHARED_COMPONENT_DIR)/.git: + $(Q) git init $(@D) diff --git a/tests/SharedComponent/Project/Makefile b/tests/SharedComponent/Project/Makefile new file mode 100644 index 0000000000..9fd0ed9bbc --- /dev/null +++ b/tests/SharedComponent/Project/Makefile @@ -0,0 +1,10 @@ +##################################################################### +#### Please don't change this file. Use component.mk instead #### +##################################################################### + +ifndef SMING_HOME +$(error SMING_HOME is not set. Please configure it as an environment variable, or in Makefile-user.mk) +endif + +# Include application Makefile +include $(SMING_HOME)/project.mk diff --git a/tests/SharedComponent/Project/app/application.cpp b/tests/SharedComponent/Project/app/application.cpp new file mode 100644 index 0000000000..0269c5a186 --- /dev/null +++ b/tests/SharedComponent/Project/app/application.cpp @@ -0,0 +1,13 @@ +#include + +#include "print-test.h" + +void init() +{ + Serial.begin(SERIAL_BAUD_RATE); + Serial.systemDebugOutput(true); + + print_test(); + + system_restart(); +} diff --git a/tests/HostTests/Makefile-user.mk b/tests/SharedComponent/Project/component.mk similarity index 64% rename from tests/HostTests/Makefile-user.mk rename to tests/SharedComponent/Project/component.mk index 7c1cc7e8d1..d9e8fc54a5 100644 --- a/tests/HostTests/Makefile-user.mk +++ b/tests/SharedComponent/Project/component.mk @@ -7,3 +7,9 @@ DISABLE_SPIFFS = 1 DEBUG_VERBOSE_LEVEL = 3 SPI_SIZE = 4M + +# Tell Sming about any Components we need +COMPONENT_DEPENDS := shared-test + +.PHONY: execute +execute: run diff --git a/tests/SharedComponent/print-test.repo/include/print-test.h b/tests/SharedComponent/print-test.repo/include/print-test.h new file mode 100644 index 0000000000..5c557a4b71 --- /dev/null +++ b/tests/SharedComponent/print-test.repo/include/print-test.h @@ -0,0 +1,3 @@ +#pragma once + +extern void print_test(); diff --git a/tests/SharedComponent/print-test.repo/src/print-test.cpp b/tests/SharedComponent/print-test.repo/src/print-test.cpp new file mode 100644 index 0000000000..dc6ab0aad2 --- /dev/null +++ b/tests/SharedComponent/print-test.repo/src/print-test.cpp @@ -0,0 +1,9 @@ +#include "print-test.h" + +#include + +void print_test() +{ + debug_i( + "This is a test load of a shared Component using code from a submodule separate from the Sming repository."); +} diff --git a/tests/SharedComponent/shared/Components/shared-test/component.mk b/tests/SharedComponent/shared/Components/shared-test/component.mk new file mode 100644 index 0000000000..997c4102e1 --- /dev/null +++ b/tests/SharedComponent/shared/Components/shared-test/component.mk @@ -0,0 +1,3 @@ +COMPONENT_SUBMODULES := print-test +COMPONENT_SRCDIRS := print-test/src +COMPONENT_INCDIRS := print-test/include