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