Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #############################################################
  30. # Rules base
  31. #
  32. #
  33. all: spiffsscript
  34. .PHONY: TEST
  35. TEST:
  36. @echo $(FLASHSIZE)
  37. @echo $(FLASH_FS_SIZE)
  38. @echo $(FLASH_FS_LOC)
  39. @echo $(FLASH_USED_END)
  40. spiffsimg/spiffsimg:
  41. .PHONY: spiffsimg
  42. .PHONY: spiffsimg/spiffsimg
  43. spiffsimg: spiffsimg/spiffsimg
  44. @echo Built spiffsimg in spiffsimg/spiffsimg
  45. spiffsimg/spiffsimg:
  46. @$(MAKE) -C spiffsimg CC=$(HOSTCC)
  47. spiffsscript: remove-image LFSimage spiffsimg/spiffsimg
  48. rm -f ./spiffsimg/spiffs.lst
  49. @echo "" >> ./spiffsimg/spiffs.lst
  50. @$(foreach f, $(SPIFFSFILES), echo "import $(FSSOURCE)$(f) $(f)" >> ./spiffsimg/spiffs.lst ;)
  51. $(foreach sz, $(FLASHSIZE), spiffsimg/spiffsimg -f ../bin/0x%x-$(sz).img $(FLASH_SW) $(sz) -U $(FLASH_FS_LOC) -r ./spiffsimg/spiffs.lst -d; )
  52. @$(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then echo Built $$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  53. ifneq ($(LFSSOURCES),)
  54. LFSimage: $(LFSSOURCES)
  55. ../luac.cross -f -o $(FSSOURCE)flash.img $(LFSSOURCES)
  56. else
  57. LFSimage:
  58. rm -f $(FSSOURCE)flash.img
  59. endif
  60. remove-image:
  61. $(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then rm -f ../bin/$$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  62. rm -f ../bin/spiffs*.dat
  63. spiffsclean: remove-image
  64. rm -f ./spiffsimg/spiffsimg
  65. rm -f ./spiffsimg/spiffs.lst