Skip to content

Commit

Permalink
tests: drivers: dma: chen_blen_transfer: add bdma test to nucleo_h743zi
Browse files Browse the repository at this point in the history
Add unit tests for BDMA driver.

Also requires adding additional kconfig options to allocate
the memory buffers in a specific SRAM section, because
the BDMA only has access to SRAM4.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
  • Loading branch information
heinwessels committed Feb 28, 2023
1 parent e3e2f63 commit be01753
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tests/drivers/dma/chan_blen_transfer/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ config DMA_TRANSFER_CHANNEL_NR_1
int "second DMA channel to use"
default 1

config DMA_LOOP_TRANSFER_SRAM_SECTION
string "the section to place the memory buffers."
depends on NOCACHE_MEMORY
default ".nocache"

config DMA_LOOP_TRANSFER_NUMBER_OF_DMAS
int "Number of DMAs to test"
default 1
12 changes: 10 additions & 2 deletions tests/drivers/dma/chan_blen_transfer/boards/nucleo_h743zi.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
CONFIG_DMA_TRANSFER_CHANNEL_NR_0=6
CONFIG_DMA_TRANSFER_CHANNEL_NR_1=10
CONFIG_DMA_TRANSFER_CHANNEL_NR_0=4
CONFIG_DMA_TRANSFER_CHANNEL_NR_1=6
CONFIG_DMA_LOOP_TRANSFER_NUMBER_OF_DMAS=2

# Required by BDMA which only has access to
# a NOCACHE SRAM4 section. All other DMAs also
# has access to this section.
CONFIG_DMA_LOOP_TRANSFER_SRAM_SECTION=".sram4"

# Required for SRAM4 to be non-cachable
CONFIG_NOCACHE_MEMORY=y
15 changes: 15 additions & 0 deletions tests/drivers/dma/chan_blen_transfer/boards/nucleo_h743zi.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@
test_dma0: &dmamux1 {
status = "okay";
};

/* The BDMA driver expects the SRAM4 region
* to be non-cachable.
*/
&sram4 {
zephyr,memory-region-mpu = "RAM_NOCACHE";
};

&bdma1 {
status = "okay";
};

test_dma1: &dmamux2 {
status = "okay";
};
5 changes: 3 additions & 2 deletions tests/drivers/dma/chan_blen_transfer/src/test_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

#ifdef CONFIG_NOCACHE_MEMORY
static __aligned(32) char tx_data[RX_BUFF_SIZE] __used
__attribute__((__section__(".nocache")));
__attribute__((__section__(CONFIG_DMA_LOOP_TRANSFER_SRAM_SECTION)));
static const char TX_DATA[] = "It is harder to be kind than to be wise........";
static __aligned(32) char rx_data[RX_BUFF_SIZE] __used
__attribute__((__section__(".nocache.dma")));
__attribute__((__section__(CONFIG_DMA_LOOP_TRANSFER_SRAM_SECTION".dma")));
#else
static const char tx_data[] = "It is harder to be kind than to be wise........";
static char rx_data[RX_BUFF_SIZE] = { 0 };
Expand Down Expand Up @@ -90,6 +90,7 @@ static int test_task(const struct device *dma, uint32_t chan_id, uint32_t blen)
return TC_FAIL;
}
k_sleep(K_MSEC(2000));

TC_PRINT("%s\n", rx_data);
if (strcmp(tx_data, rx_data) != 0) {
return TC_FAIL;
Expand Down

0 comments on commit be01753

Please sign in to comment.