Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for HiFi4 DSP on openamp_rsc_table sample #60455

Merged

Conversation

iuliana-prodan
Copy link
Collaborator

With this patchset we can run openamp_rsc_table sample on HiFi4 DSP from i.MX8MP.
We run Linux on Cortex A53 and Zephyr on HiFi4.

Compile the sample with:
west build -p always -b nxp_adsp_imx8m samples/subsys/ipc/openamp_rsc_table

The firmware is loaded on DSP from Linux, using remoteproc:

echo -n zephyr_openamp_rsc_table.elf > /sys/class/remoteproc/remoteproc0/firmware
echo start > /sys/class/remoteproc/remoteproc0/state

@iuliana-prodan
Copy link
Collaborator Author

This PR has some dependencies:
NXP_HAL: nxp-mcuxpresso/mcux-sdk#124
OpenAMP: OpenAMP/open-amp#500

@iuliana-prodan iuliana-prodan force-pushed the rpmsg_on_nxps_adsp_imx8m branch 2 times, most recently from 24fe843 to c2203ad Compare July 17, 2023 14:40
@carlocaione carlocaione added the DNM This PR should not be merged (Do Not Merge) label Jul 17, 2023
@carlocaione
Copy link
Collaborator

Blocked on the open-amp patch.

@iuliana-prodan
Copy link
Collaborator Author

Blocked on the open-amp patch.

@carlocaione how do we update the Zephyr's openamp repo?
After this PR is merged, can we:

  1. update the open-amp repo from Zephyr;
  2. create a PR to set here also the set(WITH_DCACHE_RSC_TABLE 1)?

I can do #2 :)
Can you help me with #1?

@carlocaione
Copy link
Collaborator

@carlocaione how do we update the Zephyr's openamp repo? After this PR is merged, can we:

1. update the open-amp repo from Zephyr;

Correct. You have to sync https://github.com/zephyrproject-rtos/open-amp/ opening a PR and fixing the Zephyr manifest in this PR to point to the new SHA.

2. create a PR to set CMakeLists.txt#L20 also the `set(WITH_DCACHE_RSC_TABLE 1)`?

Correct.

I can do #2 :) Can you help me with #1?

😄 ok, I can sync the zephyr open-amp repo, but you still have to fix this PR making the Zephyr manifest pointing to the new PR / SHA.

Anyway, we have to wait for the Open-AMP PR to be merged.

@arnopo
Copy link
Collaborator

arnopo commented Jul 17, 2023

FYI
OpenAMP/open-amp#500 is merged,

@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Jul 21, 2023
carlocaione
carlocaione previously approved these changes Jul 21, 2023
@@ -29,6 +29,9 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC
config SYS_CLOCK_TICKS_PER_SEC
default 50000

config IPM_IMX_REV2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? I expect that IPM_IMX_REV2 should be enabled when mailbox0 is status=okay and CONFIG_IPM=y

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is possible, you're right.
I removed the commit that was adding this config.

Add resource_table section in linker script for nxp_adsp_imx8m
for inter-process communication.

Signed-off-by: Iuliana Prodan <[email protected]>
Add mailbox and interrupt-controller nodes used for
inter-process communication.

Add also the dt binding for the interrupt-controller.
For now, this is used just to fix some compile errors,
since the mailbox requires an interrupt-controller.

For DSP, we have a direct interrupt line to the core.

Signed-off-by: Iuliana Prodan <[email protected]>
Add the dts and config overlay for nxp_adsp_imx8m board
in order to have the openamp_rsc_table sample working on
HiFi4 DSP from i.MX 8M Plus.

Signed-off-by: Iuliana Prodan <[email protected]>
While testing openamp_rsc_table sample for HiFi4 DSP from
i.MX8MP, realized the stack is not enough.
Increase the size based on Thread Analyzer measurements:

*** Booting Zephyr OS build zephyr-v3.4.0-971-g9415baf2c211 ***
Starting application threads!

OpenAMP[remote]  linux responder demo started

OpenAMP[remote] Linux sample client responder started

