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

i.MX IPM #8527

Merged
merged 4 commits into from
Nov 19, 2018
Merged

i.MX IPM #8527

merged 4 commits into from
Nov 19, 2018

Conversation

stanislav-poboril
Copy link
Collaborator

This pull request adds IPM support for i.MX via Messaging Unit peripheral. It contains driver shim and enables the Messaging Unit on i.MX 6SoloX SoC and Udoo Neo board. The pull request also adds the sample application, which echoes data back.
I have also written a sample Linux kernel module to be used to send the data from Linux and cooperate with the Zephyr application running on Cortex-M4. But I am not sure whether I should put it to a separate repository on Github and reference it - or I should put its source code into the Zephyr repository tree.

Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

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

Thanks for the documentation. Here are some recommended changes.


Overview
********
A simple example that can be used with multicore i.MX SoC's containing the
Copy link
Contributor

@dbkinder dbkinder Jun 25, 2018

Choose a reason for hiding this comment

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

Make this a complete sentence, and change SoC's to plural spelling:

This simple example can be used with multicore i.MX SoCs containing a
Messaging Unit peripheral.

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 4 32-bit transmit and receive
Copy link
Contributor

Choose a reason for hiding this comment

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

It reads better to spell out small numbers, so:

 ... consists of four 32-bit transmit ...

it blocks until the data are read by the remote side.

The i.MX Messaging Unit peripheral consists of 4 32-bit transmit and receive
registers. The sample uses the option CONFIG_IPM_IMX_MAX_DATA_SIZE_4, which
Copy link
Contributor

Choose a reason for hiding this comment

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

You can automatically create a link to the config option documentation by writing this as:

... uses the option :option:`CONFIG_IPM_IMX_MAX_DATA_SIZE_4`, which

The i.MX Messaging Unit peripheral consists of 4 32-bit transmit and receive
registers. The sample uses the option CONFIG_IPM_IMX_MAX_DATA_SIZE_4, which
effectively creates 4 IPM channels. Selecting the option
CONFIG_IPM_IMX_MAX_DATA_SIZE_8 or CONFIG_IPM_IMX_MAX_DATA_SIZE_16 would result
Copy link
Contributor

Choose a reason for hiding this comment

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

same here to have the option be a link to its documentation:

:option:`CONFIG_IPM_IMX_MAX_DATA_SIZE_4` or 
:option:`CONFIG_IPM_IMX_MAX_DATA_SIZE_16`

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 which would not
Copy link
Contributor

Choose a reason for hiding this comment

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

clarify with:

... is done in the interrupt handler, which would not ...


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 which would not
be appropriate for the real world application.
Copy link
Contributor

Choose a reason for hiding this comment

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

for a real world


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 code is not part of this Zephyr sample.
Copy link
Contributor

Choose a reason for hiding this comment

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

Start a new sentence:

multicore processors.  This remote core code is not ...

:goals: build flash
:compact:

Follow the instructions from board documentation on how to load the Zephyr
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to include a reference to the board documentation:

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have changed this, thank you.

Copy link
Contributor

@andrewboie andrewboie left a comment

Choose a reason for hiding this comment

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

Overall LGTM

@@ -0,0 +1,8 @@
sample:
description: TBD
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we fill this information in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added the name and description, thank you.

Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@stanislav-poboril
Copy link
Collaborator Author

I have a question about where to put the Linux part of the demo (which would run on the Cortex-A core).
Could it be put into the folder alongside with the Zephyr sample? But it would need to have some sort of license which is OK for both Linux and Zephyr. Would BSD-3-Clause license be OK for this Linux code (kernel module) to appear in the Zephyr repository?
Thanks

@MaureenHelm
Copy link
Member

The driver looks good, but can we unify the IPM samples into one sample with multiple build configurations?

@galak galak added area: IPC Inter-Process Communication platform: NXP NXP labels Jun 28, 2018
@stanislav-poboril
Copy link
Collaborator Author

The driver looks good, but can we unify the IPM samples into one sample with multiple build configurations?

There are three IPM examples:

  • ipm_mailbox (to be run on Intel Quark SE C1000)
    It uses platform specific things from ipm_quark_se.h.
  • ipm_mcux (to be run on NXP LPCXpresso54114)
    It uses Zephyr on both cores, prints to serial console from master core only.
  • ipm_imx (this pull request, to be run on NXP i.MX 6SoloX)
    It uses Zephyr on M4 core only and is intended to communicate with Linux on another core.
    We could unify this one with ipm_mcux, but the user would have to go into the remote subfolder and build from there. Also having the option to print to serial console is handy this time, unlike when running Zephyr on both cores.

So there is some opportunity to unify, but it could become more clumsy for the end user and having it unified could limit adding of features which are useful in one scenario only (for example with Linux demo, we need to reply data back in a blocking fashion, so Linux can read what was written to a device - other IPM samples have different functionality).

@MaureenHelm
Copy link
Member

I have a question about where to put the Linux part of the demo (which would run on the Cortex-A core).
Could it be put into the folder alongside with the Zephyr sample? But it would need to have some sort of license which is OK for both Linux and Zephyr. Would BSD-3-Clause license be OK for this Linux code (kernel module) to appear in the Zephyr repository?

