Skip to content

Implement second core on LPC54114 #7161

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

Closed
wants to merge 7 commits into from
Closed

Implement second core on LPC54114 #7161

wants to merge 7 commits into from

Conversation

stanislav-poboril
Copy link
Collaborator

Introduces support for the Cortex-M0+ core of LPC54114 in addition to the existing support for the Cortex-M4 core. Introduces support for mailbox communication between the two cores. This PR replaces #5960, which has been abandoned due to RPMsg-Lite solution not chosen as the standard AMP solution in Zephyr. So it contains the same commits (except for RPMsg-Lite related ones) and it's also rebased to the recent code in master branch.

The new mailbox (ipm_mcux) driver could be possibly used by the chosen AMP solution - OpenAMP - to enable assymetric multiprocessing.

  • Adds support for the slave core (Cortex M0+) on LPC54114
  • Adds an IPM shim driver using the mcux mailbox driver
  • Adds IPM samples

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.

startup_LPC54114_cm4.S doesn't seem to exist in SDK MCUx 2.2.1

Segger J-Link firmware variant.

Before you start using Zephyr on the LPCXpresso54114, download and run
`LPCScrypt`_ to update the LPC-Link2 firmware to the latest version, currently
Copy link
Contributor

Choose a reason for hiding this comment

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

You have a link here without defining the target, with something like:

.. _LPCScrypt: https://www.nxp.com/support/developer-resources/software-development-tools/lpc-developer-resources-/lpc-microcontroller-utilities/lpcscrypt-v1.8.2:LPCSCRYPT

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, should be fixed now.

=========

You can debug an application in the usual way. Here is an example for the
:ref:`ipm_mcux` 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 this :ref: to work, your pull request also needs to create a .rst doc in samples/subsys/ipc/ipm_mcux with a label ipm_mcux. (No such document exists.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, fixed.

``Firmware_JLink_LPC-Link2_20160923.bin``. Serial communication problems, such
as dropping characters, have been observed with older versions of the firmware.

The code for the secondary core is linked into primary core binary file.
Copy link
Contributor

Choose a reason for hiding this comment

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

into the primary

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, fixed.

as dropping characters, have been observed with older versions of the firmware.

The code for the secondary core is linked into primary core binary file.
Startup code copies secondary core's code into appropriate location in RAM
Copy link
Contributor

Choose a reason for hiding this comment

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

copies the secondary core's code into an appropriate

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, fixed.

@galak galak added area: ARM ARM (32-bit) Architecture area: Boards platform: NXP NXP EXT Has change or related to ext/ (obsolete) labels Apr 23, 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.

Various areas that need cleaning up.

#include <fsl_common.h>
#include <fsl_lpc_iocon.h>

#define IOCON_PIO_DIGITAL_EN 0x80u
Copy link
Collaborator

Choose a reason for hiding this comment

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

these defines should be somewhere common.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, fixed. This was not in MCUxpresso SDK device header file, but I have added the file pin_mux.h from SDK to ext. It defines these things.


***** BOOTING ZEPHYR OS v1.10.99 - BUILD: Feb 7 2018 20:32:27 *****
Hello World from MASTER! arm
Received: 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

The Recieved:1 ... should probalby be removed from here.

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 replaced by

Received: 1
...
Received: 99

to not include all lines.

type: mcu
arch: arm
ram: 64
flash: 256
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be 64 since its pointing to sram1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, fixed.

name: NXP LPCXpresso54114
type: mcu
arch: arm
ram: 64
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be 32 since its pointing at sram2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, fixed.

#include <soc.h>

/* Red LED */
#define RED_GPIO_NAME CONFIG_GPIO_MCUX_LPC_PORT0_NAME
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice if this moved to being in dts.

Copy link
Collaborator Author

@stanislav-poboril stanislav-poboril Apr 24, 2018

Choose a reason for hiding this comment

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

Blinky demo no longer builds even for master core on master branch.
I have moved it into DTS but commented it out. Need to add missing gpio sections in soc DTS.
I have tried to add it but haven't been able to make it work.
So blinky demo still does not work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

leds are fixed and in dts now

@@ -17,7 +17,7 @@
};

