Skip to content

Commit 4f16991

Browse files
committed
samples: drivers: IPM fixes
Updates and fixes to support IPM sample on ESP32: - fix IPM sample code for APPCPU and PROCPU - align with memory layout, add flash awarenes - shell commands to stop/start APPCPU - reorganize overlays Signed-off-by: Marek Matej <[email protected]>
1 parent 776f0be commit 4f16991

File tree

13 files changed

+150
-59
lines changed

13 files changed

+150
-59
lines changed

samples/drivers/ipm/ipm_esp32/CMakeLists.txt

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,11 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/ipm_esp32_appcpu-prefix/src/ipm_esp32_appcpu-build/zephyr)
6-
7-
if("${BOARD}" STREQUAL "esp32_devkitc_wrover/esp32/procpu")
8-
set(BOARD_REMOTE "esp32_devkitc_wrover/esp32/appcpu")
9-
elseif("${BOARD}" STREQUAL "esp32_devkitc_wroom/esp32/procpu")
10-
set(BOARD_REMOTE "esp32_devkitc_wroom/esp32/appcpu")
11-
elseif("${BOARD}" STREQUAL "esp32s3_devkitm/esp32s3/procpu")
12-
set(BOARD_REMOTE "esp32s3_devkitm/esp32s3/appcpu")
13-
else()
14-
message(FATAL_ERROR "${BOARD} was not supported for this sample")
15-
endif()
5+
set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/../ipm_esp32_remote/zephyr)
166

177
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
18-
project(ipm_esp32)
19-
20-
set_source_files_properties(${REMOTE_ZEPHYR_DIR}/esp32_appcpu_firmware.c PROPERTIES GENERATED TRUE)
21-
target_sources(app PRIVATE src/main.c ${REMOTE_ZEPHYR_DIR}/esp32_appcpu_firmware.c)
228

23-
include(ExternalProject)
24-
25-
ExternalProject_Add(
26-
ipm_esp32_appcpu
27-
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/ipm_esp_appcpu
28-
INSTALL_COMMAND ""
29-
CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
30-
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
31-
BUILD_ALWAYS True
32-
)
9+
message(STATUS "${BOARD} compile as Master in this sample")
10+
project(ipm_esp32)
3311

34-
add_dependencies(app ipm_esp32_appcpu)
12+
target_sources(app PRIVATE src/main.c src/procpu_shell.c)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2022 NXP
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source "share/sysbuild/Kconfig"
6+
7+
config IPM_REMOTE_BOARD
8+
string
9+
default "esp32_devkitc_wrover/esp32/appcpu" if $(BOARD) = "esp32_devkitc_wroom"
10+
default "esp32_devkitc_wroom/esp32/appcpu" if $(BOARD) = "esp32_devkitc_wroom"
11+
default "esp32s3_devkitm/esp32s3/appcpu" if $(BOARD) = "esp32s3_devkitm"

samples/drivers/ipm/ipm_esp32/README.rst

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Build the ESP32 IPM sample code as follows:
2626

2727
.. zephyr-app-commands::
2828
:zephyr-app: samples/drivers/ipm/ipm_esp32
29-
:board: esp32_devkitc_wroom/esp32/procpu
29+
:board: esp32s3_devkitm/esp32s3/procpu
30+
:west-args: --sysbuild
3031
:goals: build
3132
:compact:
3233

@@ -38,18 +39,20 @@ console program (e.g., minicom, putty, screen, etc).
3839

