Skip to content

Commit e59e036

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 e59e036

26 files changed

+501
-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,86 @@
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+
36+
while (1) {
37+
if (blink) {
38+
ret = gpio_pin_toggle_dt(&led);
39+
if (ret < 0) {
40+
return;
41+
}
42+
} else {
43+
ret = gpio_pin_set_dt(&led, 0);
44+
if (ret < 0) {
45+
return;
46+
}
47+
}
48+
k_msleep(SLEEP_TIME_MS);
49+
}
50+
}
51+
52+
int main(void)
53+
{
54+
int ret;
55+
56+
printk("[DSP] Hello World! %s\n", CONFIG_BOARD_TARGET);
57+
58+
if (!gpio_is_ready_dt(&btn)) {
59+
return 0;
60+
}
61+
62+
if (gpio_pin_configure_dt(&btn, GPIO_INPUT) != 0) {
63+
return 0;
64+
}
65+
66+
if (gpio_pin_interrupt_configure_dt(&btn, GPIO_INT_EDGE_TO_ACTIVE) != 0) {
67+
return 0;
68+
}
69+
70+
gpio_init_callback(&button_cb_data, &btn_isr, BIT(btn.pin));
71+
gpio_add_callback(btn.port, &button_cb_data);
72+
73+
if (!gpio_is_ready_dt(&led)) {
74+
return 0;
75+
}
76+
77+
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
78+
if (ret < 0) {
79+
return 0;
80+
}
81+
82+
k_thread_create(&th_blink, th_blink_stack, K_THREAD_STACK_SIZEOF(th_blink_stack),
83+
thread_blink, NULL, NULL, NULL, 5, 0, K_NO_WAIT);
84+
85+
return 0;
86+
}
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,46 @@
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;
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+
printk("[DSP] IPI from MU(A).\n");
21+
} else {
22+
uint32_t val = *(uint32_t *)(data->data);
23+
24+
printk("[DSP] Incoming mbox message: data(uint32_t)=0x%x\n", val);
25+
}
26+
}
27+
28+
int main(void)
29+
{
30+
int ret;
31+
32+
printk("[DSP] Hello World! %s\n", CONFIG_BOARD);
33+
34+
if (!device_is_ready(mbox)) {
35+
return 0;
36+
}
37+
38+
if (mbox_register_callback(mbox, chmbox, &mbox_cb, NULL) < 0) {
39+
return 0;
40+
}
41+
if (mbox_set_enabled(mbox, chmbox, true) < 0) {
42+
return 0;
43+
}
44+
45+
return 0;
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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;
14+
15+
static uint32_t mboxData = 0x12345678;
16+
17+
int main(void) {
18+
printk("Hello World! %s\n", CONFIG_BOARD);
19+
20+
if (!device_is_ready(mbox)) {
21+
return 0;
22+
}
23+
mbox_set_enabled(mbox, chmbox, true);
24+
25+
printk("[CM33] Starting HiFi4 DSP... \n");
26+
dspStart();
27+
k_msleep(1000);
28+
29+
struct mbox_msg msg = {.data = &mboxData, .size = sizeof(mboxData)};
30+
31+
printk("[CM33] Sending mbox message... ");
32+
if (mbox_send(mbox, chmbox, &msg) < 0) {
33+
printk("failed!");
34+
}
35+
printk("\n");
36+
37+
return 0;
38+
}
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)