Programming STM32F Using Eclipse and Open OCD

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 2

Programming STM32F3 Discovery using Eclipse and OpenOCD ST launched in September a very interesting development board STM32F3!

Discovery"# $t is a very cheap one $ have got mysel% one %or &'()"# $t has a debugger integrated ST*$+," and also some great sensors! ST MEMS *SM3(3D*.C/ 0hich contains 3 a1is accelerometer to measure acceleration intensity on each a1is" and 3 a1is magnetometer to measure angles to a %i1ed point ! the Earth2s magnetic +orth" ! ST MEMS *33D2(/ 0hich has 3 a1is gyrometer to measure rotation speed" This board is very good %or automated pilot controller pro4ects# 5%ter unpac6ing the board $ have %ound that it 0as supported 4ust by commercial so%t0are and tools# 5s $ am an opensource 6ind o% guy $ have struggled mysel% some time to get this 0or6ing 0ith Eclipse/ OpenOCD and a %ree toolchain/ on *inu1# $ have used 7buntu/ but $ thin6 the process is the same on every distribution# 5lso/ 0ith little ad4ustments it can 0or6 on 8indo0s# .ere are some steps/ that you have to %ollo0 to get the led blin6ing e1ample to 0or6'# $nstall 9ava :untime Environment# .ere are some steps %or 7buntusudo add!apt!repository ppa-0ebupd;team<4ava sudo apt!get update sudo apt!get install oracle!4ava;!installer 2# $nstall Eclipse# 3et Eclipse $DE %rom here grab the Eclipse $DE %or C<C== Developers" and unpac6 it some0here 3# $nstall 3D> .ard0are Debugging# Open Eclipse go to .elp!?$nstall +e0 So%t0are and then search %or 3D> .ard0are Debugging and install it# $nstall 3+7 5:M Eclipse plugin# 3et it %rom here and install it %rom .elp!?$nstall +e0 So%t0are!?5dd!?5rchive and select the do0nloaded #@ip %ile# A# $nstall some dependencies# Paste %ollo0ing te1t in Terminalsudo apt!get install git @lib'g!dev libtool %le1 bison libgmp3!dev libmp%r!dev libncursesB! dev libmpc!dev autocon% te1in%o build!essential lib%tdi!dev libusb!'#(#(!dev B# $nstall OpenOCD version?(#C#'"# 3et it %rom here and unpac6 it# Then/ navigate to the e1tracted %older and type in Terminal#<con%igure !!enable!maintainer!mode !!enable!stlin6 ma6e sudo ma6e install C# 5dd rule %or Stlin6 to be accessed 0ithout sudo# Type in Terminalsudo gedit <etc<udev<rules#d<DD!stlin6#rules Paste the %ollo0ing te1t5TT:SEidFendorGHHI(A;3I/ 5TT:SEidProductGHHI3JA;I/ MODEHI(CCCI Type in Terminalsudo udevadm control !!reload!rules +o0/ 0ith the board connected to PC you can enter in Terminalopenocd !% <usr<local<share<openocd<scripts<board<stm32%3discovery#c%g The %ollo0ing te1t should appear-

Open On!Chip Debugger (#C#' 2('2!'(!2D!22-(2" *icensed under 3+7 3P* v2 For bug reports/ read http-<<openocd#source%orge#net<doc<do1ygen<bugs#html adapter speed- '((( 6.@ srstKonly separate srstKnogate srstKopenKdrain $n%o - cloc6 speed '((( 6.@ $n%o - stm32%31#cpu- hard0are has C brea6points/ A 0atchpoints Lou can close the Terminal no0# J# $nstall toolchain# Lou can use Codesourcery toolchain/ li6e described in this step/ or you can use 3CC 5rm Embedded toolchain %rom here" 0hich has support %or hard0are %loating point unit and 0hich is %ree and it is easier to install# For Codesourcery %ollo0 the ne1t steps3o to Codesourcery and do0nload $532 3+7<*inu1 $nstaller# To install it open the Terminal and navigate to the %older 0here it is do0nloaded# Typechmod a=1 arm!2('2#(3!BC!arm!none!eabi#bin #<arm!2('2#(3!BC!arm!none!eabi#bin Then select ne1t at every step# ;# Do0nload sample pro4ect# 3o to this page and do0nload stm32%3#tar#g@ %ile and unpac6 it# D# Open the pro4ect in Eclipse# Open Eclipse and go to 8or6bench# Clic6 File!?$mport and then select 3eneral!?E1isting Pro4ects into 8or6space# Select the do0nloaded pro4ect and clic6 %inish# This is a ma6e%ile pro4ect/ so you have to edit ma6e%ile i% you 0ant to change some pro4ect settings# The %rst thing you should do is open the Ma6e%ile %ile and chec6 at the very beginning i% the toolchain path is correct# This should be li6eTC H MpathKtoKtoolchain?<arm!none!eabi +o0 you can build# right clic6 on pro4ect name and select build# The correct output is in the Console tab %rom Eclipse ignore the 0arnings and errors %rom Problems tab"# '(# Debugging# 5%ter the pro4ect 0as builded correctly select :un!?E1ternal Tools! ?E1ternal Tools Con%iguration# Select OpenOCD restart" in the le%t tab and clic6 run# +o0/ right clic6 pro4ect and select Debug as!?Debug Con%iguration and then select in the le%t stm32%3!debug and then clic6 Debug# +ote- $% you 0ant to add more source %iles you can add them in the src %older# +e0 headers should be added into hdr %older# $% you 0ant to add another %older you have to speci%y it li6e the *$>KS:CS in the Ma6e%ile and also create *$>KO>9S li6e variable in the Ma6e%ile#

You might also like