chosen {
zephyr,sram = &sram1;
zephyr,sram = &sram0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

add a comment in commit message about this 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.

Ok, modified commit message.

@@ -6,8 +6,6 @@

/* SoC level DTS fixup file */

#define CONFIG_NUM_IRQ_PRIO_BITS ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do this as:

#if defined(CONFIG_SOC_LPC54114_M0)
#define CONFIG_NUM_IRQ_PRIO_BITS                ARM_V6M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
#else 
#define CONFIG_NUM_IRQ_PRIO_BITS                ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
#endif

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, changed.

; * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
; */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really sure the value of having this imported from the SDK. Can you guys just do a version that is the arch/soc code that is Apache licensed.

There isn't really anything unique here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not changed yet. The file content is copied from SDK and the license text says it has to stay there. So would have to rewrite it with different implementation actually. Otherwise our license scans on SDK would probably detect this match with Zephyr.
Why is it necessary to not have it in ext and have it in soc with Apache license?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well for one, we probably want a solution that is not just NXP specific. We have other SoCs that will probably support multiple cores and we want something that works for all of them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed commit message as the file is actually from SDK 2.2.0, without Clear BSD license.

@stanislav-poboril
Copy link
Collaborator Author

startup_LPC54114_cm4.S doesn't seem to exist in SDK MCUx 2.2.1

I don't have a 2.2.1 SDK package, but I have downloaded 2.3.1 and it is there in devices/LPC54114/gcc/startup_LPC54114_cm4.S. The file amp_startup.S leaves stuff not necessary in Zephyr out, but the rest is based on the SDK file. I will change the commit message to mention mcux 2.3.1 instead of 2.2.1.

@galak
Copy link
Collaborator

galak commented Apr 24, 2018

I don't have a 2.2.1 SDK package, but I have downloaded 2.3.1 and it is there in devices/LPC54114/gcc/startup_LPC54114_cm4.S. The file amp_startup.S leaves stuff not necessary in Zephyr out, but the rest is based on the SDK file. I will change the commit message to mention mcux 2.3.1 instead of 2.2.1.

I think it should be 2 commits, include saying 2.3.1. So first import the file exactly as is from the SDK, than modify it in a separate commit for what we need in Zephyr.

@stanislav-poboril
Copy link
Collaborator Author

I think it should be 2 commits, include saying 2.3.1. So first import the file exactly as is from the SDK, than modify it in a separate commit for what we need in Zephyr.

Separated into two commits.

Overview
********

This application will use mailbox to send messages from one processor core
Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

The :ref:`lpcxpresso54114` board has two core processors (M4F and dual M0).
This sample application uses a mailbox to send messages from one processor core
to the other.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

***** Booting Zephyr OS v1.11.0-764-g4e3007a *****
Hello World from MASTER! arm
Received: 1
Received: 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do the same here with:

Received 1
...
Received 99

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

@@ -0,0 +1,138 @@
.. _ipm-mcux-sample:
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a new documentation area in the samples, you'll need to create an index/TOC page named samples/subsys/ipc/ipc.rst with the contents:

.. _ipc_samples:

IPC Samples
###########

.. toctree::
   :maxdepth: 1
   :glob:

   **/*

(This will fix the "not included in any TOC" error.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added. Is there a way to validate the rst docs myself before pushing? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. You can generate the documentation locally by following the instructions in http://docs.zephyrproject.org/README.html. In GitHub, you can get an approximation of what a document will look like by clicking on the view button -- you'll see the rendered reST format, but the Sphinx directives won't be recognized.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks.

@stanislav-poboril
Copy link
Collaborator Author

Thank you for your comments. Everything should fixed now (except for the external file incbin.S which will stay external). Could you review once more and approve or have further comments? Thanks.

*/

/* ---------------------------------------------------------------------------------------*/
/* @file: startup_LPC54114_cm4.S */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we import the version from SDK 2.3.0 as its BSD licensed and not BSD-clear licensed

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.

Some additional review comments/cleanups.

string
default lpc54114_m0

config CPU_CORTEX_M_HAS_VTOR
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 a select under config SOC_LPC54114_M0

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.

@@ -23,6 +23,17 @@ extern "C" {
#include <device.h>
#include <misc/util.h>
#include <fsl_common.h>

/* Address of RAM, where the image for core1 should be copied */
Copy link
Collaborator

Choose a reason for hiding this comment

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

The addresses seem like the should be board specific.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The address should be shared by two boards in fact: the M4 version and M0 version. But these are separate boards in Zephyr now, so unfortunately there will stay some sort of duplication. But for sure it can be done at least better than now.

@@ -5,7 +5,12 @@ string(TOUPPER ${CONFIG_SOC} MCUX_DEVICE)
if("${MCUX_DEVICE}" STREQUAL "LPC54114")
set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm4)
else()
set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
if("${MCUX_DEVICE}" STREQUAL "LPC54114_M0")
set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm0plus)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should ident these for if block

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@@ -35,6 +35,8 @@

