Turn from: http://ds.arm.com/zh-cn/developer-resources/tutorials/working-with-arm-ds-5/
Create a simple Hello World C program with bare metal as the target
After installing and obtaining the licenses required to use DS-5, this tutorial will guide you through creating, configuring, and generating simple bare-metal applications.
After the application is generated, this tutorial guides you through a series of configuration steps to establish a debug connection to the system model provided in the software to run the program. These models are called fixed virtual platforms (FVP), and DS-5 comes with some of these models. This tutorial will use the FVP_EB_CORTEX-A8 based on the CORTEX-A8 processor. Create a new C project select file > New > C Project in the DS-5 main menu, display the C Project dialog box. In the C Project dialog box:
When you select the bare metal executables option, the tool chain assumes that the application executes directly on the hardware rather than on a complex operating system such as Linux.
For ARM compiler information, see: http://infocenter.arm.com/help/topic/com.arm.doc.subset.swdev.coretools/index.html in project name field, enter HelloWorld as the project name. Under project Type , select bare Metal executable > Empty Project . Under the tool chain , select ARM compiler 5. Click Finish to create a C project named Hello World.
You can view this item in the Project Explorer view.
Create the source code and build the project in the Project Explorer view, right-click the Hello World Project and select New > Source file .
In the Xinyuan file dialog box, enter the filename hello_world.c.
Click Finish to create the source file, and then open it in code editing view.
The source file is also visible in the Project Explorer view, in the Hello world.
Add the following code to the new source file, and then press Ctrl+s to save it.
#include <stdio.h>
Main ()
{
printf ("Hello world\n");
}
In
Project Resource ManagerView, right-click
Hello WorldProject and select
Build Project。
You can view the output image hello_world.axf in the Debug folder under the HelloWorld project.
The. axf file contains the target code and debug symbols, which allow the debugger to perform source-level debugging. to debug an application on a fixed virtual platform (FVP)
After you create the project and generate the code, start the debugger to run the application on a fixed virtual platform (FVP) that is provided with DS-5.
For this tutorial, we use the Cortex-a8 fixed virtual platform (FVP) that is provided with DS-5. Create the DS-5 Debug configuration and connect to FVP in the DS-5 main menu, select run > Debug Configuration . In the Debug Configuration dialog box: Select the DS-5 debugger . Click the new launch configuration button.
This creates a new DS-5 debug configuration and displays each tab that specifies the settings that are used to load the application on the target.
In the Debug Configuration dialog box:
The workspace contains the HELLOWORLD.AXF application files that you create when you build the Hello World project.
Note: Make sure the Load Symbols option is selected.
Provides a name for the Debug configuration. For example, HELLOWORLD_FVP. In the Connection tab, select ARM fvp > Cortex-a8 > Bare Metal Debugging > Debug Cortex-a8. Select The File tab, and then in the application fields that you want to download on the host under the target configuration , click the workspace . Select HELLOWORLD.AXF. Select the Debugger tab to make sure that you select the symbol debugging option and set it to main. Click Debug to load the application on the target, and then load the debug information into the debugger. In the Confirmation perspective Toggle dialog box that appears, click Yes .
DS-5 connects to the model and displays the connection status in the debug control view.
The application is loaded on the target and stops at the main () function, ready to run.
Click to continue running the application
You can view the application output in the target console view.
Other views display information related to debugging connections.
For example, a command view displays a message that the debugger outputs. You can also use this view to enter the DS-5 command.
The C /C + + editor view displays the structure of the current C., C + +, or makefile. The view is updated accordingly as you edit the files.
The Disassembly view shows the disassembly view of a program running in memory.
Indicates the line of code that is currently being processed. In this example, it is located at the main () function. This view displays additional details about the code, giving you further information about the code.
The Disassembly view also displays the hexadecimal value of the code and the ASCII character equivalent to the memory value. You can use the memory view to see how the code is represented on target memory.
For example, to see the strings in your application Hello world's representation in memory:
In the example above, the memory view shows the hexadecimal value of the code and the ASCII character equivalent to the memory value, giving you a better idea of the code's details. Open the memory view. In the Address field, enter 0x8000, and then press enteron the keyboard. The view displays the contents of the target memory in a variety of sizes and formats. Select and highlight text Hello world. To run an application one step at a
Use the controls provided in the Debug control view to step through the application.
-Click to continue processing the code.
-Click to break or Pause code processing.
-Click to step through the code.
-Click to cross the source line of code.
-Click to exit.
-this is a switch. Select this if you want the above controls to step through the instructions. Disconnect Debug Connection
To disconnect from a debug connection, you can right-click the connection and select disconnect from Target , or select a connection and click
in the Debug Control
View toolbar