]> granicus.if.org Git - esp-idf/commitdiff
make: use otatool and parttool for build
authorRenz Christian Bagaporo <renz@espressif.com>
Thu, 15 Nov 2018 21:01:41 +0000 (05:01 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Wed, 28 Nov 2018 07:57:20 +0000 (15:57 +0800)
components/app_update/Makefile.projbuild
components/partition_table/Makefile.projbuild
make/project.mk

index f4cf1d055514689f1369e03482bf9e69162f2c44..c9ee59137309349d71b1c81a4b127f5c2f87b7e1 100644 (file)
@@ -1,60 +1,38 @@
 # Generate partition binary
 #
-.PHONY: dump_otadata erase_ota blank_ota_data
+.PHONY: blank_ota_data erase_otadata read_otadata
 
-GEN_EMPTY_PART := $(PYTHON) $(COMPONENT_PATH)/gen_empty_partition.py
-BLANK_OTA_DATA_FILE = $(BUILD_DIR_BASE)/ota_data_initial.bin
-
-PARTITION_TABLE_LEN := 0xC00
-OTADATA_LEN := 0x2000
-
-PARTITION_TABLE_ONCHIP_BIN_PATH := $(call dequote,$(abspath $(BUILD_DIR_BASE)))
-PARTITION_TABLE_ONCHIP_BIN_NAME := "onchip_partition.bin"
-OTADATA_ONCHIP_BIN_NAME := "onchip_otadata.bin"
+OTATOOL_PY := $(PYTHON) $(COMPONENT_PATH)/otatool.py
+PARTTOOL_PY := $(PYTHON) $(IDF_PATH)/components/partition_table/parttool.py
 
-PARTITION_TABLE_ONCHIP_BIN := $(PARTITION_TABLE_ONCHIP_BIN_PATH)/$(call dequote,$(PARTITION_TABLE_ONCHIP_BIN_NAME)) 
-OTADATA_ONCHIP_BIN := $(PARTITION_TABLE_ONCHIP_BIN_PATH)/$(call dequote,$(OTADATA_ONCHIP_BIN_NAME))
+# Generate blank partition file
+BLANK_OTA_DATA_FILE = $(BUILD_DIR_BASE)/ota_data_initial.bin
 
-PARTITION_TABLE_GET_BIN_CMD = $(ESPTOOLPY_SERIAL) read_flash $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_LEN) $(PARTITION_TABLE_ONCHIP_BIN)
-OTADATA_GET_BIN_CMD = $(ESPTOOLPY_SERIAL) read_flash $(OTADATA_OFFSET) $(OTADATA_LEN) $(OTADATA_ONCHIP_BIN)
+$(BLANK_OTA_DATA_FILE): partition_table_get_info $(PARTITION_TABLE_BIN) | check_python_dependencies
+       $(shell if [ $(OTA_DATA_OFFSET) != "" ] && [ $(OTA_DATA_SIZE) != "" ]; then \
+                               $(PARTTOOL_PY) --partition-type data --partition-subtype ota --partition-table-file $(PARTITION_TABLE_BIN) \
+                                                               -q generate_blank_partition_file --output $(BLANK_OTA_DATA_FILE); \
+                       fi; )
+       $(eval BLANK_OTA_DATA_FILE = $(shell if [ $(OTA_DATA_OFFSET) != "" ] && [ $(OTA_DATA_SIZE) != "" ]; then \
+                       echo $(BLANK_OTA_DATA_FILE); else echo " "; fi) )
 
-GEN_OTADATA = $(IDF_PATH)/components/app_update/dump_otadata.py
-ERASE_OTADATA_CMD = $(ESPTOOLPY_SERIAL) erase_region $(OTADATA_OFFSET) $(OTADATA_LEN)
+blank_ota_data: $(BLANK_OTA_DATA_FILE)
 
 # If there is no otadata partition, both OTA_DATA_OFFSET and BLANK_OTA_DATA_FILE 
 # expand to empty values.
 ESPTOOL_ALL_FLASH_ARGS += $(OTA_DATA_OFFSET) $(BLANK_OTA_DATA_FILE)
 
-$(PARTITION_TABLE_ONCHIP_BIN):
-       $(PARTITION_TABLE_GET_BIN_CMD)
+erase_otadata: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
+       $(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_BIN) erase_otadata
 
