14 #include "sw/device/lib/testing/flash_ctrl_testutils.h"
15 #include "sw/device/lib/testing/otp_ctrl_testutils.h"
16 #include "sw/device/lib/testing/pinmux_testutils.h"
17 #include "sw/device/lib/testing/test_framework/check.h"
18 #include "sw/device/lib/testing/test_framework/ottf_test_config.h"
19 #include "sw/device/silicon_creator/manuf/lib/flash_info_fields.h"
20 #include "sw/device/silicon_creator/manuf/lib/individualize_sw_cfg.h"
21 #include "sw/device/silicon_creator/manuf/tests/test_wafer_auth_secret.h"
24 #include "otp_ctrl_regs.h"
26 OTTF_DEFINE_TEST_CONFIG();
28 static dif_uart_t uart;
29 static dif_otp_ctrl_t otp_ctrl;
30 static dif_pinmux_t pinmux;
32 static dif_lc_ctrl_t lc_ctrl;
37 static status_t peripheral_handles_init(
void) {
43 TRY(dif_otp_ctrl_init(
53 CHECK_STATUS_OK(peripheral_handles_init());
56 pinmux_testutils_init(&pinmux);
58 CHECK(
kUartBaudrate <= UINT32_MAX,
"kUartBaudrate must fit in uint32_t");
60 "kClockFreqPeripheralHz must fit in uint32_t");
87 LOG_INFO(
"Writing to the isolated flash partition.");
88 uint32_t byte_address = 0;
89 CHECK_STATUS_OK(flash_ctrl_testutils_info_region_setup(
90 &flash_ctrl_state, kFlashInfoFieldWaferAuthSecret.page,
91 kFlashInfoFieldWaferAuthSecret.bank,
92 kFlashInfoFieldWaferAuthSecret.partition, &byte_address));
93 CHECK_STATUS_OK(flash_ctrl_testutils_erase_and_write_page(
94 &flash_ctrl_state, byte_address,
95 kFlashInfoFieldWaferAuthSecret.partition, kExpectedWaferAuthSecret,
96 kDifFlashCtrlPartitionTypeInfo,
97 kFlashInfoWaferAuthSecretSizeIn32BitWords));
98 LOG_INFO(
"Enabling ROM execution to enable bootstrap after reset.");
99 CHECK_STATUS_OK(manuf_individualize_device_creator_sw_cfg(
100 &otp_ctrl, &flash_ctrl_state));
101 CHECK_STATUS_OK(manuf_individualize_device_owner_sw_cfg(&otp_ctrl));
102 LOG_INFO(
"Done. Perform an LC transition and run flash stage.");