Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #############################################################
  2. # Options
  3. #
  4. FSSOURCE ?= ../local/fs
  5. LUASOURCE ?= ../local/lua
  6. FLASHSIZE ?= 4mb 32mb 8mb
  7. FLASH_SW = -S
  8. SUBDIRS =
  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_FS_SIZE := $(shell $(CC) -E -dM - <../app/include/user_config.h | grep SPIFFS_MAX_FILESYSTEM_SIZE| cut -d ' ' -f 3)
  18. ifneq ($(strip $(FLASH_FS_SIZE)),)
  19. FLASHSIZE = $(shell printf "0x%x" $(FLASH_FS_SIZE))
  20. FLASH_SW = -c
  21. endif
  22. FLASH_FS_LOC := $(shell $(CC) -E -dM - <../app/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3)
  23. ifeq ($(strip $(FLASH_FS_LOC)),)
  24. 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)))
  25. else
  26. FLASH_FS_LOC := $(shell printf "0x%x" $(FLASH_FS_LOC))
  27. endif
  28. LFSSOURCES := $(wildcard $(LUASOURCE)/*.lua)
  29. BUILD_TYPE := $(shell $(CC) $(EXTRA_CCFLAGS) -E -dM - <../app/include/user_config.h | grep LUA_NUMBER_INTEGRAL | wc -l)
  30. ifeq ($(BUILD_TYPE),0)
  31. LUAC_CROSS := ../luac.cross
  32. else
  33. LUAC_CROSS := ../luac.cross.int
  34. endif
  35. #############################################################
  36. # Rules base
  37. #
  38. #
  39. all: spiffsscript
  40. .PHONY: TEST
  41. TEST:
  42. @echo $(FLASHSIZE)
  43. @echo $(FLASH_FS_SIZE)
  44. @echo $(FLASH_FS_LOC)
  45. @echo $(FLASH_USED_END)
  46. spiffsimg/spiffsimg:
  47. .PHONY: spiffsimg
  48. .PHONY: spiffsimg/spiffsimg
  49. spiffsimg: spiffsimg/spiffsimg
  50. @echo Built spiffsimg in spiffsimg/spiffsimg
  51. spiffsimg/spiffsimg:
  52. @$(MAKE) -C spiffsimg
  53. spiffsscript: remove-image LFSimage spiffsimg/spiffsimg
  54. rm -f ./spiffsimg/spiffs.lst
  55. @echo "" >> ./spiffsimg/spiffs.lst
  56. @$(foreach f, $(SPIFFSFILES), echo "import $(FSSOURCE)$(f) $(f)" >> ./spiffsimg/spiffs.lst ;)
  57. $(foreach sz, $(FLASHSIZE), spiffsimg/spiffsimg -f ../bin/0x%x-$(sz).img $(FLASH_SW) $(sz) -U $(FLASH_FS_LOC) -r ./spiffsimg/spiffs.lst -d; )
  58. @$(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then echo Built $$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  59. ifneq ($(LFSSOURCES),)
  60. LFSimage: $(LFSSOURCES)
  61. $(LUAC_CROSS) -f -o $(FSSOURCE)flash.img $(LFSSOURCES)
  62. else
  63. LFSimage:
  64. rm -f $(FSSOURCE)flash.img
  65. endif
  66. remove-image:
  67. $(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then rm -f ../bin/$$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  68. rm -f ../bin/spiffs*.dat
  69. spiffsclean: remove-image
  70. rm -f ./spiffsimg/spiffsimg
  71. rm -f ./spiffsimg/spiffs.lst