From 8cd5f5fd21cebc2b0469f16acf5bab7565966082 Mon Sep 17 00:00:00 2001 From: Arkadiusz Balys Date: Wed, 30 Oct 2024 16:20:52 +0100 Subject: [PATCH] [nrf noup] Provide a workaround for Factory Data support on nRF54H Until we do not have a proper solution for merging the factory data hex file with the firmware hex file, we need to flash the factory data manually. This commit allows doing that on nRF54H20 DK. Signed-off-by: Arkadiusz Balys --- .../chip-module/generate_factory_data.cmake | 17 ++++++++++++++++- src/platform/nrfconnect/FactoryDataProvider.h | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/config/nrfconnect/chip-module/generate_factory_data.cmake b/config/nrfconnect/chip-module/generate_factory_data.cmake index b1f4ad153c..4c5858d4ef 100644 --- a/config/nrfconnect/chip-module/generate_factory_data.cmake +++ b/config/nrfconnect/chip-module/generate_factory_data.cmake @@ -141,6 +141,17 @@ else() endif() dt_reg_addr(factory_data_addr PATH ${factory_data_alias}) dt_reg_size(factory_data_size PATH ${factory_data_alias}) + + # If the location of the factory data is defined as an alias, + # add the base address to the factory data offset + # to get the proper offset calcualted from the base memory location. + dt_alias(factory_data_location PROPERTY "factory-data-location") + dt_node_exists(factory_data_location_exists PATH "${factory_data_location}") + if(${factory_data_location_exists}) + dt_reg_addr(flash_base_addr PATH ${factory_data_location}) + math(EXPR factory_data_addr "${flash_base_addr} + ${factory_data_addr}" OUTPUT_FORMAT HEXADECIMAL) + endif() + string(APPEND script_args "--offset ${factory_data_addr}\n") string(APPEND script_args "--size ${factory_data_size}\n") endif() @@ -194,7 +205,11 @@ if(CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE) set_property(GLOBAL PROPERTY factory_data_PM_TARGET factory_data) else() set_property(GLOBAL APPEND PROPERTY HEX_FILES_TO_MERGE ${OUTPUT_FILE_PATH}/factory_data.hex ${OUTPUT_FILE_PATH}/zephyr.hex) - set_property(TARGET runners_yaml_props_target PROPERTY hex_file ${OUTPUT_FILE_PATH}/merged.hex) + if(NOT CONFIG_SOC_SERIES_NRF54HX) + # Do not overwrite runners while using nRF54H series. + # In this case we need to rely on SUIT mechanisms. + set_property(TARGET runners_yaml_props_target PROPERTY hex_file ${OUTPUT_FILE_PATH}/merged.hex) + endif() endif() endif() diff --git a/src/platform/nrfconnect/FactoryDataProvider.h b/src/platform/nrfconnect/FactoryDataProvider.h index 763024e6f6..26a2d99bdf 100644 --- a/src/platform/nrfconnect/FactoryDataProvider.h +++ b/src/platform/nrfconnect/FactoryDataProvider.h @@ -36,7 +36,12 @@ #else #include #define FACTORY_DATA_SIZE DT_REG_SIZE(DT_ALIAS(factory_data)) +#define FACTORY_DATA_LOCATION_ADDRESS DT_REG_ADDR(DT_ALIAS(factory_data_location)) +#if FACTORY_DATA_LOCATION_ADDRESS +#define FACTORY_DATA_ADDRESS (DT_REG_ADDR(DT_ALIAS(factory_data)) + FACTORY_DATA_LOCATION_ADDRESS) +#else #define FACTORY_DATA_ADDRESS DT_REG_ADDR(DT_ALIAS(factory_data)) +#endif // if FACTORY_DATA_LOCATION_ADDRESS #endif // if defined(USE_PARTITION_MANAGER) && USE_PARTITION_MANAGER == 1 #include