From 5297cc82953abbbd3379bc4fc766e808de16b29a Mon Sep 17 00:00:00 2001 From: Alexandru Lastur Date: Mon, 9 Sep 2024 19:15:44 +0300 Subject: [PATCH 1/5] samples: subsystem/ipc/opanamp_rsc: Add imx8mp_evk cortex m7 Added the imx8mp_evk_mimx8ml8_m7.conf and imx8mp_evk_mimx8ml8_m7.overlay files in the boards directory. Signed-off-by: Alexandru Lastur --- .../boards/imx8mp_evk_mimx8ml8_m7.conf | 9 +++++++ .../boards/imx8mp_evk_mimx8ml8_m7.overlay | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.conf create mode 100644 samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.overlay diff --git a/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.conf b/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.conf new file mode 100644 index 00000000000000..d902b3fb68f8fb --- /dev/null +++ b/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.conf @@ -0,0 +1,9 @@ +CONFIG_LOG_PRINTK=n +CONFIG_IPM_IMX_MAX_DATA_SIZE_16=n +CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y +CONFIG_OPENAMP_WITH_DCACHE=y +CONFIG_IPM_IMX_FW_READY_REPLY=y +CONFIG_LOG=y +CONFIG_LOG_BACKEND_UART=y +CONFIG_LOG_DEFAULT_LEVEL=0 +CONFIG_LOG_MODE_MINIMAL=y diff --git a/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.overlay b/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.overlay new file mode 100644 index 00000000000000..d746a8436bc971 --- /dev/null +++ b/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_m7.overlay @@ -0,0 +1,24 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + /* + * shared memory reserved for the inter-processor communication + */ + zephyr,ipc_shm = &shram; + zephyr,ipc = &mailbox0; + }; + + shram: memory@55000000 { + compatible = "mmio-sram"; + reg = <0x55000000 0x500000>; + }; +}; + +&mailbox0 { + status = "okay"; +}; From 2975b029b6f0b1a3554e51092c9c32a4032b93c1 Mon Sep 17 00:00:00 2001 From: Alexandru Lastur Date: Mon, 9 Sep 2024 19:21:14 +0300 Subject: [PATCH 2/5] samples: subsystem/ipc/opanamp_rsc: Add imx93_evk cortex m33 Added the imx93_evk_mimx9352_m33.conf and imx93_evk_mimx9352_m33.overlay files in the boards directory Signed-off-by: Alexandru Lastur --- .../boards/imx93_evk_mimx9352_m33.conf | 9 +++++++ .../boards/imx93_evk_mimx9352_m33.overlay | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.conf create mode 100644 samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.overlay diff --git a/samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.conf b/samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.conf new file mode 100644 index 00000000000000..4d30bab6fe4fc2 --- /dev/null +++ b/samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.conf @@ -0,0 +1,9 @@ +CONFIG_LOG_PRINTK=n +CONFIG_IPM_IMX_MAX_DATA_SIZE_16=n +CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y +CONFIG_OPENAMP_WITH_DCACHE=y +CONFIG_IPM_IMX_FW_READY_REPLY=y +CONFIG_LOG=y +CONFIG_LOG_BACKEND_UART=y +CONFIG_LOG_DEFAULT_LEVEL=0 +CONFIG_LOG_MODE_MINIMAL=y \ No newline at end of file diff --git a/samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.overlay b/samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.overlay new file mode 100644 index 00000000000000..ace543bde8449d --- /dev/null +++ b/samples/subsys/ipc/openamp_rsc_table/boards/imx93_evk_mimx9352_m33.overlay @@ -0,0 +1,25 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + /* + * shared memory reserved for the inter-processor communication + */ + zephyr,ipc_shm = &shram; + zephyr,ipc = &mu1; + }; + + shram: memory@A4000000 { + compatible = "mmio-sram"; + reg = <0xA4000000 0x120000>; + }; + + mu1{ + status = "okay"; + }; + +}; From 8a4fdeeceb80d9b14ea5b75f6718fb8895c96d1b Mon Sep 17 00:00:00 2001 From: Alexandru Lastur Date: Mon, 9 Sep 2024 19:56:35 +0300 Subject: [PATCH 3/5] dts: arm: nxp_imx93_m33.dtsi: Add mailbox unit node mu1 in dtsi file drivers: ipm: ipm_imx.c Handles the status of Mailbox Unit RX register when the target is SOC_MIMX9352. This change is required as the imx93 mailbox register map have a different structure. Signed-off-by: Alexandru Lastur --- drivers/ipm/ipm_imx.c | 11 ++++++++++- dts/arm/nxp/nxp_imx93_m33.dtsi | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/ipm/ipm_imx.c b/drivers/ipm/ipm_imx.c index b8e716af7b09d9..3558f9ca961a45 100644 --- a/drivers/ipm/ipm_imx.c +++ b/drivers/ipm/ipm_imx.c @@ -1,5 +1,5 @@ /* - * Copyright 2018,2023 NXP + * Copyright 2018,2023-2024 NXP * * SPDX-License-Identifier: Apache-2.0 */ @@ -108,7 +108,16 @@ static void imx_mu_isr(const struct device *dev) int32_t i; bool all_registers_full; +#if defined(CONFIG_SOC_MIMX9352) + status_reg = base->RSR; + status_reg = (status_reg >> MU_RSR_RF0_SHIFT)&0x00000007; + status_reg = (((status_reg>>MU_RSR_RF3_SHIFT)<>MU_RSR_RF2_SHIFT)<>MU_RSR_RF1_SHIFT)<>MU_RSR_RF0_SHIFT)<SR >>= MU_SR_RFn_SHIFT; +#endif for (id = CONFIG_IPM_IMX_MAX_ID_VAL; id >= 0; id--) { if (status_reg & 0x1U) { diff --git a/dts/arm/nxp/nxp_imx93_m33.dtsi b/dts/arm/nxp/nxp_imx93_m33.dtsi index 22a87c62d04b9c..78095c16b2e88e 100644 --- a/dts/arm/nxp/nxp_imx93_m33.dtsi +++ b/dts/arm/nxp/nxp_imx93_m33.dtsi @@ -95,6 +95,12 @@ clocks = <&ccm IMX_CCM_LPUART2_CLK 0x6c 24>; status = "disabled"; }; + + mu1: mu1@44220000 { + compatible = "nxp,imx-mu"; + reg = <0x44220000 DT_SIZE_K(64)>; + interrupts = <21 0>; + }; }; }; From 3c385fb964a6734c59cbb08139d1261b6a8176b2 Mon Sep 17 00:00:00 2001 From: Alexandru Lastur Date: Mon, 9 Sep 2024 21:10:40 +0300 Subject: [PATCH 4/5] samples: ipc: openamp_rsc: main_remote.c Added a structure which will store and pass it to mailbox_notify() the channel id of the Linux messaging unit during the platform_ipm_callback(). This change was necessary, because until now the zephyr target (in openamp_rsc sample) would always notify the Linux target with a channel id of 0, even if Linux would send a notification on another channel differnt than 0. For example in imx8mp_evk cortex m7 and imx93_evk cortex m33 BSP, the .dts is configuring the messaging unit to use channel 1. Signed-off-by: Alexandru Lastur --- .../ipc/openamp_rsc_table/src/main_remote.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c b/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c index c8d12092ace05a..db98c131d993c7 100644 --- a/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c +++ b/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, STMICROELECTRONICS + * Copyright 2024 NXP * * SPDX-License-Identifier: Apache-2.0 */ @@ -63,6 +64,10 @@ struct rpmsg_rcv_msg { size_t len; }; +struct ipm_channel { + uint8_t channel_id; +}; + static struct metal_io_region *shm_io = &shm_io_data; static struct metal_io_region *rsc_io = &rsc_io_data; @@ -78,6 +83,8 @@ static struct rpmsg_rcv_msg sc_msg = {.data = rx_sc_msg}; static struct rpmsg_endpoint tty_ept; static struct rpmsg_rcv_msg tty_msg; +static struct ipm_channel app_ipm_channel; + static K_SEM_DEFINE(data_sem, 0, 1); static K_SEM_DEFINE(data_sc_sem, 0, 1); static K_SEM_DEFINE(data_tty_sem, 0, 1); @@ -85,7 +92,10 @@ static K_SEM_DEFINE(data_tty_sem, 0, 1); static void platform_ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { + struct ipm_channel *ipm_ch = (struct ipm_channel *)context; + LOG_DBG("%s: msg received from mb %d", __func__, id); + ipm_ch->channel_id = id; k_sem_give(&data_sem); } @@ -130,10 +140,10 @@ static void new_service_cb(struct rpmsg_device *rdev, const char *name, int mailbox_notify(void *priv, uint32_t id) { - ARG_UNUSED(priv); + struct ipm_channel *ipm_ch = (struct ipm_channel *)priv; LOG_DBG("%s: msg received", __func__); - ipm_send(ipm_handle, 0, id, NULL, 0); + ipm_send(ipm_handle, 0, ipm_ch->channel_id, NULL, 0); return 0; } @@ -167,7 +177,7 @@ int platform_init(void) return -1; } - ipm_register_callback(ipm_handle, platform_ipm_callback, NULL); + ipm_register_callback(ipm_handle, platform_ipm_callback, (void *)&app_ipm_channel); status = ipm_set_enabled(ipm_handle, 1); if (status) { @@ -197,7 +207,7 @@ platform_create_rpmsg_vdev(unsigned int vdev_index, vdev = rproc_virtio_create_vdev(VIRTIO_DEV_DEVICE, VDEV_ID, rsc_table_to_vdev(rsc_table), - rsc_io, NULL, mailbox_notify, NULL); + rsc_io, (void *)&app_ipm_channel, mailbox_notify, NULL); if (!vdev) { LOG_ERR("failed to create vdev"); From 46903cd2e6cc643556b41c82613caab29586a932 Mon Sep 17 00:00:00 2001 From: Alexandru Lastur Date: Mon, 9 Sep 2024 21:35:28 +0300 Subject: [PATCH 5/5] linker: add resource table section general linker file Added a resource table section named '.resource_table' because Linux remoteproc driver is parsingthe elf file, and will look for that section named '.resource_table'. Added this configuration in include/zephyr/arch/arm/cortex_m/scripts/linker.ld as it should benefits all the Cortex M cofiguration when using th sample opanamp_rsc. linker: imx8mp_evk m7 linke.ld: removed CONFIG_OPENAMP_RSC_TABLE Removed CONFIG_OPENAMP_RSC_TABLE from soc/nxp/imx/imx8m/m7 as it is already configured in the general linker.ld file Signed-off-by: Alexandru Lastur --- include/zephyr/arch/arm/cortex_m/scripts/linker.ld | 11 +++++++++++ soc/nxp/imx/imx8m/m7/linker.ld | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index fb26e91cf6144f..4691ea2d75881c 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -1,5 +1,6 @@ /* * Copyright (c) 2013-2014 Wind River Systems, Inc. + * Copyright 2024 NXP * * SPDX-License-Identifier: Apache-2.0 */ @@ -515,3 +516,13 @@ SECTION_PROLOGUE(.last_section,,) _flash_used = LOADADDR(.last_section) + SIZEOF(.last_section) - __rom_region_start; } + +/*Add resource table section for openamp_rsc example*/ +#if defined(CONFIG_OPENAMP_RSC_TABLE) + SECTIONS{ + SECTION_PROLOGUE(.resource_table,, SUBALIGN(8)) + { + KEEP(*(.resource_table*)) + } GROUP_LINK_IN(ROMABLE_REGION) + } +#endif \ No newline at end of file diff --git a/soc/nxp/imx/imx8m/m7/linker.ld b/soc/nxp/imx/imx8m/m7/linker.ld index 790e9c03074379..041aafc238e5fe 100644 --- a/soc/nxp/imx/imx8m/m7/linker.ld +++ b/soc/nxp/imx/imx8m/m7/linker.ld @@ -17,13 +17,3 @@ MEMORY } #include - -SECTIONS - { -#ifdef CONFIG_OPENAMP_RSC_TABLE - SECTION_PROLOGUE(.resource_table,, SUBALIGN(8)) - { - KEEP(*(.resource_table*)) - } GROUP_LINK_IN(ROMABLE_REGION) -#endif - }