# 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
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