OpenAMP[remote] Linux tty responder started
[00:00:00.020,000] <dbg> openamp_rsc_table: mailbox_notify:
mailbox_notify: msg received

[00:00:00.024,000] <dbg> openamp_rsc_table: mailbox_notify:
mailbox_notify: msg received

Thread analyze:
 0x9240c5a0          : STACK: unused 240 usage 1296 / 1536 (84 %); CPU: 10%
      : Total CPU cycles used: 3388523
 0x9240c628          : STACK: unused 240 usage 784 / 1024 (76 %); CPU: 10%
      : Total CPU cycles used: 4086621
 0x9240c6b0          : STACK: unused 408 usage 616 / 1024 (60 %); CPU: 7%
      : Total CPU cycles used: 3553673
 0x9240c738          : STACK: unused 152 usage 872 / 1024 (85 %); CPU: 44%
      : Total CPU cycles used: 25529572
 0x9240c7c0          : STACK: unused 352 usage 672 / 1024 (65 %); CPU: 21%
      : Total CPU cycles used: 13742359
 0x9240c888          : STACK: unused 936 usage 88 / 1024 (8 %); CPU: 0%
      : Total CPU cycles used: 0
 ISR0                : STACK: unused 1536 usage 512 / 2048 (25 %)

Signed-off-by: Iuliana Prodan <[email protected]>
Update open-amp repository with new sha.

Signed-off-by: Iuliana Prodan <[email protected]>
@carlescufi carlescufi merged commit 3945988 into zephyrproject-rtos:main Jul 26, 2023
19 checks passed
@majidBahmanigbt
Copy link

majidBahmanigbt commented Apr 3, 2024

Hi,

Hope you are well.

I would like to test “zephyr_openamp_rsc_table” on IMX8MP-EVK. In the first step I compiled the code:

