element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Blog MAX32660 Evaluation Kit - side note A: C++ Eclipse Project
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 16 Dec 2018 2:54 PM Date Created
  • Views 1599 views
  • Likes 2 likes
  • Comments 1 comment
  • RoadTest
  • eclipse
  • rt
  • max32660
  • maxim
  • road_test
  • c++
Related
Recommended

MAX32660 Evaluation Kit - side note A: C++ Eclipse Project

Jan Cumps
Jan Cumps
16 Dec 2018

I'm road testing the  Ultra-Low Power Arm Cortex-M4 Darwin MCU EVM.

In this posts I show how to create a C++ project.

image

 

 

Maxim has a tutorial that explains how to create an Eclipse project from scratch. It is for the MAX3263X but works perfectly for the MAX32660.

When you follow the instructions, you get a brand new C project.

I would like to create an object oriented example, so I tried the procedure, with as only difference choosing a new C++ Project instead of C project.

There are a few fixes you have to do to make the build and debug system work with the C++ sources.

 

Differences

 

The MAXIM tutorial tells you to create a C project. Create a C++ Project instead:

image

 

Perform all other steps as indicated in the tutorial. For the debug configuration, it's easier to just copy one from another MAX32660 project and edit all project references.

 

Makefile fixes

 

An obvious difference is that you have to replace main.c with main.cpp:

 

# Source files for this test (add path to VPATH below)
SRCS  = main.cpp

 

More subtle is that, when you try to debug the project, the debugger can't find the debug symbols and source file.

That's because in the MAXIM toolchain, there are a few inconsistencies between how C and C++ files are compiled.

The one that bites us, is that the C++ settings don't include debug symbols (-g3 -ggdb -DDEBUG).

 

It took me a while to find out why the debug info was not there for C++ files.

MAXIM uses a custom make file, so most settings in the Eclipse project are ignored and are defined in the make configuration.

 

I saw in the build console that the 3 switches were omitted for my .cpp file:

 

switches used for C++:

arm-none-eabi-g++ -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wa,-mimplicit-it=thumb -O1 -ffunction-sections -fdata-sections -MD -Wall -Wno-format -fno-rtti -fno-exceptions -std=c++11 -c  -DTARGET=32660 -DTARGET_REV=0x4131                  -DMXC_ASSERT_ENABLE -DRO_FREQ=80000000 -I. -ID:/Maxim/Firmware/MAX32660/Libraries/Boards/EvKit_V1/Include -ID:/Maxim/Firmware/MAX32660/Libraries/Boards/EvKit_V1/../Include -ID:/Maxim/Firmware/MAX32660/Libraries/MAX32660PeriphDriver/Include -ID:/Maxim/Firmware/MAX32660/Libraries/CMSIS/Device/Maxim/MAX32660/Include -ID:/Maxim/Firmware/MAX32660/Libraries/CMSIS/Include -o /d/users/jancu/workspace_eclipse_maxim/max32660_barometer_cpp/build/main.o main.cpp

 

switches used for C:

arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wa,-mimplicit-it=thumb -O1 -fsingle-precision-constant -ffunction-sections -fdata-sections -MD -Wall -Wdouble-promotion -Wno-format -c -fno-isolate-erroneous-paths-dereference -DTARGET=32660 -DTARGET_REV=0x4131 -g3 -ggdb -DDEBUG -DMXC_ASSERT_ENABLE -DRO_FREQ=80000000 -I. -ID:/Maxim/Firmware/MAX32660/Libraries/Boards/EvKit_V1/Include -ID:/Maxim/Firmware/MAX32660/Libraries/Boards/EvKit_V1/../Include -ID:/Maxim/Firmware/MAX32660/Libraries/MAX32660PeriphDriver/Include -ID:/Maxim/Firmware/MAX32660/Libraries/CMSIS/Device/Maxim/MAX32660/Include -ID:/Maxim/Firmware/MAX32660/Libraries/CMSIS/Include  -o /d/users/jancu/workspace_eclipse_maxim/max32660_barometer_cpp/build/board.o /D/Maxim/Firmware/MAX32660/Libraries/Boards/EvKit_V1/Source/board.c

 

