Lab 0
Lab 0
CENG 255
Laboratory Experiment #0
The laboratory experiments are developed to provide a hands-on introduction to the ARM archi-
tecture. The labs are based on the open source tools Eclipse and OpenOCD.
You are expected to read this manual carefully and prepare in advance of your lab session. Pay
particular attention to the parts that are bolded and underlined. You are required to address these
parts in your lab report. In particular, all items in the Prelab section must be prepared in a written
form before your lab. You are required to submit your written preparation during the lab, which
will be graded by the lab instructor.
Laboratory Experiment 0: Introduction to
Eclipse
1.1 Goal
Eclipse is an integrated development environment (IDE) that can be used to develop applications
with various programming languages such as C and C++. With the proper plug-ins, one can de-
velop ARM assembly applications in Eclipse and execute/debug programs on ARM development
boards. This is a tutorial to introduce Eclipse and the process of developing a C program to be
executed on the STM32F0 Discovery Boards in the lab.
• In the Project name: field enter the name of a new project, for example, Blinky
• In the Project type: section expand the Executable type and select STM32F0xx C/C++
Project
In the Target processor settings window, use all the default values:
• Content: use this default value Blinky (blink a LED) as this tutorial is to create a Blinky
project. If you want to create another new project, you can switch to Empty (add your own
content)
• Leave the default folders unchanged and click the Next> button.
• Leave the default settings unchanged and click Next> button to the next step. button.
• Select the Toolchain name: GNU Tools for ARM Embedded Processors (arm-none-eabi-
gcc)
The result of this wizard is a simple project, with a main() printing greetings and blinking a LED.
• Click the hammer icon, which is the shortcut to build the selected project.
Or
The build process produces a listing in the Console window like this:
The files created by the build process are left in a Debug folder
• Select the forward button on the right side of the bug icon.
• Double click GDB OpenOCD Debugging; this creates a project debug with the project name
Blinky Debug
• In Config options: fill in the following setting (f is a flag indicating the file to be used ) :
-f board\stm32f0discovery.cfg
• In the rectangle above the Enable ARM semihosting checkbox, fill in the following setting
(this command tells the debugger to stop at the beginning of the main function so that the
programmer can debug the project step by step).
• Tick the Debug checkbox in the rectangle below Display in the favorites menu
The debugging configuration wizard creates a debug setting for the Blinky project. The result of
debugging installs the binary of the project into the ARM board (that is, the executable binary file
is downloaded to the RAM on board). At the beginning of debug process, the program stops at the
main function waiting for the programmer to debug the program.
These icons labeled below in the toolbar of Eclipse are the ones used most frequently in debugging
and they help the programmer to interact with the debugger. Experiment/Play with these icons and
see how they work.
• Change the .c extension of main.c to .asm or .S and remove all the contents in that file.
• The build and debug steps are the same as described in Part 1.
• Remove all the files except main.c in the src folder in Blinky project and replace the exten-
sion of main.c by .asm.
• Clear the contents in main.asm and write some simple assembly codes for experimentation.
To change the formatted display also known as Radix right click on displayed data and select the
Radix option then select displayed format. This is shown in the image below.
Disabling console switching: During the debugging process when the debugger steps or encoun-
ters a break point it will print information on the console tab. When this occurs Eclipse will
automatically switch to the console window to display this information. In specific labs such as
the bubble sort lab it would be more convenient to not have Eclipse switch to the console and just
to stay in the Memory Browser tab. There are two ways to achieve this.
The first is to disable console switching. This option can be found in the windows-¿preferences
dialog box. In the preference dialog expand the Run/Debug section and select console. Unselect
the options “Show when program writes to standard out” and ”Show when program writes to
standard error” as shown in the image below. This is a global setting and will apply to all projects
in the Eclipse workspace.
The second method is by dragging the Memory browser to a vacant area on the computer screen
not being used by any program. Eclipse will automatically create a new window specifically for
the memory browser. This feature can be used with any view in Eclipse.
Disassembly not showing in disassembly window: If you are using the disassembly view there is
a known issue with this feature. When you first enter debug mode you will notice that the window
does not update. See picture on the left. The simple resolution is to close the current disassembly
tab and open it from the main menu. Windows->Show View->Disassembly. See picture
to the right.