Skip to content

Commit e361323

Browse files
Marek Matejhenrikbrixandersen
authored andcommitted
samples: subsys: Fix ESP32 SoCs support
Fix ESP32 and ESP32-S3 support: * Add Espressif overlays for default and remote target. * Add remote targets for Espressif boards. * Fix remote runtime by increasing the stack size in case of ESP32. * Make the test cycle config option. * Make the test stacks config options. Signed-off-by: Marek Matej <[email protected]>
1 parent 9ae10ea commit e361323

File tree

12 files changed

+110
-28
lines changed

12 files changed

+110
-28
lines changed

samples/subsys/ipc/rpmsg_service/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,4 @@ message(STATUS "${BOARD} compile as Master in this sample")
1515

1616
enable_language(C ASM)
1717

18-
if("${BOARD}" STREQUAL "esp32_devkitc" OR "${BOARD}" STREQUAL "esp32s3_devkitm")
19-
set_source_files_properties(${REMOTE_ZEPHYR_DIR}/esp32_net_firmware.c PROPERTIES GENERATED TRUE)
20-
target_sources(app PRIVATE src/main.c ${REMOTE_ZEPHYR_DIR}/esp32_net_firmware.c)
21-
else()
22-
target_sources(app PRIVATE src/main.c)
23-
endif()
18+
target_sources(app PRIVATE src/main.c)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
source "Kconfig.zephyr"
5+
6+
config RPMSG_SERVICE_DEMO_CYCLES
7+
int "Number of demo message cycles"
8+
default 1000
9+
range 10 10000
10+
11+
config MAIN_APP_TASK_STACK_SIZE
12+
int "Main application task size"
13+
default 1024

samples/subsys/ipc/rpmsg_service/Kconfig.sysbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ config RPMSG_REMOTE_BOARD
99
default "mps2/an521/cpu1" if $(BOARD) = "mps2"
1010
default "v2m_musca_b1/musca_b1/ns" if $(BOARD) = "v2m_musca_b1"
1111
default "stm32h747i_disco/stm32h747xx/m4" if $(BOARD) = "stm32h747i_disco"
12+
default "esp32_devkitc/esp32/appcpu" if $(BOARD) = "esp32_devkitc"
13+
default "esp32s3_devkitc/esp32s3/appcpu" if $(BOARD) = "esp32s3_devkitc"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
source "samples/subsys/ipc/rpmsg_service/Kconfig"
5+
6+
config APP_REMOTE_TASK_STACK_SIZE
7+
int "Remote application task size"
8+
default 2048 if SOC_SERIES_ESP32
9+
default 1024
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,ipc_shm = &shm0;
10+
zephyr,ipc = &ipm0;
11+
};
12+
};
13+
14+
&ipm0 {
15+
status = "okay";
16+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,ipc_shm = &shm0;
10+
zephyr,ipc = &ipm0;
11+
};
12+
};
13+
14+
&ipm0 {
15+
status = "okay";
16+
};

samples/subsys/ipc/rpmsg_service/remote/src/main.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,17 @@
1717

1818
#include <zephyr/ipc/rpmsg_service.h>
1919

20-
#define APP_TASK_STACK_SIZE (1024)
21-
K_THREAD_STACK_DEFINE(thread_stack, APP_TASK_STACK_SIZE);
20+
K_THREAD_STACK_DEFINE(thread_stack, CONFIG_APP_REMOTE_TASK_STACK_SIZE);
2221
static struct k_thread thread_data;
2322

2423
static volatile unsigned int received_data;
2524

2625
static K_SEM_DEFINE(data_sem, 0, 1);
2726
static K_SEM_DEFINE(data_rx_sem, 0, 1);
2827

29-
int endpoint_cb(struct rpmsg_endpoint *ept, void *data,
30-
size_t len, uint32_t src, void *priv)
28+
int endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len, uint32_t src, void *priv)
3129
{
32-
received_data = *((unsigned int *) data);
30+
received_data = *((unsigned int *)data);
3331

3432
k_sem_give(&data_rx_sem);
3533

@@ -60,15 +58,14 @@ void app_task(void *arg1, void *arg2, void *arg3)
6058

6159
printk("\r\nRPMsg Service [remote] demo started\r\n");
6260

63-
while (message < 99) {
61+
while (message < (CONFIG_RPMSG_SERVICE_DEMO_CYCLES - 1)) {
6462
message = receive_message();
6563
printk("Remote core received a message: %d\n", message);
6664

6765
message++;
6866
status = send_message(message);
6967
if (status < 0) {
70-
printk("send_message(%d) failed with status %d\n",
71-
message, status);
68+
printk("send_message(%d) failed with status %d\n", message, status);
7269
break;
7370
}
7471
}
@@ -79,8 +76,7 @@ void app_task(void *arg1, void *arg2, void *arg3)
7976
int main(void)
8077
{
8178
printk("Starting application thread!\n");
82-
k_thread_create(&thread_data, thread_stack, APP_TASK_STACK_SIZE,
83-
app_task,
79+
k_thread_create(&thread_data, thread_stack, CONFIG_APP_REMOTE_TASK_STACK_SIZE, app_task,
8480
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
8581
return 0;
8682
}

samples/subsys/ipc/rpmsg_service/sample.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ tests:
55
platform_allow:
66
- mps2/an521/cpu0
77
- v2m_musca_b1/musca_b1
8+
- esp32_devkitc/esp32/procpu
9+
- esp32s3_devkitc/esp32s3/procpu
810
integration_platforms:
911
- mps2/an521/cpu0
1012
- v2m_musca_b1/musca_b1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,ipc_shm = &shm0;
10+
zephyr,ipc = &ipm0;
11+
};
12+
};
13+
14+
&ipm0 {
15+
status = "okay";
16+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,ipc_shm = &shm0;
10+
zephyr,ipc = &ipm0;
11+
};
12+
};
13+
14+
&ipm0 {
15+
status = "okay";
16+
};

0 commit comments

Comments
 (0)