1idf_component_register(REQUIRES bootloader PRIV_REQUIRES partition_table) 2 3if(NOT BOOTLOADER_BUILD) 4 idf_build_get_property(build_dir BUILD_DIR) 5 6 if(CONFIG_APP_BUILD_GENERATE_BINARIES) 7 partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset") 8 esptool_py_custom_target(app-flash app "app") 9 10 esptool_py_flash_target_image(app-flash app "${app_partition_offset}" "${build_dir}/${PROJECT_BIN}") 11 esptool_py_flash_target_image(flash app "${app_partition_offset}" "${build_dir}/${PROJECT_BIN}") 12 endif() 13 14 # If anti-rollback option is set then factory partition should not be in Partition Table. 15 # In this case, should be used the partition table with two ota app without the factory. 16 partition_table_get_partition_info(factory_offset "--partition-type app --partition-subtype factory" "offset") 17 partition_table_get_partition_info(test_offset "--partition-type app --partition-subtype test" "offset") 18 if(CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK AND (factory_offset OR test_offset)) 19 fail_at_build_time(check_table_contents "\ 20ERROR: Anti-rollback option is enabled. Partition table should \ 21consist of two ota app without factory or test partitions.") 22 add_dependencies(app check_table_contents) 23 endif() 24 25 # Generate flasher_args.json for tools that need it. The variables below are used 26 # in configuring the template flasher_args.json.in. 27 # Some of the variables (flash mode, size, frequency, chip) are already set in project_include.cmake. 28 29 set(ESPTOOLPY_BEFORE "${CONFIG_ESPTOOLPY_BEFORE}") 30 set(ESPTOOLPY_AFTER "${CONFIG_ESPTOOLPY_AFTER}") 31 if(CONFIG_ESPTOOLPY_NO_STUB) 32 set(ESPTOOLPY_WITH_STUB false) 33 else() 34 set(ESPTOOLPY_WITH_STUB true) 35 endif() 36 37 if(CONFIG_SECURE_BOOT OR CONFIG_SECURE_FLASH_ENC_ENABLED) 38 # If security enabled then override post flash option 39 set(ESPTOOLPY_AFTER "no_reset") 40 endif() 41 42 if(CONFIG_APP_BUILD_GENERATE_BINARIES) 43 # Generate flasher args files 44 file(READ "flasher_args.json.in" flasher_args_content) 45 string(CONFIGURE "${flasher_args_content}" flasher_args_content) 46 47 file_generate("${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in" 48 CONTENT "${flasher_args_content}") 49 file_generate("${CMAKE_BINARY_DIR}/flasher_args.json" 50 INPUT "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in") 51 52 # Generate app_check_size_command target to check the app size against the partition table parameters 53 partition_table_add_check_size_target(app_check_size 54 DEPENDS gen_project_binary 55 BINARY_PATH "${build_dir}/${PROJECT_BIN}" 56 PARTITION_TYPE app) 57 add_dependencies(app app_check_size) 58 endif() 59endif() # NOT BOOTLOADER_BUILD 60 61if(BOOTLOADER_BUILD) 62 # Generate bootloader post-build check of the bootloader size against the offset 63 partition_table_add_check_bootloader_size_target(bootloader_check_size 64 DEPENDS gen_project_binary 65 BOOTLOADER_BINARY_PATH "${build_dir}/${PROJECT_BIN}" 66 RESULT bootloader_check_size_command) 67 add_dependencies(app bootloader_check_size) # note: in the subproject, so the target is 'app'... 68endif() 69