Overview

This tutorial takes you through the process of creating a simple "Hello World" Linux application and then loading the application on a Cortex-A9 Fixed Virtual Platform (FVP) model running Arm embedded Linux. The Cortex-A9 Fixed Virtual Platform (FVP) model is provided with an Arm Development Studio (Arm DS) all editions.

Creating a Simple Hello World Linux Application using C

To create a Linux application using C in Arm DS:

  1. Create a new C project and use the GCC toolchain.
  2. Set up the GCC toolchain compiler and linker options to build with the appropriate settings for Arm Embedded Linux running on a Fixed Virtual Platform (FVP) model.
  3. Create a source file and build it to create an application.

Configuring the Settings for New Project 

  1. In the Project Explorer view, right-click the HelloWorld_GCC project, and select Properties. You can also access the project properties from the main Arm DS menu. From the main menu, select Project > Properties.
  2. Select C/C++ Build > Settings > Tool Settings tab.
    1. You need to specify the relevant flags under GCC C Compiler 4 [arm-linux-gnueabihf] > Miscellaneous > Other flags
    2. Arm DS and later support a hard-float file system, so enter:
      -marm -mfloat-abi=hard
    3.    



    4. These flags instruct the GCC compiler to compile a binary that is compatible with a particular architecture and file system. For more information about GCC compiler options for Arm, see: http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
    5. On the Properties for HelloWorld_GCC project dialog, click OK to apply the settings and close the dialog.

Creating the Source Code and Building the Project

  1. In the Project Explorer view, right-click the HelloWorld_GCC project and select New > Source File.




  2. In the New Source File dialog, enter the file name HelloWorld_GCC.c.
  3. Click Finish to create the source file and open it in the code editing view.

  4. Add the following code to the new source file, and press CTRL+S to save it.
  5. #include <stdio.h> 
    
    int main(int argc, char** argv) 
    { 
          printf("Hello world\n");
          return 0; 
    } 
    </stdio.h>
  6. In the Project Explorer view, right-click the HelloWorld_GCC project and select Build Project. This creates the Linux executable and required support files.



  7. The items in the Debug folder are additional files required for debugging.

Debug the Linux Application on a Fixed Virtual Platform (FVP) Model

Once you have created the project and built the code, launch the debugger to run the application on one of the Fixed Virtual Platform (FVP) models provided with Arm DS.

For this tutorial, we use the FVP_VE_Cortex-A9x4 model provided with Arm DS.

Creating an Arm DS Debug Configuration and Connecting to a FVP Model

  1. From the Arm DS main menu, select Run > Debug Configurations.
  2. In the Debug Configurations dialog:

    a. Select "Generic Arm C/C++ Application" from the available options in the left side of Debug Configuration window.

    b. Select "Press the New button to crate a configuration of the selected type" icon as shown in above picture.

    c. This creates a new Arm DS debug configuration and displays the various tabs required to specify settings for loading your application on the target.

  3. On the Debug Configurations dialog:

    a. Give a name to the debug configuration. For example, HelloWorld_Linux_FVP.

    b. In the Connection tab, select Arm FVP (Installed with Arm DS) > Cortex-A9x4 pre-configured to boot Arm Embedded Linux > Linux Application Debug > Start gdbserver and debug target resident application.

    By default, a relative path to your workspace location is specified in the Host mount point field. This location is used by the /writeable directory specified in the Remote target mount point field.

    c. In the Files tab, and under Target Configuration > Application on target field, enter /writeable/HelloWorld_GCC/Debug/HelloWorld_GCC. This specifies that the HelloWorld_GCC application is available under the/writeable/HelloWorld_GCC/Debug/ location on the target. 

    d. Under Files, select Load symbols from a file, and click Workspace.

    e. In the Open dialog, select the HelloWorld_GCC application in the Debug folder.

    f. Click OK. This sets the path to the file that contains the required symbols information.

    g. Select the Debugger tab, and select Debug from the entry point.

    h. Click Debug to load the application on the target, and load the debug information into the debugger.

    i. In the Confirm Perspective Switch dialog that appears, click Yes.
    Arm DS-connects to the FVP model loads Linux on the FVP model and displays the connection status in the Debug Control view.

    The application is loaded on the target and has stopped at the entry point, ready to run.

Debug Views

Once the debug connection is established some of the display information relevant to the debug connection are:

  1. The Commands view displays messages output by the debugger. Also use this view to enter Arm DS commands.

     

  2. The C/C++ Editor view shows the structure of the active C, C++, or makefile. The view is updated as you edit these files.

  3. The Disassembly view shows the loaded program in memory as addresses and assembler instructions.

    Green line indicates the location in the code where your program is stopped. In this case, it is at the main() function. Light Green line indicates the next instruction which to be execute.

  4. Click Continue Button to run the application.

    You can view the application output in the App Console view.

    App console view

Stepping Through the Application

  1. Use the controls provided in the Debug Control view to stepping through the application.

    Continue Button - Click to continue processing code.

    Pause Button - Click to interrupt or pause processing code.

    Step Through button - Click to step through the code.

    Step Over button - Click to step over source line.

    Step Out button - Click to step out.

    Step instruction - This is a toggle. Select this if you want the above controls to step through instructions.

Disconnecting from the debug Connection

  • Right-click the connection and select Disconnect from Target,
  • or select the connection and in the Debug Control view toolbar click Disconnect button
  • or double-click on the selected connection.