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?
Hi Ronan and StephenThanks very much for your answer Ronan. In line with your suggestion, I am now trying to use CMSIS and thought it best to try to run the CMSIS-RTOS2 Blinky example that Stephen suggested.
I have successfully imported it and built it. Please will you explain how I can run it in ARM Dev Studio?
Best regards
David
Hi David,
I assume you imported the uVision Simulator version of the Blinky example. This is configured by default for Cortex-M3. If you wish to change it for Cortex-M4, open the .rteconfig file. and go to the Device Tab, and click Change, and select ARMCM4(_FP) (if floating point desired). The example I attached yesterday may be easier to consume.To run, select Fiile > New > Model Connection, and give it a meaningful name. Also recommend associating with the project for ease of file management. In next pane, select MPS2_Cortex-M4 from the FVPs (Fixed Virtual Platforms) installed with Arm DS. Finally, in the Files tab, navigate to the .axf built in the Workspace, and in Debugger tab, Debug from main (or entry point), Click debug, and the model will launch and load the code (to repeat, you will be able to just double click on this connection in the Debug Connections pane).
Hi Ronan,
Thanks, I have successfully built the Blinky example and created a debug connection for it. Please will you remind me what I need to do to see the printf output in the Target Console?
If you have time, I would be grateful for steps to add C++ source file.Best regards
This one had me scratching my head for a moment...
I found the default build setting is to send printf (stdout) to Event Recorder, which is a Keil MDK feature for instrumentation.
Open the .rteconfig file, and disable this setting in Compiler > I/O, to use the default (semihosting) stdout.
Rebuilt, and I do indeed see the output in the Target Console:
Iris server started listening to port 7100 telnetterminal0: Listening for serial connection on port 5000 telnetterminal1: Listening for serial connection on port 5001 telnetterminal2: Listening for serial connection on port 5002 Iris server is reported on port 7100 LED On: #0 LED On: #1 LED Off: #0 LED On: #2 LED Off: #1 ...
To add a C++ file, this is not straight forward in this case. I don't think there is an option to change a C project to a C/C++ project. If you are just adding a single C++ source file, you can right click on that file, and in Properties > Tool Chain Editor, select the C++ compiler. You then need to go to Settings and enter compatible build options for the C builds. This will only apply to this source file, so isn't very scalable :(
The easiest solution (sorry) is to create a New > Project > C/C++ > C++ Project > CMSIS C/C++ Project, and then copy over the Blinky.c source file. You will need to setup the generated .rteconfig file the same way as it was for the previous project, but that is fairly straight forward from the GUI (and is likely do-once operation).