2016-06-05 23:10:58 +02:00
|
|
|
#############################################################
|
|
|
|
# Options
|
|
|
|
#
|
|
|
|
|
|
|
|
FSSOURCE ?= ../local/fs/
|
2018-02-13 22:26:56 +01:00
|
|
|
LUASOURCE ?= ../local/lua/
|
2016-06-05 23:10:58 +02:00
|
|
|
FLASHSIZE ?= 4mb 32mb 8mb
|
|
|
|
SUBDIRS =
|
2016-09-21 03:45:53 +02:00
|
|
|
HOSTCC ?= gcc
|
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
|
|
|
|
#
|
|
|
|
|
|
|
|
SPIFFSFILES ?= $(patsubst $(FSSOURCE)%,%,$(shell find $(FSSOURCE) -name '*' '!' -name .gitignore ))
|
|
|
|
|
|
|
|
#################################################################
|
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
|
|
|
#
|
|
|
|
|
2018-02-13 22:26:56 +01:00
|
|
|
FLASH_USED_END := $$((0x`$(OBJDUMP) -t ../app/.output/eagle/debug/image/eagle.app.v6.out |grep _flash_used_end |cut -f1 -d" "` - 0x40200000))
|
|
|
|
FLASH_FS_SIZE := $(shell $(HOSTCC) -E -dM - <../app/include/user_config.h | grep SPIFFS_MAX_FILESYSTEM_SIZE| cut -d ' ' -f 3)
|
|
|
|
FLASH_FS_LOC := $(shell $(HOSTCC) -E -dM - <../app/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3)
|
|
|
|
|
|
|
|
ifneq (FLASH_FS_SIZE,'')
|
|
|
|
FLASHSIZE = $(shell printf "0x%x" $(FLASH_FS_SIZE))
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (FLASH_FS_LOC,'')
|
|
|
|
FLASH_FS_LOC := $(FLASH_USED_END)
|
|
|
|
else
|
|
|
|
FLASH_FS_LOC := $(shell printf "0x%x" $(FLASH_FS_LOC))
|
|
|
|
endif
|
2016-06-05 23:10:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
#############################################################
|
|
|
|
# Rules base
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
all: spiffsscript
|
|
|
|
|
2016-09-21 03:45:53 +02:00
|
|
|
.PHONY: spiffsimg
|
|
|
|
|
|
|
|
.PHONY: spiffsimg/spiffsimg
|
|
|
|
|
|
|
|
spiffsimg: spiffsimg/spiffsimg
|
|
|
|
@echo Built spiffsimg in spiffsimg/spiffsimg
|
|
|
|
|
|
|
|
spiffsimg/spiffsimg:
|
|
|
|
@$(MAKE) -C spiffsimg CC=$(HOSTCC)
|
|
|
|
|
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
|
2016-06-05 23:10:58 +02:00
|
|
|
@$(foreach f, $(SPIFFSFILES), echo "import $(FSSOURCE)$(f) $(f)" >> ./spiffsimg/spiffs.lst ;)
|
2018-02-13 22:26:56 +01:00
|
|
|
$(foreach sz, $(FLASHSIZE), spiffsimg/spiffsimg -f ../bin/0x%x-$(sz).img -c $(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-02-13 22:26:56 +01:00
|
|
|
LFSimage: $(LUASOURCE)*.lua
|
|
|
|
../luac.cross -f -o $(FSSOURCE)flash.img $(LUASOURCE)*.lua
|
|
|
|
|
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
|
|
|
|
|