@@ -324,17 +324,24 @@ ZTEST_USER(uart_async_multi_rx, test_multiple_rx_enable)
324324}
325325
326326#if NOCACHE_MEM
327- static __aligned (32 ) uint8_t chained_read_buf [2 ][8 ] __used __NOCACHE ;
327+ /* To ensure 32-bit alignment of the buffer array,
328+ * the two arrays are defined instead using an array of arrays
329+ */
330+ static __aligned (32 ) uint8_t chained_read_buf_0 [8 ] __used __NOCACHE ;
331+ static __aligned (32 ) uint8_t chained_read_buf_1 [8 ] __used __NOCACHE ;
328332static __aligned (32 ) uint8_t chained_cpy_buf [10 ] __used __NOCACHE ;
329333#else
330- ZTEST_BMEM uint8_t chained_read_buf [2 ][8 ];
334+ ZTEST_BMEM uint8_t chained_read_buf_0 [8 ];
335+ ZTEST_BMEM uint8_t chained_read_buf_1 [8 ];
331336ZTEST_BMEM uint8_t chained_cpy_buf [10 ];
332337#endif /* NOCACHE_MEM */
333338ZTEST_BMEM volatile uint8_t rx_data_idx ;
334339ZTEST_BMEM uint8_t rx_buf_idx ;
335340
336341ZTEST_BMEM uint8_t * read_ptr ;
337342
343+ static uint8_t * chained_read_buf [2 ] = {chained_read_buf_0 , chained_read_buf_1 };
344+
338345static void test_chained_read_callback (const struct device * dev ,
339346 struct uart_event * evt , void * user_data )
340347{
@@ -352,9 +359,8 @@ static void test_chained_read_callback(const struct device *dev,
352359 rx_data_idx += evt -> data .rx .len ;
353360 break ;
354361 case UART_RX_BUF_REQUEST :
355- err = uart_rx_buf_rsp (dev ,
356- chained_read_buf [rx_buf_idx ],
357- sizeof (chained_read_buf [0 ]));
362+ err = uart_rx_buf_rsp (dev , chained_read_buf [rx_buf_idx ],
363+ sizeof (chained_read_buf_0 ));
358364 zassert_equal (err , 0 );
359365 rx_buf_idx = !rx_buf_idx ? 1 : 0 ;
360366 break ;
@@ -387,11 +393,10 @@ ZTEST_USER(uart_async_chain_read, test_chained_read)
387393 uint32_t rx_timeout_ms = 50 ;
388394 int err ;
389395
390- err = uart_rx_enable (uart_dev ,
391- chained_read_buf [rx_buf_idx ++ ],
392- sizeof (chained_read_buf [0 ]),
396+ err = uart_rx_enable (uart_dev , chained_read_buf [rx_buf_idx ++ ], sizeof (chained_read_buf_0 ),
393397 rx_timeout_ms * USEC_PER_MSEC );
394398 zassert_equal (err , 0 );
399+ rx_data_idx = 0 ;
395400
396401 for (int i = 0 ; i < iter ; i ++ ) {
397402 zassert_not_equal (k_sem_take (& rx_disabled , K_MSEC (10 )),
@@ -406,7 +411,7 @@ ZTEST_USER(uart_async_chain_read, test_chained_read)
406411 "Unexpected amount of data received %d exp:%d" ,
407412 rx_data_idx , sizeof (tx_buf ));
408413 zassert_equal (memcmp (tx_buf , chained_cpy_buf , sizeof (tx_buf )), 0 ,
409- "Buffers not equal" );
414+ "Buffers not equal exp %s, real %s" , tx_buf , chained_cpy_buf );
410415 rx_data_idx = 0 ;
411416 }
412417 uart_rx_disable (uart_dev );
0 commit comments