Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial restructure to support multiple target architectures #1675

Merged
merged 22 commits into from
May 1, 2019
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
baa4f00
Initial restructure to support multiple platforms
mikee47 Apr 25, 2019
5d7ad1d
Makefile fixes and remove `apptest` directory
mikee47 Apr 27, 2019
cd9919a
Use `Arch` directory instead of `Platform`
mikee47 Apr 27, 2019
f4f9b61
Add makefile rule to run stack trace and update instructions
mikee47 Apr 28, 2019
6c58abb
Move `Services/libb64` into `Components`
mikee47 Apr 28, 2019
1149ba8
Move `Services/WebHelpers` into `SmingCore/Network`
mikee47 Apr 28, 2019
e120909
Rename `SmingCore` to `Core`
mikee47 Apr 28, 2019
acf29f3
Add help documenation to makefiles
mikee47 Apr 29, 2019
78b419c
WebHelpers now subject to coding style
mikee47 Apr 29, 2019
a98ba2e
Add `make help` and `make list-config` to travis/appveyor, update cod…
mikee47 Apr 29, 2019
7a1d8c1
Update `Doxyfile`
mikee47 Apr 29, 2019
3e68e58
Fix esptool2 submodule dependency
mikee47 Apr 29, 2019
100c6c9
Add individual .submodule dependencies for user libraries, make them …
mikee47 Apr 30, 2019
85a5ea7
Add optional `TRACE` variable for `decode-tracktrace` target
mikee47 Apr 30, 2019
bc3367e
Add `SmingCore/SmingCore.h` legacy file with warnings and link to Wik…
mikee47 Apr 30, 2019
e849638
In `decode-stacktrace.py`, use `sys.stdin.readline()` instead of `raw…
mikee47 Apr 30, 2019
b207eed
Remove sorting from `PrintHelp` make function to improve compatibilit…
mikee47 Apr 30, 2019
a8e25f6
Replace `#include` guards with `#pragma once`
mikee47 Apr 30, 2019
9fb2b9a
Minor change to `building.md`
mikee47 Apr 30, 2019
4498378
Fix coding style
mikee47 Apr 30, 2019
f0ad288
Fix line endings by running everything through dos2unix
mikee47 Apr 30, 2019
c929c93
Merge SmingCore warning #pragmas
mikee47 Apr 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add help documenation to makefiles
* Document relevant targets using `##` comments, groups with `##@`
* Tag configuration variables using `CONFIG_VARS` so values can be examined (using `list-config`)
* Add `help` and `list-config` targets
* Add `rebuild` target for framework (app already has one)
* Move `kill_term`, `terminal` and `decode-stacktrace` targets into `Makefile-app.mk`
* Use CURDIR instead of fabricating CURRENT_DIR
* Add `FixPath` function to deal with Windows/POSIX path conversion
mikee47 committed Apr 29, 2019
commit acf29f324e012c4464329e3e2c3f38100da5e8b0
96 changes: 51 additions & 45 deletions Sming/Arch/Esp8266/app.mk
Original file line number Diff line number Diff line change
@@ -8,10 +8,13 @@ ifndef ESP_HOME
$(error ESP_HOME variable is not set to a valid directory.)
endif

.PHONY: all checkdirs app spiff_update spiff_clean clean kill_term terminal gdb
all: libsming checkdirs app
##@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
@@ -34,13 +37,15 @@ endif
# 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

@@ -114,6 +119,7 @@ $(RBOOT_BIN):


# => 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
@@ -123,6 +129,7 @@ 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
@@ -156,6 +163,7 @@ $(LIBLWIP_DST):
endif

