Makefile 1.5 KB

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