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.
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.
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.
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.
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.
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.
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.
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
Hi, thanks, the demo project works.
If I create more tasks, Their functions end up in mqx_tasks.c. How can I move the tasks funtions in others .c files?
Thank you
Bye Giacomo
Hi Giacomo,
Have you ever succeeded with Processor Expert putting MQX tasks in separate files?
Regards,
Piotr
no.
I tried (using MQX_KSDK_1.0.0beta) but when I add a file in the project the compilation fails (it seems that it can't find libc.a anymore). I don't know why.
Since I've no time to play, I decided to not use MQX for the time being and develope bare-metal (with the aid of PE).
Regards
Giacomo
Hello MQX team,
Could we get some help here?
Thanks,
Piotr
Hello,
thanks for the example.
Just a question:
every time I change something in PE and re-generate the code, it takes a huge amount of time (around 3 minutes) to recompile because it has to recompile all the MQX files. Is there a way to speed up the compilation (in general, not only for this particular thing)?
In alternative is it possible to tell PE to generate the code only for the thing I changed and/or to block the generation of code for some components?
Thank you
Bye Giacomo
Thanks,
now it takes 1:45 to rebuild all (with 4 jobs). Better but still too long.
Any other ideas?
Best Regards
Giacomo
Sorry no.
IDE's seem to be happy with fast machine and lots of RAM. I have 8GB.
Regards,
David
Here i5@2.5GHz(HT), 8GB RAM and SSD...mah
Bye Giacomo
Hi Derek, thank you for posting your demo application. I've been trying to create my own KDS project with the MQX for KDS SDK module using your walkthrough, and have been unsuccessful thus far.
I loaded your project and then switched the configuration to use the MK64FN1M0VLL12, since that's what my FRDM-K64F has. The configuration switch went fine, but after code generation, building failed. The error I got was:
Description Resource Path Location Type
fatal error: device/MK64F12/MK64F12.h: No such file or directory fsl_device_registers.h /MQX_KSDK_PEx/SDK/platform/CMSIS/Include/device line 427 C/C++ Problem
This is the exact same error I get when I try to create my own project.
Is there something I could have missed? I have all of the latest Eclipse updates installed.
Thank you!
Ok, it seems that it is related to all of the packages installed on my system, or the fact that I specified the processor and not the board in the New Project wizard. I reinstalled everything in a clean virtual machine just for testing, and it compiled. Now the only problem is that I can't debug. I set the -f kinetis.cfg build option, and when I try to debug I get this error:
Open On-Chip Debugger 0.8.0-dev-dirty (2014-08-20-11:07)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'cmsis-dap'
Error: unable to open CMSIS-DAP device
Error: unable to init CMSIS-DAP driver
Error: Error selecting 'cmsis-dap' as transport
Runtime Error: C:/Freescale/KDS_1.1.1/openocd/bin/..//scripts/kinetis.cfg:3:
in procedure 'script'
at file "embedded:startup.tcl", line 58
in procedure 'interface' called at file "C:/Freescale/KDS_1.1.1/openocd/bin/..//scripts/kinetis.cfg", line 3
Can anyone suggest a course of action?
I think this is because you are still running the mbed code on your board. If you want to debug using the Segger J-Link you have to flash JLink_OpenSDA_V2.bin to the K20 on the board. To do that you hold down the reset while plugging in the USB cable. That should cause a BOOTLOADER USB Drive to show up on your laptop. You can then drag the JLink_OpenSDA_V2.bin to that device and it will flash the new image. Unplug and re-plug the USB and the Jlink code will expose a new virtual com port as well as a JLink debugger device. If you get the FRDM-K64-QSP.zip Quick Start Package from the Freescale web site there is a subdirectory for OpenSDAv2Applications that has a link to the Segger website with the code. Be sure you get the V2 version.
Thanks, William, that hadn't ever occurred to me because of my debug configuration settings:
I figured that if I selected OpenOCD, the mbed firmware would work fine. Is this not the case? Note that in this particular case, I followed the tutorial so I specified a debug config, as opposed to opening his project attachment. Speaking of which, I'll try that next in the VM.
Thanks!
I think your choices, at least for the FRDM-K64F and the TWR-K64F120M, are to use the PE Micro OpenSDA or the Segger OpenSDA code. I'm using the Segger on my boards and it's working.
Ok -- I'll load the Segger firmware onto one of my other boards so I can keep working in both environments. Thanks for the suggestion!
hello Derek
I've tried to use MQX with your steps but appears this error in the console when i try degug:
SEGGER J-Link GDB Server V4.88a Command Line Version
JLinkARM.dll V4.88a (DLL compiled Jul 17 2014 18:20:19)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: on
Init regs on start: on
Silent mode: off
Single run mode: on
Target connection timeout: 5 sec.
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: MK64FN1M0xxx12
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OpenSDA 2 compiled Apr 24 2014 14:44:11
Hardware: V1.00
S/N: 621000000
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0xFFFFFFFF)
Target interface speed set to 1000 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0xFFFFFFFE)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= FFFFFFFC, MSP= FFFFFFFC, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = FFFFFFFE
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Select auto target interface speed (1429 kHz)
Flash breakpoints enabled
Semi-hosting enabled (VectorAddr = 0x08)
Semihosting I/O set to TELNET Client
Downloading 20 bytes @ address 0x00000410 - Verified OK
Writing register (PC = 0x00000410)
Read 4 bytes @ address 0x00000410 (Data = 0x20000000)
Resetting target
Halting target CPU...
...Target halted (PC = 0xFFFFFFFE)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= FFFFFFFC, MSP= FFFFFFFC, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = FFFFFFFE
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0xFFFFFFFE (Data = 0x20000000)
Starting target CPU...
ERROR: Can not read register 15 (R15) while CPU is running
...Target halted (PC = 0x00000000)
Reading all registers
ERROR: Can not read register 0 (R0) while CPU is running
ERROR: Can not read register 1 (R1) while CPU is running
ERROR: Can not read register 2 (R2) while CPU is running
ERROR: Can not read register 3 (R3) while CPU is running
ERROR: Can not read register 4 (R4) while CPU is running
ERROR: Can not read register 5 (R5) while CPU is running
ERROR: Can not read register 6 (R6) while CPU is running
ERROR: Can not read register 7 (R7) while CPU is running
ERROR: Can not read register 8 (R8) while CPU is running
ERROR: Can not read register 9 (R9) while CPU is running
ERROR: Can not read register 10 (R10) while CPU is running
ERROR: Can not read register 11 (R11) while CPU is running
ERROR: Can not read register 12 (R12) while CPU is running
ERROR: Can not read register 13 (R13) while CPU is running
ERROR: Can not read register 14 (R14) while CPU is running
ERROR: Can not read register 15 (R15) while CPU is running
ERROR: Can not read register 16 (XPSR) while CPU is running
ERROR: Can not read register 17 (MSP) while CPU is running
ERROR: Can not read register 18 (PSP) while CPU is running
ERROR: Can not read register 24 (PRIMASK) while CPU is running
ERROR: Can not read register 25 (BASEPRI) while CPU is running
ERROR: Can not read register 26 (FAULTMASK) while CPU is running
ERROR: Can not read register 27 (CONTROL) while CPU is running
ERROR: Can not read register 32 (FPSCR) while CPU is running
ERROR: Can not read register 33 (FPS0) while CPU is running
ERROR: Can not read register 34 (FPS1) while CPU is running
ERROR: Can not read register 35 (FPS2) while CPU is running
ERROR: Can not read register 36 (FPS3) while CPU is running
ERROR: Can not read register 37 (FPS4) while CPU is running
ERROR: Can not read register 38 (FPS5) while CPU is running
ERROR: Can not read register 39 (FPS6) while CPU is running
ERROR: Can not read register 40 (FPS7) while CPU is running
ERROR: Can not read register 41 (FPS8) while CPU is running
ERROR: Can not read register 42 (FPS9) while CPU is running
ERROR: Can not read register 43 (FPS10) while CPU is running
ERROR: Can not read register 44 (FPS11) while CPU is running
ERROR: Can not read register 45 (FPS12) while CPU is running
ERROR: Can not read register 46 (FPS13) while CPU is running
ERROR: Can not read register 47 (FPS14) while CPU is running
ERROR: Can not read register 48 (FPS15) while CPU is running
ERROR: Can not read register 49 (FPS16) while CPU is running
ERROR: Can not read register 50 (FPS17) while CPU is running
ERROR: Can not read register 51 (FPS18) while CPU is running
ERROR: Can not read register 52 (FPS19) while CPU is running
ERROR: Can not read register 53 (FPS20) while CPU is running
ERROR: Can not read register 54 (FPS21) while CPU is running
ERROR: Can not read register 55 (FPS22) while CPU is running
ERROR: Can not read register 56 (FPS23) while CPU is running
ERROR: Can not read register 57 (FPS24) while CPU is running
ERROR: Can not read register 58 (FPS25) while CPU is running
ERROR: Can not read register 59 (FPS26) while CPU is running
ERROR: Can not read register 60 (FPS27) while CPU is running
ERROR: Can not read register 61 (FPS28) while CPU is running
ERROR: Can not read register 62 (FPS29) while CPU is running
ERROR: Can not read register 63 (FPS30) while CPU is running
ERROR: Can not read register 64 (FPS31) while CPU is running
Read 4 bytes @ address 0x00000000 (Data = 0xFFFFFFFF)
Read 4 bytes @ address 0x00000000 (Data = 0xFFFFFFFF)
How can i solve this error?
Thanks