# => GDB
CONFIG_VARS += ENABLE_GDB
APPCODE += $(ARCH_COMPONENTS)/gdbstub/appcode
EXTRA_INCDIR += $(ARCH_COMPONENTS)/gdbstub/include
ifeq ($(ENABLE_GDB), 1)
@@ -175,12 +183,14 @@ GDB := trap '' INT; $(GDB) -x $(ARCH_COMPONENTS)/gdbstub/gdbcmds -b $(COM_SPEED_


# => 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
@@ -211,6 +221,7 @@ LIBS += $(LIBMAIN)


# SSL support using axTLS
CONFIG_VARS += ENABLE_SSL SSL_DEBUG
ifeq ($(ENABLE_SSL),1)
LIBAXTLS := axtls
LIBS += $(LIBAXTLS)
@@ -230,12 +241,13 @@ $(LIBAXTLS_DST):

include/ssl/private_key.h:
$(vecho) "Generating unique certificate and key. This may take some time"
$(Q) mkdir -p $(CURRENT_DIR)/include/ssl/
AXDIR=$(CURRENT_DIR)/include/ssl/ $(ARCH_COMPONENTS)/axtls-8266/axtls-8266/tools/make_certs.sh
$(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
@@ -253,8 +265,6 @@ LIBS += $(LIBPWM)
#
LIBS := microc microgcc hal phy pp net80211 mqttc wpa $(LIBSMING) crypto smartconfig $(EXTRA_LIBS) $(LIBS)

LIBS := $(addprefix -l,$(LIBS))

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u spiffs_get_storage_config -u custom_crash_callback \
-Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local
@@ -275,10 +285,9 @@ include $(SMING_HOME)/modules.mk
# 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)

spiff_update: spiff_clean $(SPIFF_BIN_OUT)

# => Firmware images
$(RBOOT_ROM_0): $(TARGET_OUT_0)
$(vecho) "E2 $@"
@@ -291,7 +300,7 @@ $(RBOOT_ROM_1): $(TARGET_OUT_1)
$(TARGET_OUT_0): $(APP_AR)
$(vecho) "LD $@"
$(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) $(LIBS) -Wl,--end-group -o $@
-T$(RBOOT_LD_0) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@

$(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW)

@@ -315,29 +324,38 @@ $(TARGET_OUT_0): $(APP_AR)
$(TARGET_OUT_1): $(APP_AR)
$(vecho) "LD $@"
$(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) $(LIBS) -Wl,--end-group -o $@
-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 $@
$(AR) rcsP $@ $^

#
.PHONY: libsming
libsming: $(LIBSMING_DST)
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 $@

spiff_clean:
##@Cleaning

.PHONY: spiff_update
spiff_update: spiff_clean $(SPIFF_BIN_OUT) ##Rebuild the SPIFFS filesystem image

.PHONY: spiff_clean
spiff_clean: ##Remove SPIFFS image file
$(vecho) "Cleaning $(SPIFF_BIN_OUT)"
$(Q) rm -rf $(SPIFF_BIN_OUT)

@@ -358,19 +376,23 @@ else
endif


# Flashing
##@Flashing

flashboot: libsming $(RBOOT_BIN)
.PHONY: flashboot
flashboot: libsming $(RBOOT_BIN) ##Write just the rBoot boot sector
$(WRITE_FLASH) 0x00000 $(RBOOT_BIN)

flashconfig: kill_term
$(vecho) "Deleting rBoot config sector"
.PHONY: flashconfig
flashconfig: kill_term ##Erase the rBoot config sector
$(vecho) "Erasing rBoot config sector"
$(WRITE_FLASH) 0x01000 $(SDK_BASE)/bin/blank.bin

flashapp: all kill_term

.PHONY: flashapp
flashapp: all kill_term ##Write just the application image
$(WRITE_FLASH) $(ROM_0_ADDR) $(RBOOT_ROM_0)

flashfs: libsming $(SPIFF_BIN_OUT)
.PHONY: flashfs
flashfs: libsming $(SPIFF_BIN_OUT) ##Write just the SPIFFS filesystem image
ifeq ($(DISABLE_SPIFFS), 1)
$(vecho) "SPIFFS are not enabled!"
else
@@ -383,49 +405,33 @@ FLASH_CHUNKS += $(ROM_0_ADDR) $(RBOOT_ROM_0)
ifneq ($(DISABLE_SPIFFS), 1)
FLASH_CHUNKS += $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT)
endif
flash: all kill_term

.PHONY: flash
flash: all kill_term ##Write the rBoot boot sector, application image and (if enabled) SPIFFS image
$(WRITE_FLASH) $(FLASH_CHUNKS)
ifeq ($(ENABLE_GDB), 1)
$(GDB)
else
$(TERMINAL)
endif

otaserver: all
$(vecho) "Starting OTA server for TESTING"
$(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT)

kill_term:
$(vecho) "Killing Terminal to free $(COM_PORT)"
-$(Q) $(KILL_TERM)

terminal: kill_term
$(TERMINAL)

gdb: kill_term
$(GDB)

decode-stacktrace:
@echo "Decode stack trace: Paste stack trace here"
$(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0)

# 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
flashinit:

.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

rebuild: clean all

# Remove build artifacts
clean:
.PHONY: clean
clean: ##Remove all generated build files
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

15 changes: 10 additions & 5 deletions Sming/Arch/Esp8266/build.mk
Original file line number Diff line number Diff line change
@@ -15,11 +15,14 @@ endif
## MacOS / Linux:
# ESP_HOME = /opt/esp-open-sdk

ifeq ($(OS),Windows_NT)
# Convert Windows paths to POSIX paths
ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME))))
ESP_HOME := $(subst //,/,$(ESP_HOME))
endif
#ifeq ($(OS),Windows_NT)
# # Convert Windows paths to POSIX paths
# ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME))))
# ESP_HOME := $(subst //,/,$(ESP_HOME))
#endif

CONFIG_VARS += ESP_HOME
ESP_HOME := $(call FixPath,$(ESP_HOME))

export ESP_HOME

@@ -41,6 +44,7 @@ GDB := $(TOOLSPEC)gdb
CFLAGS_COMMON += -nostdlib -mlongcalls -mtext-section-literals
CFLAGS += -D__ets__ -DICACHE_FLASH -DUSE_OPTIMIZE_PRINTF -DESP8266=1

CONFIG_VARS += MFORCE32
MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32)
ifneq ($(MFORCE32),)
# Your compiler supports the -mforce-l32 flag which means that
@@ -54,6 +58,7 @@ endif
# => '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
ifneq (,$(findstring $(abspath $(SMING_HOME)),$(abspath $(SDK_BASE))))
SDK_COMPONENT := $(ARCH_COMPONENTS)/Sdk/ESP8266_NONOS_SDK
SDK_BASE := $(SMING_HOME)/$(SDK_COMPONENT)
4 changes: 4 additions & 0 deletions Sming/Arch/Esp8266/sming.mk
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ MODULES += $(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
@@ -52,6 +53,7 @@ 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
@@ -71,6 +73,7 @@ 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)
@@ -121,6 +124,7 @@ lwip-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
Loading