Skip to content

Commit

Permalink
[nrf noup] Provide a workaround for Factory Data support on nRF54H
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ArekBalysNordic committed Oct 30, 2024
1 parent 668f104 commit 8cd5f5f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion config/nrfconnect/chip-module/generate_factory_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
5 changes: 5 additions & 0 deletions src/platform/nrfconnect/FactoryDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
#else
#include <zephyr/storage/flash_map.h>
#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 <system/SystemError.h>
Expand Down

0 comments on commit 8cd5f5f

Please sign in to comment.