Skip to content

Enabling C++ for PSoC projects

PSoCProgrammable System on Chip - is an ARM Cortex based family of MCUs (wiki) by Cypress Semiconductor. Cypress offers developers a dedicated IDE - PSoC Creator. Unfortunately, PSoC Creator, (as of version 4.2) does not support C++, despite the underlying GGC Toolchain (arm-none-eabi-gcc-5.4) has C++ support at descent level.

PSoC Creator has an option for migrating to Eclipse CDT IDE, however, migrated projects has no C++ support either

This post explains how to enable C++ for PSoC projects, imported in Eclipse CDT IDE.

Preconditions: you have a project created in PSoC Creator 4.2, and it is in buildable state

Step 1:Export your project to IDE Eclipse

1.1.Select Project > Export to IDE...

1.2.Select Eclipse and click Next

1.3.On the next screen just click Export

1.4.Click Copy project path to Clipboard and paste it somewhere to preserve for future use

1.5.Click Finish

Step 2:Download and install Eclipse CDT

Step 3:Navigate to PSoC Creator IDE page select tab Downloads and download PSoC Creator Eclipse Import

Step 4:Start Eclipse and create a new workspace. The workspace directory must be different from the PSoC Creator workspace directory

Step 5:Install PSoC Creator Eclipse Import plugin

5.1.Select Help > Install New Software...

5.2.Select Add...

5.3.Select Archive...

5.4.Select downloaded ZIP file with PSoC Creator Eclipse Import and click Add

5.5.Make sure PSoC Creator Import item is checked and click Next

5.6.On the next screen just click Next

5.7.Accept the terms and click Finish

5.8.On security warning click Install anyway

5.9.On the next screen click Restart Now

Step 6:Import project to Eclipse CDT

6.1.Select New > C/C++ project

6.2.Select C++ Managed Build

6.3.Select Project type > Others > PSoC Creator Project

6.4.Uncheck Use default location

6.5.Paste PSoC project path from step 1.4 or select it via Browse

6.6.Enter a project name (it may differ PSoC Creator project name)

6.7.Click Next

6.8.On the next screen just click Next

6.9.Provide Cross compiler path. It should point to bin directory containing arm-none-eabi-gcc.
Something like C:\Program Files\PSoC Creator\import\gnu\arm\5.4.1\bin

6.10.Click Finish

6.11.Confirm OK

Intermediate results: PSoC Creator project imported in Eclipse, and it has C/C++ nature
However it fails to link, because linker's settings were not imported. Next steps fixes this problem

Step 7:Start another Eclipse and create another, temporary workspace, different from the used on previous steps

Step 8:Import PSoC project to this Eclipse instance too, but use C Managed Build instead

Step 9:Copy linker settings from C Managed Build project to C++ Managed Build project

9.1.Select Project > Properties...

9.2.In the left tree navigate to C/C++ Build > Settings

9.3.In the Tool Settings navigate to Cross GCC Linker (PSoC Creator)

9.4.Do the same in the first Eclipse instance and place dialogs side by side

9.5.Copy-paste Command line pattern, add there ${PROC_LINK_FLAGS}

9.6.Navigate to Cross GCC Linker (PSoC Creator) > Libraries

9.7.Add Library search path from C Managed Build

9.8.Navigate to Cross GCC Linker (PSoC Creator) > Miscellaneous

9.9.Copy-paste Linker flags and Other options from C Managed Build
Keep Other objects empty - this option may cause build to fail with NullPointer exception

Step 10:Copy linker settings from C Managed Build project to C++ Managed Build project

10.1.Navigate to Cross G++ Compiler > Includes

10.2.Add Include paths from Cross G Compiler (PSoC Creator) > Includes

10.3.Navigate to Cross G++ Compiler > Optimization

10.4.Add to Other optimization flags the following:
-ffunction-sections -fno-exceptions -fno-rtti -fno-threadsafe-statics

10.5.Click Apply and close

10.6.Say No on the rebuild prompt

Step 11:Clean and rebuild project

Post a Comment

Your email is never published nor shared. Required fields are marked *