]> granicus.if.org Git - esp-idf/commitdiff
cmake: use otatool and parttool for build
authorRenz Christian Bagaporo <renz@espressif.com>
Thu, 15 Nov 2018 21:01:15 +0000 (05:01 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Wed, 28 Nov 2018 07:57:20 +0000 (15:57 +0800)
components/app_update/CMakeLists.txt
components/app_update/project_include.cmake
tools/idf.py

index 8eac36935885f5eb7b466e037f865dc3589e97e3..e559ef10209741b885a89fb035aab00fb16068ca 100644 (file)
@@ -7,12 +7,21 @@ set(COMPONENT_PRIV_REQUIRES bootloader_support)
 register_component()
 
 # Add custom target for generating empty otadata partition for flashing
-if(OTADATA_PARTITION_OFFSET AND IDF_BUILD_ARTIFACTS)
+if(OTADATA_PARTITION_OFFSET AND OTADATA_PARTITION_SIZE)
     add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/${BLANK_OTADATA_FILE}"
-        COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/gen_empty_partition.py
-        --size ${OTADATA_PARTITION_SIZE} "${IDF_BUILD_ARTIFACTS_DIR}/${BLANK_OTADATA_FILE}")
+        COMMAND ${PYTHON} ${IDF_PATH}/components/partition_table/parttool.py
+        --partition-type data --partition-subtype ota -q
+        --partition-table-file ${PARTITION_CSV_PATH} generate_blank_partition_file
+        --output "${IDF_BUILD_ARTIFACTS_DIR}/${BLANK_OTADATA_FILE}")
 
     add_custom_target(blank_ota_data ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/${BLANK_OTADATA_FILE}")
-
     add_dependencies(flash blank_ota_data)
 endif()
+
+set(otatool_py ${PYTHON} ${COMPONENT_PATH}/otatool.py)
+
+add_custom_target(read_otadata DEPENDS "${PARTITION_CSV_PATH}"
+                COMMAND ${otatool_py} --partition-table-file ${PARTITION_CSV_PATH} read_otadata)
+
+add_custom_target(erase_otadata DEPENDS "${PARTITION_CSV_PATH}"
+                COMMAND ${otatool_py} --partition-table-file ${PARTITION_CSV_PATH} erase_otadata)
index 8d959bd7cb6085e13cb2ece3daaed48bfb4a5b94..0f7001056a181ec7c6933924616ee274260c412a 100644 (file)
@@ -3,6 +3,7 @@
 # partition table
 # (NB: because of component dependency, we know partition_table
 # project_include.cmake has already been included.)
-if(OTADATA_PARTITION_OFFSET AND IDF_BUILD_ARTIFACTS)
+
+if(OTADATA_PARTITION_OFFSET AND OTADATA_PARTITION_SIZE AND IDF_BUILD_ARTIFACTS)
     set(BLANK_OTADATA_FILE "ota_data_initial.bin")
 endif()
index 830ff9713379e0cf41e04990e014203d5bec4dcc..5d61d3ec52a74701e3833e7217ccff81353cd07d 100755 (executable)
@@ -386,27 +386,29 @@ def print_closing_message(args):
 
 ACTIONS = {
     # action name : ( function (or alias), dependencies, order-only dependencies )
-    "all" :                  ( build_target,    [], [ "reconfigure", "menuconfig", "clean", "fullclean" ] ),
-    "build":                 ( "all",           [], [] ),  # build is same as 'all' target
-    "clean":                 ( clean,           [], [ "fullclean" ] ),
-    "fullclean":             ( fullclean,       [], [] ),
-    "reconfigure":           ( reconfigure,     [], [ "menuconfig" ] ),
-    "menuconfig":            ( build_target,    [], [] ),
+    "all" :                  ( build_target, [], [ "reconfigure", "menuconfig", "clean", "fullclean" ] ),
+    "build":                 ( "all",        [], [] ),  # build is same as 'all' target
+    "clean":                 ( clean,        [], [ "fullclean" ] ),
+    "fullclean":             ( fullclean,    [], [] ),
+    "reconfigure":           ( reconfigure,  [], [ "menuconfig" ] ),
+    "menuconfig":            ( build_target, [], [] ),
     "defconfig":             ( build_target,    [], [] ),
-    "confserver":            ( build_target,    [], [] ),
-    "size":                  ( build_target,    [ "app" ], [] ),
-    "size-components":       ( build_target,    [ "app" ], [] ),
-    "size-files":            ( build_target,    [ "app" ], [] ),
-    "bootloader":            ( build_target,    [], [] ),
-    "bootloader-clean":      ( build_target,    [], [] ),
-    "bootloader-flash":      ( flash,           [ "bootloader" ], [ "erase_flash"] ),
-    "app":                   ( build_target,    [], [ "clean", "fullclean", "reconfigure" ] ),
-    "app-flash":             ( flash,           [ "app" ], [ "erase_flash"]),
-    "partition_table":       ( build_target,    [], [ "reconfigure" ] ),
-    "partition_table-flash": ( flash,           [ "partition_table" ], [ "erase_flash" ]),
-    "flash":                 ( flash,           [ "all" ], [ "erase_flash" ] ),
-    "erase_flash":           ( erase_flash,     [], []),
-    "monitor":               ( monitor,         [], [ "flash", "partition_table-flash", "bootloader-flash", "app-flash" ]),
+    "confserver":            ( build_target, [], [] ),
+    "size":                  ( build_target, [ "app" ], [] ),
+    "size-components":       ( build_target, [ "app" ], [] ),
+    "size-files":            ( build_target, [ "app" ], [] ),
+    "bootloader":            ( build_target, [], [] ),
+    "bootloader-clean":      ( build_target, [], [] ),
+    "bootloader-flash":      ( flash,        [ "bootloader" ], [ "erase_flash"] ),
+    "app":                   ( build_target, [], [ "clean", "fullclean", "reconfigure" ] ),
+    "app-flash":             ( flash,        [ "app" ], [ "erase_flash"]),
+    "partition_table":       ( build_target, [], [ "reconfigure" ] ),
+    "partition_table-flash": ( flash,        [ "partition_table" ], [ "erase_flash" ]),
+    "flash":                 ( flash,        [ "all" ], [ "erase_flash" ] ),
+    "erase_flash":           ( erase_flash,  [], []),
+    "monitor":               ( monitor,      [], [ "flash", "partition_table-flash", "bootloader-flash", "app-flash" ]),
+    "erase_otadata":         ( build_target, [], []),
+    "read_otadata":          ( build_target, [], []),
 }
 
 def get_commandline_options():