@@ -77,6 +77,13 @@ static uint8_t __aligned(4) expected[EXPECTED_SIZE];
7777static uint8_t erase_value ;
7878static bool ebw_required ;
7979
80+ #if DT_NODE_HAS_PROP (DT_BUS (TEST_AREA_DEV_NODE ), packet_data_limit )
81+ #define BUFFER_SIZE_OVER_PACKET_LIMIT DT_PROP(DT_BUS(TEST_AREA_DEV_NODE), packet_data_limit) + 1
82+ static uint8_t large_data_buf [BUFFER_SIZE_OVER_PACKET_LIMIT ];
83+ #else
84+ #define BUFFER_SIZE_OVER_PACKET_LIMIT 0
85+ #endif
86+
8087static void flash_driver_before (void * arg )
8188{
8289 int rc ;
@@ -334,6 +341,41 @@ ZTEST(flash_driver, test_flash_erase)
334341 zassert_not_equal (expected [0 ], erase_value , "These values shall be different" );
335342}
336343
344+ ZTEST (flash_driver , test_flash_write_read_over_the_packet_limit )
345+ {
346+ if (BUFFER_SIZE_OVER_PACKET_LIMIT == 0 ) {
347+ ztest_test_skip ();
348+ }
349+
350+ TC_PRINT ("SIZE: %u\n" , BUFFER_SIZE_OVER_PACKET_LIMIT );
351+
352+ int rc ;
353+ const uint8_t pattern = 0xA1 ;
354+
355+ /* Set every byte in the buffer to the predefined pattern */
356+ memset (large_data_buf , pattern , BUFFER_SIZE_OVER_PACKET_LIMIT );
357+
358+ /* Write flash area with buffer size over the configured packet limit */
359+ rc = flash_write (flash_dev , page_info .start_offset , large_data_buf ,
360+ BUFFER_SIZE_OVER_PACKET_LIMIT );
361+ zassert_equal (rc , 0 , "Cannot write flash" );
362+
363+ /* Flush buffer */
364+ memset (large_data_buf , 0xFF , BUFFER_SIZE_OVER_PACKET_LIMIT );
365+
366+ /* Read flash area with buffer size over the MSPI packet limit */
367+ rc = flash_read (flash_dev , page_info .start_offset , large_data_buf ,
368+ BUFFER_SIZE_OVER_PACKET_LIMIT );
369+ zassert_equal (rc , 0 , "Cannot read flash" );
370+
371+ /* Compare read data to the pre-defined pattern */
372+ for (int i = 0 ; i < BUFFER_SIZE_OVER_PACKET_LIMIT ; i ++ ) {
373+ zassert_equal (large_data_buf [i ], pattern ,
374+ "large_data_buf[%u]=%x read, does not match written pattern %x" , i ,
375+ large_data_buf [i ], pattern );
376+ }
377+ }
378+
337379ZTEST (flash_driver , test_supply_gpios_control )
338380{
339381 if (!DT_NODE_HAS_PROP (TEST_AREA_DEV_NODE , supply_gpios )) {
0 commit comments