MQX with KSDK and Processor Expert

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX with KSDK and Processor Expert

10,143 Views
dereksnell
NXP Employee
NXP Employee

The Freescale MQX RTOS is transitioning to use the Kinetis Software Development Kit (KSDK), and there is a Beta release of MQX for KSDK available now.  See Beta version of MQX RTOS for Kinetis SDK - Now Available.  Processor Expert (PEx) is a code generation and configuration tool that is already integrated with KSDK.  This post shows how PEx can be used with MQX for KSDK.  This method is good for simple MQX projects just needing the kernel.  PEx simplifies the project by adding the KSDK and MQX kernel files directly to the project. 


These steps are written using MQX for KSDK v1.0.0 Beta.  The Kinetis Design Studio (KDS) v1.1.1 toolchain is used, with example project attached.  KDS has PEx integrated in the IDE and is used for this example, although the stand-alone tool Processor Expert Driver Suite v10.4 can be used with other toolchains.  For help getting started with PEx, check out the videos at Processor Expert Tools in CodeWarrior 10.3 - Training Videos.


MQX for KSDK does not yet have any PEx projects installed with the release, but PEx can be used to create a project from scratch.  First, ensure to follow the KDS release notes to have the KSDK plugins installed.  Also, refer to the MQX documentation to ensure the latest MQX plugins are installed in KDS as well.


Now create a new project using the menu File->New.  The New Project Wizard will walkthrough the project creation.  Be sure to specify a Kinetis device that is supported by the KSDK, refer to KSDK release notes to see the available list of devices.  For the "Rapid Application Development" screen, be sure to check both Kinetis SDK and Processor Expert.

14711_14711.jpgRapid_Development.jpg


Finish creating the project.  After the project is created, use the Component Library to add the components MQX_KSDK and MQX_KSDK_Task.  The project needs at least one MQX_KSDK_Task component, and more can be added for multiple tasks in the application.

14712_14712.jpgMQX Components.jpg


After adding the MQX components, the Components View will show them included in the project.  The MQX_KSDK properties can be customized if needed using the Component Inspector View.  Each Task should be customized using the properties for the MQX_KSDK_Task components.

14713_14713.jpgProject Components.jpg


MQX uses stdin/stdout typically through a UART for IO functions like printf().  This can also be easily customized for the board being used.  In this example, the project is written for the FRDM-K64F board, and uses the UART connected to the OpenSDA USB COM port.  That board uses UART0 on pins PTB16 and PTB17.  To configure in PEx, select the fsl_uart component, which is included as a sub-component under the MQX_KSDK component.  Then, in the Component Inspector, change the Properties to use the needed UART peripheral and specify the pins.  The other UART properties can also be customized if needed.

14714_14714.jpgUART Settings.jpg


Other PEx components can be added as well to configure the peripheral drivers.  Once the PEx configuration is complete, generate the code by clicking the Generate Code button in the Components View.  This will generate the KSDK and MQX kernel code and add it directly to the project.

14715_14715.jpgGenerate Code.jpg


With the current releases, PEx will generate a warning in KDS when the code is generated.  The GNU ISO C99 standard should be used when building MQX.

14716_14716.jpgCompiler warning.jpg


To change this compiler setting, right-click the project and select Properties.  Then use this screenshot to find the Language Standard in the Compiler Optimization settings, and change to GNU ISO C99.  Click OK to save the change.

14717_14717.jpgCompiler settings.jpg


Now the MQX application can be written.  The MQX_KSDK_Task components will create function stubs for the tasks.  The task routine prototypes are located in the project header file Sources/mqx_tasks.h and stubs of task functions are in source file Sources/mqx_tasks.c.  Add the application code to these tasks.  Then use the toolchain to build the project, and download to the target hardware. 


The attached project is an example following these steps for KDS.  It has a single MQX task that prints "Hello World!" out the UART using printf().  It's written for the FRDM-K64F board, and setup to use the Segger JLink OpenSDA V2 debugger app.

Original Attachment has been moved to: MQX_KSDK_PEx.zip

36 Replies

2,121 Views
jasonscott
Contributor IV

Hi Derek,

I realize that this is an old post, but hopefully you could offer me assistance.

How could i implement the MQX shell in parallel with the processor expert example that was created here?

Thanks for your time,

Jason

0 Kudos

2,121 Views
dereksnell
NXP Employee
NXP Employee

Hi Jason,

