]> granicus.if.org Git - esp-idf/commitdiff
cmake: Add partition table generation
authorAngus Gratton <angus@espressif.com>
Thu, 18 Jan 2018 01:12:13 +0000 (12:12 +1100)
committerAngus Gratton <gus@projectgus.com>
Sun, 29 Apr 2018 23:59:20 +0000 (09:59 +1000)
components/partition_table/CMakeLists.txt
tools/cmake/project.cmake

index bdd55ceeaced15f311312d37b3e72e4abf221f3f..b8a17b13a297ab0a29337295fc3949d1a5e02f44 100644 (file)
@@ -1 +1,46 @@
+set(partition_table_offset 0x8000)
+
+# Set partition_csv to the configured partition source file
+#
+if(CONFIG_PARTITION_TABLE_CUSTOM)
+  # Custom filename expands any path relative to the project
+  get_filename_component(partition_csv "${CONFIG_PARTITION_TABLE_CUSTOM}" ABSOLUTE BASE_DIR "${PROJECT_PATH}")
+else()
+  # Other .csv files are always in the component directory
+  set(partition_csv "${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_PARTITION_TABLE_FILENAME}")
+endif()
+
+if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
+  set(unsigned_partition_bin "partition-unsigned.bin")
+  set(final_partition_bin "partition.bin")
+  set(final_partition_target "sign_partition_table")
+else()
+  set(unsigned_partition_bin "partition.bin")
+  set(final_partition_bin "partition.bin")
+  set(final_partition_target "build_partition_table")
+endif()
+
+add_custom_target(build_partition_table ALL
+  "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py" -q
+  ${partition_csv} ${unsigned_partition_bin}
+  BYPRODUCTS ${unsigned_partition_bin}
+  DEPENDS ${partition_csv} "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
+  VERBATIM)
+
+# Add signing steps
+if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
+  get_filename_component(secure_boot_signing_key "${CONFIG_SECURE_BOOT_SIGNING_KEY}" ABSOLUTE BASE_DIR "${PROJECT_PATH}")
+
+  add_custom_target(signpartition_table ALL
+    "${PYTHON}" "${ESPSECUREPY}" sign_data --keyfile "${secure_boot_signing_key}" -o "${final_partition_bin}" "${unsigned_partition_bin}"
+    BYPRODUCTS "${final_partition_bin}"
+    DEPENDS "${unsigned_partition_bin}"
+    VERBATIM)
+
+endif()
+
+# Use global properties ESPTOOL_WRITE_FLASH_ARGS & FLASH_DEPENDS to pass this info to the esptool component for flashing
+set_property(GLOBAL APPEND_STRING PROPERTY ESPTOOL_WRITE_FLASH_ARGS "${final_partition_bin} ${partition_table_offset} ")
+set_property(GLOBAL APPEND PROPERTY FLASH_DEPENDS "${final_partition_target}")
+
 register_config_only_component()
index 164e923e627c969ee16de4cc643cb3e55ed9b4f7..f45d7166d214e2567978a0ef9b94710e95cbc598 100644 (file)
@@ -38,6 +38,8 @@ kconfig_process_config()
 # Include sdkconfig.cmake so rest of the build knows the configuration
 include(${SDKCONFIG_CMAKE})
 
+set(PYTHON "${CONFIG_PYTHON}")
+
 # Add some idf-wide definitions
 idf_set_global_compiler_options()