@nashif @galak @carlescufi ^^^

@galak
Copy link
Collaborator

galak commented Jul 11, 2018

I have a question about where to put the Linux part of the demo (which would run on the Cortex-A core).
Could it be put into the folder alongside with the Zephyr sample? But it would need to have some sort of license which is OK for both Linux and Zephyr. Would BSD-3-Clause license be OK for this Linux code (kernel module) to appear in the Zephyr repository?

@nashif @galak @carlescufi ^^^

is this something that could live in the linux kernel itself in linux/samples/ ?

@stanislav-poboril
Copy link
Collaborator Author

I have a question about where to put the Linux part of the demo (which would run on the Cortex-A core).
Could it be put into the folder alongside with the Zephyr sample? But it would need to have some sort of license which is OK for both Linux and Zephyr. Would BSD-3-Clause license be OK for this Linux code (kernel module) to appear in the Zephyr repository?

@nashif @galak @carlescufi ^^^

is this something that could live in the linux kernel itself in linux/samples/ ?

I am not sure, it is related to the Zephyr sample of i.MX Messaging Unit peripheral.
I can put it into separate repository on GitHub, in case it cannot be in the Zephyr repository.

@MaureenHelm
Copy link
Member

The TSC agreed this week that it is ok to include the Linux part of the sample with a BSD-3 license in the Zephyr tree. The non-Apache license in the main part of the tree is acceptable in this case because it is a sample and will never be compiled into a Zephyr application. Will you please add it to the commit "sample: Add IMX IPM sample application"?

@stanislav-poboril
Copy link
Collaborator Author

The TSC agreed this week that it is ok to include the Linux part of the sample with a BSD-3 license in the Zephyr tree. The non-Apache license in the main part of the tree is acceptable in this case because it is a sample and will never be compiled into a Zephyr application. Will you please add it to the commit "sample: Add IMX IPM sample application"?

Yes, I am updating the documentation and will add it to the commit, but I have encountered one problem. If I use BSD license, compiling of the kernel module from example fails:

FATAL: modpost: GPL-incompatible module mu.ko uses GPL-only symbol 'platform_driver_unregister'

Therefore it seems that the example kernel module needs to have a dual license:

MODULE_LICENSE("Dual BSD/GPL");

Does it change anything, is it still ok to include in the Zephyr source tree?

@stanislav-poboril
Copy link
Collaborator Author

I have added the Linux kernel module code and updated the sample documentation to describe the Linux part. Note that the kernel module file samples/subsys/ipc/ipm_imx/linux/mu.c has dual BSD/GPL license otherwise it cannot build. Let me know if it is ok.

Copy link
Collaborator

@galak galak left a comment

Choose a reason for hiding this comment

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

I'm concerned about the zephyr_mu.patch. Is this something that can just get upstream'd to linux or the UDOOboard kernel?

@stanislav-poboril
Copy link
Collaborator Author

I'm concerned about the zephyr_mu.patch. Is this something that can just get upstream'd to linux or the UDOOboard kernel?

@galak, are you concerned because the patch is changing the GPL-ed files or because it depends on an exact commit in the outside repository?

The patch disables the kernel's usage of Messaging Unit and replaces it with the functionality needed by the demo application. Upstreaming to UDOObuntu kernel goes against their usage of Messaging Unit. Maybe the Zephyr example's Linux side should go into a different repository at the end. Or we could fork UDOObuntu kernel into a repository controlled by us (to avoid dependency on a single commit in a third party controlled repository) and commit our changes there.

@stanislav-poboril
Copy link
Collaborator Author

Hello, could this be merged as it is or should we move Linux kernel module and Linux kernel changes into a different repository and reference it? Or could we merge at least the first 3 commits, without the Linux example?

We have raised a request for UDOO Neo regarding the possibility to include our Linux kernel changes but haven't received any response yet.

I have rebased the PR recently to reflect changes in master (domain ID).

Thanks.

@codecov-io
Copy link

codecov-io commented Sep 5, 2018

Codecov Report

Merging #8527 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #8527   +/-   ##
=======================================
  Coverage   48.38%   48.38%           
=======================================
  Files         265      265           
  Lines       42193    42193           
  Branches    10137    10137           
=======================================
  Hits        20413    20413           
  Misses      17703    17703           
  Partials     4077     4077

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 644b31d...b9a8d37. Read the comment docs.

@galak
Copy link
Collaborator

galak commented Sep 12, 2018

The patch disables the kernel's usage of Messaging Unit and replaces it with the functionality needed by the demo application. Upstreaming to UDOObuntu kernel goes against their usage of Messaging Unit. Maybe the Zephyr example's Linux side should go into a different repository at the end. Or we could fork UDOObuntu kernel into a repository controlled by us (to avoid dependency on a single commit in a third party controlled repository) and commit our changes there.

How is UDOObuntu using the message unit? Trying to understand how this differs from what they are doing? Do you have a pointer to the UDOObuntu kernel repo?

