5 #include "sw/device/lib/base/crc32.h"
6 #include "sw/device/lib/base/status.h"
9 #include "sw/device/lib/testing/flash_ctrl_testutils.h"
11 #include "sw/device/silicon_creator/manuf/lib/flash_info_fields.h"
13 OTTF_DEFINE_TEST_CONFIG(.console.test_may_clobber =
true);
15 static uint32_t ast_cfg_data[kFlashInfoAstCalibrationDataSizeIn32BitWords] = {
19 extern status_t ast_program_config(
bool verbose);
20 extern status_t ast_program_init(
bool verbose);
26 uint32_t ast_nr_writes;
27 void ast_write(uint32_t addr, uint32_t data) {
28 crc32_add32(&ast_crc, data);
35 static void test_state_reset(
void) {
45 uint32_t byte_address =
46 (kFlashInfoFieldAstCalibrationData.page * device_info.
bytes_per_page);
48 return flash_ctrl_testutils_erase_page(
49 &flash_state, byte_address, kFlashInfoFieldAstCalibrationData.partition,
50 kDifFlashCtrlPartitionTypeInfo);
58 uint32_t byte_address =
59 (kFlashInfoFieldAstCalibrationData.page * device_info.
bytes_per_page) +
60 kFlashInfoFieldAstCalibrationData.byte_offset;
63 for (
size_t i = 0; i <
ARRAYSIZE(ast_cfg_data); ++i) {
66 return flash_ctrl_testutils_write(
67 &flash_state, byte_address, kFlashInfoFieldAstCalibrationData.partition,
68 ast_cfg_data, kDifFlashCtrlPartitionTypeInfo,
69 kFlashInfoAstCalibrationDataSizeIn32BitWords);
74 TRY(ast_program_init(
true));
76 "Erase and program a sample blob into the INFO page, and verify AST "
81 TRY(ast_program_config(
true));
84 kFlashInfoAstCalibrationDataSizeIn32BitWords *
sizeof(uint32_t));
85 TRY_CHECK(ast_nr_writes == 39);
86 TRY_CHECK(crc32_finish(&ast_crc) == crc);
94 return status_ok(sts);