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

samples/ipc/openamp: Introduce OpenAMP v2018.10 Remote Echo Sample #11934

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions samples/subsys/ipc/openamp/remote_echo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.8.2)
# Copyright (c) 2018 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

macro(set_conf_file)
if(EXISTS ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf)
set(CONF_FILE "prj.conf ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf")
else()
set(CONF_FILE "prj.conf")
endif()
endmacro()

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(openamp_remote_echo)

target_sources(app PRIVATE src/main.c)
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
142 changes: 142 additions & 0 deletions samples/subsys/ipc/openamp/remote_echo/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
.. _openAMP_remote_echo_sample:

OpenAMP Remote Echo Sample Application
######################################

Overview
********

This sample application demonstrates how to integrate coding and building of
OpenAMP with Zephyr. Currently this integration is specific to the i.MX7 and
i.MX6 SoCs and the Master side (Cortex-A) should be running Linux with the i.MX
RPMsg and mailbox driver.


Building the application
*************************

.. zephyr-app-commands::
:zephyr-app: samples/subsys/ipc/openamp/remote_echo
:board: colibri_imx7d_m4 warp7_m4 udoo_neo_full_m4
:goals: build flash


On the Linux side (Master) make sure you have the following Linux kernel config
options enabled:

.. code-block:: none

CONFIG_HAVE_IMX_MU=y
CONFIG_HAVE_IMX_RPMSG=y
CONFIG_RPMSG=y
CONFIG_RPMSG_VIRTIO=y
CONFIG_IMX_RPMSG_TTY=m
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any reason to enable IMX_RPMST_TTY driver?
Just check the .c file, it looks like it implements the echo, from meta-openamp, there is userspace demo which uses the kernel rpmsg_char driver, as @arnop2 mentioned, there is also kernel sample driver.
Here is the OpenAMP apps for the kernel sample driver: https://github.com/OpenAMP/open-amp/blob/master/apps/examples/rpmsg_sample_echo/rpmsg-sample-ping.c

It looks like only the virtio operation implementation is different, maybe you can reuse that application.



And make sure that you have the following Linux devitree nodes:

.. code-block:: none

i.MX7 - arch/arm/boot/dts/imx7s.dtsi:
mu: mu@30aa0000 {
compatible = "fsl,imx7d-mu", "fsl,imx6sx-mu";
reg = <0x30aa0000 0x10000>;
interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX7D_MU_ROOT_CLK>;
clock-names = "mu";
status = "okay";
};

rpmsg: rpmsg{
compatible = "fsl,imx7d-rpmsg";
status = "disabled";
};


i.MX6SX - arch/arm/boot/dts/imx6sx.dtsi:
mu: mu@02294000 {
compatible = "fsl,imx6sx-mu";
reg = <0x02294000 0x4000>;
interrupts = <0 90 0x04>;
status = "okay";
};

rpmsg: rpmsg{
compatible = "fsl,imx6sx-rpmsg";
status = "disabled";
};


BOARD - arch/arm/boot/dts/<board>.dts:
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;

rpmsg_reserved: rpmsg@8fff0000 {
No-map;
reg = <0x8fff0000 0x10000>;
};
};

&rpmsg {
vdev-nums = <1>;
reg = <0x8fff0000 0x10000>;
status = "okay";
};

&uart2 { // adjust to the Zephyr uart console number of your board
status = "disabled";
};


You can use this repository as a reference:

https://github.com/diegosueiro/linux-fslc/tree/4.9-1.0.x-imx


Open a serial terminal (minicom, putty, etc.) and connect the board with the
following settings for UART_2 for the colibri_imx7d_m4 and warp7_m4 boards, and
UART_5 for the udoo_neo_full_m4 board:

- Speed: 115200
- Data: 8 bits
- Parity: None
- Stop bits: 1

Here are the instructions to load and run Zephyr on M4 from A7 using u-boot.

Copy the compiled ``zephyr.bin`` to the first EXT partition of the SD card and
plug the SD card into the board. Power up the board and stop the u-boot
execution. Set the u-boot environment variables and run the ``zephyr.bin`` from
the TCML memory, as described here:

.. code-block:: console

setenv bootm4 'ext4load mmc 0:1 $m4addr $m4fw && dcache flush && bootaux $m4addr'
setenv m4tcml 'setenv m4fw zephyr.bin; setenv m4addr 0x007F8000'
setenv bootm4tcml 'run m4tcml && run bootm4'
run bootm4tcml
run bootcmd

In the Linux console load the imx_rpmsg_tty module:

.. code-block:: console

modprobe imx_rpmsg_tty

And in the Zephyr console you should see:

.. code-block:: console

***** Booting Zephyr OS zephyr-v1.13.0-2189-gdda6786 *****
Starting application thread!

OpenAMP remote echo demo started
echo message: hello world!

You can use microcom on the Linux side to send and receive the characters:

.. code-block:: console

microcom /dev/ttyRPMSG
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_IPM_IMX=y
CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_IPM_IMX=y
CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y
3 changes: 3 additions & 0 deletions samples/subsys/ipc/openamp/remote_echo/boards/warp7_m4.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_IPM_IMX=y
CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y
31 changes: 31 additions & 0 deletions samples/subsys/ipc/openamp/remote_echo/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2018 Diego Sueiro
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef COMMOM_H__
#define COMMON_H__

#define RPMSG_CHAN_NAME "rpmsg-openamp-demo-channel"

#if defined(CONFIG_SOC_SERIES_IMX7_M4) || defined(CONFIG_SOC_SERIES_IMX_6X_M4)
/* Values aligned with Linux Master side implementation */
#define SHM_START_ADDR 0x90040000
#define SHM_SIZE 0x40000
#define SHM_DEVICE_NAME "ddr.shm"

#define VRING_COUNT 2
#define VRING_TX_ADDRESS 0x8fff0000
#define VRING_RX_ADDRESS 0x8fff8000
#define VRING_ALIGNMENT 0x1000
#define VRING_SIZE 256

#define IPM_LABEL DT_IPM_IMX_MU_B_NAME
#define RPMSG_MU_CHANNEL 1

#else
#error "Current SoC not support"
#endif

#endif /* COMMON_H__ */
6 changes: 6 additions & 0 deletions samples/subsys/ipc/openamp/remote_echo/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_IPM=y
CONFIG_PLATFORM_SPECIFIC_INIT=n
CONFIG_HEAP_MEM_POOL_SIZE=4096
CONFIG_OPENAMP=y
10 changes: 10 additions & 0 deletions samples/subsys/ipc/openamp/remote_echo/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sample:
description: This app provides an example of how to integrate OpenAMP
with Zephyr.
name: OpenAMP remote echo example
tests:
test:
build_only: true
filter: CONFIG_SOC_FAMILY_IMX
platform_whitelist: colibri_imx7d_m4 warp7_m4 udoo_neo_full_m4
tags: samples ipm
Loading