This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C++ example for Cortex-M4 using gnu g++ compiler?

I want to build and simulate a C++ project for Cortex-M4, using the g++ arm compiler, in Arm Dev Studio.

Which example would be suitable as a template please?

Parents
  • Hi,

    My name is Stephen and I work at Arm.

    As a starting point, I suggest you take a look at the ready-made example for Cortex-M4, provided in the Arm DS Examples, named "startup_Cortex-M4_AC6".  That example is intended for use with Arm Compiler 6 ("AC6").

    To import this example into the workspace:

    1. File > Import
    2. Arm Development Studio > Examples & Programming Libraries
    3. In the search field, enter e.g. "M4"
    4. Select the "startup_Cortex-M4_AC6" example

    To run the example, follow the instructions in the readme.

    Sorry, there is no a GCC-specific example for Cortex-M4 in the Arm DS examples, though the command-lines are similar, so it should be straightforward to convert from AC6 to GCC.

    C code for Cortex-M4 would normally be compiled using Arm Compiler 6 with, e.g.:
    armclang --target=arm-arm-none-eabi -mcpu=cortex-m4 -g -O1 ...

    C++ code for Cortex-M4 would normally be compiled using g++ with, e.g.:
    arm-none-eabi-g++ -c -mcpu=cortex-m4 -g -01 ...

    The "startup_Cortex-M4_AC6" example uses some AC6 compiler intrinsics such as __arm_wsr(), though these can be converted to inline assembler if needed for g++.

    Alternatively, take a look at the CMSIS Pack examples for the Cortex-M family.  For example, the RTX RTOS can be compiled with either AC6 or GCC.  To explore these, go to the CMSIS-Pack Manager perspective (button the top-right of the IDE).  Then, in the Devices tab, select your M-class device (or "All Devices"), then select the Examples tab.   The CMSIS-RTOS2 Blinky example might be a good one to start with.

    Hope this helps,

    Stephen

Reply
  • Hi,

    My name is Stephen and I work at Arm.

    As a starting point, I suggest you take a look at the ready-made example for Cortex-M4, provided in the Arm DS Examples, named "startup_Cortex-M4_AC6".  That example is intended for use with Arm Compiler 6 ("AC6").

    To import this example into the workspace:

    1. File > Import
    2. Arm Development Studio > Examples & Programming Libraries
    3. In the search field, enter e.g. "M4"
    4. Select the "startup_Cortex-M4_AC6" example

    To run the example, follow the instructions in the readme.

    Sorry, there is no a GCC-specific example for Cortex-M4 in the Arm DS examples, though the command-lines are similar, so it should be straightforward to convert from AC6 to GCC.

    C code for Cortex-M4 would normally be compiled using Arm Compiler 6 with, e.g.:
    armclang --target=arm-arm-none-eabi -mcpu=cortex-m4 -g -O1 ...

    C++ code for Cortex-M4 would normally be compiled using g++ with, e.g.:
    arm-none-eabi-g++ -c -mcpu=cortex-m4 -g -01 ...

    The "startup_Cortex-M4_AC6" example uses some AC6 compiler intrinsics such as __arm_wsr(), though these can be converted to inline assembler if needed for g++.

    Alternatively, take a look at the CMSIS Pack examples for the Cortex-M family.  For example, the RTX RTOS can be compiled with either AC6 or GCC.  To explore these, go to the CMSIS-Pack Manager perspective (button the top-right of the IDE).  Then, in the Devices tab, select your M-class device (or "All Devices"), then select the Examples tab.   The CMSIS-RTOS2 Blinky example might be a good one to start with.

    Hope this helps,

    Stephen

Children