Getting started with a Kinetics K64 C++ project

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

Getting started with a Kinetics K64 C++ project

2,035 Views
jheni
Contributor I

Hey guys,

I started to work with an existing K64 project.

However i could not get c++ to run (Constructors and destructors are not getting called).

Therefore i decided to

1) take a clean K64 project,

2)try to get this to run on my target

3)and hence convert it to c++.

(first question: is there already an example c++ project out there?)

However this is easier said than done.

Unlike ST NXP does not seam to offer anything like CubeMX (or i haven't found it).

I did come across the MCUXpresso SDK Builder. I did select my MCU "MK64FN1M0VDC12" and selected "build"

However the "GCC Arm Embedded toolchain" fails to compile when i run the provided shell scripts (several CMAKE errors).

After failing the GCC Arm embedded toolchain i tried the MCUexpresso IDE version. What version do i have to select from this dialog?

pastedImage_1.png

The SDK Archive or the Config Tools Data?

Could you help me figure out how to get this program to run

Labels (1)
Tags (2)
0 Kudos
Reply
4 Replies

1,781 Views
jheni
Contributor I

Hey thx for your answer. This was indeed helpful :smileyhappy:.

I did setup an USB sample project.

I event did manage to convert this project to c++ using this instruction

Convert project to C++ 

However Linking fails with various undefined references

c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 00008000

undefined reference to `memset'

undefined reference to `__data_section_table'

and so on

If i remove the -nostandardlib flag from the linker options the error messages go down to a few

make -r -j8 all
Building target: frdmk64f_host_hid_mouse_keyboard_freertos.axf
Invoking: MCU C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o
c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x16): undefined reference to `_exit'


c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: ./startup/startup_mk64f12.o: in function `ResetISR':
C:\Users\heju\mcuxpresso\workspace\frdmk64f_host_hid_mouse_keyboard_freertos\Debug/../startup/startup_mk64f12.c:537: undefined reference to `__data_section_table'


c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\heju\mcuxpresso\workspace\frdmk64f_host_hid_mouse_keyboard_freertos\Debug/../startup/startup_mk64f12.c:537: undefined reference to `__data_section_table_end'


c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\heju\mcuxpresso\workspace\frdmk64f_host_hid_mouse_keyboard_freertos\Debug/../startup/startup_mk64f12.c:537: undefined reference to `__bss_section_table_end'


c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: ./startup/startup_mk64f12.o:(.isr_vector+0x0): undefined reference to `_vStackTop'


c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:60: frdmk64f_host_hid_mouse_keyboard_freertos.axf] Error 1
"make -r -j8 all" terminated with exit code 2. Build might be incomplete.

Is there any reason why nostlibs flag is used?

the data_section objects are declared extern in the startup script. But i couldn't find an actual definition of these objects? Where are they coming from?

0 Kudos
Reply

1,781 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello jheni@testo.de

If you are using the wrong library variant you will see the error "undefined reference to".

I suggest you to read the chapter 17. C/C++ Library Support https://www.nxp.com/docs/en/user-guide/MCUXpresso_IDE_User_Guide.pdf

There you can find information about which library variant choose.

 

Also this post may be useful: https://community.nxp.com/thread/389070

 

Let me know if this is helpful.

Best Regards,

Omar

0 Kudos
Reply

1,781 Views
jheni
Contributor I

Hey Omar,

thx for your answer. I'll have a look and try to figure out the problem :smileyhappy:

0 Kudos
Reply

1,781 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello jheni@testo.de

Unfortunately we don’t have any c++ example. I suggest you to take a look at this link https://isocpp.org/wiki/faq/mixing-c-and-cpp for mixing C and C++.

 

On the other hand, the file you have to download is the SDK archive, please refer to this video to import an example https://www.nxp.com/video/mcuxpresso-ide-importing-sdk-example-project:MCUXPRESSO-IDE-IMPORTING-SDK-...

 

The config tool is an integrated suite of configurations tools that helps users with the development on arm processors.

pastedImage_2.png

Let me know if it helps.

 

Best Regards,

Omar

0 Kudos
Reply