Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf toup] Factory data partition location change #499

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/platform/nrfconnect/FactoryDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct InternalFlashFactoryData
// 2) it does not exceed the settings partition start address
// Note that this block can overlap with app partition but this is not a problem since we do not aim to modify
// the application code at runtime anyway.
constexpr size_t FactoryDataBlockBegin()
static constexpr size_t FactoryDataBlockBegin()
{
// calculate the nearest multiple of CONFIG_FPROTECT_BLOCK_SIZE smaller than FACTORY_DATA_ADDRESS
return FACTORY_DATA_ADDRESS & (-CONFIG_FPROTECT_BLOCK_SIZE);
Expand All @@ -81,11 +81,19 @@ struct InternalFlashFactoryData
// and make sure we do not overlap with settings partition
constexpr size_t kFactoryDataBlockEnd =
(FACTORY_DATA_ADDRESS + FACTORY_DATA_SIZE + CONFIG_FPROTECT_BLOCK_SIZE - 1) & (-CONFIG_FPROTECT_BLOCK_SIZE);
static_assert(kFactoryDataBlockEnd <= PM_SETTINGS_STORAGE_ADDRESS,

// Only the partition that is protected by fprotect must be aligned to fprotect block size
constexpr size_t kSettingsBlockEnd = PM_SETTINGS_STORAGE_ADDRESS + PM_SETTINGS_STORAGE_SIZE;

constexpr bool kOverlapsCheck =
(kSettingsBlockEnd <= FactoryDataBlockBegin()) || (kFactoryDataBlockEnd <= PM_SETTINGS_STORAGE_ADDRESS);

static_assert(kOverlapsCheck,
ArekBalysNordic marked this conversation as resolved.
Show resolved Hide resolved
"FPROTECT memory block, which contains factory data"
"partition overlaps with the settings partition."
"Probably your settings partition size is not a multiple"
"of the atomic FPROTECT block size of " TO_STR(CONFIG_FPROTECT_BLOCK_SIZE) "kB");

return kFactoryDataBlockEnd - FactoryDataBlockBegin();
}
#undef TO_STR
Expand All @@ -100,7 +108,10 @@ struct InternalFlashFactoryData
#endif // if CONFIG_FPROTECT
}
#else
CHIP_ERROR ProtectFactoryDataPartitionAgainstWrite() { return CHIP_ERROR_NOT_IMPLEMENTED; }
CHIP_ERROR ProtectFactoryDataPartitionAgainstWrite()
{
return CHIP_ERROR_NOT_IMPLEMENTED;
}
#endif
};

Expand Down
Loading