Using C++ with Kinetis Studio - SDK 2.0 project

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

Using C++ with Kinetis Studio - SDK 2.0 project

2,862 Views
simplethings
Contributor III

Hello guys, I've just started using Kinetis SDK.

I downloaded SDK_2.1_FRDM-KL25Z folder from kex.nxp.com

 

I created a new project using

File -> Kinetis SDK 2.x Project

 

However while creating project I was never asked what compiler should be used nor is it  C or C++ project.

 

In the source folder there is a following code:

[code]

#include <string.h>

 

#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
/*#include "fsl_debug_console.h"*/

 

/* FreeRTOS kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"

 


/* Task priorities. */
#define hello_task_PRIORITY (configMAX_PRIORITIES - 1)

 

/*!
 * @brief Task responsible for printing of "Hello world." message.
 */
static void hello_task(void *pvParameters) {
  for (;;) {
    /*PRINTF("Hello world.\r\n");*/
    /* Add your code here */
    vTaskSuspend(NULL);
  }
}

 

/*!
 * @brief Application entry point.
 */
int main(void) {
  /* Init board hardware. */
  BOARD_InitPins();
  BOARD_BootClockRUN();
  BOARD_InitDebugConsole();

 

  /* Add your code here */

 

  /* Create RTOS task */
  xTaskCreate(hello_task, "Hello_task", configMINIMAL_STACK_SIZE, NULL, hello_task_PRIORITY, NULL);
  vTaskStartScheduler();

 

  for(;;) { /* Infinite loop to avoid leaving the main function */
    __asm("NOP"); /* something to use as a breakpoint stop while looping */
  }
}

 

[/code]

 

After trying the build the project from

Project -> Build all I get the following error (in the picture attached)

Also If I try to run the program it says that 'Binary could not be found'

 

I am really not familiar with eclipse so if someone could help me I am stuck with googleing whole day this problem.

 

Big thanks!

step 1 — Postimage.org 

kinetis error — Postimage.org 

0 Kudos
Reply
9 Replies

2,045 Views
simplethings
Contributor III

WithoutFreeRTOS.JPG

That is what I get after not choosing FreeRTOS and trying to run a project, I don't get any error building it

0 Kudos
Reply

2,045 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello fsa,

- Please download the latest  sdk version  "SDK_2.2_FRDM-KL25Z"

from Welcome to MCUXpresso | MCUXpresso Config Tools 

- Install the KDS update about New Kinetis SDK 2.x Project Wizard :

pastedImage_1.png

Then create a new project based on SDK , there is no error when build , I have test it on my side .

Hope it helps


Have a great day,
Alice Yang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

2,045 Views
simplethings
Contributor III

I followed your instructions,

So I have created new SDK 2.0 Project

Capture.JPGCapture2.JPG

This image happens when I try to run the project after building it.

I am not sure what should I choose from this launch configuration?

However if I create C++ Project and build it and then run it I get this error:

Capture3.JPG

0 Kudos
Reply

2,045 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Fsa,

What about your debug firmware on your board ,  OpenOCD , PE or J-link ?

Please select the right one refer to your firmware :

pastedImage_1.png

(right your project ->debug AS -. debug configuration ...)

About the three debug mode introduce and configuration , please check

KDS_Users_Guide.pdf -> 2.5 Debugging Projects

Hope it helps

Alice

0 Kudos
Reply

2,045 Views
simplethings
Contributor III

Hello everyone again, so at one point I just gave up ARM microcontrollers and kept working with my old good buddies, AVRs. I want to give Kinetis Design and ARM MCUs another chance. So basically I managed to successfully add new SDK 2.0 C/C++ project, and it builded with no errors.

I have followed the KSD_USERS_Guide.pdf that you attached.

Kinetis_debugger_settings.JPG

So I have installed GDB PEMicro drivers and set up all the data in Kinetis Design Debugger Options as described in the pdf. There are several MCU Targets, I have tried to enter Bootloader and clicked on of the HTMLs : FRDM-KL25Z|Freedom Development Platform|Kinetis MCU|NXP . Seems like my board is KL25Z128M4. My MCU is plugged in, but under Port label I cannot see any devices.