Processor Expert (PEx) does not provide the ability with MQX to add the other libraries for you, like the shell, MFS file system, RTCS TCP/IP or USB stacks.  But you can manually add these libraries to the MQX project generated by PEx.  That means changing the linker settings to add the library and change the compiler include paths for the library header files.  You can refer to our MQX examples that use the shell or these libraries as an example for these settings, and as a reference for the source code in your application to use the library.

Below is an example of these project settings.  I no longer have this older version of MQX for KSDK installed, which was the version used at the beginning of this post.  But I'll use the latest MQX for KSDK v1.3 as an example.  This is using the RTCS shell example installed at \KSDK_1.3.0\middleware\tcpip\rtcs\examples\shell\build\kds\shell_frdmk64f, and uses the Kinetis Design Studio (KDS) toolchain.

Here are the linker settings including the nshell library, and the path to that library:

shell_linker.jpg

And the compiler settings for the include path

shell_compiler.jpg

2,121 Views
jasonscott
Contributor IV

Hey Derek,

Thanks for replying.

I was not sure if it would work using sdk 1.3 because of all of the compiler issues i got when i attempted it.

Could you tell me if my process is right?

1) Import and build the libraries for the MQX, Mfs, and Nshell.

2) Create a project with my processor using the PE.

3) I add the MQX lite component, because I could not figure out how to add tasks using the MQX standard component.

4) I add the following lines to the project...

     #include <mfs.h>

     #include <shell.h>

const SHELL_COMMAND_STRUCT Shell_commands[] = {

    { "cd",        Shell_cd },

    { "copy",      Shell_copy },

    { "create",    Shell_create },

    { "del",       Shell_del },

    { "dir",       Shell_dir },

    { "format",    Shell_format },

    { "mkdir",     Shell_mkdir },

    { "pwd",       Shell_pwd },

    { "read",      Shell_read },

    { "ren",       Shell_rename },

    { "rmdir",     Shell_rmdir },

    { "write",     Shell_write },

    { "help",      Shell_help },

    { "?",         Shell_command_list },

    { NULL,        NULL }

};

5) Add the included files to the compiler and the linker libraries.

6) Build.

I have done this numerous times, but I have not had any success.

Can you offer any insight?

Thanks!

I appreciate your time,

Jason Scott

0 Kudos

2,121 Views
dereksnell
NXP Employee
NXP Employee

Hi Jason,

First, it would be best if you create a new question in this Community forum site for your specific issues.  That way, the support team that moderates the Community will see you have open questions that need to be resolved, and they can help with your specific issues.

Your process looks correct to me, except for using the MQX Lite configuration.  The MFS and RTCS libraries require the full MQX configuration, to support dynamic memory allocation.  The discussion at this link below has a tutorial for using PEx to generate an MQX for KSDK project with the Standard MQX configuration instead of MQX-Lite.

How To: Create an MQX RTOS for KSDK project with Processor Expert in Kinetis Design Studio IDE

If you still have compiler errors, then it would be helpful to include more details in the new question you create, so the support team can offer more help.  Like what are the specific compiler errors, and what toolchain and release are you using. 

0 Kudos

2,121 Views
jasonscott
Contributor IV

Hey Derek,

Thanks for the followup.

I will do as you suggested and will create a support question after i try this latest build.

The tutorial you noted is using a older version of the sdk.

Since the gui options in the processor expert have changed (at least from what i am seeing,)

Is there a newer tutorial I can follow for sdk 1.3?

Thanks for your time,

Jason

0 Kudos

2,121 Views
dereksnell
NXP Employee
NXP Employee

Hi Jason,

The link below is for a hands-on training, and one of the lab guides walks through the process of creating an MQX for KSDK project using PEx.

MQX for KSDK Training 2015-September.zip

0 Kudos

2,121 Views
rémiraynaud
Contributor III

Hello Derek Snell,

I followed your instructions but I have errors when building project.

error.png

Anybody could help me?

Regards,

Rémi

0 Kudos

2,121 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello remi:

Are you working with the latest tool versions (KSDK v1.1.0 / KDS v2.0.0)?

There is an updated starting guide which you should refer to in the next link:

How To: Create an MQX RTOS for KSDK project with Processor Expert in Kinetis Design Studio IDE


Regards!,
Jorge Gonzalez

2,121 Views
F50SC
Contributor III

Hi Derek

If I create a new KDS project with PE enabled & select an MCU not a Kinetis board there is no OSs shown in the Components window for the project???

