-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Introduce OpenAMP/RPMsg-Lite on LPC54114 #5960
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5960 +/- ##
==========================================
- Coverage 43.77% 43.76% -0.01%
==========================================
Files 485 485
Lines 54660 54660
Branches 10690 10690
==========================================
- Hits 23926 23924 -2
- Misses 30594 30596 +2
Partials 140 140
Continue to review full report at Codecov.
|
drivers/ipm/ipm_mcux_mailbox.c
Outdated
@@ -0,0 +1,173 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file looks like an earlier version of ipm_mcux.c, it can be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
env_lock_mutex(lock); | ||
|
||
assert(0 <= isr_counter); | ||
if (!isr_counter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding braces to this if
, to make it clearer what goes inside it. Same goes for platform_init_interrupt()
in the LPC5410x platform file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. However the files come from RPMsg-Lite project version 1.2.0. So it will be fixed in the next release of RPMsg-Lite and then it can get into Zephyr. I would not change the file in Zephyr now in order for the file content to be the same as in referenced version of RPMsg-Lite.
{ | ||
switch (RL_GET_LINK_ID(vq_id)) | ||
{ | ||
case 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is only link ID 0 supported here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LPC54114 has two cores so there is an expectation that most of the applications would use a single link there. I am going to replace 0 with RL_PLATFORM_LPC5411x_M4_M0_LINK_ID. If somebody wants to use multiple instances of RPMsg-Lite, he or she has to define more link IDs and implement it in the switch statement.
I think the external library should be in |
@pizi-nordic FYI |
ext/multicore/CMakeLists.txt
Outdated
@@ -0,0 +1 @@ | |||
add_subdirectory_ifdef(MULTICORE_RPMSG_LITE rpmsg_lite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be in ext/lib/ipc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I can move ext/multicore/rpmsg_lite/
into ext/lib/ipc/rpmsg_lite
. It will match naming of samples subfolders then.
arch/arm/core/cortex_m/prep_c.c
Outdated
!defined(CONFIG_XIP) && (CONFIG_SRAM_BASE_ADDRESS != 0) | ||
#if defined(CONFIG_CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is going to work. CONFIG_CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP
doesn't mean it has a VTOR, but rather a mechanism to remap its table, whatever that might be. In particular I think the STM32F0 does something different than VTOR for this. @b0661, @simple2017 can you weigh in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is that you redefine the weak function relocate_vector_table
in your soc.c
like the STM32F0 code has done, in order to have your own particular version that uses VTOR. I think that might be the simplest. At the same time I do realize that VTOR is the standard relocation mechanism of an M0+, so it would make sense to have it in the generic prep_c.c
. I'm just not sure this is not gonna break another chip's vector table handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the relevant STM32F0 commit if you want to take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should merge this PR and you could then simply set CPU_CORTEX_M_HAS_VTOR
for this IC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this gonna work on STM32F0, check here as @carlescufi mentioned. Its not really a offset register but a remap address 0x2000_0000 to address 0x0000_0000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I will remove the changes of prep_c.c
from this PR and add CPU_CORTEX_M_HAS_VTOR
for LPC54414's M0+ core instead. Once the other PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. The PR is merged now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, this commit: lpc: Add code to include slave core binary for lpc54114 from mcux 2.2.1
Should probably be prefixed with ext
instead of lpc
yeah, or at least ext/lib/multicore/... |
Ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit that imports the startup code for AMP doesn’t exactly match the SDK, also we are importing it from SDK 2.3.0 and the reset of the code is from SDK 2.2.1. So can we sync this with SDK 2.3.0 and either match the SDK or comment about the change of name, etc in commit message/readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Various code review comments.
@@ -57,6 +60,10 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__reset) | |||
*/ | |||
SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start) | |||
|
|||
#if defined(CONFIG_PLATFORM_SPECIFIC_INIT) | |||
bl _PlatformInit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to call _PlatformInit this early? Can't we just call it from nxp_lpc54114_init(). Also do we really need this implemented in ASM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The developer of RPMsg-Lite told me it needs to be run while the code executes from address 0x0000000. This comment may give some information:
/* Setup the reset handler pointer (PC) and stack pointer value. * This is used once the second core runs its startup code. * The second core first boots from flash (address 0x00000000) * and then detects its identity (Cortex-M0, slave) and checks * registers CPBOOT and CPSTACK and use them to continue the * boot process. * Make sure the startup code for current core (Cortex-M4) is * appropriate and shareable with the Cortex-M0 core! */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not related to RPMsg-Lite, but to the architecture of LPC54114.
The secondary core in LPC54114 SOC needs to have a possibility of platform specific code in startup and cannot only use the generic cortex_m/reset.S
@galak Can you develop on why you disagree with this? Do you think other platforms may not need this?
drivers/ipm/ipm_mcux.c
Outdated
struct device *dev = arg; | ||
struct mcux_mailbox_data *data = dev->driver_data; | ||
mailbox_cpu_id_t cpu_id; | ||
#if defined(__CM4_CMSIS_VERSION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than having multiple ifdef blocks, can we just do something at the top of this file like:
#if defined(__CM4_CMSIS_VERION)
#define MAILBOX_ID kMAILBOX_CM4
#else
#define MAILBOX_ID kMAILBOX_CM0
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -22,3 +22,10 @@ config IPM_QUARK_SE_MASTER | |||
Sets up the initial interrupt mask and clears out all | |||
channels. Should be turned on for one CPU only. | |||
|
|||
config IPM_MCUX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be IPM_MCUX_LPC (fixup below as well if we make this LPC specific)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for all SoC's which have HAS_MCUX defined: LPC, Kinetis, i.MX. So it is not only for LPC.
Fine with me |
Before you start using Zephyr on the LPCXpresso54114, download and run | ||
`LPCScrypt`_ to update the LPC-Link2 firmware to the latest version. Serial | ||
communication problems, such as dropping characters, have been observed with | ||
older versions of the firmware. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you provide a version number here (what will "older versions" mean in 3-6 months)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version is in the primary core doc in master branch now. The secondary core board doc has been updated to reference this main doc.
You can debug an application in the usual way. Here is an example for the | ||
:ref:`hello_world` application. | ||
|
||
.. zephyr-app-commands:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the commit message you mentioned an "extra manual step required between running cmake and make". Does that need to be addressed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need for manual step has been eliminated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea. You might then want to update the commit message that says the manual step is needed.
The new file amp_startup.S is freely based on parts of the file startup_LPC54114_cm4.S from mcux 2.2.1. It contains platform specific initialization code for both cores. Origin: NXP MCUXpresso SDK 2.2.1 URL: mcux.nxp.com Maintained-by: External Signed-off-by: Stanislav Poboril <[email protected]>
Add soc configuration support and dts files for nxp_lpc54xxx_m0. Adjusted nxp_lpc54xxx soc linker, configuration and dts files for the presence of slave core. Added startup hook support in ARM Cortext-M arch to allow the initialization of slave core from startup and reset. Origin: Original Signed-off-by: Stanislav Poboril <[email protected]>
Add lpcxpresso54114_m0 board dts, yaml, fixup, docs, configuration, pinmux and header files. Origin: Original Signed-off-by: Stanislav Poboril <[email protected]>
Add driver for MCUX mailbox which can be used for lpcxpresso54114 and other lpc, kinetis and iMX socs. Origin: Original Signed-off-by: Stanislav Poboril <[email protected]>
Add ext code to be able to include image of slave core in primary core image. Origin: NXP MCUXpresso SDK 2.2.1 URL: mcux.nxp.com Maintained-by: External Signed-off-by: Stanislav Poboril <[email protected]>
Add MCUX IPM sample application. It can be run on lpcxpresso54114 board at the moment. First, the slave core image has to be built from samples/subsys/ipc/ipm_mcux/remote/. Then, buid primary core image from samples/subsys/ipc/ipm_mcux/master/. Origin: Original Signed-off-by: Stanislav Poboril <[email protected]>
Add RPMsg-Lite version 1.2.0 to ext. Origin: RPMsg-Lite License: BSD 3-Clause URL: https://github.com/codeauroraforum/rpmsg-lite commit: 3ed2d34376a2d1ec04f59e4a89e201d820b5d5e5 Purpose: Introduction of lightweight implementation of the Remote Processor Messaging (RPMsg) protocol to Zephyr. Maintained-by: External Signed-off-by: Stanislav Poboril <[email protected]>
Add RPMsg-Lite sample application. It can be run on lpcxpresso54114 board at the moment. The application sends messages from slave to primary core. First, the slave core image has to be built from samples/subsys/ipc/rpmsg_lite/remote/. Then, buid primary core image from samples/subsys/ipc/rpmsg_lite/master/. Origin: Original Signed-off-by: Stanislav Poboril <[email protected]>
AMP startup is freely based on parts of SDK code, I have updated the commit message. |
Thanks for the comments. I have made some updates internally, @MaureenHelm will update this PR, then you could review again. |
Done |
enable_language(C ASM) | ||
|
||
target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/drivers) | ||
target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/samples/subsys/ipc/ipm_mcux/master/src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This include directory is not needed.
|
||
target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/samples/subsys/ipc/rpmsg_lite) | ||
target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/drivers) | ||
target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/samples/subsys/ipc/rpmsg_lite/master/src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This include directory is not needed.
This commit adds a sample application using OpenAMP for remote procedure calls on the LPCXpresso54114. It is adapted from the RPMsg-Lite sample application added in PR zephyrproject-rtos#5960, and uses the IPM driver to provide interprocessor interrupts. Instructions for how to compile the application, including OpenAMP and libmetal is provided in the README.md file in the application's toplevel directory. Signed-off-by: Kristian Klomsten Skordal <[email protected]>
This commit adds a sample application using OpenAMP for remote procedure calls on the LPCXpresso54114. It is adapted from the RPMsg-Lite sample application added in PR zephyrproject-rtos#5960, and uses the IPM driver to provide interprocessor interrupts. Instructions for how to compile the application, including OpenAMP and libmetal is provided in the README.md file in the application's toplevel directory. Signed-off-by: Kristian Klomsten Skordal <[email protected]>
This commit adds a sample application using OpenAMP for remote procedure calls on the LPCXpresso54114. It is adapted from the RPMsg-Lite sample application added in PR zephyrproject-rtos#5960, and uses the IPM driver to provide interprocessor interrupts. Signed-off-by: Kristian Klomsten Skordal <[email protected]> Signed-off-by: Kumar Gala <[email protected]>
This commit adds a sample application using OpenAMP for remote procedure calls on the LPCXpresso54114. It is adapted from the RPMsg-Lite sample application added in PR #5960, and uses the IPM driver to provide interprocessor interrupts. Signed-off-by: Kristian Klomsten Skordal <[email protected]> Signed-off-by: Kumar Gala <[email protected]>
Introduces support for Open Asymmetric Multiprocessing (OpenAMP) using RPMsg-Lite, which is a lightweight implementation of the protocol targeting small memory footprint devices. Support for eRPC is not yet included due to build system issues with c++, as well as to limit the scope of changes in a single PR.
There is an outstanding issue when building the master application, such that the slave core binary cannot be found by the assembly files (incbin.S). This issue occurs only with Zephyr SDK toolchain, but not ARM gcc.
Therefore an extra manual step required between running cmake and make of the master application:
Fixes #3065