Unfortunately, now the NXP Kinetis SDK V2.0 does not include Processor Expert support (see “First NXP Kinetis SDK Release: SDK V2.0 with Online On-Demand Package Builder“). But at the Lucerne University we are using more than 150 different custom Processor Expert components we would like to use with that new SDK. So how to make them working with the Kinetis SDK V2.0? Using a Processor Expert as “the mother of all components”:
Processor Expert is a plugin in Eclipse which is used to create embedded applications for Freescale and NXP microcontroller. It has the concept of software blocks and components: I add software components and blocks to the project, configure them and it will generate normal source code I can use in my applications. If you are unfamiliar with Processor Expert, have a read at Overview: Processor Expert.
The core of Processor Expert is a knowledge base: it knows about the pins, peripherals and clocks of the microcontroller used. For example when I add the UART or I2C component, it knows about the microcontroller capabilities for UART and I2C and can configure the component. That knowledge is in the ‘CPU’ component.
Component Development Environment: User components
I can create my Processor Expert components and we have created more than 150 at the university: from simple device drivers up to complex networking stacks) using the ‘Component Development Environment’ (CDE). These are ‘user’ components as they are not provided by NXP/Freescale.
Such user components can inherit from existing components. For example a user LED component can inherit functionality from the build-in BitIO
Or a user sensor can inherit functionality from an I2C or SPI component to use it to use a shared bus.
Until the advent of the Kinetis SDK, there were two types of APIs and components:
- ‘Non-LDD’ components or ‘Beans’: they the ‘original’ and first ones. A simple and straight forward API, easy to use.
- ‘LDD’ (Logical Device Driver’ components: these components are using mostly a ‘device handle’ in the API: in general, more powerful and usable in a multithreaded system, but more difficult to use especially in a bare metal system.
To support both types of APIs from a user component is possible, but requires a dual interface. Over time most of the McuOnEclipse components can support and use both types of components (see There is a Time and Date for both Worlds).
Kinetis SDK V1.x and Processor Expert
And then, there was yet another change with the introduction of the Kinetis SDK. Up to that time the Processor Expert components were producing full drivers source code: all the source files and header files. With the Kinetis SDK this changed: The Kinetis SDK is providing the driver source files. The Processor Expert component does not generate the driver code any more, it generates the configuration structures and files for it.
With some tweaking, I was finally able get some user components (e.g. the one for FreeRTOS to work with Kinetis SDK V1.x) because NXP still was providing CPU components for the devices supported by the Kinetis SDK, plus components e.g. for UART and GPIO. Because the SDK API is different from SDK V1.0 to V1.1 to V1.2 and V1.3, different components had to be used for each SDK version.
Kinetis SDK V2.0
The new Kinetis SDK V2.0 (see First NXP Kinetis SDK Release: SDK V2.0 with Online On-Demand Package Builder) made an even bigger change: From that version on there is no CPU component and no components e.g. for GPIO and UART: all is in plain C source files and header files. So how could I continue to use all the user components with the Kinetis SDK V2.0: using the SDK V2.0 drivers combined with the ease-of-use and configuration power of Processor Expert component?
The problem is this: there is no CPU component or the possibility to create a Processor Expert component for the Kinetis SDK. But I could use a Processor Expert project (for any Processor) to create source code, and use them in a normal Kinetis SDK V2.0 project J. That works pretty well for pure software drivers (like the Utility component) where there is no dependency on the hardware. But as soon as there is an interface to the hardware (timer, pin, peripheral, clock) I have to provide and use the API of the Kinetis SDK.
Kinetis SDK Component
So the McuOnEclipse components have to deal with multiple API’s: the component itself can already differentiate between non-LDD and LDD components. But for the SDK I need to tell the component(s) what kind of API I’m using. For this I have created the ‘KinetisSDK’ component were I can specify the SDK to be used:
Inside that component, I specify what SDK version shall be used:
💡 SDK v1.3 support is now experimental only.
From the other components I’m referencing that SDK component:
That way the component has all the information needed.
One problem remains: how to use the microcontroller peripherals from my user components? One really cool thing with these Processor Expert components is that they can inherit from an another component using a common interface. I can replace say the Processor Expert BitIO component with a GPIO component which uses the Kinetis SDK instead. The SDK_BitIO component is such a component: it is a replacement of the NXP provided BitIO component:
For the LDD and non-LDD components, because there is the CPU data base and knowledge base behind it, I can select the pin used from the available pins:
Because there is no CPU component data base for the SDK, the pin used has to be specified directly by the user:
Wherever I could use the BitIO component, I can pick and choose the SDK_BitIO component one: For example in the LED component I choose the SDK BitIO one:
That way a component can use the SDK version of a GPIO pin:
Processor Expert ‘Mother’ Project
To generate the code for the SDK project, I need a ‘mother’ project: a dummy Processor Expert project which I can use to configure the components and to generate the code. The generated code is then used in SDK project.
That ‘Mother’ project is used as the host for Procesor Expert and the components, and will generate the source files. In the above picture I’m linking to the Generated_Code folder from the SDK V2.0 project. With that approach I need to tell the compiler where it finds the header files in the project settings of the SDK V2.0 project:
Inside the Processor Expert ‘Mother’ project I have added my components and configured them to use the SDK V2.0 as a setting in the KinetisSDK component:
What to Exclude
The ‘mother’ Processor Expert has no knowledge about the SDK V2.0, except the things I tell it with my KinetisSDK component. Therefore there are as well files generated in the mother project which I cannot use. To avoid that they are included, I exclude them from the build:
Typical files to exclude are Cpu.c and PE_LDD.c:
Some Processor Expert have a PinSettings component in it by default: For SDK V2.0 projects disable it with the contex menu so it has the ‘x’ in the icon:
What is not covered
There are several things which are done in the Cpu component which now is not available with the SDK V2.0 approach outlined here. Instead, the ‘normal’ SDK V2.0 functions have to be used from the application code:
- Vector table: I have to set-up the interrupts and the interrupt table
- Pin Muxing: muxing of pins need to be performed as part of the initialization
- Port clocking: any clock gates need to be enabled
Because all the Freescale/NXP provided components (BitIO, InternalI2C, AsynchroSerial, …) are not open and I cannot edit them, they are still not usable for SDK V2.0 projects.
Processor Expert really makes my life easier and I’m more productive. I need to get there with using the SDK V2.0 as well, and re-using Processor Expert for that SDK definitely helps. I think I have found a reasonable way how to continue using Processor Expert with the Kinetis SDK V2.0. That approach works very well for the McuOnEclipse user component, but it does not allow me to use the closed Freescale/NXP components. Enabling my components for the SDK V2.0 is still work in progress (see “McuOnEclipse Components: 8-May-2016 Release“). If time permits, I could come up with some SDK V2.0 components for UART, I2C, SPI, USB, maybe?
I’m woring on a step-by-step tutorial to use the approach outlined in this article, so that tutorial should be published next, stay tuned!
I appreciate any comments on this ‘mother project’ approach.
Happy Mothering 🙂
- Projects source on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-K22F/FRDM-K22F_PEx_for_SDK_v2.0 and https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-K22F/FRDM-K22F_SDK_V2.0_PEx
- Latest McuOnEclipse Components release: McuOnEclipse Components: 8-May-2016 Release
- NXP Kinetis SDK: http://kex.nxp.com/
- Article about SDK V2.0: First NXP Kinetis SDK Release: SDK V2.0 with Online On-Demand Package Builder
- Overview about Processor Expert: https://mcuoneclipse.com/2015/10/18/overview-processor-expert/