static ALWAYS_INLINE void clkInit(void)
{

#ifdef CONFIG_SOC_LPC54114
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wonder if this would be a bit more clear as #ifndef CONFIG_SOC_LPC54114_M0, or do we have a CONFIG_SOC_LPC54114_M4 define?

Maybe a comment, about doing this only on the master/m4

Copy link
Member

Choose a reason for hiding this comment

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

Do we want to change the name of the original soc to append _M4 so it's explicit?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think renaming to _M4 would be good.

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 rename to _M4.

Note that SOCs are _M4 and _M0 now, while board has no suffix for M4 configuration and board with M0 configuration has suffix for M0. This is because the name of the board already existed without _M4 suffix before.


enable_language(C ASM)

zephyr_sources_ifdef(CONFIG_SOC_LPC54114 devices/${MCUX_DEVICE}/amp_startup.S)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason not to keep the same path & filename as the SDK?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, kept the same name.

@@ -32,4 +32,12 @@ config USART_MCUX_LPC

endif # SERIAL

config SLAVE_CORE_MCUX
Copy link
Member

Choose a reason for hiding this comment

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

This needs to move to Kconfig.soc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved.

/* Specify the memory areas */
MEMORY
{
m_core1_image (RX) : ORIGIN = 0x00030000, LENGTH = 0x00010000
Copy link
Member

Choose a reason for hiding this comment

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

Can these values come from dts?

@@ -35,6 +35,8 @@

static ALWAYS_INLINE void clkInit(void)
{

#ifdef CONFIG_SOC_LPC54114
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to change the name of the original soc to append _M4 so it's explicit?

/* reduced from 0x40000 to 0x30000
* to leave room for secondary core
*/
reg = <0 0x30000>;
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to use partitions instead, like we do for mcuboot?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The partition names currently available for mcuboot might be a little misleading for this case, but I can try to change it.

config PLATFORM_SPECIFIC_INIT
bool
prompt "Enable platform (SOC) specific startup hook"
default n
Copy link
Member

Choose a reason for hiding this comment

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

Some help text, here, would be very nice, since this will be a generic Cortex-M K-option (even though the option is self-descriptive)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a simple help text.

@@ -7,7 +7,8 @@

config SOC_SERIES_LPC54XXX
bool "LPC LPC54xxx Series MCU"
select CPU_CORTEX_M4
select CPU_CORTEX_M
Copy link
Member

Choose a reason for hiding this comment

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

Aren't CPU_CORTEX_M explicit selections obsolete, now @galak ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed CPU_CORTEX_M, as it is automatically selected by including CPU_CORTEX_M4 or CPU_CORTEX_M0PLUS elsewhere.

default n
depends on IPM && HAS_MCUX
help
Driver for MCUX mailbox
Copy link
Member

Choose a reason for hiding this comment

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

Fix indentation for help message

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

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.

Doc changes look OK. Thanks.

The new file startup_LPC54114_cm4.S is a copy of the file
devices/LPC54114/gcc/startup_LPC54114_cm4.S from mcux 2.2.0.
It contains platform specific initialization code for both cores.

Origin: NXP MCUXpresso SDK 2.2.0
URL: mcux.nxp.com
Maintained-by: External

Signed-off-by: Stanislav Poboril <[email protected]>
The instructions performed by standard Zephyr startup files are removed
from the file startup_LPC54114_cm4.S. Introduced the section
_PlatformInit which will be called when platform specific initialization
is needed.

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.

The primary core changed to use sram0 instead of sram1 now.
The secondary core uses sram1 for its code and sram2 as a sram.

Origin: Original

Signed-off-by: Stanislav Poboril <[email protected]>
Add driver for MCUX mailbox which can be used for lpcxpresso54114
and other lpc and kinetis 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.0
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]>
@stanislav-poboril
Copy link
Collaborator Author

This PR is replaced by #7558 (already merged) and #7560.

@stanislav-poboril stanislav-poboril deleted the lpc54114_multicore branch May 21, 2018 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture area: Boards EXT Has change or related to ext/ (obsolete) platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants