Kinetis Design Studio - enabling C++ in KSDK projects

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Kinetis Design Studio - enabling C++ in KSDK projects

ソリューションへジャンプ
98,065件の閲覧回数
bluetiger9
Contributor II

I would like to use C++ in a project generated with KSDK Project Generator 2.1 (board FRDM-K82F). I imported the project into Kinetis Design Studio. It was all ok until that point.

 

I added a simple C++ class in a .hpp files and included that into the main.c. I got some compile errors. This was somewhat expected, as I tried to use C++ in a C file. So, I renamed the main.c to main.cpp, but I'm getting the following error: "(.text+0x4a): undefined reference to `main'". As I saw the main.cpp is not even compiled.

 

Any idea what is the problem?

ラベル(1)
0 件の賞賛
返信
1 解決策
2,973件の閲覧回数
MarekTrmac
NXP Employee
NXP Employee

Hi Atilla,

in KDS 3.2, there is also New Project Wizard for KSDK2.0 available. This allows to create CPP projects too.

Use "File - New - C++ Project - Executable - Kinetis Project for SDK 2.x"

Regards,

Marek Trmac

元の投稿で解決策を見る

0 件の賞賛
返信
11 返答(返信)
2,973件の閲覧回数
MarekTrmac
NXP Employee
NXP Employee

Hi Attila,

there is problem in the manifest - wrong linker specification. Please download the latest package from the KEX server.

Regards

Marek

0 件の賞賛
返信
2,973件の閲覧回数
bluetiger9
Contributor II

Hi Marek,

Here is the _manifest.xml:

[XML] FRDM-K82F_manifest.xml - Pastebin.com

Thanks,

Attila

0 件の賞賛
返信
2,973件の閲覧回数
MarekTrmac
NXP Employee
NXP Employee

Hi Attila,

could you please post as attachment "*_manifest.xml" file from the root folder of your KSDK package? I still cannot reproduce the issue, and I susupect the problem is in the manifest file.

Thanks

Marek

0 件の賞賛
返信
2,973件の閲覧回数
MarekTrmac
NXP Employee
NXP Employee

Hi Atilla,

can you describe how to reproduce your problem with two linker scripts in one project?

If I create project for the board (all drivers, no RTOS), there is just one linker, see attached picture:

Capture.PNG

Regards

Marek

0 件の賞賛
返信
2,973件の閲覧回数
bluetiger9
Contributor II

Hi Marek,

I just created a project with the File - New - C++ Project - Executable - Kinetis Project for SDK 2.x wizard. I'm using KDS on Ubuntu. Maybe it's related to this.

Thanks,

Attila

0 件の賞賛
返信
2,973件の閲覧回数
MarekTrmac
NXP Employee
NXP Employee

Hi Attilla,

we cannot reproduce your problem on UBuntu 16.04 (also not on Windows 7). Can you specify what parameters have you selected during project creation (what driver and what RTOS - if any)? Can you find what version of NewProjectWizard do you have - using Help - About - Installation Details - item "New Kinetis SDK 2.x Project Wizard" (version is displayed in the second column).

Thanks

Marek

0 件の賞賛
返信
2,973件の閲覧回数
bluetiger9
Contributor II

Hi Marek,

I am using the default setting: all drivers, no RTOS.

Here is a quick video of how I create the project:

KDS 3 - Two linkers scripts - vidme

Eclipse component versions:

pastedImage_4.png

Thanks,

Attila

0 件の賞賛
返信
2,973件の閲覧回数
bluetiger9
Contributor II

Ok, I found the problem.

There were two conflicting linker scripts used with the linker:

MK82FN256xxx15_flash.ld

MK82FN256xxx15_ram.ld

so the second fucked up the memory regions defined by the first.

The solution was to remove the MK82FN256xxx15_ram.ld from script files from the Cross ARM C++ Linker settings.

Thanks!

0 件の賞賛
返信
2,974件の閲覧回数
MarekTrmac
NXP Employee
NXP Employee

Hi Atilla,

in KDS 3.2, there is also New Project Wizard for KSDK2.0 available. This allows to create CPP projects too.

Use "File - New - C++ Project - Executable - Kinetis Project for SDK 2.x"

Regards,

Marek Trmac

0 件の賞賛
返信
2,973件の閲覧回数
bluetiger9
Contributor II

Hi Marek,

Thanks for your suggestion. I tried it and the following happens:

  • the project is successfully created along with a main.cpp
  • the build is successful, with some warnings:

    DescriptionResourcePathLocationType
    redeclaration of memory region `m_text'CppTest222line 61, external location: /opt/Freescale/KDS_v3/toolchain/arm-none-eabi/bin/ld:../MK82FN256xxx15_ram.ldC/C++ Problem
    redeclaration of memory region `m_interrupts'CppTest222line 59, external location: /opt/Freescale/KDS_v3/toolchain/arm-none-eabi/bin/ld:../MK82FN256xxx15_ram.ldC/C++ Problem
    redeclaration of memory region `m_data'CppTest222line 60, external location: /opt/Freescale/KDS_v3/toolchain/arm-none-eabi/bin/ld:../MK82FN256xxx15_ram.ldC/C++ Problem
  • but when I try to upload & debug the project, I get this:

pastedImage_0.png

     and the board is still executing the old program.

I looked into the logs, but I can't figure out what could be wrong.

Here are the consoles from KDS:

CDT-Global-Build-Console - Pastebin.com

gdb-traces - Pastebin.com

JLinkGDBServerCL - Pastebin.com

arm-none-eabi-gdb - Pastebin.com

Can you please take a look?

Thanks,

Attila

0 件の賞賛
返信
2,973件の閲覧回数
TICS_Fiona
NXP Employee
NXP Employee

Hello Attila

You may refer to these blogs to use GCC tool chain with C++:

http://mcuoneclipse.com/2012/10/04/processor-expert-gcc-c-and-kinetis-l-and-mqxlite/

http://mcuoneclipse.com/2014/10/25/c-with-kinetis-design-studio/

Hope this helps!

Best Regards

Fiona Kuang

TIC - Technical Information Center

-----------------------------------------------------------------------------------------------------------------------

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

-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信