2020-06-24 15:52:50 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								idf_component_register(REQUIRES bootloader PRIV_REQUIRES partition_table)
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-01 17:45:41 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-06 14:17:00 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if(NOT BOOTLOADER_BUILD)
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-14 12:53:46 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    idf_build_get_property(build_dir BUILD_DIR)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-06 14:17:00 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if(CONFIG_APP_BUILD_GENERATE_BINARIES)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        esptool_py_custom_target(app-flash app "app")
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-14 12:53:46 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-06 14:17:00 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        esptool_py_flash_target_image(app-flash app "${app_partition_offset}" "${build_dir}/${PROJECT_BIN}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        esptool_py_flash_target_image(flash app "${app_partition_offset}" "${build_dir}/${PROJECT_BIN}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    endif()
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-14 12:53:46 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-10 18:01:58 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # If anti-rollback option is set then factory partition should not be in Partition Table.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # In this case, should be used the partition table with two ota app without the factory.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    partition_table_get_partition_info(factory_offset "--partition-type app --partition-subtype factory" "offset")
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-01 23:17:12 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    partition_table_get_partition_info(test_offset "--partition-type app --partition-subtype test" "offset")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if(CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK AND (factory_offset OR test_offset))
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-10 17:51:08 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fail_at_build_time(check_table_contents "\
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								ERROR: Anti-rollback option is enabled. Partition table should \
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-01 23:17:12 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								consist of two ota app without factory or test partitions.")
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-10 18:01:58 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        add_dependencies(app check_table_contents)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    endif()
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-20 09:55:02 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # Generate flasher_args.json for tools that need it. The variables below are used
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # in configuring the template flasher_args.json.in.
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-30 20:12:08 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Some of the variables (flash mode, size, frequency, chip) are already set in project_include.cmake.
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-20 09:55:02 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    set(ESPTOOLPY_BEFORE "${CONFIG_ESPTOOLPY_BEFORE}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    set(ESPTOOLPY_AFTER  "${CONFIG_ESPTOOLPY_AFTER}")
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-21 04:28:05 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if(CONFIG_ESPTOOLPY_NO_STUB)
							 | 
						
					
						
							
								
									
										
										
										
											2020-04-25 16:44:27 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        set(ESPTOOLPY_WITH_STUB false)
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-21 04:28:05 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    else()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        set(ESPTOOLPY_WITH_STUB true)
							 | 
						
					
						
							
								
									
										
										
										
											2020-04-25 16:44:27 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    endif()
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-20 09:55:02 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-25 01:21:41 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if(CONFIG_SECURE_BOOT OR CONFIG_SECURE_FLASH_ENC_ENABLED)
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-20 09:55:02 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # If security enabled then override post flash option
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        set(ESPTOOLPY_AFTER "no_reset")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    endif()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-04 19:11:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if(CONFIG_APP_BUILD_GENERATE_BINARIES)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-24 15:52:50 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # Generate flasher args files
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-04 19:11:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        file(READ "flasher_args.json.in" flasher_args_content)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        string(CONFIGURE "${flasher_args_content}" flasher_args_content)
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-20 09:55:02 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-10 18:40:01 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        file_generate("${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in"
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-04 19:11:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    CONTENT "${flasher_args_content}")
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-10 18:40:01 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        file_generate("${CMAKE_BINARY_DIR}/flasher_args.json"
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-04 19:11:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    INPUT "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in")
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-24 15:52:50 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # Generate app_check_size_command target to check the app size against the partition table parameters
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        partition_table_add_check_size_target(app_check_size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            DEPENDS gen_project_binary
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            BINARY_PATH "${build_dir}/${PROJECT_BIN}"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            PARTITION_TYPE app)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        add_dependencies(app app_check_size)
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-04 19:11:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    endif()
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-24 15:52:50 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								endif()  # NOT BOOTLOADER_BUILD
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								if(BOOTLOADER_BUILD)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # Generate bootloader post-build check of the bootloader size against the offset
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  partition_table_add_check_bootloader_size_target(bootloader_check_size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      DEPENDS gen_project_binary
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      BOOTLOADER_BINARY_PATH "${build_dir}/${PROJECT_BIN}"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      RESULT bootloader_check_size_command)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  add_dependencies(app bootloader_check_size)  # note: in the subproject, so the target is 'app'...
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-10 18:01:58 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								endif()
							 |