20
1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse 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 develop 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 C and assembly programs to be executed on the STM32F0 Discovery Boards in the lab. Part 1: Create a Blinky C Project 1. Configure Eclipse for STM32F0 You develop and store your source code as projects. To create a project, go to Eclipse menu, File ->New, and select C Project:

CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

  • Upload
    vohuong

  • View
    217

  • Download
    2

Embed Size (px)

Citation preview

Page 1: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

1

CENG255LaboratoryExperiment#0

Tutorial:IntroductiontoEclipse

Eclipse is an integrated development environment (IDE) that can beusedtodevelopapplicationswithvariousprogramminglanguagessuchasCandC++.Withtheproperplug-ins,onecandevelopARMassemblyapplications in Eclipse and execute/debug programs on ARMdevelopment boards. This is a tutorial to introduce Eclipse and theprocessofdevelopingCandassemblyprogramstobeexecutedontheSTM32F0DiscoveryBoardsinthelab.

Part1:CreateaBlinkyCProject

1.ConfigureEclipseforSTM32F0Youdevelopandstoreyoursourcecodeasprojects.Tocreateaproject,gotoEclipsemenu,File->New,andselectCProject:

Page 2: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

2

A.InsidetheCProjectwindow:

• IntheProjectname:fieldenterthenameofanewproject,forexample,Blinky• IntheProjecttype:sectionexpandtheExecutabletypeandselectSTM32F0xxC/C++Project• IntheToolchains:selectCrossARMGCC• ClicktheNext>button

Page 3: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

3

B.IntheTargetprocessorsettingswindow,useallthedefaultvalues:

• Chipfamily:defaultvalue(STM32F051)isthetargetARMboard• Flashsize(KB):theflashsizeofourARMboard• RAMsize(KB):theRAMsizeofourARMboard• Clock(Hz):thedefaultvalueofourARMboard• Content:usethisdefaultvalue–Blinky(blinkinganLED)asthistutorial is tocreateaBlinky

project. Ifyouwanttocreateanothernewproject,youcanswitchtoEmpty (addyourowncontent)

• ClicktheNext>button

Page 4: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

4

C.IntheFolders_settingswindow:

LeavethedefaultfoldersunchangedandclicktheNext>button.

Page 5: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

5

D.IntheSelectConfigurationswindow:

LeavethedefaultsettingsunchangedandclickNext>buttontothenextstep.

Page 6: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

6

E.IntheCrossGNUARMToolchainwindow:

• SelecttheToolchainname:GNUToolsforARMEmbeddedProcessors(arm-none-eabi-gcc)• ClicktheFinishbutton

Page 7: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

7

F.Theresultofthiswizardisasimpleproject,withamain()printinggreetingsandblinkinganLED.

Page 8: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

8

2.Buildtheproject• SelecttheBlinkyprojectintheProjectExplorer• Clickthehammericon,whichistheshortcuttobuildtheselectedproject.

Or

• RightclicktheBlinkyprojectintheProjectExplorer• SelectBuildProjectinthepopupwindow

Page 9: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

9

ThebuildprocessproducesalistingintheConsolewindowlikethis:

ThefilescreatedbythebuildprocessareleftinaDebugfolder

Page 10: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

10

3.ConfiguredebuggingTosetdebugging:

• Selecttheforwardbuttonontherightsideofthebugicon.• SelectDebugConfigurations…inthepopupwindow

IntheDebugConfigurationswindow:

• Double click GDB OpenOCD Debugging; this creates a project debug with the project nameBlinkyDebug

Page 11: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

11

• GototheDebuggertabo InExecutable:enteropenocd.exeo InConfigoptions:fillinthefollowingsetting:

§ -(note:thisshouldbeaminussign)fboard\stm32f0discovery.cfg(fisanoptionindicatingtheconfigurationfileoftheboardtobeused)

Page 12: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

12

• GototheStartuptabo In the rectangle above the Enable ARM semihosting checkbox, fill in the following

setting§ monitorresethalt(thiscommandtellsthedebuggertostopatthebeginningof

themainfunctionsothattheprogrammercandebugtheprojectstepbystep.)

Page 13: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

13

• GototheCommontabo TicktheDebugcheckboxintherectanglebelowDisplayinthefavoritesmenuo ClicktheApplybuttono ClicktheDebugbuttontostartdebugging

Page 14: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

14