_**xxxx@LinuxForiMX:~/nxp/Repositories/DSP_Zephyr/zephyr$ west build -p always -b nxp_adsp_imx8m samples/subsys/ipc/openamp_rsc_table
-- west build: making build dir /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/samples/subsys/ipc/openamp_rsc_table
-- CMake version: 3.22.1
-- Found Python3: /usr/bin/python3 (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/xxxx/.cache/zephyr
-- Zephyr version: 3.6.99 (/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
CMake Warning at /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr/cmake/modules/boards.cmake:105 (message):
Deprecated BOARD=nxp_adsp_imx8m specified, board automatically changed to:
imx8mp_evk/mimx8ml8/adsp.
Call Stack (most recent call first):
/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr/cmake/modules/zephyr_default.cmake:132 (include)
/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:7 (find_package)

-- Board: imx8mp_evk, qualifiers: mimx8ml8/adsp
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.5 (/home/xxxx/zephyr-sdk-0.16.5-1)
-- Found toolchain: zephyr 0.16.5 (/home/xxxx/zephyr-sdk-0.16.5-1)
-- Found Dtc: /home/xxxx/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr/boards/nxp/imx8mp_evk/imx8mp_evk_mimx8ml8_adsp.dts
-- Found devicetree overlay: /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_adsp.overlay
-- Generated zephyr.dts: /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build/zephyr/dts.cmake

warning: PRINTK (defined at subsys/debug/Kconfig:204) was assigned the value 'n' but got the value
'y'. See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_PRINTK and/or look up PRINTK in
the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

Parsing /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr/Kconfig
Loaded configuration '/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr/boards/nxp/imx8mp_evk/imx8mp_evk_mimx8ml8_adsp_defconfig'
Merged configuration '/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/samples/subsys/ipc/openamp_rsc_table/prj.conf'
Merged configuration '/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/samples/subsys/ipc/openamp_rsc_table/boards/imx8mp_evk_mimx8ml8_adsp.conf'
Configuration saved to '/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /home/xxxx/zephyr-sdk-0.16.5-1/xtensa-nxp_imx8m_adsp_zephyr-elf/bin/../lib/gcc/xtensa-nxp_imx8m_adsp_zephyr-elf/12.2.0/../../../../xtensa-nxp_imx8m_adsp_zephyr-elf/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/xxxx/zephyr-sdk-0.16.5-1/xtensa-nxp_imx8m_adsp_zephyr-elf/bin/xtensa-nxp_imx8m_adsp_zephyr-elf-gcc
Load components for MIMX8ML8_dsp:
driver_common component is included.
driver_reset component is included.
driver_mu component is included.
driver_iuart component is included.
-- libmetal version: 1.5.0 (/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/samples/subsys/ipc/openamp_rsc_table)
-- Build type:
-- Host: Linux/x86_64
-- Target: Generic/xtensa
-- Machine: xtensa
-- Looking for include file stdatomic.h
-- Looking for include file stdatomic.h - found
-- open-amp version: 1.5.0 (/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/modules/lib/open-amp/open-amp)
-- Host: Linux/x86_64
-- Target: Generic/xtensa
-- Machine: xtensa
-- C_FLAGS : -Wall -Wextra
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build
-- west build: building application
[2/189] Preparing syscall dependency handling

[3/189] Generating include/generated/version.h
-- Zephyr version: 3.6.99 (/home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/zephyr), build: v3.6.0-2050-g3c42daee9c1b
[188/189] Linking C executable zephyr/zephyr_openamp_rsc_table.elf
Memory region Used Size Region Size %age Used
vector_reset_text: 289 B 736 B 39.27%
vector_reset_lit: 0 GB 288 B 0.00%
vector_base_text: 362 B 376 B 96.28%
vector_int2_lit: 0 GB 4 B 0.00%
vector_int2_text: 3 B 28 B 10.71%
vector_int3_lit: 0 GB 4 B 0.00%
vector_int3_text: 3 B 28 B 10.71%
vector_int4_lit: 0 GB 4 B 0.00%
vector_int4_text: 3 B 28 B 10.71%
vector_int5_lit: 0 GB 4 B 0.00%
vector_int5_text: 3 B 28 B 10.71%
vector_kernel_lit: 0 GB 4 B 0.00%
vector_kernel_text: 3 B 28 B 10.71%
vector_user_lit: 0 GB 4 B 0.00%
vector_user_text: 22 B 28 B 78.57%
vector_double_lit: 0 GB 4 B 0.00%
vector_double_text: 6 B 28 B 21.43%
iram_text_start: 192 B 424 B 45.28%
sdram0: 88920 B 8 MB 1.06%
sdram1: 0 GB 8172 KB 0.00%
IDT_LIST: 0 GB 8 KB 0.00%
static_uuid_entries_seg: 0 GB 24 KB 0.00%
static_log_entries_seg: 0 GB 32 MB 0.00%
fw_metadata_seg: 0 GB 32 MB 0.00%
Generating files from /home/xxxx/nxp/Repositories/DSP_Zephyr/zephyr/build/zephyr/zephyr_openamp_rsc_table.elf for board: imx8mp_evk
[189/189] west sign --if-tool-available --tool rimage ...
WARNING: rimage not found; either install it or provide --tool-path
WARNING: zephyr binary not signed!**_

Then when I load the elf file on DSP I am receiving the error and ttyRPMGx was not created:
image

On DSP at first I couldn't receive log then I change LOG_INFO to printf. Do you have any idea in this regard?

Thank you,
Majid.

@dbaluta
Copy link
Collaborator

dbaluta commented Apr 3, 2024

On DSP at first I couldn't receive log then I change LOG_INFO to printf. Do you have any idea in this regard?

-2 means

#define [ENOENT](https://elixir.bootlin.com/linux/latest/C/ident/ENOENT) 2 /* No such file or directory */

This means that the file path you provided is not correct.

I think first line should read:

echo -n "imx/zephyr/zephyr_openamp_rsc_table.elf" > /sys/class/..../firmware"

Cc: @iuliana-prodan

Later edit: or maybe your commands are OK but the firmware elf file is not in the correct location in the rootfs.

@majidBahmanigbt
Copy link

Thank you for your reply.

I think my command line is correct as you see when I use your suggested command I receive "No such file or directory" error.

root@imx8mp-lpddr4-evk:# echo -n zephyr_openamp_rsc_table.elf > /sys/class/remoteproc/remoteproc0/firmware
root@imx8mp-lpddr4-evk:
# echo start > /sys/class/remoteproc/remoteproc0/state
-sh: echo: write error: No such f[ 1510.407177] remoteproc remoteproc0: powering up imx-dsp-rproc
ile or directory
[ 1510.407272] remoteproc remoteproc0: Direct firmware load for zephyr_openamp_rsc_table.elf failed with error -2
[ 1510.407280] remoteproc remoteproc0: Falling back to sysfs fallback for: zephyr_openamp_rsc_table.elf
[ 1510.408062] remoteproc remoteproc0: request_firmware failed: -2
[ 1510.408073] remoteproc remoteproc0: Boot failed: -2

As you see in the image, it seems that the elf is loaded into DSP and I am receiving the initial log in DSP side (PuTTY COM11).

image

I checked the openamp_rsc_table and based on the DSP log, it seems that DSP crashes in the first thread and two other threads are not executed:

int main(void)
{
#ifdef USE_LOG
LOG_INF("Starting application threads!");
#elif defined USE_PRINTF
printf("Starting application threads!");
printf("\r\n");
#endif
k_thread_create(&thread_mng_data, thread_mng_stack, APP_TASK_STACK_SIZE,
rpmsg_mng_task,
NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT);

k_thread_create(&thread_rp__client_data, thread_rp__client_stack, APP_TASK_STACK_SIZE,
app_rpmsg_client_sample,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
k_thread_create(&thread_tty_data, thread_tty_stack, APP_TTY_TASK_STACK_SIZE,
app_rpmsg_tty,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
return 0;
}

@iuliana-prodan
Copy link
Collaborator Author

@majidBahmanigbt I've checked on latest Zephyr and as you, I can't see any logging messages.
I've tried

diff --git a/samples/subsys/ipc/openamp_rsc_table/prj.conf b/samples/subsys/ipc/openamp_rsc_table/prj.conf
index 2d86c8b8140..9ebc71e45d4 100644
--- a/samples/subsys/ipc/openamp_rsc_table/prj.conf
+++ b/samples/subsys/ipc/openamp_rsc_table/prj.conf
@@ -10,3 +10,5 @@ CONFIG_OPENAMP_MASTER=n
 
 CONFIG_SHELL=y
 CONFIG_SHELL_BACKEND_RPMSG=y
+
+CONFIG_LOG=y
\ No newline at end of file
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 8bc1a475d08..bab89e02ebb 100644
--- a/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c
+++ b/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c
@@ -23,7 +23,7 @@
 #endif
 
 #include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(openamp_rsc_table, LOG_LEVEL_DBG);
+LOG_MODULE_REGISTER(openamp_rsc_table, LOG_LEVEL_INF);
 
 #define SHM_DEVICE_NAME        "shm"

but still no messages.
I still need to figure this out, why the logging messages are not displayed.

So, I've changed some LOG_INF with printk and the sample is working fine.

Be sure you follow all the steps from here: https://www.nxp.com/docs/en/application-note/AN13970.pdf

In order for the TTY sample to work, you have to probe the rpmsg_tty kernel module.
Here's my Linux console output:

root@imx8mpevk:~# ls -la
total 1560
drwx------ 5 root root    4096 Apr  3 14:34 .
drwxr-xr-x 4 root root    4096 Mar  9  2018 ..
-rw-r--r-- 1 root root      51 Mar  9  2018 .profile
drwx------ 2 root root    4096 Apr  3  2024 .ssh
-rwxr-xr-x 1 root root 1569008 Apr  3  2024 zephyr_openamp_rsc_table.elf
root@imx8mpevk:~# 
root@imx8mpevk:~# modprobe rpmsg_tty
root@imx8mpevk:~# echo -n /home/root/zephyr_openamp_rsc_table.elf > /sys/class/remoteproc/remoteproc0/firmware
root@imx8mpevk:~# echo start > /sys/class/remoteproc/remoteproc0/state
root@imx8mpevk:~# cat /dev/ttyRPMSG
ttyRPMSG0  ttyRPMSG1  
root@imx8mpevk:~# cat /dev/ttyRPMSG1 &
[1] 1475
root@imx8mpevk:~# echo "helloooo" > /dev/ttyRPMSG1
root@imx8mpevk:~# TTY 0x0402: helloooo

root@imx8mpevk:~# echo "helloooo again" > /dev/ttyRPMSG1
root@imx8mpevk:~# TTY 0x0402: helloooo again

root@imx8mpevk:~# echo stop > /sys/class/remoteproc/remoteproc0/state
[1]+  Done                    cat /dev/ttyRPMSG1
root@imx8mpevk:~# uname -a
Linux imx8mpevk 6.8.0-rc5-next-20240220-lts-next-05643-g850e962175d9 #1 SMP PREEMPT Mon Mar 25 12:20:49 UTC 2024 aarch64 GNU/Linux
root@imx8mpevk:~# 

Here's Zephyr output:

*** Booting Zephyr OS build v3.6.0-2050-g3c42daee9c1b ***
Starting application threads!
OpenAMP[remote] Linux sample client responder started
OpenAMP[remote] Linux TTY responder started
OpenAMP Linux sample client responder ended
[Linux TTY] incoming msg: helloooo

[Linux TTY] incoming msg: helloooo again

You can see above, what Linux Kernel and Zephyr versions I've used.
Can you try with latest Zephyr?
Be aware that in Zephyr we have now HWMv2 and we compile the sample with new board name:
west build -p always -b imx8mp_evk//adsp samples/subsys/ipc/openamp_rsc_table/

The failed with error -2 is expected (see also in the Application note link above) when the firmware is not in the expected location /lib/firmware, but is still loaded (see Falling back to sysfs fallback for)

@majidBahmanigbt
Copy link

Thank you for your explanations.

Yes, I did the steps by: https://www.nxp.com/docs/en/application-note/AN13970.pdf

It seems that the Linux version is different. I use real-time edge https://github.com/nxp-real-time-edge-sw/meta-real-time-edge. And I have enabled "Fully Preemptible Kernel". Please give me time to test more.

If the problem comes from Linux version, do you know if there is any way to solve it?

root@imx8mp-lpddr4-evk:# ls -la
total 1596
drwx------ 5 root root 4096 Mar 8 13:01 .
drwxr-xr-x 5 root root 4096 Mar 9 2018 ..
-rw------- 1 root root 7491 Mar 8 13:01 .bash_history
-rw-r--r-- 1 root root 51 Mar 9 2018 .profile
-rw-r--r-- 1 root root 68 Mar 3 16:52 ethh.sh
drwxr-xr-x 2 root root 4096 Mar 9 2018 nservo_example
drwxr-xr-x 2 root root 12288 Mar 9 2018 open62541_example
drwxr-xr-x 5 root root 4096 Mar 9 2018 samples
-rw-r--r-- 1 root root 150 Dec 30 2023 send_loop.sh
-rw-r--r-- 1 root root 16573 Dec 31 2023 send_loop2.sh
-rw-r--r-- 1 root root 108 Dec 31 2023 send_loop3.sh
-rw-r--r-- 1 root root 83 Dec 30 2023 set_ondemand.sh
-rw-r--r-- 1 root root 86 Dec 30 2023 set_performance.sh
-rw-r--r-- 1 root root 71 Dec 30 2023 show_governor.sh
-rw-r--r-- 1 root root 41 Dec 26 2023 start_ping_pong.sh
-rw-r--r-- 1 root root 316 Mar 8 12:17 test_dsp_rpmsg.sh
-rw-r--r-- 1 root root 89 Mar 3 17:43 test_mailboxj.sh
-rw-r--r-- 1 root root 145 Dec 31 2023 test_rpmsg_tty.sh
-rw-r--r-- 1 root root 1530548 Apr 3 2024 zephyr_openamp_rsc_table.elf
root@imx8mp-lpddr4-evk:
# modprobe rpmsg_tty
root@imx8mp-lpddr4-evk:# echo -n /home/root/zephyr_openamp_rsc_table.elf > /sys/class/remoteproc/remoteproc0/firmware
root@imx8mp-lpddr4-evk:
# echo start > /sys/class/remoteproc/remoteproc0/state
[ 146.352236] remoteproc remoteproc0: powering up imx-dsp-rproc
[ 146.352296] remoteproc remoteproc0: Direct firmware load for /home/root/zephyr_openamp_rsc_table.elf failed with error -2
[ 146.352304] remoteproc remoteproc0: Falling back to sysfs fallback for: /home/root/zephyr_openamp_rsc_table.elf
[ 146.356679] remoteproc remoteproc0: Booting fw image /home/root/zephyr_openamp_rsc_table.elf, size 1530548
[ 146.362659] rproc-virtio rproc-virtio.2.auto: assigned reserved memory node vdev0buffer@94300000
[ 146.374010] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 146.374099] rproc-virtio rproc-virtio.2.auto: registered virtio0 (type 7)
[ 146.374105] remoteproc remoteproc0: remote processor imx-dsp-rproc is now up
root@imx8mp-lpddr4-evk:# cat /dev/ttyRPMSG
cat: /dev/ttyRPMSG: No such file or directory
root@imx8mp-lpddr4-evk:
# uname -a
Linux imx8mp-lpddr4-evk 6.1.22-rt8 #1 SMP PREEMPT_RT Mon Apr 1 11:35:00 UTC 2024 aarch64 GNU/Linux
root@imx8mp-lpddr4-evk:~#

@majidBahmanigbt
Copy link

majidBahmanigbt commented Apr 5, 2024

Hi,
Hope you are all fine
I logged into the code “samples/subsys/ipc/openamp_rsc_table/src/main_remote.c” read the memory address and checked which functions run. What I have found is that the process stops in

rproc_virtio_wait_remote_ready(vdev);

In the above function rproc_virtio_get_status(vdev) is always return 0 and stuck in while loop.

void rproc_virtio_wait_remote_ready(struct virtio_device *vdev)
{
	uint8_t status;

#ifndef VIRTIO_DEVICE_ONLY
	/*
	 * No status available for remote. As virtio driver has not to wait
	 * remote action, we can return. Behavior should be updated
	 * in future if a remote status is added.
	 */
	if (vdev->role == VIRTIO_DEV_DRIVER)
		return;
#endif
	while (1) {
		status = rproc_virtio_get_status(vdev);
		
		if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK)
			return;
		else{
			if(counter < 10){
				counter++;
				printk("rproc_virtio_get_status : %d\r\n", status);
			}
		}	
		metal_cpu_yield();
	}
}

Log output:

Starting application threads!
OpenAMP[remote] Linux responder demo started
SHM_START_ADDR: 0x942f0000
SHM_SIZE: 0x110000
CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF: 0x8
RSC_VDEV: 0x3
VRING_TX_ADDRESS: 0xffffffff
VRING_RX_ADDRESS: 0xffffffff
rsc_tab_addr: 0x92400000
ipm_set_enabled
Starting app_rpmsg_client_sample
Starting app_rpmsg_tty
platform_ipm_callback: msg received from mb 0
Giving Sem...
Sem give done
ipm_set_enable success
platform_create_rpmsg_vdev
rproc_virtio_create_vdev
rproc_virtio_wait_remote_ready
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0

The other two threads don’t run because the semaphore has locked them, and they wait for the first thread to finish. The only problem is that for some reason “rproc_virtio_wait_remote_ready()” stocks in a loop.

I have also check the dsp reserved memory address and size in both Linux and Zephyr device tree and they are equal. However, about other register values I don't have any idea if they are correct specially for VRING_TX_ADDRESS and VRING_RX_ADDRESS.

Could you please check my register value in the log? I would really appreciate it if you had any idea what can make this problem.
Many Thanks,
Majid.

@iuliana-prodan
Copy link
Collaborator Author

Hi, Hope you are all fine I logged into the code “samples/subsys/ipc/openamp_rsc_table/src/main_remote.c” read the memory address and checked which functions run. What I have found is that the process stops in

rproc_virtio_wait_remote_ready(vdev);

In the above function rproc_virtio_get_status(vdev) is always return 0 and stuck in while loop.

void rproc_virtio_wait_remote_ready(struct virtio_device *vdev)
{
	uint8_t status;

#ifndef VIRTIO_DEVICE_ONLY
	/*
	 * No status available for remote. As virtio driver has not to wait
	 * remote action, we can return. Behavior should be updated
	 * in future if a remote status is added.
	 */
	if (vdev->role == VIRTIO_DEV_DRIVER)
		return;
#endif
	while (1) {
		status = rproc_virtio_get_status(vdev);
		
		if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK)
			return;
		else{
			if(counter < 10){
				counter++;
				printk("rproc_virtio_get_status : %d\r\n", status);
			}
		}	
		metal_cpu_yield();
	}
}

Log output:

Starting application threads!
OpenAMP[remote] Linux responder demo started
SHM_START_ADDR: 0x942f0000
SHM_SIZE: 0x110000
CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF: 0x8
RSC_VDEV: 0x3
VRING_TX_ADDRESS: 0xffffffff
VRING_RX_ADDRESS: 0xffffffff
rsc_tab_addr: 0x92400000
ipm_set_enabled
Starting app_rpmsg_client_sample
Starting app_rpmsg_tty
platform_ipm_callback: msg received from mb 0
Giving Sem...
Sem give done
ipm_set_enable success
platform_create_rpmsg_vdev
rproc_virtio_create_vdev
rproc_virtio_wait_remote_ready
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0
rproc_virtio_get_status : 0

The other two threads don’t run because the semaphore has locked them, and they wait for the first thread to finish. The only problem is that for some reason “rproc_virtio_wait_remote_ready()” stocks in a loop.

I have also check the dsp reserved memory address and size in both Linux and Zephyr device tree and they are equal. However, about other register values I don't have any idea if they are correct specially for VRING_TX_ADDRESS and VRING_RX_ADDRESS.

Could you please check my register value in the log? I would really appreciate it if you had any idea what can make this problem. Many Thanks, Majid.

I had a similar problem.
On OpenAMP, at least for DSP, when reading the status from resource table structure we need to do DCACHE invalidate, otherwise the status is never updated. See OpenAMP/open-amp#500

@majidBahmanigbt
Copy link

Hi,

After a lot of test, I finally found that the problem is in my outdated imx_dsp_rproc.c kernel module. I found and apply your modification in DSP kernel module
nxp-imx/linux-imx@8dde0bb
and now it works.

Many thanks for you help.

@dbaluta
Copy link
Collaborator

dbaluta commented Apr 9, 2024

@majidBahmanigbt Glad that you finally find the solution!

May I ask what kind of project are you working on that involves the HIFI4 DSP? This can helps us at NXP understanding customer's needs and plan ahead for next features.

@majidBahmanigbt
Copy link

@majidBahmanigbt Glad that you finally find the solution!

May I ask what kind of project are you working on that involves the HIFI4 DSP? This can helps us at NXP understanding customer's needs and plan ahead for next features.

Well... Our products should meet some real-time tight deadlines. I am investigating DSP to take advantage of this core for reducing some loads on the main cores IMX8MP (CA53 and CM7).

Thank you for your support.

@majidBahmanigbt
Copy link

I have another question but I don't know here is a right place to ask.

According to IMX8MPRM.pdf, there is a messaging unit between CM7 and DSP (MU_3).
AN13970.pdf explains the interconnection between CA53 and DSP. Do you have any idea how it is possible establish a direct connection between CM7 and DSP? If there is any document please let me know.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Interrupt Controller area: IPC Inter-Process Communication area: IPM Inter-Processor Mailbox area: Xtensa Xtensa Architecture manifest manifest-open-amp platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants