|
71 | 71 | #error There is no flash device enabled or it is missing Kconfig options |
72 | 72 | #endif |
73 | 73 |
|
| 74 | +#if DT_NODE_HAS_PROP(DT_BUS(TEST_AREA_DEV_NODE), packet_data_limit) |
| 75 | +#define CONTROLLER_PACKET_DATA_LIMIT DT_PROP(DT_BUS(TEST_AREA_DEV_NODE), packet_data_limit) |
| 76 | +#define BUFFER_SIZE_OVER_PACKET_LIMIT CONTROLLER_PACKET_DATA_LIMIT + 1 |
| 77 | +#endif |
| 78 | + |
74 | 79 | static const struct device *const flash_dev = TEST_AREA_DEVICE; |
75 | 80 | static struct flash_pages_info page_info; |
76 | 81 | static uint8_t __aligned(4) expected[EXPECTED_SIZE]; |
@@ -334,6 +339,39 @@ ZTEST(flash_driver, test_flash_erase) |
334 | 339 | zassert_not_equal(expected[0], erase_value, "These values shall be different"); |
335 | 340 | } |
336 | 341 |
|
| 342 | +ZTEST(flash_driver, test_flash_write_read_over_the_packet_limit) |
| 343 | +{ |
| 344 | + |
| 345 | +#if !defined(CONTROLLER_PACKET_DATA_LIMIT) |
| 346 | + TC_PRINT("Given bus controller does not have 'packet_data_limit' property\n"); |
| 347 | + ztest_test_skip(); |
| 348 | +#else |
| 349 | + int rc; |
| 350 | + const uint8_t pattern = 0xA1; |
| 351 | + static uint8_t large_data_buf[BUFFER_SIZE_OVER_PACKET_LIMIT]; |
| 352 | + |
| 353 | + /* Flatten area corresponding to the size of two packets */ |
| 354 | + rc = flash_flatten(flash_dev, page_info.start_offset, 2 * CONTROLLER_PACKET_DATA_LIMIT); |
| 355 | + zassert_equal(rc, 0, "Flash flatten failed: %d", rc); |
| 356 | + |
| 357 | + /* Fill flash area with buffer size over the configured packet limit */ |
| 358 | + rc = flash_fill(flash_dev, pattern, page_info.start_offset, BUFFER_SIZE_OVER_PACKET_LIMIT); |
| 359 | + zassert_equal(rc, 0, "Flash fill failed"); |
| 360 | + |
| 361 | + /* Read flash area with buffer size over the MSPI packet limit */ |
| 362 | + rc = flash_read(flash_dev, page_info.start_offset, large_data_buf, |
| 363 | + BUFFER_SIZE_OVER_PACKET_LIMIT); |
| 364 | + zassert_equal(rc, 0, "Flash read failed"); |
| 365 | + |
| 366 | + /* Compare read data to the pre-defined pattern */ |
| 367 | + for (int i = 0; i < BUFFER_SIZE_OVER_PACKET_LIMIT; i++) { |
| 368 | + zassert_equal(large_data_buf[i], pattern, |
| 369 | + "large_data_buf[%u]=%x read, does not match written pattern %x", i, |
| 370 | + large_data_buf[i], pattern); |
| 371 | + } |
| 372 | +#endif |
| 373 | +} |
| 374 | + |
337 | 375 | ZTEST(flash_driver, test_supply_gpios_control) |
338 | 376 | { |
339 | 377 | if (!DT_NODE_HAS_PROP(TEST_AREA_DEV_NODE, supply_gpios)) { |
|
0 commit comments