Hi everybody,
Please find attache the UPDATED version of this guide using KDS3.0 and KSDK1.2. As there is not a New Project Wizard for MQX projects it is necessary to create it manually. These guide explains 2 different ways to do it.
I am very sorry for the inconvenience and confusion that the previous version caused.
For information about creating a new KSDK project without RTOS (bareboard) please see the following document.
Writing my first KSDK1.2 Application in KDS3.0 - Hello World and Toggle LED with GPIO Interrupt
For information about porting a classic MQX RTOS project to a MQX RTOS for KSDK project please see the document below:
http://www.freescale.com/files/soft_dev_tools/doc/support_info/MQXKSDKPUG.pdf?fsrch=1
For information about creating a new C++ project in MQX for KSDK1.2 please see the following document.
How to Create a C++ Project Using MQX RTOS for KSDK1.2
For information about getting started with FreeRTOS and KSDK1.2 see the following document.
How to: Create a New FreeRTOS for KSDS1.2 Project in KDS3.0
Best regards,
Carlos Musich
Technical Support Engineer
Dear Carlos,
Thank yoo for the Manual. I have tried to follow it, but when I built the project, I get this error.
make: *** No rule to make target `C:/Freescale/KSDK_1.1.0/lib/ksdk_mqx_lib/K64F12/Debug/libksdk_platform_mqx.a', needed by `Enrutadora.elf'. Stop.
And I don't know how to solve it.
Best Regards
Hi Daniel,
Did you follow below steps from “Creating a New MQX RTOS for KSDK Project in KDS.pdf”?
1.5 It is necessary to build the following libraries: 1.5.1 Platform Library for MQX, ‘libksdk_platform_mqx.a’
• This project is located in “$/lib/ksdk_mqx_lib/kds/ 1.5.2 MQX Library, ‘lib_mqx.a’ • This project is located in “$/rtos/mqx/mqx/build/kds/mqx_” 1.5.3 MQX Standard Library, ‘lib_mqx_stdlib.a’
• This project is located in “$/rtos/mqx/mqx_stdlib/build/kds/mqx_stdlib_”
NOTE: For information about building KSDK and MQX libraries in KDS please see chapter ‘3 Building the MQX RTOS libraries’ of ‘Getting Started with Freescale MQX™ RTOS for Kinetis SDK and Kinetis Design Studio IDE’ located in MQX for KSDK installation path C:\Freescale\KSDK_1.1.0\rtos\mqx\doc\tools
Regards,
David
Hi David,
At the end, I was a problen with the quotes. I rewrite all the quotes and the application works.
Thank you,
Regards
Daniel
Hi Carlos,
The project description looks very good here, but I can't get it to work. I have done it twice on two PCs with identical results - it seems to be looking for information that is in standard include files (see below) but these includes are not called from the source the include file nor is the path to these include files part of the build properties.
I'm using the latest versions of KDS and KSDK from the Freescale websites and I'm following the instructions in the document at the top of this thread explicitly.
When I went through the instructions to page 13 (through to section 3.15), I saw the following differences:
3.7 BSP_Files generate a number of path statements that I am saying "Yes" to. These can be seen in section 3.10
3.8 Should the path be "C:\Freescale\KSDK_1.1.0\rtos\mqx\config\board\<board>"? The original doesn't seem to match.
3.12 Rearranged the includes to match the order in the screen shot on page 10 of the pdf instructions. NOTE: that the includes generated in step 3.7 are after these includes.
3.15 Rearranged the library list to match the order in the screen shot on page 12 of the pdf instructions.
I don't think the extra path statements that are being generated in 3.7 could be causing a problem?
When I build, I get:
17:08:34 **** Build of configuration Debug for project K64_MQX_KSDK_Example ****
make all
'Building file: ../Sources/Utilities/fsl_debug_console.c'
'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -D"CPU_MK64FN1M0VMD12" -I"../Sources" -I"../Sources/Board" -I"../Sources/BSP_Files" -I"../Sources/Config_Files" -I"../Sources/Config_Files/Common" -I"../Sources/Utilities" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/bsp" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/include" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/config" -I"C:\Freescale\KSDK_1.1.0/platform/hal/inc" -I"C:\Freescale\KSDK_1.1.0/platform/drivers/inc" -I"C:\Freescale\KSDK_1.1.0/platform/osa/inc" -I"C:\Freescale\KSDK_1.1.0/platform/system/inc" -I"../Project_Settings/Startup_Code" -I"../SDK/platform/CMSIS/Include" -I"../SDK/platform/CMSIS/Include/device" -I"../SDK/platform/CMSIS/Include/device/MK64F12" -I"C:\Freescale\KSDK_1.1.0/platform/utilities/inc" -I"C:\Freescale\KSDK_1.1.0/platform/utilities/src" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/drivers/nio_serial" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/string" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/config/common" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/psp/cortex_m/core/M4" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx_stdlib/source/include" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/kernel" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/src" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/bsp" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/drivers/nio_serial/src" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx_stdlib/source/strings" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/psp/cortex_m" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/drivers/nio_tty/src" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/drivers/nio_dummy/src" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/psp/cortex_m/cpu" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/fs" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx_stdlib/source/stdio" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/drivers/nio_tty" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/nio/drivers/nio_dummy" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/include" -std=c99 -MMD -MP -MF"Sources/Utilities/fsl_debug_console.d" -MT"Sources/Utilities/fsl_debug_console.o" -c -o "Sources/Utilities/fsl_debug_console.o" "../Sources/Utilities/fsl_debug_console.c"
In file included from C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx_stdlib/source/include/std_prv.h:30:0,
from C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx_stdlib/source/include/stdio.h:32,
from ../Sources/Utilities/fsl_debug_console.c:32:
C:\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx/nio.h:122:1: error: unknown type name 'ssize_t'
ssize_t _nio_read(int fd, void *buf, size_t nbytes);
^
C:\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk64f.kds/debug/mqx/nio.h:132:1: error: unknown type name 'ssize_t'
ssize_t _nio_write(int fd, const void *buf, size_t nbytes);
^
../Sources/Utilities/fsl_debug_console.c: In function 'DbgConsole_Init':
../Sources/Utilities/fsl_debug_console.c:214:5: warning: implicit declaration of function 'setvbuf' [-Wimplicit-function-declaration]
setvbuf(stdout, NULL, _IONBF, 0);
^
../Sources/Utilities/fsl_debug_console.c:214:27: error: '_IONBF' undeclared (first use in this function)
setvbuf(stdout, NULL, _IONBF, 0);
^
../Sources/Utilities/fsl_debug_console.c:214:27: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Sources/Utilities/fsl_debug_console.o] Error 1
17:08:34 Build Finished (took 479ms)
Doing a search on "ssize_t", is is defined in C:/Freescale/KDS_2.0.0/toolchain/arm-none-eabi/include/sys/types.h,
"_IONBF" is defined in C:/Freescale/KDS_2.0.0/toolchain/arm-none-eabi/include/stdlib.h
and "setvbuf" is defined in C:/Freescale/KDS_2.0.0/toolchain/arm-none-eabi/include/stdio.h
I tried adding "C:/Freescale/KDS_2.0.0/toolchain/arm-none-eabi/include" to the build path in project ==> Properties ==> C/C++ Build ==> Settings ==> Cross ARM C Compiler ==> Includes without any changes to the output (which was not a surprise because I would have thought there would be include file not found error messages.
I will try to add the include files to the errors above but do you have any suggestions as to what I am doing wrong?
Thanx,
myke
Doing a bit more digging and in fsl_debug_console.h, I found the line before the issues with the "setvbuf" and "IONBF":
#if ((defined(__GNUC__)) && (!defined(FSL_RTOS_MQX))) && (!defined(__KSDK_STDLIB__))
I would have thought that *somewhere*, I would be setting the "FLS_RTOS_MQX" flag (which I presume indicates that this is an MQX project) - not to mention __KSDK_STDLIB__.
Could this be my problem, and if it is, where do I cause this flag to be set?
Thanx,
myke
Success! (I think).
I took a look at the compiler properties for the "hello_frdmk64f" project that is in the KSDK 1.1.0 MQX examples and found that the Cross Arm C Compiler ==> Preprocessor contained:
CPU_MK64FN1M0VMD12=1
FSL_RTOS_MQX=1
_AEABI_LC_CTYPE=C
__STRICT_ANSI__=1
_DEBUG=1
In the project that is built from Carlos' instructions just has:
"CPU_MK64FN1M0VMD12"
So, I left that line and then copied in the other lines from the example application and ...
It builds and runs.
Now, the next step is trying to add the Task Aware Debugger so that I can check operation during execution.
myke
Okay, everything still works after I added the MQX plugins from Help ==> Install New Software...
And, I have the "MQX" drop down at the top so, I think everything is good.
Carlos (and anybody else),
Is there anything else I need to do for the projects?
Thanx,
myke
Hi Carlos,
First of all, EXCELLENT write-up!
I followed the procedure but for the FRDM-K22F and when I compile, I get the error:
=====
'Building file: ../Sources/Utilities/fsl_debug_console.c'
'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -D"CPU_MK22FN512VDC12" -I"../Sources" -I"../Sources/Board" -I"../Sources/BSP_Files" -I"../Sources/Config_Files" -I"../Sources/Config_Files/Common" -I"../Sources/Utilities" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk22f.kds/debug/mqx" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/bsp" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/mqx/source/include" -I"C:\Freescale\KSDK_1.1.0/rtos/mqx/lib/frdmk22f.kds/debug/config" -I"C:\Freescale\KSDK_1.1.0/platform/hal/inc" -I"C:\Freescale\KSDK_1.1.0/platform/drivers/inc" -I"C:\Freescale\KSDK_1.1.0/platform/osa/inc" -I"C:\Freescale\KSDK_1.1.0/platform/system/inc" -I"../Project_Settings/Startup_Code" -I"../SDK/platform/CMSIS/Include" -I"../SDK/platform/CMSIS/Include/device" -I"../SDK/platform/CMSIS/Include/device/MK22F51212" -I"C:\Freescale\KSDK_1.1.0/platform/utilities/inc" -I"C:\Freescale\KSDK_1.1.0/platform/utilities/src" -std=c99 -MMD -MP -MF"Sources/Utilities/fsl_debug_console.d" -MT"Sources/Utilities/fsl_debug_console.o" -c -o "Sources/Utilities/fsl_debug_console.o" "../Sources/Utilities/fsl_debug_console.c"
arm-none-eabi-gcc: fatal error: no input files
compilation terminated.
make: *** [Sources/Utilities/fsl_debug_console.o] Error 1
====
The file is in the Sources/Utilities folder, both on the hard drive and in the project. So, I suspect that my problem may be in the project referencing of "../Sources/Utilities" Is there some way to verify this?
In Window Explorer, my file structure is:
Can you see something I've been overlooking? Thanks.
Yup, saw it on close examination. Forgot a quote(") in the Include Paths. See: "../Sources/BSP_Files" (note the underline).
After this, I ran into the same problems that Myke Predko did and corrected them by editing the preprocessor directives in the same way.
Myke,
I've got exactly the same errors as you did. Thank you very much for your valuable participation! You can't imagine how hard I worked on that!
But, at the same time, I'm still wondering why those symbols have to be manually included in "Preprocessor Settings", instead of being automatically included during MQX header files and libraries linking and compilation...
Can anybody from KSDK team explain me that?
Best regards,
Marco Coelho
Hi Marco,
I'm glad you found the Preprocessor settings useful.
I've been told by Freescale engineers that they are working at making KDS/KSDK (with MQX) easier to work with in this regard - I want to use the USB parts of the stack (which is why I started the discussion https://community.freescale.com/thread/342700) which will hopefully get some traction soon.
If anybody has any experience with the USB stack in KDS/KSDK, please respond to the discussion.
myke
Have you looked at Trying the throughput test with the host_msd_fatfs_frdmk22f_mqx_frdmk22f
You didn't say whether you were interested in host or device mode, but I was able to get the device mode demo to work on the FRDM-K22F board. I was rather impressed by the numbers and am working to get it to run in a more general application.
Hi David,
I'm interested in device mode, specifically a USB bi-directional HID implementation.
In the example you cite above, were you bringing in the example .wsd or were you creating your own project from scratch? I'm asking because I find that the canned applications work very well, but it's a bear to come up with your own KDS/KSDK (for MQX).
myke
Hi Myke,
I was merely trying to get their demo to run. I agree with you that the combination of KDS/KSDK/PE/MQX is a bear. When I first learned about the combination, I thought it was a "great thing" but I find that Freescale has a long way to go.
To me the PE aspect is (was) important as I need to be able to migrate projects quickly from one design to another. However, this has not panned out as the documentation is sparse and quickly outdated. I've decided that for now, I'll build on the material presented at the start of this thread. This means that I'll be going back to the material in Freescale MQX RTOS 4.1 for the FRDM-K22F and "borrowing" segments of code as needed. (The key problem is that the download does not include anything for KDS. So, it must be migrated over. It also appears to not use PE at all - a real bummer!)
Meanwhile, I'm hoping that Freescale can get it together and deliver the total package. It would be a real boon for the product line.
It would be great to see a rewrite of this article based on using KSD/KSDK/PE/MQX. That would do what software is supposed to do: Remove the tedium of setting things up and let us get to work!
Hi guys,
I am having the following error once I have built.
<<cannot find entry symbol Reset_Handler>>
I have selected the same board as the example, so i have done exactly the same.
Any suggestion?
Thanks and best regards.
Alberto
Hi Myke
Thanks for finding this....as I had exactly the same error, the pre-processor defines are definitely required & are missing from Carlos's instructions.
Any ideas what could be causing this error?
make: *** No rule to make target `C:/Freescale/KSDK_1.1.0/lib/ksdk_mqx_lib/K22F51212/Debug/libksdk_platform_mqx.a', needed by `xxxxxxxxxxx.elf'. Stop.
Solved guys......was missing the /kds folder before processor name.
The correct path for my project is shown below.
`C:/Freescale/KSDK_1.1.0/lib/ksdk_mqx_lib/kds/K22F51212/Debug/libksdk_platform_mqx.a'
This could be one of two problems. The first I'd look at is covered by How can I run MQX USB demo on FRDM-K22F? where the library issue is discussed.
If your library is there in the file system, then look at the project properties for the C/C++ Build linker section and make sure that the library is listed and that the path to it are correct.
Hope this helps!
Hi Carlos Musich:
can i use this tutorial with the board Frdm-KL25Z?, cause i only see the board Frdm-K64F,
thanks
Carlos Enrique
Hello Carlos Enrique:
The FRDM-KL25 is not supported yet. It is coming with the next Release of KSDK v1.2 at the end of April or beginning of May.
Regards!
Jorge Gonzalez
Carlos, I have followed this tutorial exactly (it is very well written), however the resulting program seems to still have an issue with the IRQ vectors.
I am using the FRDM-K64F board.
The project compiles fine without warnings, and does successfully program and begin to run, however it seems I get a hard fault / unhandled interrupt almost immediately after starting the project. I have tried many things to determine the source of this fault, to no avail. Nothing else can run with this project.
Here are the stack trace and registers at time of error:
All required libraries were compiled with default settings. I have validated that it is not actually the WDOG interrupt, as the flag is not set - also if I include a handler for the WDOG_EWM_IRQ it will not fire, and one of the other undefined interrupts that goes to DefaultHandler will show in the disassembly screen instead in that case. It seems to me this could is an issue with the vectors or memory conflict with MQX, but I do not know.
Please review this procedure as I don't think it results in a useable baseline project.
Thanks for putting this together, hopefully someone can sort out what the issue is.
Update: the interrupt was determined to be coming from a missing Systick_Handler. I added this to main.c and the program now runs:
void SysTick_Handler(void) {}
I don't know why this interrupt is enabled or whether it is required by MQX, but a handler was needed for me to get this project working.
Good debugging Kris.Thanks for sharing fix.
Systick timer is used for RTOS TICK (heart beat) of 200 Hz or every 5ms.
Regards,
David
What I am still struggling to understand is how this project differs from the demo projects, which use the exact same MQX initialization code and BSP config files. There is no Systick_Handler in those projects, so I presume they must be disabling the interrupt – and yet with this tutorial the interrupt still fires and I have to add the handler.
What’s the difference?
Hello Kris Simonsen:
Actually your solution about adding SysTick handler is strange. Is your MQX project working as expected? Do you have more than 1 task?
The handler is compiled as part of the MQX library and it is declared in _boot.S; as David mentioned the SysTick is used as the timebase for the MQX scheduler. By defining it in your project you should see multiple definition errors and if somehow it compiled then you would be overriding MQX SysTick handler. Did you add the mqx library (lib_mqx.a) to your project?
Also please read the comments above by Myke Predko, it seems that the tutorial is missing some macro definitions for the Preprocessor. I will let Carlos know about this.
Regards!
Jorge Gonzalez
Yes, the MQX library was compiled with default settings after a clean install and is linked to the project. I followed the instructions in the tutorial. As far as I can tell MQX is working normally with the two ‘hello’ and ‘world’ tasks.
I do not get any compile or multiple definition errors with or without the handler, but if I don’t include the handler it goes to a DefaultHandler() crash the first time the SysTick interrupt fires.
Thank you Carlos,
This was very helpful and between your guide and these comments I was able to get a new project running following many of the steps that were both unexpected and not documented in any of the MQX manuals I can find included with the KSDK. Which leads me to my question:
How would you go about replicating this to include the RTCS, MFS, or other components into a project. Much to my surprise the RTCS documentation does not mention anything about how to incorporate it into a project, just what it's functionality is. Including the "${PROJECT_KSDK_PATH}/tcpip/rtcs/lib/frdmk64f.kds/debug/rtcs" directory and relevant lib_rtcs.a file alone doesn't do it. It causes certain #defines in the RTCS project to not be read properly in new project, stopping compilation. Also, I am under the impression I should copy the rtcs_user_config.h file into the Config_files directory I created, but I'm unsure if I should be copying any more.
Thanks,
Sean
Hello, Kris
I'm in the same struggle to find out how to fix this issue in MQX-SDK. I had no idea the problem could be caused by the SysTick_Handler. Thanks for the tip. When I included it in my main.c file, it worked for me too. But I don't know if this workaround really solves or just disguises the issue. I'm afraid that, during the software development, this could cause more bugs to appear. So, I feel more comfortable and secure to use the method Iva suggested in this Community: https://community.freescale.com/docs/DOC-104144.
This method clones existing projects from mqx/examples folder into the same folder so you can use it as reference for your project. It is less prone to errors.
If you or somebody else find out how to fix the issue, please let me know. I think a lot of people may be facing the same problem.
Thanks,
Marco Coelho
I am wondering about the exact same thing. Would also appreciate an answer!
As well, after doing so, I ran into several issues such as multiple definition errors beginning to pop up when including library headers (Re: Re: arm-none-eabi conflicting with mqx: multiple definitions of stdio.h and others causing compi...). I'm not sure if this is an ideal solution but it allowed me to add the components and compile.
Kris, I must not have read your issue clearly beforehand. I've been dealing with this issue for quite a while now, trying to figure out why my project would randomly halt. I started this community post where I tried many things (Re: Printf fails half way through printing, causing firmware to cease execution?). After adding that function I can now have my code execute properly.
However, like you I do not feel this is a safe solution in any way. It seems as though it would stop MQX from functioning properly by disabling the tick heartbeat. If MQX uses ticks internally for any timing (like task switching?) then those functions would likely break. DavidS, can you let us know if this is the case or what might be missing to not let it work? It seems this will happen to anyone who's project takes longer than 5ms to execute, making it hard to program anything useful this way.
EDIT: I just had the frightening thought. If this internal interrupt is not properly linked, then who knows what else will not be found either, and can cause other strange and subtle failures.
I thought I was onto something: Comparing the httpsrv_frdmk64f project to the project I generated here I noticed there are some notable linker settings that are different.
Changing these settings to match does not fix the issue though. I'm going to see if I can force it to use the C linker instead of the C++ linker next.
From my point of view described issue with interrupt and SysTick looks like some side effect.
I tried follow up How To: Create a New MQX RTOS for KSDK Project in KDS guide.
Additionally I add Cross Arm C Compiler ==> Preprocessor symbols:
"CPU_MK64FN1M0VMD12=1"
"FSL_RTOS_MQX=1"""
"_AEABI_LC_CTYPE=C"
"__STRICT_ANSI__=1"
"_DEBUG=1"
and set Cross Arm C Compiler ==> Optimization as the “GNU ISO C99 (-std=gnu99)”
But I stopped at step 3.15. With this step I was able build project but without them, building cause errors (no reference to serial interface). It was strange because step 3.15 should do the same as steps 3.13 and 3.14 together.
This leads us (thank you Marian) that problem will be in compiler dependencies.
Proposed solution:
Please modify Cross Arm C++ Linker Command line patter by adding “-Wl,--start-group” and “-Wl,--end-group” commend line option.
${COMMAND} ${cross_toolchain_flags} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} -Wl,--start-group ${INPUTS} -Wl,--end-group
This will resolve cyclic references between several libraries.
With these settings we don’t need step 3.15 and code works correctly on my side. I see “Hello World” on terminal.
Could you please test it on your side?
I hope it helps you.
Hello RadekS,
Short version:
I tested the changes and it did not solve the issue.
"Hello World" Always printed fine on the terminal. The issue is that "Hello World" executes too quickly for the problem to become apparent. Replace the text with longer strings and you will see that the execution stops partway through, (at the 5ms mark I would wager, when SysTick_Handler() attempts to be called.) Or add a _time_delay(10) call before one of the printf statements.
Longer version:
This helps explain one of the confusing differences between the new project and existing example projects: The existing examples only had the .a files linked, and not the libraries or library directories as described in this guide. The example projects also had -Xlinker --start-group ${INPUTS} -Xlinker --end-group wrapping the Inputs, which appears to do the same thing as the above command. It also eliminates the need for adding the -z muldefs option as I required when adding the RTCS/MFS. Though the examples projects still had a muldefs option added as their linker options are " -Xlinker -static -Xlinker -z -Xlinker muldefs -Xlinker --undefined=__isr_vector" plus "Cross reference (-Xlinker --cref)" is selected. However, they don't appear necessary to compile, and are maybe just redundant.
Thank you for testing.
I spend several hours yesterday with modification of this project - but unfortunately without success.
Reason for wrong behavior is clear: Compiler/Linker somehow prefer startup code and vector table from SDK project instead of choose these components from MQX library. Bad thing is that till now we didn’t found way how to “convince” linker for implement MQX code (e.g. boot.s) instead of original SDK.
RadekS
Hi all,
Sometime after I published this document I found those errors. I kept investigating and know I have a fully functional project created from scratch. You can find it attached.
I will fix this and publish the new version with KSDK1.2 and KDS3.0 very soon.
Sorry for the inconvenience.
Carlos
Hello Carlos, do you know how far off the new version for KSDK1.2 is?
Thanks,
Sean
Sorry, the new version of this guide, relevant to the KSDK1.2 release. When is the new version of the guide available?
Hi Sean,
Probably tomorrow. But before Friday for sure.
Regards,
Carlos
Good news first:
This new guide and the new tools work! The project in some basic testing allows execution without the interrupt detection issues of the previous one. It also listed all the necessary includes, preprocessor settings, and linker commands to make it compile without issue.
Middling news:
Still no mention of including RTCS/MFS/ETC here, but it outlines the general way to do it so I can do that myself. I might write a comment here in the next day or two showing how to add the components I know about.
Also, the decision to use Absolute paths instead of relative was a bit annoying because my KSDK is not installed in C:/. But KSDK 1.2 also doesn't write the KSDK_PATH environment variable itself either, so I had to manually do that to start using relative paths properly.
Bad News:
The PDF formatting is AWFUL for copy and pasting out parts of the code. The include directories have an invisible column that makes the directories copy and paste in chunks with some parts repeated. I had to fix a lot of them myself.
I'm going to paste some of the fixed formatting ones here to help others. Note I also switched to Relative paths with the PROJECT_KSDK_PATH variable defined in Build Variables. I would have put them in Code formatting but I can't find the option on the new community site posting tool.
3.9a Physical Folders
"../BSP_Files"
"../Config_Files"
"../Config_Files/Common"
"../Debug_Console"
"../KSDK_Files"
"${PROJECT_KSDK_PATH}\rtos\mqx\mqx\source\include"
"${PROJECT_KSDK_PATH}\platform\devices\MK64F12\startup"
"${PROJECT_KSDK_PATH}\platform\devices\MK64F12\include"
"${PROJECT_KSDK_PATH}\platform"
"${PROJECT_KSDK_PATH}\platform\devices"
"${PROJECT_KSDK_PATH}\platform\CMSIS\Include"
"${PROJECT_KSDK_PATH}\platform\hal\inc"
"${PROJECT_KSDK_PATH}\platform\drivers\inc"
"${PROJECT_KSDK_PATH}\platform\drivers\src\mpu"
"${PROJECT_KSDK_PATH}\platform\drivers\src\uart"
"${PROJECT_KSDK_PATH}\platform\utilities\inc"
"${PROJECT_KSDK_PATH}\platform\osa\inc"
"${PROJECT_KSDK_PATH}\platform\system\inc"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\config"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx_stdlib"
3.9b Virtual Folders
"${PROJECT_KSDK_PATH}\rtos\mqx\config\mcu\MK64F12"
"${PROJECT_KSDK_PATH}\rtos\mqx\config\board\frdmk64f"
"${PROJECT_KSDK_PATH}\rtos\mqx\config\common"
"${PROJECT_KSDK_PATH}\rtos\mqx\mqx\source\include"
"${PROJECT_KSDK_PATH}\rtos\mqx\mqx\source\bsp"
"${PROJECT_KSDK_PATH}\platform\utilities\src"
"${PROJECT_KSDK_PATH}\platform\utilities\inc"
"${PROJECT_KSDK_PATH}\examples\frdmk64f"
"${PROJECT_KSDK_PATH}\platform\devices\MK64F12\startup"
"${PROJECT_KSDK_PATH}\platform\devices\MK64F12\include"
"${PROJECT_KSDK_PATH}\platform"
"${PROJECT_KSDK_PATH}\platform\devices"
"${PROJECT_KSDK_PATH}\platform\CMSIS\Include"
"${PROJECT_KSDK_PATH}\platform\hal\inc"
"${PROJECT_KSDK_PATH}\platform\drivers\inc"
"${PROJECT_KSDK_PATH}\platform\drivers\src\mpu"
"${PROJECT_KSDK_PATH}\platform\drivers\src\uart"
"${PROJECT_KSDK_PATH}\platform\utilities\inc"
"${PROJECT_KSDK_PATH}\platform\osa\inc"
"${PROJECT_KSDK_PATH}\platform\system\inc"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\config"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx_stdlib"
3.11 Link library paths
ksdk_platform_mqx
_mqx_stdlib
_mqx
gcc
c
supc++
m
nosys
"${PROJECT_KSDK_PATH}\lib\ksdk_mqx_lib\kds\K64F12\debug"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx_stdlib"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx"
3.12 Library Full Paths
"${PROJECT_KSDK_PATH}\lib\ksdk_mqx_lib\kds\K64F12\debug\libksdk_platform_mqx.a"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx_stdlib\lib_mqx_stdlib.a"
"${PROJECT_KSDK_PATH}\rtos\mqx\lib\frdmk64f.kds\debug\mqx\lib_mqx.a"
3.18
-Xlinker -static -Xlinker -z -Xlinker muldefs -Xlinker --undefined=__isr_vector -Xlinker --defsym=__stack_size__=0x400 -Xlinker --defsym=__heap_size__=0x200
3.19
#include <stdio.h>
#include <mqx.h>
#include <bsp.h>
/* Task IDs */
#define HELLO_TASK 5
#define WORLD_TASK 6
extern void hello_task(uint32_t);
extern void world_task(uint32_t);
const TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/* Task Index, Function, Stack, Priority, Name, Attributes, Param, Time Slice */
{WORLD_TASK, world_task, 700, 9, "world", MQX_AUTO_START_TASK, 0, 0},
{HELLO_TASK, hello_task, 700, 8, "hello", 0, 0, 0},
{0}
};
/*TASK*-----------------------------------------------------*
* Task Name : world_task
* Comments :
* This task creates hello_task and then prints "World ".
*
*END*-----------------------------------------------------*/
void world_task(uint32_t initial_data)
{
_task_id hello_task_id;
hello_task_id = _task_create(0, HELLO_TASK, 0);
if(hello_task_id == MQX_NULL_TASK_ID)
{
printf("\n Could not create hello_task\n");
}
else
{
printf(" World \n");
}
_task_block();
}
/*TASK*-----------------------------------------------------*
* Task Name : hello_task
* Comments :
* This task prints " Hello".
*
*END*-----------------------------------------------------*/
void hello_task(uint32_t initial_data)
{
printf("\n Hello\n");
_task_block();
}
/* EOF */
Thanks for your comments, I will fix that. I did not notice the invisible column.
I will also include guidelines to add environment variable and other libraries.
Please note that it is not necessary to add quotes in the paths unless there are spaces.
Regards,
Carlos
An additional note:
After adding the RTCS library and including it's directories I found that first PLATFORM_SDK_ENABLED=1 must be added to the compiler preprocessor (as well as the include directories and lib locations. But I'll post about that in more detail later).
Then I got an error that __aeabi_d2iz was undefined, located in the libm. Based on this post (__aeabi_d2iz ) I have found that in the linker libraries gcc must be located AFTER m, because libm references things located in libgcc.
Hi,
Just in case it helps, we have a new guide with details porting to MQX RTOS for Kinetis SDK. It includes the paths and configuration for adding in RTCS and MFS libraries to a project.
How To: Porting MQX RTOS v4.x to MQX RTOS for KSDK v1.2
Thanks,
Mac
When I try to build a project from scratch using the instructions in section 3 of the document I get a significantly different result from the example project. The new project wizard creates a directory "Project_Settings" with a subdirectory "Startup_Code" that are not in the example project. The files in this directory are included in the linker command even if the -nostartfiles linker switch is set. As a result, the vector table is filled from these files rather than from the MQX libraries and the project will not start MQX.
Are the instructions for building an MQX project from scratch obsolete?
Do you have an example project that was built from scratch rather than copied from a demo?
A you can see in step 3.5 it says that the virtual folder structure will be recreated manually.
In step 3.6 it says that Project_Settings folder should be removed.
At the end the project must look the same as the copy of the demo.
I missed that. That's embarrassing.
thank you.
No worries :smileywink:
Frustrating! So close and yet there are still catches.
The new project pdf says "Now the new project is completely self-dependent and ready to run" in section 2.8.
Wrong.
The new project references THE SAME FILES as the original project.
I can't create a new physical file in a virtual folder (main.c). So, I have to start from the beginning again somehow, with half modified demo / example code.
When will a new MQX project wizard be available for KDS?
Imagine I'm making a new product, and I've got something fairly close to what I need with the LWIP K64F ping demo. Do I just alter the demo? Or do I create a new project from scratch?
Hi Turboman,
here you can download project generator tool. Please note that is still beta version.
You may also find interesting following document: How to Add lwIP to KDS3.0 Project
Regards,
Carlos
Carlos,
thank you very much. The first solution was better than nothing at all - my apologies for showing my frustration. I'll try the wizard and and your updated suggestions when I have time. I'm getting closer, and need to learn more about MQX anyway.
I'm trying any solution I can and will post anything useful I find back up here,
best regards :smileyhappy: