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

sample: openamp_rsc_table: enable colibri imx7d #72970

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jlh-makeen
Copy link
Contributor

@jlh-makeen jlh-makeen commented May 18, 2024

Following PR #71684 we can now properly boot the M4 core on IMX7D using Linux RPROC.

Adds prompts to the PR #71684 config flags so they can be used in the board's config files.
Adds the necessary definition for the .resource_table for the imx7d soc.
Adds support for the Toradex Colibri IMX7D board for openamp_rsc_table.

This is the first IMX7D board to be officially supported in a openamp_rsc_table sample.
It provides a template for porting other board by providing documentation and a base configuration for the SOC.

Note that this sample is supposed to be loaded using Linux RPROC as we only use the .elf file to boot it from Linux.
This makes sure Linux has fine control over the M4 core state.

Booting from U-boot is not directly supported.
It might be possible to boot from U-boot if ROMSTART_RELOCATION_ROM is disabled and BUILD_OUTPUT_BIN is enabled.

Tested on official Colibri IMX7D on Viola Carrier board running BSP 6.6.0 Minimal image with Linux Kernel 6.1.83.

ithinuel
ithinuel previously approved these changes May 18, 2024
@jlh-makeen jlh-makeen force-pushed the sample/openamp_rsc_table/colibri_imx7d branch 2 times, most recently from 16d6573 to 2972e30 Compare May 18, 2024 06:50
@jlh-makeen
Copy link
Contributor Author

Sorry for the noise, and force-pushes I had to fix typos in the comments 🙃

@jlh-makeen jlh-makeen force-pushed the sample/openamp_rsc_table/colibri_imx7d branch 2 times, most recently from eca2b23 to a86e909 Compare May 18, 2024 08:06
@jlh-makeen jlh-makeen requested a review from ithinuel May 18, 2024 10:24
iuliana-prodan
iuliana-prodan previously approved these changes May 20, 2024
@jlh-makeen jlh-makeen force-pushed the sample/openamp_rsc_table/colibri_imx7d branch from 229ff2f to d1ed834 Compare May 20, 2024 21:31
@jlh-makeen
Copy link
Contributor Author

jlh-makeen commented May 21, 2024

Apparently the latest rebase on the latest main fails CI on the frdm_k64f.
I tried building the failing script on the latest main and it still fails, so it's not related to this PR.

#73050

~/zephyrproject/zephyr$ git status
On branch main