Whereas if I select a Kinetis board when creating a project, the project will show the osa1:fsl_os_abstraction component under the OSs folder.

It would appear you cannot have OS support if you select an MCU, only a Kinetis board.

How can I add OS support using PE for custom hardware....ie not a development board?

Jerome

0 Kudos

2,121 Views
dereksnell
NXP Employee
NXP Employee

Hi Jerome,

I’m able to use OS components with projects created for MCUs, and I haven’t seen your issue. But this post is not flagged as a question, and you’re better off creating a new post for any questions you have so the support team will see +it as unanswered. You can create a new post for this in the Processor Expert group. https://community.freescale.com/community/pex

Thanks

0 Kudos

2,121 Views
w2vy
Contributor V

Is there an updated version for KDS 2.0 and KSDK 1.1?

Tom

2,123 Views
ChrisTango
Contributor IV

Thanks for this demo. It works very good.

I'm trying to find a demo using Ethernet. Is this already in the pipe for MQX-KDS?

0 Kudos

2,123 Views
dereksnell
NXP Employee
NXP Employee

Hi Chris

MQX for KSDK has Ethernet examples included in the installation. You'll find them in the directory /tcpip/RTCS/examples

Thanks

0 Kudos

2,121 Views
ChrisTango
Contributor IV

I gave up spending time on merging the MQX package to the project. I also tried to only add the enet driver into the project; but this needs more effort than I would be able to spend on. There should be a demo out there which works right out of the box without spending hours.

0 Kudos

2,121 Views
dave408
Senior Contributor II

Hi Chris, I'm working on getting RTCS into my own application as well.  Haven't quite gotten there yet, but perhaps I can help you with getting the demo running.  Did you install MQX 4.1.x or MQX for KDSK 1.0.0 Beta?  I think you only need one or the other.  I opted for the latter.

There isn't anything that works right out of the box as far as examples go (as far as I can tell).  However, the example I did get running was httpsrv.  You'll want to import that, and then you go through the following steps:

  • add any necessary include folders to remove the compiler errors
  • import and build any libraries that are needed.  You'll know which ones because once you get past the compilation errors, you'll end up with linker errors

I followed those two basic steps and after changing the IP address in config.h, I was able to hit the webserver running on my FRDM-K64F.

Post up if you can't get it working, and maybe I'll be able to help.

0 Kudos

2,121 Views
ChrisTango
Contributor IV

Hi Dave, That sounds promising!

Your right that the most demos doesn't run right out the box; but I think that you would agree if I'am saying they should. The saving of time is the biggest intention behind demos.

Perhaps you read already about the uTasker-Demo. This works without additional effort and had a web server included; but for me it seems to far beside the standard.

I tried your steps before, but in between KDS asked me about updating the SDK-sources of the project and unfortunately I clicked OK. After this the project was messed-up, and I tried with a new one and only added the enet driver, which didn't pay out.

Okay, I'll try it the next weekend again.

Do you know an easy way for adding include paths? It took me almost an hour for the MQX files. Is it possible to add them all at once?

Thanks

-Chris

0 Kudos

2,121 Views
dave408
Senior Contributor II

I wrote a walkthrough on my company's internal wiki.  Here are the excerpts.  I suppose you can probably just copy and paste into whatever eclipse's equivalent of a "solution" file is, but I am new to eclipse so I don't know.

Regarding something working out of the box, in some ways I agree, and in other ways I don't.  If you want to just test the environment and libraries to see if they are capable of what you are looking for (before spending a lot of time on it), then yes, having something work out of the box is a plus.  However, if you intend to work with an IDE long-term, it's probably best to figure out for yourself how to resolve all of the issues, so that you gain the background / insight / intuition to solve problems down the road.

Here's the text from my post:

In order to proceed, you'll need to install the following two packages:

In addition, you will need to overwrite the mbed firmware with one provided by Segger.

Now open KDS and import an existing project, and point to C:\Freescale\MQX_KSDK_1.0.0\tcpip\rtcs\examples\httpsrv\build\kds\httpsrv_frdmk64f120m.  Try building it, and you'll end up with a bunch of compiler errors because gcc won't be able to find several header files.  You need to add a bunch of file paths to the includes list.

To include the paths, go to Project Properties -> C/C++ Build -> Settings -> Cross ARM C Compiler -> Includes and then add the following paths:

