sample: Add IMX IPM sample application
Add IMX IPM sample application. It reads the data sent to the Messaging Unit and sends them back. It has been tested on Udoo Neo Full board with the Cortex-A9 core running Linux and sending the data into the Messaging Unit A and the Cortex-M4 running this sample Zephyr application and reading the data from Messaging Unit B and sending it back for Linux side to read it from Messaging Unit A. Origin: Original Signed-off-by: Stanislav Poboril <stanislav.poboril@nxp.com>
This commit is contained in:
parent
15eace97c9
commit
7ca69b385d
5 changed files with 144 additions and 0 deletions
7
samples/subsys/ipc/ipm_imx/CMakeLists.txt
Normal file
7
samples/subsys/ipc/ipm_imx/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.8.2)
|
||||
|
||||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
project(NONE)
|
||||
|
||||
target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/drivers)
|
||||
target_sources(app PRIVATE src/main.c)
|
75
samples/subsys/ipc/ipm_imx/README.rst
Normal file
75
samples/subsys/ipc/ipm_imx/README.rst
Normal file
|
@ -0,0 +1,75 @@
|
|||
.. _ipm_imx:
|
||||
|
||||
i.MX IPM example
|
||||
################
|
||||
|
||||
Overview
|
||||
********
|
||||
This simple example can be used with multicore i.MX SoCs containing a
|
||||
Messaging Unit peripheral. It reads the received data from the Messaging Unit
|
||||
using the IPM and transmits it back unchanged. The information about
|
||||
the received data is printed to the console. When sending the data back,
|
||||
it blocks until the data are read by the remote side.
|
||||
|
||||
The i.MX Messaging Unit peripheral consists of four 32-bit transmit and receive
|
||||
registers. The sample uses the option :option:`CONFIG_IPM_IMX_MAX_DATA_SIZE_4`,
|
||||
which effectively creates four IPM channels. Selecting the option
|
||||
:option:`CONFIG_IPM_IMX_MAX_DATA_SIZE_8` or
|
||||
:option:`CONFIG_IPM_IMX_MAX_DATA_SIZE_16` would result in two 64-bit channels
|
||||
or a single 128-bit channel respectively.
|
||||
|
||||
Note that this is just a simple demo to demonstrate the i.MX IPM functionality
|
||||
and blocking sending of the data back is done in the interrupt handler, which
|
||||
would not be appropriate for a real world application.
|
||||
|
||||
Building and Running the Zephyr Code
|
||||
************************************
|
||||
|
||||
The sample requires that data are being sent by the remote core so it can echo
|
||||
it back. The other core is usually not running Zephyr but Linux on i.MX
|
||||
multicore processors.
|
||||
|
||||
This project outputs data to the console.
|
||||
It can be built as follows:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/subsys/ipc/ipm_imx
|
||||
:board: udoo_neo_full_m4
|
||||
:goals: build flash
|
||||
:compact:
|
||||
|
||||
Follow the instructions in the :ref:`udoo_neo_full_m4` board documentation
|
||||
for how to load the Zephyr binary to the desired core and execute it.
|
||||
|
||||
Building and Running the Linux Code
|
||||
***********************************
|
||||
|
||||
The remote code is in the form of a loadable Linux kernel module. It creates
|
||||
four character devices /dev/mu0 till /dev/mu3, which are used to read data from
|
||||
and write data into the Messaging Unit.
|
||||
|
||||
The remote code and the instructions how to build and run it are located at:
|
||||
|
||||
https://source.codeaurora.org/external/imxsupport/imx-mu/
|
||||
|
||||
Sample Output
|
||||
=============
|
||||
|
||||
Typing this in the Linux console:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# cat > /dev/mu0
|
||||
abcdefgh
|
||||
^D
|
||||
|
||||
Results in the following output on the Zephyr side:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
***** Booting Zephyr OS v1.12.0-291-g8cc508b *****
|
||||
IPM initialized, data size = 4
|
||||
ipm_callback: id = 0, data = 0x03323130
|
||||
ipm_callback: id = 0, data = 0x03353433
|
||||
ipm_callback: id = 0, data = 0x03383736
|
||||
ipm_callback: id = 0, data = 0x02000a39
|
5
samples/subsys/ipc/ipm_imx/prj.conf
Normal file
5
samples/subsys/ipc/ipm_imx/prj.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
CONFIG_STDOUT_CONSOLE=n
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_IPM=y
|
||||
CONFIG_IPM_IMX=y
|
||||
CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y
|
10
samples/subsys/ipc/ipm_imx/sample.yaml
Normal file
10
samples/subsys/ipc/ipm_imx/sample.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
sample:
|
||||
description: the sample reads the received data from the Messaging Unit
|
||||
using the IPM and transmits it back unchanged
|
||||
name: i.MX IPM sample
|
||||
tests:
|
||||
test:
|
||||
build_only: true
|
||||
filter: CONFIG_SOC_FAMILY_IMX
|
||||
platform_whitelist: udoo_neo_full_m4
|
||||
tags: samples ipm
|
47
samples/subsys/ipc/ipm_imx/src/main.c
Normal file
47
samples/subsys/ipc/ipm_imx/src/main.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2018, NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <misc/printk.h>
|
||||
#include <device.h>
|
||||
#include <ipm.h>
|
||||
|
||||
static struct device *ipm;
|
||||
|
||||
static void ipm_callback(void *context, u32_t id, volatile void *data)
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
u32_t *data32 = (u32_t *)data;
|
||||
|
||||
printk("%s: id = %u, data = 0x", __func__, id);
|
||||
for (i = 0; i < (CONFIG_IPM_IMX_MAX_DATA_SIZE / 4); i++) {
|
||||
printk("%08x", data32[i]);
|
||||
}
|
||||
printk("\n");
|
||||
|
||||
status = ipm_send(ipm, 1, id, (const void *)data,
|
||||
CONFIG_IPM_IMX_MAX_DATA_SIZE);
|
||||
if (status) {
|
||||
printk("ipm_send() failed: %d\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ipm = device_get_binding("MU_B");
|
||||
if (!ipm) {
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
ipm_register_callback(ipm, ipm_callback, NULL);
|
||||
ipm_set_enabled(ipm, 1);
|
||||
printk("IPM initialized, data size = %d\n",
|
||||
CONFIG_IPM_IMX_MAX_DATA_SIZE);
|
||||
|
||||
while (1) {
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue