2016-06-05 23:10:58 +02:00
|
|
|
#############################################################
|
|
|
|
# Options
|
|
|
|
#
|
|
|
|
|
2018-08-11 19:28:01 +02:00
|
|
|
FSSOURCE ?= ../local/fs
|
|
|
|
LUASOURCE ?= ../local/lua
|
2016-06-05 23:10:58 +02:00
|
|
|
FLASHSIZE ?= 4mb 32mb 8mb
|
2018-03-08 01:20:59 +01:00
|
|
|
FLASH_SW = -S
|
2019-02-17 19:26:29 +01:00
|
|
|
SUBDIRS =
|
2019-07-23 17:47:18 +02:00
|
|
|
APP_DIR = ../app
|
2016-06-05 23:10:58 +02:00
|
|
|
OBJDUMP = $(or $(shell which objdump),xtensa-lx106-elf-objdump)
|
|
|
|
|
|
|
|
#############################################################
|
|
|
|
# Get the files to pack into the spiffs image
|
|
|
|
#
|
|
|
|
|
2018-08-11 19:28:01 +02:00
|
|
|
SPIFFSFILES ?= $(patsubst $(FSSOURCE)/%,%,$(shell find $(FSSOURCE)/ -name '*' '!' -name .gitignore ))
|
2016-06-05 23:10:58 +02:00
|
|
|
|
|
|
|
#################################################################
|
2018-02-13 22:26:56 +01:00
|
|
|
# Get the filesize of /bin/0x10000.bin and SPIFFS sizing
|
2016-06-05 23:10:58 +02:00
|
|
|
#
|
|
|
|
|
2019-07-23 17:47:18 +02:00
|
|
|
FLASH_FS_SIZE := $(shell $(CC) -E -dM - <$(APP_DIR)/include/user_config.h | grep SPIFFS_MAX_FILESYSTEM_SIZE| cut -d ' ' -f 3)
|
2018-02-13 22:26:56 +01:00
|
|
|
|
2018-03-08 01:20:59 +01:00
|
|
|
ifneq ($(strip $(FLASH_FS_SIZE)),)
|
2018-02-13 22:26:56 +01:00
|
|
|
FLASHSIZE = $(shell printf "0x%x" $(FLASH_FS_SIZE))
|
2018-03-08 01:20:59 +01:00
|
|
|
FLASH_SW = -c
|
2019-02-17 19:26:29 +01:00
|
|
|
endif
|
2018-02-13 22:26:56 +01:00
|
|
|
|
2019-07-23 17:47:18 +02:00
|
|
|
FLASH_FS_LOC := $(shell $(CC) -E -dM - <$(APP_DIR)/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3)
|
2018-03-08 01:20:59 +01:00
|
|
|
ifeq ($(strip $(FLASH_FS_LOC)),)
|
2019-07-23 17:47:18 +02:00
|
|
|
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)))
|
2019-02-17 19:26:29 +01:00
|
|
|
else
|
2018-02-13 22:26:56 +01:00
|
|
|
FLASH_FS_LOC := $(shell printf "0x%x" $(FLASH_FS_LOC))
|
2019-02-17 19:26:29 +01:00
|
|
|
endif
|
2016-06-05 23:10:58 +02:00
|
|
|
|
2018-04-19 17:27:47 +02:00
|
|
|
LFSSOURCES := $(wildcard $(LUASOURCE)/*.lua)
|
2016-06-05 23:10:58 +02:00
|
|
|
|
2019-07-23 17:47:18 +02:00
|
|
|
BUILD_TYPE := $(shell $(CC) $(EXTRA_CCFLAGS) -E -dM - <$(APP_DIR)/include/user_config.h | grep LUA_NUMBER_INTEGRAL | wc -l)
|
2018-08-11 19:28:01 +02:00
|
|
|
ifeq ($(BUILD_TYPE),0)
|
|
|
|
LUAC_CROSS := ../luac.cross
|
|
|
|
else
|
|
|
|
LUAC_CROSS := ../luac.cross.int
|
|
|
|
endif
|
|
|
|
|
2016-06-05 23:10:58 +02:00
|
|
|
#############################################################
|
|
|
|
# Rules base
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
all: spiffsscript
|
|
|
|
|
2018-03-08 01:20:59 +01:00
|
|
|
.PHONY: TEST
|
|
|
|
|
|
|
|
TEST:
|
|
|
|
@echo $(FLASHSIZE)
|
|
|
|
@echo $(FLASH_FS_SIZE)
|
|
|
|
@echo $(FLASH_FS_LOC)
|
|
|
|
@echo $(FLASH_USED_END)
|
|
|
|
|
2019-02-17 19:26:29 +01:00
|
|
|
spiffsimg/spiffsimg:
|
2018-03-08 01:20:59 +01:00
|
|
|
|
2016-09-21 03:45:53 +02:00
|
|
|
.PHONY: spiffsimg
|
|
|
|
|
|
|
|
.PHONY: spiffsimg/spiffsimg
|
|
|
|
|
|
|
|
spiffsimg: spiffsimg/spiffsimg
|
|
|
|
@echo Built spiffsimg in spiffsimg/spiffsimg
|
|
|
|
|
2019-02-17 19:26:29 +01:00
|
|
|
spiffsimg/spiffsimg:
|
|
|
|
@$(MAKE) -C spiffsimg
|
2016-09-21 03:45:53 +02:00
|
|
|
|
2018-02-13 22:26:56 +01:00
|
|
|
spiffsscript: remove-image LFSimage spiffsimg/spiffsimg
|
2016-06-05 23:10:58 +02:00
|
|
|
rm -f ./spiffsimg/spiffs.lst
|
2018-02-13 22:26:56 +01:00
|
|
|
@echo "" >> ./spiffsimg/spiffs.lst
|
2018-08-15 10:48:23 +02:00
|
|
|
@$(foreach f, $(SPIFFSFILES), echo "import $(FSSOURCE)/$(f) $(f)" >> ./spiffsimg/spiffs.lst ;)
|
2018-03-08 01:20:59 +01:00
|
|
|
$(foreach sz, $(FLASHSIZE), spiffsimg/spiffsimg -f ../bin/0x%x-$(sz).img $(FLASH_SW) $(sz) -U $(FLASH_FS_LOC) -r ./spiffsimg/spiffs.lst -d; )
|
2016-06-05 23:10:58 +02:00
|
|
|
@$(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then echo Built $$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
|
2018-04-19 17:27:47 +02:00
|
|
|
|
|
|
|
ifneq ($(LFSSOURCES),)
|
|
|
|
LFSimage: $(LFSSOURCES)
|
2018-08-15 10:48:23 +02:00
|
|
|
$(LUAC_CROSS) -f -o $(FSSOURCE)/LFS.img $(LFSSOURCES)
|
2018-04-19 17:27:47 +02:00
|
|
|
else
|
2019-02-17 19:26:29 +01:00
|
|
|
LFSimage:
|
2018-08-15 10:48:23 +02:00
|
|
|
rm -f $(FSSOURCE)/LFS.img
|
2018-04-19 17:27:47 +02:00
|
|
|
endif
|
2018-02-13 22:26:56 +01:00
|
|
|
|
2016-06-05 23:10:58 +02:00
|
|
|
remove-image:
|
|
|
|
$(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then rm -f ../bin/$$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
|
|
|
|
rm -f ../bin/spiffs*.dat
|
|
|
|
|
|
|
|
|
|
|
|
spiffsclean: remove-image
|
|
|
|
rm -f ./spiffsimg/spiffsimg
|
|
|
|
rm -f ./spiffsimg/spiffs.lst
|
|
|
|
|