Makefile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #############################################################
  2. # Options
  3. #
  4. FSSOURCE ?= ../local/fs/
  5. LUASOURCE ?= ../local/lua/
  6. FLASHSIZE ?= 4mb 32mb 8mb
  7. SUBDIRS =
  8. HOSTCC ?= gcc
  9. OBJDUMP = $(or $(shell which objdump),xtensa-lx106-elf-objdump)
  10. #############################################################
  11. # Get the files to pack into the spiffs image
  12. #
  13. SPIFFSFILES ?= $(patsubst $(FSSOURCE)%,%,$(shell find $(FSSOURCE) -name '*' '!' -name .gitignore ))
  14. #################################################################
  15. # Get the filesize of /bin/0x10000.bin and SPIFFS sizing
  16. #
  17. FLASH_USED_END := $$((0x`$(OBJDUMP) -t ../app/.output/eagle/debug/image/eagle.app.v6.out |grep _flash_used_end |cut -f1 -d" "` - 0x40200000))
  18. FLASH_FS_SIZE := $(shell $(HOSTCC) -E -dM - <../app/include/user_config.h | grep SPIFFS_MAX_FILESYSTEM_SIZE| cut -d ' ' -f 3)
  19. FLASH_FS_LOC := $(shell $(HOSTCC) -E -dM - <../app/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3)
  20. ifneq (FLASH_FS_SIZE,'')
  21. FLASHSIZE = $(shell printf "0x%x" $(FLASH_FS_SIZE))
  22. endif
  23. ifeq (FLASH_FS_LOC,'')
  24. FLASH_FS_LOC := $(FLASH_USED_END)
  25. else
  26. FLASH_FS_LOC := $(shell printf "0x%x" $(FLASH_FS_LOC))
  27. endif
  28. #############################################################
  29. # Rules base
  30. #
  31. #
  32. all: spiffsscript
  33. .PHONY: spiffsimg
  34. .PHONY: spiffsimg/spiffsimg
  35. spiffsimg: spiffsimg/spiffsimg
  36. @echo Built spiffsimg in spiffsimg/spiffsimg
  37. spiffsimg/spiffsimg:
  38. @$(MAKE) -C spiffsimg CC=$(HOSTCC)
  39. spiffsscript: remove-image LFSimage spiffsimg/spiffsimg
  40. rm -f ./spiffsimg/spiffs.lst
  41. @echo "" >> ./spiffsimg/spiffs.lst
  42. @$(foreach f, $(SPIFFSFILES), echo "import $(FSSOURCE)$(f) $(f)" >> ./spiffsimg/spiffs.lst ;)
  43. $(foreach sz, $(FLASHSIZE), spiffsimg/spiffsimg -f ../bin/0x%x-$(sz).img -c $(sz) -U $(FLASH_FS_LOC) -r ./spiffsimg/spiffs.lst -d; )
  44. @$(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then echo Built $$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  45. LFSimage: $(LUASOURCE)*.lua
  46. ../luac.cross -f -o $(FSSOURCE)flash.img $(LUASOURCE)*.lua
  47. remove-image:
  48. $(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then rm -f ../bin/$$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  49. rm -f ../bin/spiffs*.dat
  50. spiffsclean: remove-image
  51. rm -f ./spiffsimg/spiffsimg
  52. rm -f ./spiffsimg/spiffs.lst