"${KSDK_PATH}/rtos/mqx/mqx/source/bsp/K64F12"
"${KSDK_PATH}/boards/frdmk64f120m"
"${KSDK_PATH}/platform/system/hwtimer"
"${KSDK_PATH}/platform/osa"
"${KSDK_PATH}/rtos/mqx/mqx/source/bsp"
"${KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm"
"${KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m"
"${KSDK_PATH}/rtos/mqx/mqx/source/include"
"${KSDK_PATH}/rtos/mqx/config/common"
"${KSDK_PATH}/rtos/mqx/config/mcu/mk64f120m"
"${KSDK_PATH}/rtos/mqx/config/board/frdmk64f120m"
"${KSDK_PATH}/tcpip/rtcs/source/include"
"${KSDK_PATH}/rtos/mqx/nshell/source/include"

where ${KSDK_PATH} is likely C:\Freescale\MQX_KSDK_1.0.0.

Build again, and you'll end up with the following linker errors:

arm-none-eabi-gcc: error: ..\..\..\..\..\..\..\..\lib\ksdk_mqx_lib\kds\K64F12\debug\ksdk_mqx_lib.a: No such file or directory
arm-none-eabi-gcc: error: ..\..\..\..\..\..\lib\frdmk64f120m.kds\debug\rtcs\rtcs.a: No such file or directory
arm-none-eabi-gcc: error: ..\..\..\..\..\..\..\..\rtos\mqx\lib\frdmk64f120m.kds\debug\nshell\nshell.a: No such file or directory
arm-none-eabi-gcc: error: ..\..\..\..\..\..\..\..\rtos\mqx\lib\frdmk64f120m.kds\debug\bsp\bsp.a: No such file or directory
arm-none-eabi-gcc: error: ..\..\..\..\..\..\..\..\rtos\mqx\lib\frdmk64f120m.kds\debug\psp\psp.a: No such file or directory
arm-none-eabi-gcc: error: ..\..\..\..\..\..\..\..\rtos\mqx\lib\frdmk64f120m.kds\debug\mqx_stdlib\mqx_stdlib.a: No such file or directory

Add the following projects to your KDS workspace and build them:

C:\Freescale\MQX_KSDK_1.0.0\lib\ksdk_mqx_lib\kds\K64F12

C:\Freescale\MQX_KSDK_1.0.0\tcpip\rtcs\build\kds\rtcs_frdmk64f120m

C:\Freescale\MQX_KSDK_1.0.0\rtos\mqx\nshell\build\kds\nshell_frdmk64f120m

C:\Freescale\MQX_KSDK_1.0.0\rtos\mqx\mqx\build\kds\bsp_frdmk64f120m

C:\Freescale\MQX_KSDK_1.0.0\rtos\mqx\mqx\build\kds\psp_frdmk64f120m

C:\Freescale\MQX_KSDK_1.0.0\rtos\mqx\mqx_stdlib\build\kds\mqx_stdlib_frdmk64f120m

Now go back and build httpsrv.  You shouldn't get any errors.  At this point, you need to change the IP address of the K64F.  This is found in config.h.

To debug/run the application, right click httpsrv in the project view, then go to Debug As.. -> Debug Configurations.  Double-click the "GDB SEGGER J-Link Debugging" node and it will auto-generate a configuration called "httpsrv_frdmk64f120m In Flash Debug" with all of the relevant information auto-populated.

Click Debug.  You'll know it's working if you get this dialog:

pastedImage_0.png

Ignore this warning:

pastedImage_1.png

The debugger should have started in the paused state in main.  Just click the Run icon to continue running.  If you ping the IP that you had specified in config.h, it should work.  In addition, you should be able to reach the mbed device via a web browser!

pastedImage_2.png

2,121 Views
ChrisTango
Contributor IV

Hi Dave,

Thanks for the detailed desciption! It worked very well. :-) You made my day. Now I can finally try the demos.

- Chris

2,121 Views
dave408
Senior Contributor II

Great, I'm really glad it helped you out!  Thanks for letting me know.

0 Kudos

2,123 Views
ChrisTango
Contributor IV

Hi Derek,

Thanks for this hint. In the demo attached to this thread RTCS isn't included. So, I downloaded the package for MQX; but this doesn't include KDS projects.

I'm now adding the RTCS files and updating the MQX files. Hopefuly this works out. After this I would be able to try the examples. :-)

Thanks

-Chris

0 Kudos