I tried to run debug but I get the following error:

Kinetis_debugging.JPG

Two days ago I changed my bootloader to mbed, since I was able to successfully flash my MCU with mbed platform. Maybe I do need to install bootloader version from: PEmicro - P&E Microcomputer Systems: Over 30 years as an Industry leader in Embedded Systems Develop... in order to run debugging in KDS?

I have the following hardware information on my board: 

Board Name is: FRDM-KL25Z
MicroBoot Kernel Version is: 1.03
Bootloader Version is: 1.05
Application Version is: 0.00

Besides debugging, is there a possibility like in Atmel Studio to flash compiled code on MCU directly from KDS?

 

About creating FreeRTOS project. I tried to create FreeRTOS project, however I am not able to build the project. There seems to be errors in makefile and tasks.c files

 

makefile

# Tool invocations
KL25Z_FreeRTOS.elf: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'   // This line of the script that is in red and it doesn't tell anything
@echo 'Invoking: Cross ARM C++ Linker'
arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -T "../MKL25Z128xxx4_flash.ld" -Xlinker --gc-sections -Wl,-Map,"KL25Z_FreeRTOS.map" --specs=nano.specs -specs=nosys.specs -Xlinker -z -Xlinker muldefs -o "KL25Z_FreeRTOS.elf" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

in tasks.c I have several undefined references to function calls of methods portRESET_READY_PRIORITY and port_RECORD_READY_PRIORITY

I have created FreeRTOS project as File->New->Kinetis SDK 2.x project -> checked on the right side "All drivers and RTOS " boxes & chose under "Processors -> New MKL25Z128xxx4 project"

Best regards.

0 Kudos
Reply

2,045 Views
simplethings
Contributor III

I am aware of that I am using FreeRTOS on AVR ATmega devices.

However could you provide me link on how to make a C++ project in Kinetis Design studio I have never used it in my life and I have board which I cannot use because of it.

0 Kudos
Reply

2,045 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello fsa,

- For the C++ code on project , please  add the below code

#ifdef __cplusplus
extern "C" {
#endif               
                     
   /* your C++ codes*/
       
#ifdef __cplusplus
} /* extern "C" */
#endif‍‍‍‍‍‍‍‍‍

As this case https://community.nxp.com/message/859161  

-  About your this question , does it  happen when you just create a new FreeRTOS project on KSDK ?

If not, could you please share your project with me, I will check it on my side .

BR

Alice

0 Kudos
Reply

2,045 Views
simplethings
Contributor III

I have just tried to make a new SDK 2.0 project without FreeRTOS, I don't get error 'Binary not found'.

But instead I get to choose these 3 launch configurations:

[url=https://postimg.org/image/qqa1sh60r/][img]https://s9.postimg.org/908d7fsfz/Without_Free_RTOS.jpg[/im... upload[/url]

When I select any of those 3 configurations nothings happens and if I try to run again project same thing happens over again.

It seems like Binary not found is related to a project that includes FreeRTOS.

Also in link you provided, you suggested to rename file.c into file.cpp

This happens when I try to rename it

[url=https://postimg.org/image/idcy0lj81/][img]https://s16.postimg.org/rxwknh8k5/File_Rename_From_Cto_CPP...]

How would you like from me to share project with you, is there a way to upload files on the forum?

I uploaded FreeRTOS project files to my github profile

GitHub - IvanAntunovic/KinetisFreeRTOS 

0 Kudos
Reply

2,045 Views
MarekTrmac
NXP Employee
NXP Employee

Hi fsa saf,

if you use FreeRTOS, you should use device with 16KB of RAM or more. Devices with smaller RAM are not recommended.

It might be possible to manually tune the project for specific use-cases, but this use case is not supported by NewProjectWizard.

Regards

Marek

0 Kudos
Reply