nxp-mcuxpresso / rpmsg-lite

RPMsg implementation for small MCUs
BSD 3-Clause "New" or "Revised" License
238 stars 73 forks source link

I need rpmsg_env_specific.h to user rpmsg-lite (new version) with Yocto Kirkstone and Zephyr upstream #48

Open neuberfran opened 7 months ago

neuberfran commented 7 months ago

Hi,

Realy I stay searching for "rpmsg_env_specific.h" because I can't found in https://github.com/nxp-mcuxpresso/rpmsg-lite/tree/main/lib/include Or in anywhere

Captura de tela de 2024-04-15 20-53-43

Hadatko commented 7 months ago

Hello you need add include based on your target system: https://github.com/nxp-mcuxpresso/rpmsg-lite/tree/main/lib/include/environment

neuberfran commented 7 months ago

@Hadatko undefined reference to `z_impl_k_event_init'

I have other project(which is a copy of this) here(with old rpmsg_lite version) https://github.com/zephyrproject-rtos/zephyr/discussions/66669#discussioncomment-7908788 with errors in execution moment (not appear /dev/ttyRPMSG) But I can generate zephyr.bin at least

But in this project, I have one issue. Pls help-me I need test my project with new rpmsg_lite

west build -p auto -b pico_pi_m4 remote_echo 
-- west build: generating a build system
CMake Warning at /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/cmake/app/boilerplate.cmake:20 (message):
  Loading of Zephyr boilerplate.cmake directly is deprecated, please use
  'find_package(Zephyr)'
Call Stack (most recent call first):
  CMakeLists.txt:4 (include)

Loading Zephyr default modules (Zephyr base).
-- Application: /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo
-- CMake version: 3.24.1
-- Found Python3: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: /home/neuberfran/.cache/zephyr
-- Zephyr version: 3.6.99 (/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr)
-- Found west (found suitable version "1.0.0", minimum required is "0.14.0")
CMake Warning at /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/cmake/modules/boards.cmake:110 (message):
  Deprecated BOARD=pico_pi_m4 specified, board automatically changed to:
  pico_pi/mcimx7d/m4.
Call Stack (most recent call first):
  /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/cmake/modules/zephyr_default.cmake:132 (include)
  /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/cmake/app/boilerplate.cmake:25 (find_package)
  CMakeLists.txt:4 (include)

-- Board: pico_pi, qualifiers: mcimx7d/m4
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.0 (/home/neuberfran/zephyr-sdk-0.16.0)
-- Found toolchain: zephyr 0.16.0 (/home/neuberfran/zephyr-sdk-0.16.0)
-- Found Dtc: /home/neuberfran/zephyr-sdk-0.16.0/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/boards/technexion/pico_pi/pico_pi_mcimx7d_m4.dts
-- Generated zephyr.dts: /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/dts.cmake
Parsing /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/Kconfig
Loaded configuration '/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/boards/technexion/pico_pi/pico_pi_mcimx7d_m4_defconfig'
Merged configuration '/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/prj.conf'
Configuration saved to '/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/.config'
Kconfig header saved to '/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/include/generated/autoconf.h'

warning: IPM_IMX (defined at soc/nxp/imx/imx8m/Kconfig.defconfig.mimx8ml8_m7:20,
soc/nxp/imx/imx8m/Kconfig.defconfig.mimx8mm6_m4:13, drivers/ipm/Kconfig.imx:11) was assigned the
value 'y' but got the value 'n'. Check these unsatisfied dependencies: ((IPM && SOC_MIMX8ML8_M7 &&
SOC_SERIES_IMX8M && SOC_FAMILY_NXP_IMX) || (IPM && SOC_MIMX8MM6_M4 && SOC_SERIES_IMX8M &&
SOC_FAMILY_NXP_IMX) || (DT_HAS_NXP_IMX_MU_ENABLED && IPM)) (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_IPM_IMX and/or look up IPM_IMX 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.

-- Found GnuLd: /home/neuberfran/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/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/neuberfran/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Warning at /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/CMakeLists.txt:872 (message):
  No SOURCES given to Zephyr library: drivers__clock_control

  Excluding target from build.

CMake Warning at /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/CMakeLists.txt:872 (message):
  No SOURCES given to Zephyr library: drivers__ipm

  Excluding target from build.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build
-- west build: building application
[1/121] Preparing syscall dependency handling

[2/121] Generating include/generated/version.h
-- Zephyr version: 3.6.99 (/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr), build: v3.6.0-2554-g2c8ea07b3498
[15/121] Building C object CMakeFiles/app.dir/src/main_remote_echo.c.obj
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c:31:1: warning: multi-line comment [-Wcomment]
   31 | //#error Please define RPMSG_MAX_SIZE, RPMSG_LITE_LINK_ID, RPMSG_LITE_SHMEM_BASE,\
      | ^
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c: In function 'app_task':
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c:73:48: warning: passing argument 2 of 'rpmsg_ns_bind' from incompatible pointer type [-Wincompatible-pointer-types]
   73 |         ns_handle = rpmsg_ns_bind(rl_instance, app_nameservice_isr_cb, NULL);
      |                                                ^~~~~~~~~~~~~~~~~~~~~~
      |                                                |
      |                                                void (*)(unsigned int,  const char *, long unsigned int,  void *)
In file included from /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c:16:
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/../../../../../../lib/include/rpmsg_ns.h:106:95: note: expected 'rpmsg_ns_new_ept_cb' {aka 'void (*)(unsigned int,  const char *, unsigned int,  void *)'} but argument is of type 'void (*)(unsigned int,  const char *, long unsigned int,  void *)'
  106 | rpmsg_ns_handle rpmsg_ns_bind(struct rpmsg_lite_instance *rpmsg_lite_dev, rpmsg_ns_new_ept_cb app_cb, void *user_data);
      |                                                                           ~~~~~~~~~~~~~~~~~~~~^~~~~~
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c:82:34: warning: passing argument 3 of 'rpmsg_queue_recv' from incompatible pointer type [-Wincompatible-pointer-types]
   82 |                                  (unsigned long*)&remote_addr, (char*)buf,
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  long unsigned int *
In file included from /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c:15:
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/../../../../../../lib/include/rpmsg_queue.h:132:36: note: expected 'uint32_t *' {aka 'unsigned int *'} but argument is of type 'long unsigned int *'
  132 |                          uint32_t *src,
      |                          ~~~~~~~~~~^~~
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c: At top level:
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/remote_echo/src/main_remote_echo.c:99:6: warning: return type of 'main' is not 'int' [-Wmain]
   99 | void main(void)
      |      ^~~~
[21/121] Building C object CMakeFile...d_m4/rpmsg_platform_zephyr_ipm.c.obj
/home/neuberfran/diegosueiro6/rpmsg-lite/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c: In function 'platform_init':
/home/neuberfran/diegosueiro6/rpmsg-lite/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c:241:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  241 |     ipm_handle = device_get_binding("MU_B");
      |                ^
/home/neuberfran/diegosueiro6/rpmsg-lite/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c:248:39: warning: passing argument 2 of 'ipm_register_callback' from incompatible pointer type [-Wincompatible-pointer-types]
  248 |     ipm_register_callback(ipm_handle, platform_ipm_callback, ((void *)0));
      |                                       ^~~~~~~~~~~~~~~~~~~~~
      |                                       |
      |                                       void (*)(void *, uint32_t,  volatile void *) {aka void (*)(void *, unsigned int,  volatile void *)}
In file included from /home/neuberfran/diegosueiro6/rpmsg-lite/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c:14:
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/zephyr/include/zephyr/drivers/ipm.h:168:57: note: expected 'ipm_callback_t' {aka 'void (*)(const struct device *, void *, unsigned int,  volatile void *)'} but argument is of type 'void (*)(void *, uint32_t,  volatile void *)' {aka 'void (*)(void *, unsigned int,  volatile void *)'}
  168 |                                          ipm_callback_t cb, void *user_data)
      |                                          ~~~~~~~~~~~~~~~^~
[116/121] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/zephyr_pre0.map 
: && /home/neuberfran/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/libarch__arm__core.a  zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a  zephyr/lib/libc/picolibc/liblib__libc__picolibc.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/hal_nxp/hal_nxp/lib..__modules__hal__nxp.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/home/neuberfran/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp"  -L/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -mtp=soft  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie  -DPICOLIBC_LONG_LONG_PRINTF_SCANF  --specs=picolibc.specs  -lc  -lgcc && cd /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr && /opt/cmake-3.24.1/bin/cmake -E true
/home/neuberfran/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: app/libapp.a(rpmsg_env_zephyr.c.obj): in function `k_event_post':
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/include/generated/syscalls/kernel.h:811: undefined reference to `z_impl_k_event_post'
/home/neuberfran/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: app/libapp.a(rpmsg_env_zephyr.c.obj): in function `k_event_init':
/home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build/zephyr/include/generated/syscalls/kernel.h:794: undefined reference to `z_impl_k_event_init'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build /home/neuberfran/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite/build
neuberfran@neuberfran2004:~/diegosueiro6/rpmsg-lite/zephyr/samples/subsys/ipc/rpmsg_lite$ 

Captura de tela de 2024-04-16 20-38-06

https://github.com/zephyrproject-rtos/zephyr/issues/31613

Hadatko commented 7 months ago

Hi, if you mean linking error, then google is providing answer like this: https://stackoverflow.com/questions/74132932/zephyr-project-event-handling

neuberfran commented 7 months ago

@Hadatko Ok. But not Solved yet. Everytime stop in waiting for master.... Captura de tela de 2024-04-17 17-20-14

neuberfran commented 7 months ago

@Hadatko I have all sorts of code with zephyr upstream, without success

printk("Waiting for Master.\r\n");
    // while (!rpmsg_lite_is_link_up(rl_instance)) {
    // }
    while (!rpmsg_lite_wait_for_link_up(rl_instance, 1000)) {       
    } 

    rl_queue = rpmsg_queue_create(rl_instance);
    rl_endpoint = rpmsg_lite_create_ept(rl_instance, LOCAL_EPT_ADDR,
                       rpmsg_queue_rx_cb, rl_queue);

But With Zephyr 1.13 (Original project transpose from warp7 device to imx7d-pico device) It's works

Captura de tela de 2024-04-17 18-56-57 Captura de tela de 2024-04-17 18-57-31

neuberfran commented 7 months ago

https://github.com/zephyrproject-rtos/zephyr/discussions/66669#discussioncomment-7908788

neuberfran commented 7 months ago

@Hadatko Pls help-me. I need rpmsg-lite in zephyr upstream https://github.com/zephyrproject-rtos/zephyr/discussions/66669#discussioncomment-7908788

TomasGalbickaNXP commented 7 months ago

Hello, @neuberfran Let me just try to point out what needs to happen to get out of "Waiting for Master.":

At Zephyr side you need to receive IRQ Callback from IPM from Linux side. https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c#L20C6-L20C27

This call back has to go to env_isr https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/lib/rpmsg_lite/porting/environment/rpmsg_env_zephyr.c#L509

isr_table is set in function here: https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/lib/rpmsg_lite/porting/environment/rpmsg_env_zephyr.c#L426

And isr registration is done here: https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c#L43 and here for remote TX side: https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/lib/rpmsg_lite/rpmsg_lite.c#L1107

And at the End this will trigger this tx callback which will get out rpsmg-lite remote out of waiting for master: https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/lib/rpmsg_lite/rpmsg_lite.c#L166

That means that the Linux side has to trigger this IRQ via IPM with correct link_id so it goes to above callback.

I recommend to try to debug this if you are getting at least IRQ from Linux side to Zephyr. That means if at lease this IRQ is triggered: https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c#L20 If not something is not correct on Linux side. Where I cannot at the moment assist much.

Or even if you are getting any IRQ on IPM size with are maybe not propagated correctly here: https://github.com/neuberfran/diegosueiro/blob/main/rpmsg-lite/zephyr/samples/driver/ipm/ipm_imx.c#L36

If you boot Zephyr first via uboot it will stays at rpmsg_lite_wait_for_link_up and then its Linux time to sent it correct IRQ so it would be good to try focus here if IRQ from Linux is propagated here.

neuberfran commented 7 months ago

@TomasGalbickaNXP Thank you very much for the details friend. But, I don't think the problem is on the Linux side, because with the same Linux image (kernel=5.15, Kirkstone) I uploaded this project using Zephyr 1.13 (https://youtu.be/E34apiomZO4?si=e8YZgYdrSspPHPWo )(photos above) But the Zephyr upstream doesn't work. It may be that I find an error in Zephyr's CMakeLists.txt that is calling the wrong ipm_imx.

Second observation: My imx7d-pico board does not have a debug port.