diff --git a/Makefile b/Makefile index 052908ff..4e796ed2 100644 --- a/Makefile +++ b/Makefile @@ -29,14 +29,15 @@ else endif SDK_REL_DIR := sdk/esp_iot_sdk_v$(SDK_VER) SDK_DIR := $(TOP_DIR)/$(SDK_REL_DIR) +APP_DIR := $(TOP_DIR)/app ESPTOOL_VER := 2.6 -# Ensure that the Espresif SDK is searched before the tool-chain's SDK (if any) -# Also, prevent the SDK's c_types.h from being included from anywhere, by -# predefining its include-guard. -CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(TOP_DIR)/app/include/lwip/app -I$(SDK_DIR)/include -D_C_TYPES_H_ -LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS) +# Ensure that the Espresif SDK is search before application paths and also prevent +# the SDK's c_types.h from being included from anywhere, by predefining its include-guard. + +CCFLAGS := $(CCFLAGS) -I $(PDIR)sdk-overrides/include -I $(SDK_DIR)/include -D_C_TYPES_H_ +LDFLAGS := -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS) ifdef DEBUG CCFLAGS += -ggdb -O0 @@ -61,18 +62,18 @@ else endif # $(V)==1 ifndef BAUDRATE - BAUDRATE=115200 + BAUDRATE=115200 endif ############################################################# # Select compile # -# ** HEALTH WARNING ** This section is largely legacy directives left over from +# ** HEALTH WARNING ** This section is largely legacy directives left over from # an Espressif template. As far as I (TerrryE) know, we've only used the Linux # Path. I have successfully build AMD and Intel (both x86, AMD64) and RPi ARM6 # all under Ubuntu. Our docker container runs on Windows in an Ubuntu VM. # Johny Mattson maintains a prebuild AMD64 xtensa cross-compile gcc v4.8.5 -# toolchain which is compatible with the non-OS SDK and can be used on any recent +# toolchain which is compatible with the non-OS SDK and can be used on any recent # Ubuntu version including the Docker and Travis build environments. # # You have the option to build your own toolchain and specify a TOOLCHAIN_ROOT @@ -80,7 +81,7 @@ endif # architecture is compatable then you can omit this variable and the make will # download and use this prebuilt toolchain. # -# If any developers wish to develop, test and support alternative environments +# If any developers wish to develop, test and support alternative environments # then please raise a GitHub issue on this work. # @@ -95,39 +96,39 @@ endif ifneq (,$(findstring indows,$(OS))) #------------ BEGIN UNTESTED ------------ We are not under Linux, e.g.under windows. - ifeq ($(XTENSA_CORE),lx106) - # It is xcc - AR = xt-ar - CC = xt-xcc - CXX = xt-xcc - NM = xt-nm - CPP = xt-cpp - OBJCOPY = xt-objcopy - #MAKE = xt-make - CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal - else - # It is gcc, may be cygwin - # Can we use -fdata-sections? - CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections - AR = xtensa-lx106-elf-ar - CC = xtensa-lx106-elf-gcc - CXX = xtensa-lx106-elf-g++ - NM = xtensa-lx106-elf-nm - CPP = xtensa-lx106-elf-cpp - OBJCOPY = xtensa-lx106-elf-objcopy - endif - FIRMWAREDIR = ..\\bin\\ - ifndef COMPORT - ESPPORT = com1 - else - ESPPORT = $(COMPORT) - endif - ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + ifeq ($(XTENSA_CORE),lx106) + # It is xcc + AR = xt-ar + CC = xt-xcc + CXX = xt-xcc + NM = xt-nm + CPP = xt-cpp + OBJCOPY = xt-objcopy + #MAKE = xt-make + CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal + else + # It is gcc, may be cygwin + # Can we use -fdata-sections? + CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections + AR = xtensa-lx106-elf-ar + CC = xtensa-lx106-elf-gcc + CXX = xtensa-lx106-elf-g++ + NM = xtensa-lx106-elf-nm + CPP = xtensa-lx106-elf-cpp + OBJCOPY = xtensa-lx106-elf-objcopy + endif + FIRMWAREDIR = ..\\bin\\ + ifndef COMPORT + ESPPORT = com1 + else + ESPPORT = $(COMPORT) + endif + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) # ->AMD64 - endif - ifeq ($(PROCESSOR_ARCHITECTURE),x86) + endif + ifeq ($(PROCESSOR_ARCHITECTURE),x86) # ->IA32 - endif + endif #---------------- END UNTESTED ---------------- We are under windows. else # We are under other system, may be Linux. Assume using gcc. @@ -141,23 +142,23 @@ else TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN) GITHUB_TOOLCHAIN = https://github.com/jmattsson/esp-toolchains export PATH:=$(PATH):$(TOOLCHAIN_ROOT)/bin - endif - endif - - ifndef COMPORT - ESPPORT = /dev/ttyUSB0 - else - ESPPORT = $(COMPORT) - endif + endif + endif - CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections - AR = xtensa-lx106-elf-ar - CC = $(WRAPCC) xtensa-lx106-elf-gcc - CXX = $(WRAPCC) xtensa-lx106-elf-g++ - NM = xtensa-lx106-elf-nm - CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E - OBJCOPY = xtensa-lx106-elf-objcopy - FIRMWAREDIR = ../bin/ + ifndef COMPORT + ESPPORT = /dev/ttyUSB0 + else + ESPPORT = $(COMPORT) + endif + + CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections + AR = xtensa-lx106-elf-ar + CC = $(WRAPCC) xtensa-lx106-elf-gcc + CXX = $(WRAPCC) xtensa-lx106-elf-g++ + NM = xtensa-lx106-elf-nm + CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E + OBJCOPY = xtensa-lx106-elf-objcopy + FIRMWAREDIR = ../bin/ WGET = wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused endif @@ -221,7 +222,7 @@ CCFLAGS += \ -fno-inline-functions \ -nostdlib \ -mlongcalls \ - -mtext-section-literals + -mtext-section-literals \ # -Wall CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES) @@ -370,7 +371,7 @@ flash1m-dout: flashinternal: ifndef PDIR - $(MAKE) -C ./app flashinternal + $(MAKE) -C $(APP_DIR) flashinternal else $(ESPTOOL) --port $(ESPPORT) --baud $(BAUDRATE) write_flash $(FLASHOPTIONS) 0x00000 $(FIRMWAREDIR)0x00000.bin 0x10000 $(FIRMWAREDIR)0x10000.bin endif @@ -395,20 +396,20 @@ spiffs-image-remove: spiffs-image: bin/0x10000.bin $(MAKE) -C tools - +############ Note: this target needs moving into app/modules make ############ .PHONY: pre_build ifneq ($(wildcard $(TOP_DIR)/server-ca.crt),) -pre_build: $(TOP_DIR)/app/modules/server-ca.crt.h +pre_build: $(APP_DIR)/modules/server-ca.crt.h -$(TOP_DIR)/app/modules/server-ca.crt.h: $(TOP_DIR)/server-ca.crt +$(APP_DIR)/modules/server-ca.crt.h: $(TOP_DIR)/server-ca.crt $(summary) MKCERT $(patsubst $(TOP_DIR)/%,%,$<) - python $(TOP_DIR)/tools/make_server_cert.py $(TOP_DIR)/server-ca.crt > $(TOP_DIR)/app/modules/server-ca.crt.h + python $(TOP_DIR)/tools/make_server_cert.py $(TOP_DIR)/server-ca.crt > $(APP_DIR)/modules/server-ca.crt.h DEFINES += -DHAVE_SSL_SERVER_CRT=\"server-ca.crt.h\" else pre_build: - @-rm -f $(TOP_DIR)/app/modules/server-ca.crt.h + @-rm -f $(APP_DIR)/modules/server-ca.crt.h endif ifdef TARGET @@ -484,6 +485,5 @@ endif # TARGET # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -I $(PDIR)include/$(TARGET) PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/Makefile b/app/Makefile index 897b3f8b..4fab0eed 100644 --- a/app/Makefile +++ b/app/Makefile @@ -15,8 +15,6 @@ TARGET = eagle #FLAVOR = release FLAVOR = debug -#EXTRA_CCFLAGS += -u - ifndef PDIR # { GEN_IMAGES= eagle.app.v6.out GEN_BINS= eagle.app.v6.bin @@ -42,10 +40,10 @@ SUBDIRS= \ smart \ modules \ spiffs \ - net \ + net \ fatfs \ esp-gdbstub \ - pm \ + pm \ uzlib \ $(OPT_SEL_MKTARGETS) @@ -54,19 +52,19 @@ endif # } PDIR APPDIR = . LDDIR = ../ld -TARGET_LDFLAGS = \ +TARGET_LDFLAGS = \ -nostdlib \ -Wl,-EL \ - --longcalls \ + --longcalls \ --text-section-literals LD_FILE = $(LDDIR)/nodemcu.ld -COMPONENTS_eagle.app.v6 = \ +COMPONENTS_eagle.app.v6 = \ user/libuser.a \ crypto/libcrypto.a \ driver/libdriver.a \ - platform/libplatform.a \ + platform/libplatform.a \ task/libtask.a \ libc/liblibc.a \ lua/liblua.a \ @@ -74,16 +72,15 @@ COMPONENTS_eagle.app.v6 = \ smart/smart.a \ spiffs/spiffs.a \ fatfs/libfatfs.a \ - pm/libpm.a \ - esp-gdbstub/libgdbstub.a \ - net/libnodemcu_net.a \ - mbedtls/libmbedtls.a \ - modules/libmodules.a \ + pm/libpm.a \ + esp-gdbstub/libgdbstub.a \ + net/libnodemcu_net.a \ + mbedtls/libmbedtls.a \ + modules/libmodules.a \ smart/smart.a \ uzlib/libuzlib.a \ $(OPT_SEL_COMPONENTS) - # Inspect the modules library and work out which modules need to be linked. # For each enabled module, a symbol name of the form XYZ_module_selected is # returned. At link time those names are declared undefined, so those (and @@ -134,28 +131,16 @@ DEPENDS_eagle.app.v6 = \ #UNIVERSAL_TARGET_DEFINES = \ -# Other potential configuration flags include: -# -DTXRX_TXBUF_DEBUG -# -DTXRX_RXBUF_DEBUG -# -DWLAN_CONFIG_CCX -CONFIGURATION_DEFINES = -D__ets__ \ - -DICACHE_FLASH \ - -DLWIP_OPEN_SRC \ - -DPBUF_RSV_FOR_WLAN \ - -DEBUF_LWIP \ - -DUSE_OPTIMIZE_PRINTF \ - -DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \ - -DMEM_DEFAULT_USE_DRAM +CONFIGURATION_DEFINES += -DLWIP_OPEN_SRC -DEFINES += \ - $(UNIVERSAL_TARGET_DEFINES) \ +DEFINES += \ + $(UNIVERSAL_TARGET_DEFINES) \ $(CONFIGURATION_DEFINES) -DDEFINES += \ - $(UNIVERSAL_TARGET_DEFINES) \ +DDEFINES += \ + $(UNIVERSAL_TARGET_DEFINES) \ $(CONFIGURATION_DEFINES) - ############################################################# # Recursion Magic - Don't touch this!! # @@ -167,10 +152,10 @@ DDEFINES += \ # # Required for each makefile to inherit from the parent # - -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ +INCLUDES := -I $(PDIR)libc -I $(PDIR)lua -I $(PDIR)platform \ + $(INCLUDES) -I $(PDIR) -I $(PDIR)include PDIR := ../$(PDIR) + sinclude $(PDIR)Makefile .PHONY: FORCE diff --git a/app/coap/Makefile b/app/coap/Makefile index 89ea3b43..6ad9dcc9 100644 --- a/app/coap/Makefile +++ b/app/coap/Makefile @@ -36,10 +36,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc -INCLUDES += -I ../lua PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/crypto/Makefile b/app/crypto/Makefile index e472e6d6..17c77134 100644 --- a/app/crypto/Makefile +++ b/app/crypto/Makefile @@ -38,10 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc -INCLUDES += -I ../platform PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/dht/Makefile b/app/dht/Makefile index 2da62da8..5bb139ff 100644 --- a/app/dht/Makefile +++ b/app/dht/Makefile @@ -37,13 +37,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ./include -INCLUDES += -I ../include -INCLUDES += -I ../../include -INCLUDES += -I ../libc -INCLUDES += -I ../platform PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/driver/Makefile b/app/driver/Makefile index a3f15156..5dbd6853 100644 --- a/app/driver/Makefile +++ b/app/driver/Makefile @@ -38,9 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../platform PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/esp-gdbstub/Makefile b/app/esp-gdbstub/Makefile index 015e9df7..f5f390ab 100644 --- a/app/esp-gdbstub/Makefile +++ b/app/esp-gdbstub/Makefile @@ -37,8 +37,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES += -I $(PDIR)include -INCLUDES += -I ./ INCLUDES += -I ../../include/ets PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/fatfs/Makefile b/app/fatfs/Makefile index 33d242ae..d1bca3e2 100644 --- a/app/fatfs/Makefile +++ b/app/fatfs/Makefile @@ -42,11 +42,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit -imacros $(FATFS_INC_DIR)fatfs_prefix_lib.h # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../platform -INCLUDES += -I ../libc -INCLUDES += -I ../lua PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/http/Makefile b/app/http/Makefile index e4a184ef..963cf28c 100644 --- a/app/http/Makefile +++ b/app/http/Makefile @@ -38,11 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ./include -INCLUDES += -I ../include -INCLUDES += -I ../../include PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/libc/Makefile b/app/libc/Makefile index 9bc7eb87..dfb6232d 100644 --- a/app/libc/Makefile +++ b/app/libc/Makefile @@ -36,8 +36,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/lua/Makefile b/app/lua/Makefile index 059f69e2..16d97ab0 100644 --- a/app/lua/Makefile +++ b/app/lua/Makefile @@ -40,12 +40,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../spiffs -INCLUDES += -I ../libc -INCLUDES += -I ../modules -INCLUDES += -I ../platform INCLUDES += -I ../uzlib PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/lua/luac_cross/Makefile b/app/lua/luac_cross/Makefile index 984d2b65..2589b63b 100644 --- a/app/lua/luac_cross/Makefile +++ b/app/lua/luac_cross/Makefile @@ -53,7 +53,7 @@ CC := $(WRAPCC) gcc ECHO := echo -BUILD_TYPE := $(shell $(CC) $(EXTRA_CCFLAGS) -E -dM - <../../../app/include/user_config.h | grep LUA_NUMBER_INTEGRAL | wc -l) +BUILD_TYPE := $(shell $(CC) $(EXTRA_CCFLAGS) -E -dM - <../../include/user_config.h | grep LUA_NUMBER_INTEGRAL | wc -l) ifeq ($(BUILD_TYPE),0) IMAGE := ../../../luac.cross else diff --git a/app/lwip/Makefile b/app/lwip/Makefile index 461a7c94..a8b25699 100644 --- a/app/lwip/Makefile +++ b/app/lwip/Makefile @@ -14,9 +14,9 @@ ifndef PDIR UP_EXTRACT_DIR = .. GEN_LIBS = liblwip.a -COMPONENTS_liblwip = api/liblwipapi.a \ - app/liblwipapp.a \ - core/liblwipcore.a \ +COMPONENTS_liblwip = api/liblwipapi.a \ + app/liblwipapp.a \ + core/liblwipcore.a \ core/ipv4/liblwipipv4.a \ netif/liblwipnetif.a endif @@ -29,7 +29,11 @@ endif # makefile at its root level - these are then overridden # for a subtree within the makefile rooted therein # -#DEFINES += +# Other potential configuration flags include: +# -DTXRX_TXBUF_DEBUG +# -DTXRX_RXBUF_DEBUG +# -DWLAN_CONFIG_CCX +CONFIGURATION_DEFINES += -DPBUF_RSV_FOR_WLAN -DEBUF_LWIP ############################################################# # Recursion Magic - Don't touch this!! @@ -43,8 +47,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/lwip/api/Makefile b/app/lwip/api/Makefile index 95abe4b6..cecc962e 100644 --- a/app/lwip/api/Makefile +++ b/app/lwip/api/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/lwip/app/Makefile b/app/lwip/app/Makefile index 8f5bef15..94353577 100644 --- a/app/lwip/app/Makefile +++ b/app/lwip/app/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/lwip/core/Makefile b/app/lwip/core/Makefile index e3cd64df..b3fc4f67 100644 --- a/app/lwip/core/Makefile +++ b/app/lwip/core/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/lwip/core/ipv4/Makefile b/app/lwip/core/ipv4/Makefile index 51c59543..4570cf55 100644 --- a/app/lwip/core/ipv4/Makefile +++ b/app/lwip/core/ipv4/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/lwip/netif/Makefile b/app/lwip/netif/Makefile index 368e0d21..ecdffab8 100644 --- a/app/lwip/netif/Makefile +++ b/app/lwip/netif/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/mbedtls/Makefile b/app/mbedtls/Makefile index 9af2841f..46282136 100644 --- a/app/mbedtls/Makefile +++ b/app/mbedtls/Makefile @@ -14,7 +14,9 @@ ifndef PDIR UP_EXTRACT_DIR = .. GEN_LIBS = libmbedtls.a -COMPONENTS_libmbedtls = library/liblibrary.a platform/libplatform.a app/libapp.a +COMPONENTS_libmbedtls = library/liblibrary.a \ + platform/libplatform.a \ + app/libapp.a endif @@ -26,7 +28,7 @@ endif # for a subtree within the makefile rooted therein # DEFINES += -#CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal +CONFIGURATION_DEFINES += -DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" ############################################################# # Recursion Magic - Don't touch this!! @@ -40,8 +42,6 @@ DEFINES += # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/mbedtls/app/Makefile b/app/mbedtls/app/Makefile index 6bdb009f..fa5dc92f 100644 --- a/app/mbedtls/app/Makefile +++ b/app/mbedtls/app/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/mbedtls/library/Makefile b/app/mbedtls/library/Makefile index d746b860..7c74cde4 100644 --- a/app/mbedtls/library/Makefile +++ b/app/mbedtls/library/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/mbedtls/platform/Makefile b/app/mbedtls/platform/Makefile index 72136eee..5d1d1564 100644 --- a/app/mbedtls/platform/Makefile +++ b/app/mbedtls/platform/Makefile @@ -39,8 +39,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/modules/Makefile b/app/modules/Makefile index 1387c840..db18e743 100644 --- a/app/modules/Makefile +++ b/app/modules/Makefile @@ -25,6 +25,7 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # for a subtree within the makefile rooted therein # #DEFINES += +CONFIGURATION_DEFINES += -DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" ############################################################# # Recursion Magic - Don't touch this!! @@ -38,25 +39,8 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc -INCLUDES += -I ../coap -INCLUDES += -I ../mqtt -INCLUDES += -I ../u8g2lib/u8g2/src/clib -INCLUDES += -I ../ucglib/ucg/src/clib -INCLUDES += -I ../lua -INCLUDES += -I ../pcm -INCLUDES += -I ../platform -INCLUDES += -I ../spiffs -INCLUDES += -I ../smart -INCLUDES += -I ../dht -INCLUDES += -I ../fatfs -INCLUDES += -I ../http -INCLUDES += -I ../sjson -INCLUDES += -I ../websocket -INCLUDES += -I ../pm -INCLUDES += -I ../sqlite3 +INCLUDES += -I ../u8g2lib/u8g2/src/clib -I ../ucglib/ucg/src/clib + PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/modules/coap.c b/app/modules/coap.c index a50a086f..0c37af48 100644 --- a/app/modules/coap.c +++ b/app/modules/coap.c @@ -13,12 +13,12 @@ #include "espconn.h" #include "driver/uart.h" -#include "coap.h" -#include "uri.h" -#include "node.h" -#include "coap_timer.h" -#include "coap_io.h" -#include "coap_server.h" +#include "coap/coap.h" +#include "coap/uri.h" +#include "coap/node.h" +#include "coap/coap_timer.h" +#include "coap/coap_io.h" +#include "coap/coap_server.h" coap_queue_t *gQueue = NULL; diff --git a/app/modules/dht.c b/app/modules/dht.c index 85e2bdfb..7e3e4f1d 100644 --- a/app/modules/dht.c +++ b/app/modules/dht.c @@ -4,7 +4,7 @@ #include "lauxlib.h" #include "platform.h" #include "cpu_esp8266.h" -#include "dht.h" +#include "dht/dht.h" #define NUM_DHT GPIO_PIN_NUM diff --git a/app/modules/http.c b/app/modules/http.c index 0b37d577..fddc902a 100644 --- a/app/modules/http.c +++ b/app/modules/http.c @@ -8,7 +8,7 @@ #include "lauxlib.h" #include "platform.h" #include "cpu_esp8266.h" -#include "httpclient.h" +#include "http/httpclient.h" static int http_callback_registry = LUA_NOREF; diff --git a/app/modules/mqtt.c b/app/modules/mqtt.c index dcb25005..035c0059 100644 --- a/app/modules/mqtt.c +++ b/app/modules/mqtt.c @@ -12,8 +12,8 @@ #include "lwip/ip_addr.h" #include "espconn.h" -#include "mqtt_msg.h" -#include "msg_queue.h" +#include "mqtt/mqtt_msg.h" +#include "mqtt/msg_queue.h" #include "user_interface.h" diff --git a/app/modules/pcm.c b/app/modules/pcm.c index f9056bcd..55c85bd4 100644 --- a/app/modules/pcm.c +++ b/app/modules/pcm.c @@ -6,8 +6,8 @@ #include #include -#include "pcm.h" -#include "pcm_drv.h" +#include "pcm/pcm.h" +#include "pcm/pcm_drv.h" #define GET_PUD() pud_t *pud = (pud_t *)luaL_checkudata(L, 1, "pcm.driver"); \ diff --git a/app/modules/sjson.c b/app/modules/sjson.c index 530dfb25..cc39cedf 100644 --- a/app/modules/sjson.c +++ b/app/modules/sjson.c @@ -11,8 +11,8 @@ #include #endif -#include "json_config.h" -#include "jsonsl.h" +#include "sjson/json_config.h" +#include "sjson/jsonsl.h" #define LUA_SJSONLIBNAME "sjson" diff --git a/app/modules/sqlite3.c b/app/modules/sqlite3.c index c8422498..d5fa4648 100644 --- a/app/modules/sqlite3.c +++ b/app/modules/sqlite3.c @@ -59,7 +59,7 @@ #endif #endif -#include "sqlite3.h" +#include "sqlite3/sqlite3.h" /* compile time features */ #if !defined(SQLITE_OMIT_PROGRESS_CALLBACK) diff --git a/app/modules/websocket.c b/app/modules/websocket.c index 71ecd67a..d7b840ea 100644 --- a/app/modules/websocket.c +++ b/app/modules/websocket.c @@ -17,7 +17,7 @@ #include #include -#include "websocketclient.h" +#include "websocket/websocketclient.h" #define METATABLE_WSCLIENT "websocket.client" diff --git a/app/modules/wifi.c b/app/modules/wifi.c index 6e5b6d02..7d5766a5 100644 --- a/app/modules/wifi.c +++ b/app/modules/wifi.c @@ -16,8 +16,8 @@ #ifdef WIFI_SMART_ENABLE -#include "smart.h" -#include "smartconfig.h" +#include "smart/smart.h" +#include "smart/smartconfig.h" static int wifi_smart_succeed = LUA_NOREF; #endif diff --git a/app/modules/wifi_eventmon.c b/app/modules/wifi_eventmon.c index f5d87170..0989c7d4 100644 --- a/app/modules/wifi_eventmon.c +++ b/app/modules/wifi_eventmon.c @@ -9,7 +9,7 @@ #include #include "user_interface.h" -#include "smart.h" +#include "smart/smart.h" #include "smartconfig.h" #include "user_config.h" diff --git a/app/mqtt/Makefile b/app/mqtt/Makefile index a0fde1e7..c47de52b 100644 --- a/app/mqtt/Makefile +++ b/app/mqtt/Makefile @@ -38,9 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/net/Makefile b/app/net/Makefile index 1c9cdcf6..d67ec5c2 100644 --- a/app/net/Makefile +++ b/app/net/Makefile @@ -36,9 +36,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/pcm/Makefile b/app/pcm/Makefile index 4beb5794..9cb5272c 100644 --- a/app/pcm/Makefile +++ b/app/pcm/Makefile @@ -38,10 +38,5 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../lua -INCLUDES += -I ../libc -INCLUDES += -I ../platform PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/platform/Makefile b/app/platform/Makefile index 07bb225c..b8cadc7a 100644 --- a/app/platform/Makefile +++ b/app/platform/Makefile @@ -38,13 +38,7 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../spiffs -INCLUDES += -I ../libc -INCLUDES += -I ../lua -INCLUDES += -I ../u8g2lib/u8g2/src/clib -INCLUDES += -I ../ucglib/ucg/src/clib +INCLUDES += -I ../spiffs -I ../u8g2lib/u8g2/src/clib -I ../ucglib/ucg/src/clib PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/pm/Makefile b/app/pm/Makefile index b338250b..de66032d 100644 --- a/app/pm/Makefile +++ b/app/pm/Makefile @@ -38,15 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ./include -INCLUDES += -I ../include -INCLUDES += -I ../../include -INCLUDES += -I ../lua -INCLUDES += -I ../platform -INCLUDES += -I ../libc - PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/sjson/Makefile b/app/sjson/Makefile index a4398004..6e441319 100644 --- a/app/sjson/Makefile +++ b/app/sjson/Makefile @@ -37,11 +37,6 @@ DEFINES += -include memcompat.h -include json_config.h # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ./include -INCLUDES += -I ../include -INCLUDES += -I ../../include PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/smart/Makefile b/app/smart/Makefile index 635d27b8..4259ecd6 100644 --- a/app/smart/Makefile +++ b/app/smart/Makefile @@ -36,9 +36,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/spiffs/Makefile b/app/spiffs/Makefile index 688bc9f3..b7b6b9b9 100644 --- a/app/spiffs/Makefile +++ b/app/spiffs/Makefile @@ -36,9 +36,5 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc -INCLUDES += -I ../platform PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/sqlite3/Makefile b/app/sqlite3/Makefile index 2b5339b4..fcaa2a43 100644 --- a/app/sqlite3/Makefile +++ b/app/sqlite3/Makefile @@ -38,9 +38,6 @@ STD_CFLAGS= -std=gnu11 -Wimplicit -Wno-undef -include config_ext.h # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc -INCLUDES += -I ../platform +INCLUDES += -I . PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/task/Makefile b/app/task/Makefile index 24a454fe..b7db4b50 100644 --- a/app/task/Makefile +++ b/app/task/Makefile @@ -36,9 +36,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/tsl2561/Makefile b/app/tsl2561/Makefile index 48dfef98..b9648316 100644 --- a/app/tsl2561/Makefile +++ b/app/tsl2561/Makefile @@ -38,13 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ./include -INCLUDES += -I ../include -INCLUDES += -I ../../include -INCLUDES += -I ../libc -INCLUDES += -I ../platform PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/u8g2lib/Makefile b/app/u8g2lib/Makefile index e1b0b82d..173b5ce6 100644 --- a/app/u8g2lib/Makefile +++ b/app/u8g2lib/Makefile @@ -40,11 +40,7 @@ DEFINES += -DU8X8_USE_PINS -DU8G2_USE_LARGE_FONTS -DU8X8_WITH_USER_PTR CSRCS := $(wildcard u8g2/src/clib/*.c *.c) -INCLUDES := $(INCLUDES) -I $(PDIR)include INCLUDES += -I u8g2/src/clib -INCLUDES += -I ../libc -INCLUDES += -I ../lua -INCLUDES += -I ../platform PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/ucglib/Makefile b/app/ucglib/Makefile index ff257844..0e495e6e 100644 --- a/app/ucglib/Makefile +++ b/app/ucglib/Makefile @@ -40,10 +40,7 @@ DEFINES += -DUSE_PIN_LIST CSRCS := $(wildcard ucg/src/clib/*.c *.c) -INCLUDES := $(INCLUDES) -I $(PDIR)include INCLUDES += -I ucg/src/clib -INCLUDES += -I ./ -INCLUDES += -I ../libc PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/user/Makefile b/app/user/Makefile index 5ffdb00a..34e6446d 100644 --- a/app/user/Makefile +++ b/app/user/Makefile @@ -38,12 +38,6 @@ DEFINES += -DESP_INIT_DATA_DEFAULT="\"$(SDK_DIR)/bin/esp_init_data_default_v05.b # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../../include/ets -INCLUDES += -I ../libc -INCLUDES += -I ../platform -INCLUDES += -I ../lua INCLUDES += -I ../spiffs PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/user/dbg_printf.c b/app/user/dbg_printf.c index 6dcb5895..0be12d8a 100644 --- a/app/user/dbg_printf.c +++ b/app/user/dbg_printf.c @@ -39,6 +39,7 @@ // overflows. The downside is that it does not implement a wide range // of formatting characters. +#include #include #include #include diff --git a/app/uzlib/Makefile b/app/uzlib/Makefile index 379af8bd..5b3d1b54 100644 --- a/app/uzlib/Makefile +++ b/app/uzlib/Makefile @@ -37,9 +37,6 @@ endif # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ../libc PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/app/websocket/Makefile b/app/websocket/Makefile index 8a4a39d2..0c20357a 100644 --- a/app/websocket/Makefile +++ b/app/websocket/Makefile @@ -38,12 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit # Required for each makefile to inherit from the parent # -INCLUDES := $(INCLUDES) -I $(PDIR)include -INCLUDES += -I ./ -INCLUDES += -I ./include -INCLUDES += -I ../include -INCLUDES += -I ../libc -INCLUDES += -I ../../include PDIR := ../$(PDIR) sinclude $(PDIR)Makefile diff --git a/sdk-overrides/include/c_types.h b/sdk-overrides/include/c_types.h index 6d455802..1657ced1 100644 --- a/sdk-overrides/include/c_types.h +++ b/sdk-overrides/include/c_types.h @@ -1,3 +1,4 @@ + #ifndef _SDKOVERRIDES_C_TYPES_H_ #define _SDKOVERRIDES_C_TYPES_H_ diff --git a/sdk-overrides/include/espconn.h b/sdk-overrides/include/espconn.h new file mode 120000 index 00000000..401b860b --- /dev/null +++ b/sdk-overrides/include/espconn.h @@ -0,0 +1 @@ +../../app/include/lwip/app/espconn.h \ No newline at end of file diff --git a/sdk-overrides/include/mem.h b/sdk-overrides/include/mem.h index b55c7bd5..b0c9fcdd 100644 --- a/sdk-overrides/include/mem.h +++ b/sdk-overrides/include/mem.h @@ -1,2 +1,3 @@ #include +#define MEM_DEFAULT_USE_DRAM #include_next "mem.h" diff --git a/sdk-overrides/include/osapi.h b/sdk-overrides/include/osapi.h index c192fa0d..9d736de4 100644 --- a/sdk-overrides/include/osapi.h +++ b/sdk-overrides/include/osapi.h @@ -4,6 +4,7 @@ #include #include #include +#define USE_OPTIMIZE_PRINTF #include_next "osapi.h" diff --git a/tools/Makefile b/tools/Makefile index dd973312..db93291d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -7,7 +7,7 @@ LUASOURCE ?= ../local/lua FLASHSIZE ?= 4mb 32mb 8mb FLASH_SW = -S SUBDIRS = - +APP_DIR = ../app OBJDUMP = $(or $(shell which objdump),xtensa-lx106-elf-objdump) ############################################################# @@ -20,23 +20,23 @@ SPIFFSFILES ?= $(patsubst $(FSSOURCE)/%,%,$(shell find $(FSSOURCE)/ -name '*' '! # Get the filesize of /bin/0x10000.bin and SPIFFS sizing # -FLASH_FS_SIZE := $(shell $(CC) -E -dM - <../app/include/user_config.h | grep SPIFFS_MAX_FILESYSTEM_SIZE| cut -d ' ' -f 3) +FLASH_FS_SIZE := $(shell $(CC) -E -dM - <$(APP_DIR)/include/user_config.h | grep SPIFFS_MAX_FILESYSTEM_SIZE| cut -d ' ' -f 3) ifneq ($(strip $(FLASH_FS_SIZE)),) FLASHSIZE = $(shell printf "0x%x" $(FLASH_FS_SIZE)) FLASH_SW = -c endif -FLASH_FS_LOC := $(shell $(CC) -E -dM - <../app/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3) +FLASH_FS_LOC := $(shell $(CC) -E -dM - <$(APP_DIR)/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3) ifeq ($(strip $(FLASH_FS_LOC)),) -FLASH_FS_LOC := $(shell printf "0x%x" $$((0x$(shell $(OBJDUMP) -t ../app/.output/eagle/debug/image/eagle.app.v6.out |grep " _flash_used_end" |cut -f1 -d" ") - 0x40200000))) +FLASH_FS_LOC := $(shell printf "0x%x" $$((0x$(shell $(OBJDUMP) -t $(APP_DIR)/.output/eagle/debug/image/eagle.app.v6.out |grep " _flash_used_end" |cut -f1 -d" ") - 0x40200000))) else FLASH_FS_LOC := $(shell printf "0x%x" $(FLASH_FS_LOC)) endif LFSSOURCES := $(wildcard $(LUASOURCE)/*.lua) -BUILD_TYPE := $(shell $(CC) $(EXTRA_CCFLAGS) -E -dM - <../app/include/user_config.h | grep LUA_NUMBER_INTEGRAL | wc -l) +BUILD_TYPE := $(shell $(CC) $(EXTRA_CCFLAGS) -E -dM - <$(APP_DIR)/include/user_config.h | grep LUA_NUMBER_INTEGRAL | wc -l) ifeq ($(BUILD_TYPE),0) LUAC_CROSS := ../luac.cross else diff --git a/tools/spiffsimg/Makefile b/tools/spiffsimg/Makefile index d5ba6a8d..ee77e6a5 100644 --- a/tools/spiffsimg/Makefile +++ b/tools/spiffsimg/Makefile @@ -1,13 +1,13 @@ - +APP_DIR = ../../app summary ?= @true CC =gcc SRCS=\ main.c \ - ../../app/spiffs/spiffs_cache.c ../../app/spiffs/spiffs_check.c ../../app/spiffs/spiffs_gc.c ../../app/spiffs/spiffs_hydrogen.c ../../app/spiffs/spiffs_nucleus.c + $(APP_DIR)/spiffs/spiffs_cache.c $(APP_DIR)/spiffs/spiffs_check.c $(APP_DIR)/spiffs/spiffs_gc.c $(APP_DIR)/spiffs/spiffs_hydrogen.c $(APP_DIR)/spiffs/spiffs_nucleus.c -CFLAGS=-g -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -I. -I../../app/spiffs -I../../app/include -DNODEMCU_SPIFFS_NO_INCLUDE --include spiffs_typedefs.h -Ddbg_printf=printf +CFLAGS=-g -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -I. -I$(APP_DIR)/spiffs -I$(APP_DIR)/include -DNODEMCU_SPIFFS_NO_INCLUDE --include spiffs_typedefs.h -Ddbg_printf=printf spiffsimg: $(SRCS) $(summary) HOSTCC $(CURDIR)/$<