3940
.. code-block:: console
4041
41-
*** Booting Zephyr OS build v3.3.0-rc3-38-gc9225e4365b9 ***
42-
PRO_CPU is sending a fake request, waiting remote response...
43-
PRO_CPU received a message from APP_CPU : APP_CPU: This is a response
44-
PRO_CPU is sending a fake request, waiting remote response...
45-
PRO_CPU received a message from APP_CPU : APP_CPU: This is a response
46-
PRO_CPU is sending a fake request, waiting remote response...
47-
PRO_CPU received a message from APP_CPU : APP_CPU: This is a response
48-
PRO_CPU is sending a fake request, waiting remote response...
49-
PRO_CPU received a message from APP_CPU : APP_CPU: This is a response
50-
PRO_CPU is sending a fake request, waiting remote response...
51-
PRO_CPU received a message from APP_CPU : APP_CPU: This is a response
52-
PRO_CPU is sending a fake request, waiting remote response...
53-
PRO_CPU received a message from APP_CPU : APP_CPU: This is a response
54-
PRO_CPU is sending a fake request, waiting remote response...
55-
PRO_CPU received a message from APP_CPU : APP_CPU: This is a response
42+
*** Booting Zephyr OS build v4.0.0-rc2-61-ga24efebe15e2 ***
43+
PRO_CPU is sending a request, waiting remote response...
44+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 502
45+
PRO_CPU is sending a request, waiting remote response...
46+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 10502
47+
PRO_CPU is sending a request, waiting remote response...
48+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 20503
49+
PRO_CPU is sending a request, waiting remote response...
50+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 30504
51+
PRO_CPU is sending a request, waiting remote response...
52+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 40505
53+
PRO_CPU is sending a request, waiting remote response...
54+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 50506
55+
PRO_CPU is sending a request, waiting remote response...
56+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 60507
57+
PRO_CPU is sending a request, waiting remote response...
58+
PRO_CPU received a message from APP_CPU : APP_CPU uptime ticks 70508

samples/drivers/ipm/ipm_esp32/ipm_esp_appcpu/prj.conf

Lines changed: 0 additions & 2 deletions
This file was deleted.

samples/drivers/ipm/ipm_esp32/ipm_esp_appcpu/CMakeLists.txt renamed to samples/drivers/ipm/ipm_esp32/remote/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
cmake_minimum_required(VERSION 3.20.0)
44

55
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6-
project(ipm_esp32_appcpu)
6+
7+
message(STATUS "${BOARD} compiles as remote in this sample")
8+
project(ipm_esp32_remote)
79

810
target_sources(app PRIVATE src/main.c)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_HEAP_MEM_POOL_SIZE=2048
2+
CONFIG_MAIN_STACK_SIZE=4096
3+
CONFIG_IPM=y

samples/drivers/ipm/ipm_esp32/ipm_esp_appcpu/src/main.c renamed to samples/drivers/ipm/ipm_esp32/remote/src/main.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <stdio.h>
78
#include <zephyr/kernel.h>
9+
#include <zephyr/device.h>
810
#include <zephyr/sys/printk.h>
911
#include <zephyr/drivers/ipm.h>
10-
#include <zephyr/device.h>
1112

1213
static const struct device *ipm_dev;
13-
static const char fake_resp[] = {"APP_CPU: This is a response"};
14+
static char resp[64];
1415
struct k_sem sync;
1516

16-
static void ipm_receive_callback(const struct device *ipmdev, void *user_data,
17-
uint32_t id, volatile void *data)
17+
static void ipm_receive_callback(const struct device *ipmdev, void *user_data, uint32_t id,
18+
volatile void *data)
1819
{
1920
k_sem_give(&sync);
2021
}
@@ -33,7 +34,9 @@ int main(void)
3334

3435
while (1) {
3536
k_sem_take(&sync, K_FOREVER);
36-
ipm_send(ipm_dev, -1, sizeof(fake_resp), &fake_resp, sizeof(fake_resp));
37+
snprintf(resp, sizeof(resp), "APP_CPU uptime ticks %lli\n", k_uptime_ticks());
38+
ipm_send(ipm_dev, -1, sizeof(resp), &resp, sizeof(resp));
3739
}
40+
3841
return 0;
3942
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
&ipm0 {
2+
status = "okay";
3+
};

0 commit comments

Comments
 (0)