Makefile.projbuild 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #
  2. # Partition table
  3. #
  4. # The partition table is not a real component that gets linked into
  5. # the project. Instead, it is a standalone project to generate
  6. # the partition table binary as part of the build process. This
  7. # binary is then added to the list of files for esptool.py to flash.
  8. #
  9. .PHONY: partition_table partition_table-flash partition_table-clean
  10. # NB: gen_esp32part.py lives in the sdk/bin/ dir not component dir
  11. GEN_ESP32PART := $(PYTHON) $(COMPONENT_PATH)/gen_esp32part.py -q
  12. # Has a matching value in bootloader_support esp_flash_partitions.h
  13. PARTITION_TABLE_OFFSET := 0x8000
  14. ifndef PARTITION_TABLE_CSV_PATH
  15. # Path to partition CSV file is relative to project path for custom
  16. # partition CSV files, but relative to component dir otherwise.$
  17. PARTITION_TABLE_ROOT := $(call dequote,$(if $(CONFIG_PARTITION_TABLE_CUSTOM),$(PROJECT_PATH),$(COMPONENT_PATH)))
  18. PARTITION_TABLE_CSV_PATH := $(call dequote,$(abspath $(PARTITION_TABLE_ROOT)/$(subst $(quote),,$(CONFIG_PARTITION_TABLE_FILENAME))))
  19. endif
  20. PARTITION_TABLE_BIN := $(BUILD_DIR_BASE)/$(notdir $(PARTITION_TABLE_CSV_PATH:.csv=.bin))
  21. ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
  22. PARTITION_TABLE_BIN_UNSIGNED := $(PARTITION_TABLE_BIN:.bin=-unsigned.bin)
  23. # add an extra signing step for secure partition table
  24. $(PARTITION_TABLE_BIN): $(PARTITION_TABLE_BIN_UNSIGNED) $(SDKCONFIG_MAKEFILE) $(SECURE_BOOT_SIGNING_KEY)
  25. $(ESPSECUREPY) sign_data --keyfile $(SECURE_BOOT_SIGNING_KEY) -o $@ $<
  26. else
  27. # secure bootloader disabled, both files are the same
  28. PARTITION_TABLE_BIN_UNSIGNED := $(PARTITION_TABLE_BIN)
  29. endif
  30. $(PARTITION_TABLE_BIN_UNSIGNED): $(PARTITION_TABLE_CSV_PATH) $(SDKCONFIG_MAKEFILE)
  31. @echo "Building partitions from $(PARTITION_TABLE_CSV_PATH)..."
  32. $(GEN_ESP32PART) $< $@
  33. all_binaries: $(PARTITION_TABLE_BIN)
  34. PARTITION_TABLE_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
  35. ESPTOOL_ALL_FLASH_ARGS += $(PARTITION_TABLE_OFFSET) $(PARTITION_TABLE_BIN)
  36. partition_table: $(PARTITION_TABLE_BIN)
  37. @echo "Partition table binary generated. Contents:"
  38. @echo $(SEPARATOR)
  39. $(GEN_ESP32PART) $<
  40. @echo $(SEPARATOR)
  41. @echo "Partition flashing command:"
  42. @echo "$(PARTITION_TABLE_FLASH_CMD)"
  43. partition_table-flash: $(PARTITION_TABLE_BIN)
  44. @echo "Flashing partition table..."
  45. $(PARTITION_TABLE_FLASH_CMD)
  46. partition_table-clean:
  47. rm -f $(PARTITION_TABLE_BIN)
  48. clean: partition_table-clean