The debugging configuration wizard creates a debug setting for the Blinky project. The result ofdebugging installs the binary of the project into theARMboard (that is, the executable binary file isdownloaded to thememory onboard). At the beginning of debugprocess, the program stops at themainfunctionwaitingfortheprogrammertodebugtheprogram.

Page 15: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

15

The icons labeledbelow inthetoolbarofEclipsearetheonesusedmost frequently indebuggingandtheyhelptheprogrammertointeractwiththedebugger.Experimentandplaywiththeseiconsandseehowtheywork.

• IconA:toskipallthebreakpoints• IconB:toresumeprogramexecutionfromdebugging• IconC:tosuspendprogramexecutionandsetitbacktodebug• IconD:toterminateprogramexecution• IconE:tostepintoafunction• IconF:tostepoverafunction• IconG:toreturntothefunction• IconH:torestartaprocessordebugtargetwithoutterminatingandre-launching

Page 16: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

16

Part2:CreateanARMAssemblyProject1. FollowthewizardsinPart1ofthistutorialthatcreateanARMCproject.2. Changethe.cextensionofmain.cto.asmor.Sandremoveallthecontentsinthatfile.3. Writesomesimpleassemblycodesinthemain.asm/main.Stoimplementyourapplication.4. ThebuildanddebugstepsarethesameasdescribedinPart1.

Creatinganassemblyproject:(usingBlinkyprojectasanexample)

1. Removeallthefilesexceptmain.cinthesrcfolderinBlinkyprojectandreplacetheextensionofmain.cby.asm.

2. Clearthecontentsinmain.asmandwritesomesimpleassemblycodesforexperimentation.

Page 17: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

17

Part3:TipsforusingeclipseA.Changingdisplayedformatinregistertab:

During the debugging process you will be examining registers in the processor. You can change thedisplayedformatofaregisterbyrightclickingonthespecificregisterandselectingtheNumberFormatoptionasshowninthefigurebelow.Youcanalsochangeagroupofregisters.Iftheregistertabisnotthere,youcandisplayitbyselectingtheWindowoptiononthemainmenuthenShowView->Registers.

Note:InothersectionsofEclipseyoumayfindnumberformatisalsocalledRadix.

B.Changingcellsizeandformatinthememorybrowser:

Thememorybrowser allows you toexamine sectionsofmemory in youprogram. The cell size is thenumberEclipseuses in theMemoryBrowser tab.Tochangeyourcell size rightclickon thedisplayeddata inyourMemoryBrowser tabandselect theCellSizeoption, thenselect thecell size tobeused.Thisisshownintheimagebelow.

Page 18: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

18

C.TochangetheformatteddisplayalsoknownasRadix,rightclickondisplayeddataandselecttheRadixoption,thenselectdisplayedformat.Thisisshownintheimagebelow.

D.Disablingconsoleswitching:

During the debugging process when the debugger steps or encounters a break point it will printinformation on the console tab. When this occurs Eclipse will automatically switch to the consolewindowtodisplay this information. In specificCENG255 labs suchas thebubble sort lab itwouldbemoreconvenienttonothaveEclipseswitchtotheconsoleandjusttostayintheMemoryBrowsertab.Therearetwowaystoachievethis.

The first is todisableconsoleswitching.Thisoptioncanbe found in thewindows->preferencesdialogbox. InthepreferencesdialogexpandtheRun/Debugsectionandselectconsole.Unselecttheoptions

Page 19: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

19

“Showwhenprogramwrites to standardout”and “Showwhenprogramwrites to standarderror”asshownintheimagebelow.ThisisaglobalsettingandwillapplytoallprojectsintheEclipseworkspace.

ThesecondmethodisbydraggingtheMemorybrowsertoavacantareaonthescreennotbeingusedbyanyprogram.Eclipsewill automatically createanewwindowspecifically for thememorybrowser.ThisfeaturecanbeusedwithanyviewinEclipse.

Page 20: CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255 Laboratory Experiment #0 Tutorial: Introduction to Eclipse Eclipse is an integrated

20

E.Disassemblynotshowingindisassemblywindow:

If you are using the disassembly view there is a known issuewith this feature.When you first enterdebug mode you will notice that the window does not update. See picture on the left. The simpleresolution is toclose thecurrentdisassembly tabandopen it fromthemainmenu. Windows->ShowView->Disassembly.Seepicturetotheright.

Reference:

1. Tutorial:createaHelloARMtestproject,http://gnuarmeclipse.livius.net/blog/test-project/