2 # LWS-style images are composed like this
4 # [ OTA or Factory standard xpressif image ]
5 # [ 32-b LE len ] [ ROMFS ]
6 # [ 32-b LE len ] [ Image information JSON ]
11 jbi=$(COMPONENT_PATH)/../build/json-buildinfo
13 FAC=$(CONFIG_LWS_IS_FACTORY_APPLICATION)
21 DIRNAME=$$(basename $$(pwd) | tr -d '\n') ;\
22 cp $(COMPONENT_PATH)/../build/$(PROJECT_NAME).bin $(COMPONENT_PATH)/../build/$$DIRNAME.bin ; \
23 genromfs -f $(COMPONENT_PATH)/../build/romfs.img -d $(COMPONENT_PATH)/../romfs-files ; \
24 RLEN=$$(stat -c %s $(COMPONENT_PATH)/../build/romfs.img) ;\
25 LEN=$$(stat -c %s $(COMPONENT_PATH)/../build/$$DIRNAME.bin) ;\
26 printf " Original length: 0x%06x (%8d)\n" $$LEN $$LEN ; \
27 printf %02x $$(( $$RLEN % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
28 printf %02x $$(( ( $$RLEN / 256 ) % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
29 printf %02x $$(( ( $$RLEN / 65536 ) % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
30 printf %02x $$(( ( $$RLEN / 16777216 ) % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
31 cat $(COMPONENT_PATH)/../build/romfs.img >>$(COMPONENT_PATH)/../build/$$DIRNAME.bin ; \
32 LEN=$$(stat -c %s $(COMPONENT_PATH)/../build/$$DIRNAME.bin) ;\
33 UNIXTIME=$$(date +%s | tr -d '\n') ; \
34 echo -n -e "{\r\n \"schema\": \"lws1\",\r\n \"model\": \"$(CONFIG_LWS_MODEL_NAME)\",\r\n \"builder\": \"" > $(jbi) ;\
35 hostname | tr -d '\n' >> $(jbi) ;\
36 echo -n -e "\",\r\n \"app\": \"" >> $(jbi) ;\
37 echo -n $$DIRNAME >> $(jbi) ;\
38 echo -n -e "\",\r\n \"user\": \"" >> $(jbi) ;\
39 whoami | tr -d '\n' >>$(jbi) ;\
40 echo -n -e "\",\r\n \"git\": \"" >> $(jbi) ;\
41 git describe --dirty --always | tr -d '\n' >> $(jbi) ;\
42 echo -n -e "\",\r\n \"date\": \"" >> $(jbi) ;\
43 date | tr -d '\n' >> $(jbi) ;\
44 echo -n -e "\",\r\n \"unixtime\": \"" >> $(jbi) ;\
45 echo -n $$UNIXTIME >> $(jbi) ;\
46 echo -n -e "\",\r\n \"file\": \""$$DIRNAME-$$UNIXTIME.bin >> $(jbi) ;\
47 echo -n -e "\",\r\n \"factory\": \"$(FAC)" >> $(jbi) ;\
48 echo -n -e "\"\r\n}" >> $(jbi) ;\
49 JLEN=$$(stat -c %s $(jbi)) ;\
50 printf %02x $$(( $$JLEN % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
51 printf %02x $$(( ( $$JLEN / 256 ) % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
52 printf %02x $$(( ( $$JLEN / 65536 ) % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
53 printf %02x $$(( ( $$JLEN / 16777216 ) % 256 )) | xxd -r -p >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
54 cat $(jbi) >> $(COMPONENT_PATH)/../build/$$DIRNAME.bin ;\
55 LEN=$$(stat -c %s $(COMPONENT_PATH)/../build/$$DIRNAME.bin) ;\
56 cp $(COMPONENT_PATH)/../build/$$DIRNAME.bin $(COMPONENT_PATH)/../build/$$DIRNAME-$$UNIXTIME.bin ;\
57 printf " After ROMFS + Build info: 0x%06x (%8d)\n" $$LEN $$LEN
62 echo "Usage make F=<factory app dir> A=<app dir> manifest"
66 echo "Usage make F=<factory app dir> A=<app dir> manifest"
69 echo -n -e "{\r\n\"app\": " > build/manifest.json
70 cat $(A)/build/json-buildinfo >> build/manifest.json
71 echo -n -e ", \"factory\": " >> build/manifest.json
72 cat $(F)/build/json-buildinfo >> build/manifest.json
73 echo -n -e "\r\n}\r\n" >> build/manifest.json
78 DIRNAME=$$(basename $$(pwd) | tr -d '\n') ;\
79 $(IDF_PATH)/components/esptool_py/esptool/esptool.py \
81 --port $(CONFIG_ESPTOOLPY_PORT) \
82 --baud $(CONFIG_ESPTOOLPY_BAUD) \
83 write_flash 0x110000 $(COMPONENT_PATH)/../build/$$DIRNAME.bin
86 $(IDF_PATH)/components/esptool_py/esptool/esptool.py \
88 --port $(CONFIG_ESPTOOLPY_PORT) \
89 --baud $(CONFIG_ESPTOOLPY_BAUD) \
90 erase_region 0x110000 0x2f0000
98 echo "Usage make F=<factory app dir> A=<app dir> manifest"
102 echo "Usage make F=<factory app dir> A=<app dir> manifest"
105 UPL=$(CONFIG_LWS_OTA_SERVER_UPLOAD_USER)@$(CONFIG_LWS_OTA_SERVER_FQDN):$(CONFIG_LWS_OTA_SERVER_UPLOAD_PATH)/$(CONFIG_LWS_OTA_SERVER_BASE_URL)/$(CONFIG_LWS_MODEL_NAME)/ ;\
106 AFILE=$(A)/build/$$(cat $$A/build/json-buildinfo | grep -- \"file\"\: |cut -d' ' -f3 |cut -d'"' -f2) ;\
107 echo " Uploading $$AFILE to " $$UPL ;\
109 FFILE=$(F)/build/$$(cat $$F/build/json-buildinfo | grep -- \"file\"\: |cut -d' ' -f3 |cut -d'"' -f2) ;\
110 echo " Uploading $$FFILE" ;\
112 echo " Uploading manifest" ;\
113 scp build/manifest.json $$UPL