-onchip_otadata_get_info: $(PARTITION_TABLE_ONCHIP_BIN) 
-       $(eval OTADATA_OFFSET:=$(shell $(GET_PART_INFO) --type data --subtype ota --offset $(PARTITION_TABLE_ONCHIP_BIN)))
-       @echo $(if $(OTADATA_OFFSET), $(shell export OTADATA_OFFSET), $(shell rm -f $(PARTITION_TABLE_ONCHIP_BIN));$(error "ERROR: ESP32 does not have otadata partition."))
-
-$(OTADATA_ONCHIP_BIN):
-       $(OTADATA_GET_BIN_CMD)
-
-dump_otadata: onchip_otadata_get_info $(OTADATA_ONCHIP_BIN) $(PARTITION_TABLE_ONCHIP_BIN) 
-       @echo "otadata retrieved. Contents:"
-       @echo $(SEPARATOR)
-       $(GEN_OTADATA) $(OTADATA_ONCHIP_BIN)
-       @echo $(SEPARATOR)
-       rm -f $(PARTITION_TABLE_ONCHIP_BIN)
-       rm -f $(OTADATA_ONCHIP_BIN)
-
-$(BLANK_OTA_DATA_FILE): partition_table_get_info
-       $(GEN_EMPTY_PART) --size $(OTA_DATA_SIZE) $(BLANK_OTA_DATA_FILE)
-       $(eval BLANK_OTA_DATA_FILE = $(shell if [ $(OTA_DATA_SIZE) != 0 ]; then echo $(BLANK_OTA_DATA_FILE); else echo " "; fi) )
-
-blank_ota_data: $(BLANK_OTA_DATA_FILE)
+read_otadata: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
+       $(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_BIN) read_otadata
 
-erase_ota: partition_table_get_info | check_python_dependencies
-       @echo $(if $(OTA_DATA_OFFSET), "Erase ota_data [addr=$(OTA_DATA_OFFSET) size=$(OTA_DATA_SIZE)] ...", $(error "ERROR: Partition table does not have ota_data partition."))
-       $(ESPTOOLPY_SERIAL) erase_region $(OTA_DATA_OFFSET) $(OTA_DATA_SIZE)
+erase_ota: erase_otadata
+       @echo "WARNING: erase_ota is deprecated. Use erase_otadata instead."
 
 all: blank_ota_data
 flash: blank_ota_data
 
 clean:
-       rm -f $(BLANK_OTA_DATA_FILE)
+       rm -f $(BLANK_OTA_DATA_FILE)
\ No newline at end of file
index 71e26868b801204de7d3a1b8fc7e7d9d70e081b2..7128e6ab6f865e9b106702020b64f1a1f44b5a02 100644 (file)
@@ -63,10 +63,14 @@ $(PARTITION_TABLE_BIN_UNSIGNED): $(PARTITION_TABLE_CSV_PATH) $(SDKCONFIG_MAKEFIL
 all_binaries: $(PARTITION_TABLE_BIN) partition_table_get_info
 
 partition_table_get_info: $(PARTITION_TABLE_BIN)
-       $(eval PHY_DATA_OFFSET:=$(shell $(GET_PART_INFO) --type data --subtype phy --offset $(PARTITION_TABLE_BIN)))
-       $(eval APP_OFFSET:=$(shell $(GET_PART_INFO) --default-boot-partition --offset $(PARTITION_TABLE_BIN)))
-       $(eval OTA_DATA_SIZE := $(shell $(GET_PART_INFO) --type data --subtype ota --size $(PARTITION_TABLE_BIN) || echo 0))
-       $(eval OTA_DATA_OFFSET := $(shell $(GET_PART_INFO) --type data --subtype ota --offset $(PARTITION_TABLE_BIN)))
+       $(eval PHY_DATA_OFFSET:=$(shell $(GET_PART_INFO) --partition-type data --partition-subtype phy \
+                                                       --partition-table-file $(PARTITION_TABLE_BIN) get_partition_info --info offset))
+       $(eval APP_OFFSET:=$(shell $(GET_PART_INFO) --partition-boot-default \
+                                                       --partition-table-file $(PARTITION_TABLE_BIN) get_partition_info --info offset))
+       $(eval OTA_DATA_OFFSET:=$(shell $(GET_PART_INFO) --partition-type data --partition-subtype ota \
+                                                       --partition-table-file $(PARTITION_TABLE_BIN) get_partition_info --info offset))
+       $(eval OTA_DATA_SIZE:=$(shell $(GET_PART_INFO) --partition-type data --partition-subtype ota \
+                                                       --partition-table-file $(PARTITION_TABLE_BIN) get_partition_info --info size))
 
 export APP_OFFSET
 export PHY_DATA_OFFSET
index cf5548c0ce1c136f5a375898f80e2ccf9e88da2a..feab67c5e2177ee244ef6773632e69e28f0442b3 100644 (file)
@@ -34,7 +34,8 @@ help:
        @echo "make size-components, size-files - Finer-grained memory footprints"
        @echo "make size-symbols - Per symbol memory footprint. Requires COMPONENT=<component>"
        @echo "make erase_flash - Erase entire flash contents"
-       @echo "make erase_ota - Erase ota_data partition. After that will boot first bootable partition (factory or OTAx)."
+       @echo "make erase_otadata - Erase ota_data partition; First bootable partition (factory or OTAx) will be used on next boot."
+       @echo "                     This assumes this project's partition table is the one flashed on the device."
        @echo "make monitor - Run idf_monitor tool to monitor serial output from app"
        @echo "make simple_monitor - Monitor serial output on terminal console"
        @echo "make list-components - List all components in the project"