CENG 255 Laboratory Experiment #0 Tutorial: …kinli/ceng255/CENG-255-2017-Lab0-v1.pdf1 CENG 255...

Preview:

Citation preview

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:

2

A.InsidetheCProjectwindow:

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

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

4

C.IntheFolders_settingswindow:

LeavethedefaultfoldersunchangedandclicktheNext>button.

5

D.IntheSelectConfigurationswindow:

LeavethedefaultsettingsunchangedandclickNext>buttontothenextstep.

6

E.IntheCrossGNUARMToolchainwindow:

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

7

F.Theresultofthiswizardisasimpleproject,withamain()printinggreetingsandblinkinganLED.

8

2.Buildtheproject• SelecttheBlinkyprojectintheProjectExplorer• Clickthehammericon,whichistheshortcuttobuildtheselectedproject.

Or

• RightclicktheBlinkyprojectintheProjectExplorer• SelectBuildProjectinthepopupwindow

9

ThebuildprocessproducesalistingintheConsolewindowlikethis:

ThefilescreatedbythebuildprocessareleftinaDebugfolder

10

3.ConfiguredebuggingTosetdebugging:

• Selecttheforwardbuttonontherightsideofthebugicon.• SelectDebugConfigurations…inthepopupwindow

IntheDebugConfigurationswindow:

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

11

• GototheDebuggertabo InExecutable:enteropenocd.exeo InConfigoptions:fillinthefollowingsetting:

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

12

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

setting§ monitorresethalt(thiscommandtellsthedebuggertostopatthebeginningof

themainfunctionsothattheprogrammercandebugtheprojectstepbystep.)

13

• GototheCommontabo TicktheDebugcheckboxintherectanglebelowDisplayinthefavoritesmenuo ClicktheApplybuttono ClicktheDebugbuttontostartdebugging

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.

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

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.

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.

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

19

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

ThesecondmethodisbydraggingtheMemorybrowsertoavacantareaonthescreennotbeingusedbyanyprogram.Eclipsewill automatically createanewwindowspecifically for thememorybrowser.ThisfeaturecanbeusedwithanyviewinEclipse.

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/

Recommended