9 #include "sw/device/lib/base/status.h"
12 #include "sw/device/lib/testing/spi_device_testutils.h"
13 #include "sw/device/lib/testing/spi_flash_emulator.h"
14 #include "sw/device/lib/testing/spi_flash_testutils.h"
15 #include "sw/device/lib/testing/test_framework/check.h"
20 OTTF_DEFINE_TEST_CONFIG(.enable_uart_flow_control =
true);
23 kSpiDeviceDatasetSize = 128,
24 kSpiDeviceFlashAddress = 0x00,
28 const uint8_t kSpiTxData[kSpiDeviceDatasetSize] = {
29 0xe8, 0x50, 0xc6, 0xb4, 0xbe, 0x16, 0xed, 0x55, 0x16, 0x1d, 0xe6, 0x1c,
30 0xde, 0x9f, 0xfd, 0x24, 0x89, 0x81, 0x4d, 0x0d, 0x1a, 0x12, 0x4f, 0x57,
31 0xea, 0xd6, 0x6f, 0xc0, 0x7d, 0x46, 0xe7, 0x37, 0x81, 0xd3, 0x8e, 0x16,
32 0xad, 0x7b, 0xd0, 0xe2, 0x4f, 0xff, 0x39, 0xe6, 0x71, 0x3c, 0x82, 0x04,
33 0xec, 0x3a, 0x27, 0xcc, 0x3d, 0x58, 0x0e, 0x56, 0xd2, 0xd2, 0xb9, 0xa3,
34 0xb5, 0x3d, 0xc0, 0x40, 0xba, 0x90, 0x16, 0xd8, 0xe3, 0xa4, 0x22, 0x74,
35 0x80, 0xcb, 0x7b, 0xde, 0xd7, 0x3f, 0x4d, 0x93, 0x4d, 0x59, 0x79, 0x88,
36 0x24, 0xe7, 0x68, 0x8b, 0x7a, 0x78, 0xb7, 0x07, 0x09, 0x26, 0xcf, 0x6b,
37 0x52, 0xd9, 0x4c, 0xd3, 0x33, 0xdf, 0x2e, 0x0d, 0x3b, 0xab, 0x45, 0x85,
38 0xc2, 0xc2, 0x19, 0xe5, 0xc7, 0x2b, 0xb0, 0xf6, 0xcb, 0x06, 0xf6, 0xe2,
39 0xf5, 0xb1, 0xab, 0xef, 0x6f, 0xd8, 0x23, 0xfd,
45 .manufacturer_id = 0x74,
46 .continuation_code = 0x17,
47 .num_continuation_code = 2,
64 .
opcode = kSpiDeviceFlashOpReadStatus1,
68 .payload_dir_to_host =
true,
72 .opcode = kSpiDeviceFlashOpReadStatus2,
76 .payload_dir_to_host =
true,
80 .opcode = kSpiDeviceFlashOpReadStatus3,
84 .payload_dir_to_host =
true,
88 .opcode = kSpiDeviceFlashOpReadJedec,
92 .payload_dir_to_host =
true,
96 .opcode = kSpiDeviceFlashOpReadSfdp,
100 .payload_dir_to_host =
true,
104 .opcode = kSpiDeviceFlashOpReadNormal,
108 .payload_dir_to_host =
true,
112 for (uint8_t i = 0; i <
ARRAYSIZE(read_commands); ++i) {
113 uint8_t slot = i + kSpiDeviceReadCommandSlotBase;
121 .
opcode = kSpiDeviceFlashOpPageProgram,
124 .payload_dir_to_host =
false,
126 .set_busy_status =
true,
130 for (uint8_t i = 0; i <
ARRAYSIZE(write_commands); ++i) {
131 uint8_t slot = i + (uint8_t)kSpiDeviceWriteCommandSlotBase;
143 CHECK_STATUS_OK(configure_flash_mode(&spid));
145 LOG_INFO(
"SYNC: Waiting for write page");
147 CHECK_STATUS_OK(spi_device_testutils_wait_for_upload(&spid, &info));
149 CHECK_ARRAYS_EQ(info.data, kSpiTxData,
ARRAYSIZE(kSpiTxData));
161 CHECK(address == (kSpiDeviceFlashAddress + kSpiDeviceDatasetSize - 1));