@stanislav-poboril
Copy link
Collaborator Author

@galak, UDOObuntu version of kernel is here: https://github.com/UDOOboard/linux_kernel
There is the file https://github.com/UDOOboard/linux_kernel/blob/3.14-1.0.x-udoo/arch/arm/mach-imx/mu.c which handles Messaging Unit device. It is part of the kernel image, not a loadable module, so it cannot be easily unloaded. UDOObuntu uses M4 core in an Arduino-like fashion and uses MCC + MU to communicate between A9 and M4. I wanted to bypass this communication since there will be no "Arduino-like" code on M4 but Zephyr and wanted to demonstrate the basic MU functionality without the logic already present in the existing mu.c.

@galak
Copy link
Collaborator

galak commented Sep 12, 2018

@galak, UDOObuntu version of kernel is here: https://github.com/UDOOboard/linux_kernel
There is the file https://github.com/UDOOboard/linux_kernel/blob/3.14-1.0.x-udoo/arch/arm/mach-imx/mu.c which handles Messaging Unit device. It is part of the kernel image, not a loadable module, so it cannot be easily unloaded. UDOObuntu uses M4 core in an Arduino-like fashion and uses MCC + MU to communicate between A9 and M4. I wanted to bypass this communication since there will be no "Arduino-like" code on M4 but Zephyr and wanted to demonstrate the basic MU functionality without the logic already present in the existing mu.c.

I understand, we should focus on what upstream Linux supports or see what we can get supported there and not worry about the UDOOboard kernel being pretty old.

I see code for remoteproc on imx in the upstream kernel, not sure if there is a message unit driver or not in the upstream/mainline kernel.

diegosueiro added a commit to diegosueiro/zephyr that referenced this pull request Oct 18, 2018
This branch is the PR zephyrproject-rtos#8527 which was not upstreamed yet.
@stanislav-poboril
Copy link
Collaborator Author

The non-Apache-2.0 / Linux code has been removed from this PR. It will go into a new repository https://source.codeaurora.org/external/imxsupport/imx-mu/. Unfortunatelly I cannot push it myself - another person must do. Once the content is there, I will let you know so this can be finally merged.

@stanislav-poboril
Copy link
Collaborator Author

stanislav-poboril commented Nov 7, 2018

@galak The non-Apache-2.0 / Linux code has been moved to https://source.codeaurora.org/external/imxsupport/imx-mu/. I think the pull request could be merged now.

@diegosueiro
Copy link
Contributor

@galak ,

Any idea when this is going to be merged?

@diegosueiro diegosueiro mentioned this pull request Nov 14, 2018
Copy link
Collaborator

@galak galak left a comment

Choose a reason for hiding this comment

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

Inline comments:

Also (related to inline comments), these build warnings:
udoo_neo_full_m4.dts_compiled: Warning (simple_bus_reg): /soc/mu@4229C000: simple-bus unit address format error, expected "4229c000"
extract_dts_includes.py: WARNING: id field set in 'IMX MESSAGING UNIT', should be removed.

@@ -241,6 +241,18 @@
#gpio-cells = <2>;
status = "disabled";
};

mub:mu@4229C000 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make this 4229C000 -> 4229c000 (and the reg as well)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

#
---
title: IMX MESSAGING UNIT
id: nxp,imx-mu
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove id:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

tests:
test:
build_only: true
filter: CONFIG_SOC_IMX
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be filter: CONFIG_SOC_FAMILY_IMX

If we do that, do we need the platform_whitelist as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done - filter changed. The platform_whitelist is still needed, once @diegosueiro merges MU support into his work on i.MX7, platform_whitelist could be perhaps removed then.

@@ -72,27 +72,32 @@
#define CONFIG_UART_IMX_UART_3_BASE_ADDRESS NXP_IMX_UART_421EC000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_3_NAME NXP_IMX_UART_421EC000_LABEL
#define CONFIG_UART_IMX_UART_3_IRQ_NUM NXP_IMX_UART_421EC000_IRQ_0
#define CONFIG_UART_IMX_UART_3_IRQ_PRI NXP_IMX_UART_421EC000_IRQ_0_PRIORITY
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix up for CONFIG_ -> DT_ change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Add driver for i.MX Messaging Unit peripheral which can be used for
i.MX6SoloX, i.MX7D and other i.MX socs.

Origin: Original

Signed-off-by: Stanislav Poboril <[email protected]>
Add Messaging Unit B peripheral support for i.MX6SoloX soc so it can
use IMX IPM.

Origin: Original

Signed-off-by: Stanislav Poboril <[email protected]>
Enabled Messaging Unit B in Cortex-M4 core of Udoo Neo Full board
so it can use IMX IPM.

Origin: Original

Signed-off-by: Stanislav Poboril <[email protected]>
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 <[email protected]>
@galak galak merged commit 7ca69b3 into zephyrproject-rtos:master Nov 19, 2018
@stanislav-poboril stanislav-poboril deleted the imx6sx_mu branch November 19, 2018 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: IPC Inter-Process Communication platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants