Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #############################################################
  2. # Options
  3. #
  4. FSSOURCE ?= ../local/fs/
  5. FLASHSIZE ?= 4mb 32mb 8mb
  6. SUBDIRS =
  7. HOSTCC ?= gcc
  8. OBJDUMP = $(or $(shell which objdump),xtensa-lx106-elf-objdump)
  9. #############################################################
  10. # Get the files to pack into the spiffs image
  11. #
  12. SPIFFSFILES ?= $(patsubst $(FSSOURCE)%,%,$(shell find $(FSSOURCE) -name '*' '!' -name .gitignore ))
  13. #################################################################
  14. # Get the filesize of /bin/0x10000.bin
  15. #
  16. FLASH_USED_END = $$((0x`$(OBJDUMP) -t ../app/.output/eagle/debug/image/eagle.app.v6.out |grep _flash_used_end |cut -f1 -d" "` - 0x40200000))
  17. #############################################################
  18. # Rules base
  19. #
  20. #
  21. all: spiffsscript
  22. .PHONY: spiffsimg
  23. .PHONY: spiffsimg/spiffsimg
  24. spiffsimg: spiffsimg/spiffsimg
  25. @echo Built spiffsimg in spiffsimg/spiffsimg
  26. spiffsimg/spiffsimg:
  27. @$(MAKE) -C spiffsimg CC=$(HOSTCC)
  28. spiffsscript: remove-image spiffsimg/spiffsimg
  29. rm -f ./spiffsimg/spiffs.lst
  30. echo "" >> ./spiffsimg/spiffs.lst
  31. @$(foreach f, $(SPIFFSFILES), echo "import $(FSSOURCE)$(f) $(f)" >> ./spiffsimg/spiffs.lst ;)
  32. @$(foreach sz, $(FLASHSIZE), spiffsimg/spiffsimg -U $(FLASH_USED_END) -o ../bin/spiffs-$(sz).dat -f ../bin/0x%x-$(sz).bin -S $(sz) -r ./spiffsimg/spiffs.lst -d; )
  33. @$(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then echo Built $$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  34. remove-image:
  35. $(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then rm -f ../bin/$$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  36. rm -f ../bin/spiffs*.dat
  37. spiffsclean: remove-image
  38. rm -f ./spiffsimg/spiffsimg
  39. rm -f ./spiffsimg/spiffs.lst