sample: Add MCUX IPM sample application

Add MCUX IPM sample application. It can be run on lpcxpresso54114
board at the moment.

We first build the slave core image out of the remote/ dir than the
primary core image is build which includes the slave core image.

Origin: Original

Signed-off-by: Stanislav Poboril <stanislav.poboril@nxp.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Stanislav Poboril 2018-02-07 21:34:35 +01:00 committed by Kumar Gala
parent 5477ee4531
commit 37b7caa6bb
10 changed files with 189 additions and 2 deletions

View File

@ -32,7 +32,7 @@ Debugging
=========
You can debug an application in the usual way. Here is an example for the
:ref:`ipm_mcux` application.
:ref:`ipm-mcux-sample` application.
.. zephyr-app-commands::
:zephyr-app: samples/subsys/ipc/ipm_mcux
@ -52,7 +52,7 @@ serial port:
.. code-block:: console
***** BOOTING ZEPHYR OS v1.10.99 - BUILD: Feb 7 2018 20:32:27 *****
***** Booting Zephyr OS v1.11.0-764-g4e3007a *****
Hello World from MASTER! arm
Received: 1
...

View File

@ -0,0 +1,10 @@
.. _ipc_samples:
IPC Samples
###########
.. toctree::
:maxdepth: 1
:glob:
**/*

View File

@ -0,0 +1,20 @@
# Copyright (c) 2017, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
set(BOARD lpcxpresso54114_m4)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
include(ExternalProject)
ExternalProject_Add(
ipm_mcux_remote
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote
INSTALL_COMMAND "" # This particular build system has no install command
)
project(NONE)
target_sources(app PRIVATE src/main_master.c)
add_dependencies(core_m0_inc_target ipm_mcux_remote)

View File

@ -0,0 +1,43 @@
.. _ipm-mcux-sample:
Sample mailbox application
##########################
Overview
********
The :ref:`lpcxpresso54114` board has two core processors (Cortex-M4F
and Cortex-M0+). This sample application uses a mailbox to send messages
from one processor core to the other.
Requirements
************
- :ref:`lpcxpresso54114` board
Building and Running
********************
.. zephyr-app-commands::
:zephyr-app: samples/subsys/ipc/ipm_mcux
:board: lpcxpresso54114_m4
:goals: debug
Open a serial terminal (minicom, putty, etc.) and connect the board with the
following settings:
- Speed: 115200
- Data: 8 bits
- Parity: None
- Stop bits: 1
Reset the board and the following message will appear on the corresponding
serial port:
.. code-block:: console
***** Booting Zephyr OS v1.11.0-764-g4e3007a *****
Hello World from MASTER! arm
Received: 1
...
Received: 99

View File

@ -0,0 +1,7 @@
CONFIG_PRINTK=y
CONFIG_IPM=y
CONFIG_IPM_MCUX=y
CONFIG_SLAVE_CORE_MCUX=y
CONFIG_SLAVE_IMAGE_MCUX="${ZEPHYR_BINARY_DIR}/../ipm_mcux_remote-prefix/src/ipm_mcux_remote-build/zephyr/zephyr.bin"
CONFIG_TIMESLICE_SIZE=1
CONFIG_MAIN_STACK_SIZE=2048

View File

@ -0,0 +1,10 @@
# Copyright (c) 2017, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
set(BOARD lpcxpresso54114_m0)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)
target_sources(app PRIVATE src/main_remote.c)

View File

@ -0,0 +1,5 @@
CONFIG_STDOUT_CONSOLE=n
CONFIG_PRINTK=n
CONFIG_IPM=y
CONFIG_IPM_MCUX=y
CONFIG_PLATFORM_SPECIFIC_INIT=n

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2018, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <misc/printk.h>
#include <device.h>
#include <ipm.h>
struct device *ipm;
void ping_ipm_callback(void *context, u32_t id, volatile void *data)
{
ipm_send(ipm, 1, 0, (const void *)data, 4);
}
void main(void)
{
ipm = device_get_binding(MAILBOX_0_LABEL);
if (!ipm) {
while (1) {
}
}
ipm_register_callback(ipm, ping_ipm_callback, NULL);
ipm_set_enabled(ipm, 1);
while (1) {
}
}

View File

@ -0,0 +1,8 @@
sample:
description: Sample app that sends messages between the two cores on
the lpcxpresso54114 using a mailbox.
name: IPM MCUX Mailbox Sample
tests:
test:
platform_whitelist: lpcxpresso54114_m4
tags: samples ipm

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2018, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <misc/printk.h>
#include <device.h>
#include <ipm.h>
struct device *ipm;
int gcounter;
void ping_ipm_callback(void *context, u32_t id, volatile void *data)
{
gcounter = *(int *)data;
/* Show current ping-pong counter value */
printk("Received: %d\n", gcounter);
/* Increment on our side */
gcounter++;
if (gcounter < 100) {
/* Send back to the other core */
ipm_send(ipm, 1, 0, &gcounter, 4);
}
}
void main(void)
{
int first_message = 1; /* do not start from 0,
* zero value can't be sent via mailbox register
*/
printk("Hello World from MASTER! %s\n", CONFIG_ARCH);
/* Get IPM device handle */
ipm = device_get_binding(MAILBOX_0_LABEL);
if (!ipm) {
printk("Could not get IPM device handle!\n");
while (1) {
}
}
/* Register application callback with no context */
ipm_register_callback(ipm, ping_ipm_callback, NULL);
/* Enable the IPM device */
ipm_set_enabled(ipm, 1);
/* Send initial message with 4 bytes length*/
ipm_send(ipm, 1, 0, &first_message, 4);
while (1) {
}
}