~/zephyrproject/zephyr$ west build -p -b frdm_k64f samples/subsys/mgmt/mcumgr/smp_svr -T sample.mcumgr.smp_svr.udp
-- west build: making build dir /home/dev/zephyrproject/zephyr/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/dev/zephyrproject/zephyr/samples/subsys/mgmt/mcumgr/smp_svr
-- 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/dev/.cache/zephyr
-- Zephyr version: 3.6.99 (/home/dev/zephyrproject/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: frdm_k64f, qualifiers: mk64f12
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.5 (/home/dev/zephyr-sdk-0.16.5)
-- Found toolchain: zephyr 0.16.5 (/home/dev/zephyr-sdk-0.16.5)
-- Found Dtc: /home/dev/zephyr-sdk-0.16.5/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/dev/zephyrproject/zephyr/boards/nxp/frdm_k64f/frdm_k64f.dts
-- Generated zephyr.dts: /home/dev/zephyrproject/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/dev/zephyrproject/zephyr/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/dev/zephyrproject/zephyr/build/zephyr/dts.cmake
Parsing /home/dev/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/dev/zephyrproject/zephyr/boards/nxp/frdm_k64f/frdm_k64f_defconfig'
Merged configuration '/home/dev/zephyrproject/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf'
Merged configuration '/home/dev/zephyrproject/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/overlay-udp.conf'
Configuration saved to '/home/dev/zephyrproject/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/dev/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /home/dev/zephyr-sdk-0.16.5/arm-zephyr-eabi/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/dev/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
Load components for MK64F12:
driver_common component is included.
driver_reset component is included.
device_CMSIS component is included.
CMSIS_Include_core_cm component is included.
device_system component is included.
driver_rnga component is included.
driver_enet component is included.
driver_uart component is included.
driver_flash component is included.
driver_port component is included.
driver_sysmpu component is included.
-- Using ccache: /usr/bin/ccache
-- Including signing script: /home/dev/zephyrproject/zephyr/cmake/mcuboot.cmake
CMake Warning at /home/dev/zephyrproject/zephyr/cmake/mcuboot.cmake:28 (message):
  Neither CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE or
  CONFIG_MCUBOOT_SIGNATURE_KEY_FILE are set, the generated build will not be
  bootable by MCUboot unless it is signed manually/externally.
Call Stack (most recent call first):
  /home/dev/zephyrproject/zephyr/cmake/mcuboot.cmake:189 (zephyr_mcuboot_tasks)
  /home/dev/zephyrproject/zephyr/CMakeLists.txt:1904 (include)


-- Configuring done
-- Generating done
-- Build files have been written to: /home/dev/zephyrproject/zephyr/build
-- west build: building application
[1/230] Preparing syscall dependency handling

[3/230] Generating include/generated/version.h
-- Zephyr version: 3.6.99 (/home/dev/zephyrproject/zephyr), build: v3.6.0-4302-gde526632ae7a
[223/230] Building C object zephyr/subsys/mgmt/mcumgr/transport/CMakeFiles/subsys__mgmt__mcumgr__transport.dir/src/smp_udp.c.obj
FAILED: zephyr/subsys/mgmt/mcumgr/transport/CMakeFiles/subsys__mgmt__mcumgr__transport.dir/src/smp_udp.c.obj 
ccache /home/dev/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DCPU_MK64FN1M0VLL12 -DKERNEL -DK_HEAP_MEM_POOL_SIZE=0 -DNDEBUG -DPICOLIBC_LONG_LONG_PRINTF_SCANF -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/dev/zephyrproject/zephyr/include -I/home/dev/zephyrproject/zephyr/build/zephyr/include/generated -I/home/dev/zephyrproject/zephyr/soc/nxp/kinetis -I/home/dev/zephyrproject/zephyr/soc/nxp/kinetis/k6x/. -I/home/dev/zephyrproject/zephyr/soc/nxp/kinetis/common -I/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/util/include -I/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/include -I/home/dev/zephyrproject/zephyr/subsys/net/l2 -I/home/dev/zephyrproject/zephyr/subsys/net/conn_mgr/. -I/home/dev/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/home/dev/zephyrproject/zephyr/modules/cmsis/. -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/devices/MK64F12 -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/devices/MK64F12/drivers -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/common -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/rnga -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/enet -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/uart -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/flash -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/port -I/home/dev/zephyrproject/modules/hal/nxp/mcux/mcux-sdk/drivers/sysmpu -I/home/dev/zephyrproject/zephyr/modules/hal_nxp/. -I/home/dev/zephyrproject/modules/lib/zcbor/include -isystem /home/dev/zephyrproject/zephyr/lib/libc/common/include -Wshadow -fno-strict-aliasing -Os -imacros /home/dev/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft --sysroot=/home/dev/zephyr-sdk-0.16.5/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/dev/zephyrproject/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/dev/zephyrproject/zephyr/samples/subsys/mgmt/mcumgr/smp_svr=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/dev/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/dev/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT zephyr/subsys/mgmt/mcumgr/transport/CMakeFiles/subsys__mgmt__mcumgr__transport.dir/src/smp_udp.c.obj -MF zephyr/subsys/mgmt/mcumgr/transport/CMakeFiles/subsys__mgmt__mcumgr__transport.dir/src/smp_udp.c.obj.d -o zephyr/subsys/mgmt/mcumgr/transport/CMakeFiles/subsys__mgmt__mcumgr__transport.dir/src/smp_udp.c.obj -c /home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c: In function 'smp_udp_open_iface':
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c:275:13: warning: implicit declaration of function 'net_if_is_up' [-Wimplicit-function-declaration]
  275 |         if (net_if_is_up(iface)) {
      |             ^~~~~~~~~~~~
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c:277:21: warning: implicit declaration of function 'net_if_flag_is_set'; did you mean 'net_buf_frag_insert'? [-Wimplicit-function-declaration]
  277 |                 if (net_if_flag_is_set(iface, NET_IF_IPV4) &&
      |                     ^~~~~~~~~~~~~~~~~~
      |                     net_buf_frag_insert
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c:277:47: error: 'NET_IF_IPV4' undeclared (first use in this function)
  277 |                 if (net_if_flag_is_set(iface, NET_IF_IPV4) &&
      |                                               ^~~~~~~~~~~
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c:277:47: note: each undeclared identifier is reported only once for each function it appears in
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c:284:47: error: 'NET_IF_IPV6' undeclared (first use in this function)
  284 |                 if (net_if_flag_is_set(iface, NET_IF_IPV6) &&
      |                                               ^~~~~~~~~~~
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c: In function 'smp_udp_open':
/home/dev/zephyrproject/zephyr/subsys/mgmt/mcumgr/transport/src/smp_udp.c:339:17: warning: implicit declaration of function 'net_if_foreach' [-Wimplicit-function-declaration]
  339 |                 net_if_foreach(smp_udp_open_iface, NULL);
      |                 ^~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/dev/zephyrproject/zephyr/build

EDIT: this is now closed, rebased to retrigger CI :)

@jlh-makeen jlh-makeen force-pushed the sample/openamp_rsc_table/colibri_imx7d branch from d1ed834 to 487c5b6 Compare May 21, 2024 08:03
iuliana-prodan
iuliana-prodan previously approved these changes May 21, 2024
@jlh-makeen
Copy link
Contributor Author

@ithinuel Are you willing to give another look at this PR now that it passes CI ?

@jlh-makeen
Copy link
Contributor Author

@danieldegrasse Are you interested in reviewing this PR too ? 😄

ithinuel
ithinuel previously approved these changes May 23, 2024
@@ -9,6 +9,9 @@ zephyr_sources(
soc_clk_freq.c
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/ressource/resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have you found anything ? 🙃
I don't think I have misspelled resource in the sources have I ?

carlocaione
carlocaione previously approved these changes May 23, 2024
boards/toradex/colibri_imx7d/doc/index.rst Show resolved Hide resolved
boards/toradex/colibri_imx7d/doc/index.rst Show resolved Hide resolved
Comment on lines 383 to 411
#Copy zephyr_openamp_rsc_table.elf to /lib/firmware on your board
modprobe imx_rproc
modprobe virtio_rpmsg_bus
modprobe rpmsg_tty

#Request RPROC to load the M4 image
echo stop > /sys/class/remoteproc/remoteproc0/state
echo zephyr_openamp_rsc_table.elf > /sys/class/remoteproc/remoteproc0/firmware
echo start > /sys/class/remoteproc/remoteproc0/state

#dmesg will detail the boot process:
dmesg
[ 497.120499] remoteproc remoteproc0: stopped remote processor imx-rproc
[ 497.138938] remoteproc remoteproc0: powering up imx-rproc
[ 497.168735] remoteproc remoteproc0: Booting fw image zephyr_openamp_rsc_table.elf, size 1267076
[ 497.184826] rproc-virtio rproc-virtio.1.auto: assigned reserved memory node vdev0buffer0@90002000
[ 497.221395] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 497.233806] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x400
[ 497.236666] rproc-virtio rproc-virtio.1.auto: registered virtio0 (type 7)
[ 497.259822] remoteproc remoteproc0: remote processor imx-rproc is now up
[ 497.293913] virtio_rpmsg_bus virtio0: creating channel rpmsg-client-sample addr 0x401
[ 497.308388] rpmsg_client_sample virtio0.rpmsg-client-sample.-1.1025: new channel: 0x401 -> 0x401!
[ 497.337969] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x402

ls /dev | grep ttyRPMSG
ttyRPMSG0 -> used for zephyr shell interface
ttyRPMSG1 -> used for sample interface
Copy link
Collaborator

Choose a reason for hiding this comment

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

The below should provide better syntax coloring

Suggested change
#Copy zephyr_openamp_rsc_table.elf to /lib/firmware on your board
modprobe imx_rproc
modprobe virtio_rpmsg_bus
modprobe rpmsg_tty
#Request RPROC to load the M4 image
echo stop > /sys/class/remoteproc/remoteproc0/state
echo zephyr_openamp_rsc_table.elf > /sys/class/remoteproc/remoteproc0/firmware
echo start > /sys/class/remoteproc/remoteproc0/state
#dmesg will detail the boot process:
dmesg
[ 497.120499] remoteproc remoteproc0: stopped remote processor imx-rproc
[ 497.138938] remoteproc remoteproc0: powering up imx-rproc
[ 497.168735] remoteproc remoteproc0: Booting fw image zephyr_openamp_rsc_table.elf, size 1267076
[ 497.184826] rproc-virtio rproc-virtio.1.auto: assigned reserved memory node vdev0buffer0@90002000
[ 497.221395] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 497.233806] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x400
[ 497.236666] rproc-virtio rproc-virtio.1.auto: registered virtio0 (type 7)
[ 497.259822] remoteproc remoteproc0: remote processor imx-rproc is now up
[ 497.293913] virtio_rpmsg_bus virtio0: creating channel rpmsg-client-sample addr 0x401
[ 497.308388] rpmsg_client_sample virtio0.rpmsg-client-sample.-1.1025: new channel: 0x401 -> 0x401!
[ 497.337969] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x402
ls /dev | grep ttyRPMSG
ttyRPMSG0 -> used for zephyr shell interface
ttyRPMSG1 -> used for sample interface
#Copy zephyr_openamp_rsc_table.elf to /lib/firmware on your board
$ modprobe imx_rproc
$ modprobe virtio_rpmsg_bus
$ modprobe rpmsg_tty
#Request RPROC to load the M4 image
$ echo stop > /sys/class/remoteproc/remoteproc0/state
$ echo zephyr_openamp_rsc_table.elf > /sys/class/remoteproc/remoteproc0/firmware
$ echo start > /sys/class/remoteproc/remoteproc0/state
#dmesg will detail the boot process:
$ dmesg
[ 497.120499] remoteproc remoteproc0: stopped remote processor imx-rproc
[ 497.138938] remoteproc remoteproc0: powering up imx-rproc
[ 497.168735] remoteproc remoteproc0: Booting fw image zephyr_openamp_rsc_table.elf, size 1267076
[ 497.184826] rproc-virtio rproc-virtio.1.auto: assigned reserved memory node vdev0buffer0@90002000
[ 497.221395] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 497.233806] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x400
[ 497.236666] rproc-virtio rproc-virtio.1.auto: registered virtio0 (type 7)
[ 497.259822] remoteproc remoteproc0: remote processor imx-rproc is now up
[ 497.293913] virtio_rpmsg_bus virtio0: creating channel rpmsg-client-sample addr 0x401
[ 497.308388] rpmsg_client_sample virtio0.rpmsg-client-sample.-1.1025: new channel: 0x401 -> 0x401!
[ 497.337969] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x402
$ ls /dev | grep ttyRPMSG
ttyRPMSG0 -> used for zephyr shell interface
ttyRPMSG1 -> used for sample interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm gonna try that and rebuild the docs to see how it looks :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
image

Does indeed provide syntax coloring ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Solved

Add RPMSG/OpenAMP ressource table definition for the
IMX7d SOC.

Signed-off-by: Jérémy LOCHE - MAKEEN Energy <jlh@makeenenergy.com>
Add a prompt to ROMSTART_RELOCATION_ROM configs to allow
projects config file selection.
This simplifies the usage in samples/app for board porting.

Signed-off-by: Jérémy LOCHE - MAKEEN Energy <jlh@makeenenergy.com>
Enable openamp sample for Toradex Colibri IMX7D.
Tested with LTS BSP 6.6.0 on kernel 6.1.83.

Signed-off-by: Jérémy LOCHE - MAKEEN Energy <jlh@makeenenergy.com>
@jlh-makeen jlh-makeen force-pushed the sample/openamp_rsc_table/colibri_imx7d branch from 487c5b6 to a652555 Compare May 24, 2024 06:38
@jlh-makeen
Copy link
Contributor Author

Took a chance to rebase, correct the docs and tested building docs to check the updates.

Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

+1 for docs, thanks for addressing the requested changes!

@jlh-makeen
Copy link
Contributor Author

Any more comments on this PR ?
Else, an authorized user can step in and conclude the merge 😄

@danieldegrasse
Copy link
Collaborator

Assignee approval is needed for PRs to merge- @carlocaione can you refresh your +1 if everything looks good?

@jlh-makeen
Copy link
Contributor Author

jlh-makeen commented Jun 4, 2024

@carlocaione Hope you can get time to give a last look at this PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture area: IPC Inter-Process Communication area: Samples Samples platform: NXP MPU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants