Skip to content

Commit 0f35bd2

Browse files
committed
samples: Add RTxxx AMP samples
Move CM33-HiFi4 memory split into a separate DT fragment. Add common structure for RTxxx AMP samples. Add amp_blink and amp_mbox samples. These samples are now configured only for the mimxrt685_evk, but are intended to support other NXP microcontrollers with HiFi * DSP cores instantiated at a later date. Signed-off-by: Vit Stanicek <[email protected]>
1 parent 324f4f1 commit 0f35bd2

26 files changed

+508
-1
lines changed

dts/arm/nxp/nxp_rt6xx_common.dtsi

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
sram0: memory@180000 {
100100
compatible = "mmio-sram";
101-
reg = <0x180000 DT_SIZE_K(2560)>;
101+
reg = <0x180000 DT_SIZE_K(3072)>;
102102
};
103103

104104
sram1: memory@40140000 {
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&sram0 {
8+
reg = <0x180000 DT_SIZE_K(2560)>;
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
7+
8+
project(amp_blinky)
9+
target_sources(app PRIVATE src/main.c)
10+
11+
set(HIFI4_BUILD_DIR "${CMAKE_CURRENT_LIST_DIR}/build/remote/zephyr")
12+
include("${CMAKE_CURRENT_LIST_DIR}/../common/adsp-load.cmake")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_INIT_AUDIO_PLL=y
2+
CONFIG_INIT_SYS_PLL=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <nxp/nxp_rt6xx_hifi4memsplit.dtsi>
8+
9+
&adsp {
10+
status = "okay";
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_NXP_RTXXX_ADSP_CTRL=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(BOARD mimxrt685_evk/mimxrt685s/hifi4)
5+
6+
cmake_minimum_required(VERSION 3.20.0)
7+
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9+
project(remote)
10+
11+
target_sources(app PRIVATE src/main.c)
12+
13+
include("${CMAKE_CURRENT_LIST_DIR}/../../common/remote-adsp-imgs.cmake")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Nothing here - default config suffices.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <stdbool.h>
8+
#include <zephyr/kernel.h>
9+
#include <zephyr/drivers/gpio.h>
10+
#include <zephyr/devicetree.h>
11+
#include <zephyr/drivers/i2s.h>
12+
13+
#define SLEEP_TIME_MS 1000
14+
#define LED_NODE DT_ALIAS(led1)
15+
#define BTN_NODE DT_ALIAS(sw0)
16+
17+
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED_NODE, gpios);
18+
static const struct gpio_dt_spec btn = GPIO_DT_SPEC_GET_OR(BTN_NODE, gpios, {0});
19+
static struct gpio_callback button_cb_data;
20+
21+
static bool blink = true;
22+
23+
static struct k_thread th_blink;
24+
static K_THREAD_STACK_DEFINE(th_blink_stack, 4096);
25+
26+
void btn_isr(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
27+
{
28+
printk("[DSP] Button pressed!\n");
29+
blink = !blink;
30+
}
31+
32+
void thread_blink(void *unused0, void *unused1, void *unused2)
33+
{
34+
int ret = 0;
35+
while (1) {
36+
if (blink) {
37+
ret = gpio_pin_toggle_dt(&led);
38+
if (ret < 0) {
39+
return;
40+
}
41+
} else {
42+
ret = gpio_pin_set_dt(&led, 0);
43+
if (ret < 0) {
44+
return;
45+
}
46+
}
47+
k_msleep(SLEEP_TIME_MS);
48+
}
49+
}
50+
51+
int main(void)
52+
{
53+
int ret;
54+
printk("[DSP] Hello World! %s\n", CONFIG_BOARD_TARGET);
55+
56+
if (!gpio_is_ready_dt(&btn)) {
57+
return 0;
58+
}
59+
60+
if (gpio_pin_configure_dt(&btn, GPIO_INPUT) != 0) {
61+
return 0;
62+
}
63+
64+
if (gpio_pin_interrupt_configure_dt(&btn, GPIO_INT_EDGE_TO_ACTIVE) != 0) {
65+
return 0;
66+
}
67+
68+
gpio_init_callback(&button_cb_data, &btn_isr, BIT(btn.pin));
69+
gpio_add_callback(btn.port, &button_cb_data);
70+
71+
if (!gpio_is_ready_dt(&led)) {
72+
return 0;
73+
}
74+
75+
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
76+
if (ret < 0) {
77+
return 0;
78+
}
79+
80+
k_thread_create(&th_blink, th_blink_stack, K_THREAD_STACK_SIZEOF(th_blink_stack),
81+
thread_blink, NULL, NULL, NULL, 5, 0, K_NO_WAIT);
82+
83+
return 0;
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
9+
#include "adsp.h"
10+
11+
int main(void)
12+
{
13+
printk("Hello World! %s\n", CONFIG_BOARD_TARGET);
14+
15+
printk("[CM33] Starting HiFi4 DSP... \n");
16+
dspStart();
17+
18+
return 0;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include("${CMAKE_CURRENT_LIST_DIR}/../common/remote-adsp-board-select.cmake")
5+
6+
ExternalZephyrProject_Add(
7+
APPLICATION remote
8+
SOURCE_DIR ${APP_DIR}/remote
9+
BOARD ${REMOTE_BOARD}
10+
BUILD_ONLY TRUE
11+
)
12+
13+
add_dependencies(${DEFAULT_IMAGE} remote)
14+
sysbuild_add_dependencies(CONFIGURE ${DEFAULT_IMAGE} remote)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
7+
8+
project(amp_blinky)
9+
target_sources(app PRIVATE src/main.c)
10+
11+
set(HIFI4_BUILD_DIR "${CMAKE_CURRENT_LIST_DIR}/build/remote/zephyr")
12+
include("${CMAKE_CURRENT_LIST_DIR}/../common/adsp-load.cmake")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_INIT_AUDIO_PLL=y
2+
CONFIG_INIT_SYS_PLL=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <nxp/nxp_rt6xx_hifi4memsplit.dtsi>
8+
9+
&adsp {
10+
status = "okay";
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_NXP_RTXXX_ADSP_CTRL=y
2+
CONFIG_MBOX=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(BOARD mimxrt685_evk/mimxrt685s/hifi4)
5+
6+
cmake_minimum_required(VERSION 3.20.0)
7+
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9+
project(remote)
10+
11+
target_sources(app PRIVATE src/main.c)
12+
13+
include("${CMAKE_CURRENT_LIST_DIR}/../../common/remote-adsp-imgs.cmake")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_MBOX=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <stdbool.h>
8+
#include <zephyr/kernel.h>
9+
#include <zephyr/drivers/gpio.h>
10+
#include <zephyr/drivers/mbox.h>
11+
#include <zephyr/devicetree.h>
12+
#include <zephyr/drivers/i2s.h>
13+
14+
const static struct device *mbox = DEVICE_DT_GET(DT_ALIAS(mbox));
15+
static mbox_channel_id_t chmbox = 0;
16+
17+
void mbox_cb(const struct device *dev, uint32_t channel, void *user_data, struct mbox_msg *data)
18+
{
19+
if(data == NULL)
20+
{
21+
printk("[DSP] IPI from MU(A).\n");
22+
}
23+
else
24+
{
25+
uint32_t val = *(uint32_t*)(data->data);
26+
printk("[DSP] Incoming mbox message: data(uint32_t)=0x%x\n", val);
27+
}
28+
}
29+
30+
int main(void)
31+
{
32+
int ret;
33+
printk("[DSP] Hello World! %s\n", CONFIG_BOARD);
34+
35+
if(!device_is_ready(mbox))
36+
{
37+
return 0;
38+
}
39+
40+
if(mbox_register_callback(mbox, chmbox, &mbox_cb, NULL) < 0)
41+
{
42+
return 0;
43+
}
44+
if(mbox_set_enabled(mbox, chmbox, true) < 0)
45+
{
46+
return 0;
47+
}
48+
49+
return 0;
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/drivers/mbox.h>
9+
10+
#include "adsp.h"
11+
12+
static const struct device *mbox = DEVICE_DT_GET(DT_ALIAS(mbox));
13+
static mbox_channel_id_t chmbox = 0;
14+
15+
static uint32_t mboxData = 0x12345678;
16+
17+
int main(void)
18+
{
19+
printk("Hello World! %s\n", CONFIG_BOARD);
20+
21+
if(!device_is_ready(mbox))
22+
{
23+
return 0;
24+
}
25+
mbox_set_enabled(mbox, chmbox, true);
26+
27+
printk("[CM33] Starting HiFi4 DSP... \n");
28+
dspStart();
29+
k_msleep(1000);
30+
31+
struct mbox_msg msg = {
32+
.data = &mboxData,
33+
.size = sizeof(mboxData)
34+
};
35+
printk("[CM33] Sending mbox message... ");
36+
if(mbox_send(mbox, chmbox, &msg) < 0)
37+
{
38+
printk("failed!");
39+
}
40+
printk("\n");
41+
42+
return 0;
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include("${CMAKE_CURRENT_LIST_DIR}/../common/remote-adsp-board-select.cmake")
5+
6+
ExternalZephyrProject_Add(
7+
APPLICATION remote
8+
SOURCE_DIR ${APP_DIR}/remote
9+
BOARD ${REMOTE_BOARD}
10+
BUILD_ONLY TRUE
11+
)
12+
13+
add_dependencies(${DEFAULT_IMAGE} remote)
14+
sysbuild_add_dependencies(CONFIGURE ${DEFAULT_IMAGE} remote)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
target_sources(app PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src/adsp.c" "${CMAKE_CURRENT_LIST_DIR}/src/adspimgs.S")
5+
include_directories("${CMAKE_CURRENT_LIST_DIR}/src/")
6+
7+
set(HIFI4_BIN_SYMS
8+
"HIFI4_BIN_RESET=\"${HIFI4_BUILD_DIR}/zephyr.reset.bin\""
9+
"HIFI4_BIN_TEXT=\"${HIFI4_BUILD_DIR}/zephyr.text.bin\""
10+
"HIFI4_BIN_DATA=\"${HIFI4_BUILD_DIR}/zephyr.data.bin\""
11+
)
12+
13+
set_source_files_properties(
14+
"${CMAKE_CURRENT_LIST_DIR}/src/adspimgs.S"
15+
PROPERTIES
16+
COMPILE_DEFINITIONS
17+
"${HIFI4_BIN_SYMS}"
18+
)
19+
20+
set_source_files_properties(
21+
"${CMAKE_CURRENT_LIST_DIR}/src/adspimgs.S"
22+
OBJECT_DEPENDS
23+
${HIFI4_BUILD_DIR}/zephyr.elf
24+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if(${BOARD} STREQUAL "mimxrt685_evk")
5+
set(REMOTE_BOARD "mimxrt685_evk/mimxrt685s/hifi4")
6+
else()
7+
message(FATAL_ERROR "This example is not supported on the selected board.")
8+
endif()

0 commit comments

Comments
 (0)