Then it took me a while to find out why this was different.

The project's make file does not have anything that can influence this.

But that makefile includes a MAXIM specific makefile:

 

################################################################################
# Include the rules for building for this target. All other makefiles should be
# included before this one.
include $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/$(COMPILER)/$(TARGET_LC).mk

 

This resolves to <your drive>:\Maxim\Firmware\MAX32660\Libraries\CMSIS\Device\Maxim\MAX32660\Source\GCC\max32660.mk.

Again, in that file there's nothing to explain this behavior. But this one also includes a makefile:

 

# Include the rules and goals for building
include $(CMSIS_ROOT)/Device/Maxim/MAX32660/Source/GCC/gcc.mk

 

And that makefile, in the same directory as the one above, is the bad guy:

 

ifneq "$(TARGET_REV)" ""
CFLAGS+=-DTARGET_REV=$(TARGET_REV)
CXXFLAGS+=-DTARGET_REV=$(TARGET_REV)
endif

# Exclude debug for 'release' builds
ifneq (${MAKECMDGOALS},release)
ifneq (${DEBUG},0)
CFLAGS+=-g3 -ggdb -DDEBUG
endif
endif


CFLAGS+=$(PROJ_CFLAGS)
CXXFLAGS+=$(PROJ_CFLAGS)

 

On line 09 above, you can see that the debug options are only set for the C compiler variable CFLAGS.

They forgot to also do this for CXXFLAGS.

 

This can be fixed without changing MAXIM's SDK. You can adapt the projec's makefile to add the switches:

 

###############################################################################
# Include the rules for building for this target. All other makefiles should be
# included before this one.
include $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/$(COMPILER)/$(TARGET_LC).mk

#jc 20181216: also enable debug info for C++
# Exclude debug for 'release' builds
ifneq (${MAKECMDGOALS},release)
ifneq (${DEBUG},0)
CXXFLAGS+=-g3 -ggdb -DDEBUG
endif
endif

 

After doing that, everything works:

 

arm-none-eabi-g++ -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wa,-mimplicit-it=thumb -O1 -ffunction-sections -fdata-sections -MD -Wall -Wno-format -fno-rtti -fno-exceptions -std=c++11 -c -DTARGET=32660 -DTARGET_REV=0x4131 -DMXC_ASSERT_ENABLE -DRO_FREQ=80000000 -I. -ID:/Maxim/Firmware/MAX32660/Libraries/Boards/EvKit_V1/Include -ID:/Maxim/Firmware/MAX32660/Libraries/Boards/EvKit_V1/../Include -ID:/Maxim/Firmware/MAX32660/Libraries/MAX32660PeriphDriver/Include -ID:/Maxim/Firmware/MAX32660/Libraries/CMSIS/Device/Maxim/MAX32660/Include -ID:/Maxim/Firmware/MAX32660/Libraries/CMSIS/Include -g3 -ggdb -DDEBUG -o /d/users/jancu/workspace_eclipse_maxim/max32660_barometer_cpp/build/main.o main.cpp

 

The debug symbols are found and you can step through the code.

 

image

 

The binary - with debug symbols - is 10 K bigger than the C version. 568 K vs 558 K.

I haven't built a release version. I don't know how big the difference will be.

 

part 1: IDE install and Build First Example
part 2: Mod the PCB for Power Measurement
part 3: Power Measurement
part 4a: Low Power Sensor design - Barometer Hardware
part 4b: Low Power Sensor design - Barometer i2c and Init
part 4c: Low Power Sensor design - Barometer, Not Yet Power Optimised
MAX32660 Evaluation Kit - part 5: FreeRTOS Example
side note A: C++ Eclipse Project
side note B: Create a Release Configuration
  • Sign in to reply

Top Comments

  • DAB
    DAB over 6 years ago +1
    I admire your perseverance Jan. I hate it when they do not five you the right information to make a system work. DAB
  • DAB
    DAB over 6 years ago

    I admire your perseverance Jan.

     

    I hate it when they do not five you the right information to make a system work.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube