Intern ati o n a Journ a l of  Re con f igur able  and Embe dded  Sys t ems  (I JRES)  V o l.  4, N o . 3 ,  N o v e m b er  2 015 , pp . 16 1 ~ 17 I S SN : 208 9-4 8 6 4           1 61     Jo urn a l  h o me pa ge : h ttp ://iaesjo u r na l.com/ o n lin e/ind e x.ph p / IJRES  Devel o p m ent of BSP for ARM 9 E valu a tion Board       V i n aya k   P a ndit  K . ,  Sa nk et   D e s s a i ,  Sh ilp a C h a u d h a r Department o f  C o mputer Engin e eri ng, M.S. Ramaiah  School of A dvanced  Studies , Bangalore-5600 58, India        Article Info    A B STRAC T Article histo r y:  Received  Ma r 2, 2015  Rev i sed  Jun  19,  201 Accepte J u l 12, 2015      W ith an increas i ng us age of ARM 9  core  for different kinds of applications   ranging from data acquisition to   Mobile  a ppli cat i on, th ere  aris es   t h e ne ed for  develop i ng ARM9 based board . To br ing up  this board, bo ar d supporting   packag e (BSP) is mu st. Board supporti ng pack age virtualiz es the platform  hardware s o  th at  the dif f eren t dri v ers  can b e  port e d eas i l y  on an y hardwar e .   The boot lo ader is the init ial  stag e of firm ware, which  in itializes the  hardware components presen ts on th bo ard. A universal B ootload er is   chos en and is  t o  be cus t om ize d  with res p ect  t o  target bo ard.  In the la ter   section bootlo ad er is interfa ced  to th e kernel  which is obtain e d form an  authorized distributor under general pur pose license. The custo m ized board   s p ecifi c rout ines  as  well  drive r s  are po rted  ont o the h a rdware .  Then  the   compiled kernel image is ported onto  the target  board using a debugger and  SAM-BA utilit y .  Linux kern el h a s seen m a jor rel eases; th e basi archi t ecture  of the Linux k e rnel has remain ed more  or less unchanged .  Th e latest 2.6   version of  Linu x kernel is  ported ont o  target h a rdware. Kern el support for   man y  arch itectu r es and high-en d I/O devices gives the indep e ndence to   choose appropr iate hardware  for de veloping  sy stem. The bootloader   customization is the critic al step , which involves  a lot of modifications in the  header f i les. BSP components such as  bootlo ad er, kernel  is co mpiled using  GNU tool chain ;  obtain e d imag e is por ted on target using d e b ugger. BSP  porting is a very  complex task, whic h required  knowledge of h a rdware an d   software control seque nce and  bo ot strateg y   of th e contro ller .   Keyword:  ARM 9    Bo ard    BSP      Eval uat i o n   GN U   Copyright ©  201 5 Institut e  o f   Ad vanced  Engin eer ing and S c i e nce.  All rights re se rve d Co rresp ond i ng  Autho r Sanket De ssai,    Depa rt em ent  of C o m put er  En gi nee r i n g,   M.S.Ram a iah   Scho o l  of  A dvan ced  Stud ies,  # 470 - P , Peen y a  In du str i al  A r ea, Bang alor e,  K a rn atak a, India. 56 005 8.  Em a il: san k e tdessai@m s rsas.o rg       1.   INTRODUCTION   In t h e wa ke o f  i n crease i n  t h e usa g e of AR M 9  pr ocess o rs fo r di ffe re nt  ki n d s  of ap pl i cat i ons ra ngi n g   fro m  si m p le a u to m a tio n  to  th e co m p lex  mo b ile app licatio n s , th ere arises a n eed  fo dev e lop i ng  app l icatio n s   base d on AR M9 proces sors . The r efor e ,  in recent years,  e m bedde d syst e m s play a key role in the  era of  cu ttin g edg e  t ech no log y With  th is t h ough t I h a v e  taken   u p  th e proj ect to d e v e lop m en t A R M9 b a sed  d e v e l o p m en t b o a rd . In itiall y Dev e lop m en t b o a rd  is co nsid ering  b e i n g a raw b o a rd   wh ich  con s ist  m a n y   har d ware c o m p o n e n t s . T h D e vel o pm ent  bo ard  nee d s a p p r op riate firm ware o r  s o ft ware t o  m a ke the ha r d wa re   wo rk  pr o p erl y . No net h el ess ,  t h e req u i r em ent s  of c u r r e n t  em bedde d  appl i cat i ons  are t oo  heav y  and  com p l i cat ed t o  be ha ndl e d  b y   m o st  of fi r m ware and si n g l e  pr ocess s o ft ware sy st em s. Neve rt hel e ss ,  wel l - desi g n e d  o p e r a t i ng sy st em s can ha n d l e  t h ose  heavy  a n com p licated re quire m ents. The r efore ,  m o re and  m o re   o p e rating  syste m s are runn in g   on  em b e d d ed  system s. On e k iller ap p l i catio n   o f  Li n u x  is to   b e  used  as the  ope rat i n g sy st em  of an em bedde d sy st em . AR M  i s  an archi t ect u r e p r efer red  by  m a ny  em bedded  Li nu x   devel ope rs.  S o  t h at  i n  t h i s   p r o j ect  Li n u x   Ope r at i n g Sy st em  pl ay s vi t a l  rol e  i n  de vel opm ent  en vi r o nm ent.  AT 91S AM 92 6 0  c ont rol l e r  i s   t h e hea r t   of  t h e de vel o pm ent  b o ar d.  U S B ,   Et her n et , S D R A M ,  Fl as h M e m o ry an d  MMC card in terfaced  wit h  th e co n t ro ller for fu ture  app l icatio n .  Th roug h   ou t do cu m e n t  I will d i scu s s h o Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 089 -48 64  I J RES Vo l. 4 ,  N o . 3 ,  No v e m b er  201  1 61   17 16 2 t o   depl oy  t h e  basi c  sy st em  o n t o  an  AR M 9   devel opm ent   boa rd . B a si c sy st em  i s  not hi n g   b u t  a  B o a r d   Su pp ort i ng  Pac k age .   A BSP  o r  “B oard   Supp ort Pack ag e” is t h e set o f  fi rm ware so ft ware  u s ed to  in itialize th e h a rdware  com pone nt s o r  devi ces  on t h e  boa rd a nd i m pl em ent  t h e boa rd -sp eci fi c ro u t i n es t h at  can b e  used  by  t h e k e rnel   and  de vi ce d r i v ers  al i k e. B S P i s  t h u s  a  har d wa re a b st ract i on l a y e gl ui n g  h a r d wa re t o   t h e O S  by   hi di ng t h det a i l s  of  t h p r oces so r a n d  t h e b o ar d.  The  B SP  hi des t h board- and CPU-speci fic deta ils fro m  th e rest  o f  t h OS, so portab ility o f   d r iv ers  acro ss m u ltip le b o a rd s an CPUs  b e co m e s ex trem e l y easy. Ano t h e r term  th at is  oft e used  i n st ead  of  B SP i s  t h Har d ware  A b stractio n Lay e r ( H AL) .   The BSP  has t w o com p onent s 1.  The  m i cropr oc essor  su p p o r t Li nu x ha s wi de su p p o r t  f o r  al l  t h e l eadi ng p r oce sso rs i n  t h e em bedd ed   m a rket suc h  a s  ARM, M I PS and s o on t h e P o we rPC.   2 .  Th bo ard - sp ecific  rou tin es A typ i cal HAL fo r t h b o a rd   h a rdware  will in clud e:  a. Bootloa d er  s u pport   b .   M e mo r y  ma p  s u p p o r t   c. Syste m   timers  d.   Int e r r upt  c o nt r o l l e r s u p p o rt   e. Real-Tim Clock  (RTC)  f .  Ser i al  supp or   g.  Bus  s u p p o rt  (P CI/ISA )   h .  D M A   supp or i .  Po wer  m a nage m e nt        2.   BOAR D HA R D W ARE A N D  DE VELOPMENT  SUIT E      Th On k iller ap p lication  of Lin u x  is to b e  u s ed  as th op erating  system o f  an em b e d d e d  system .   AR M  i s  an archi t ect ure p r efe r ed  by   m a ny  em bedded Li n u x  de vel o pers . Devel opm ent  of E v al uat i o ki t  i s  a  v e ry ch alleng i n g   ro le,  we need  to   consi d er both hardware and softwa re specificati ons . BSP is a  set of  so ft ware  p ack ag es wh ich  m a i n ly in itializes  th e b o a rd  sp ecific ro u t i n es.  BSP is th u s  a h a rdware abstractio l a y e r gl ui ng  h a rd ware  t o  t h e  OS  by   hi di ng  t h det a i l s  o f  t h pr ocess o r  an d t h e   boa rd . T h e B S P  hi d e s t h e   boa r d - a n d C P U-s p eci fi det a i l s  fr om  t h e res t  of  t h OS . P r oject  deal wi t h  Li nu x B SP a n d  p o r t i n g  i ssu es o n   AT 91S AM 92 6 0 -E boa r d . F r ee Li n u x  ke r n el  versi on i s   u s ed t o  i m pl em ent  B SP.  Ke rn el  2. 6 seri es  v e rsi o n   su ppo r t s fo llow i ng  d e v i ces:     A 32 -bi t  AR M  pr ocess o r     64   M B   of  SD R A M     8  M B   of  fl as h     25 6 M b y t es o f   NA N D  Fl as m e m o ry     1  Serial Data-Flash     1 se rial EEPR O M     USB ( 2. 0)  De vi ce an Ho st  I n t e rface     M M C  Card  Int e rface     2. 1.  De vel o p m ent S u i t       Fig u re 2  illu strates th e o v eral l d e sig n   of th p r oj ect. Too l ch ain  set u p  is i n itial step  o f  t h e em b e d d e d   l i nux  de vel o p m ent .  The t o ol chai n t h at  i s  use d  o n  em bed d e d  sy st em i s  kno w n  as t h e cr oss - pl at fo rm   t ool chai n. T h t ool  ch ai nee d  t o   put  t oget h er t o  c r oss - dev e l op a ppl i cat i o ns f o r any  t a r g et  i n cl udes t h bi na ry   u tilities,  su ch as  ld , g a s,  and ar, th e C co mp iler, g cc,  an d th e C  lib rary, g lib c. Bo o t strap  p r og ram  d o e s th m i nim u m  hardwa re c o n f i g u r at i on s u c h  a s  p o we r m a nagem e nt  cont r o l ,  P I O   a n d cl ock  c o nfi g u r at i o n .   B oot st ra p i s  c o m p i l e d by  usi n g  t o ol chai n  w h i c h i s  al ready  i n st al l e d o n   h o st  com put er In t h next  st e p  i s  t o   cu sto m ize th e b o o tlo ad er, th e b o o t  lo ad er is ex p ected  to  i n itialize v a riou s d e v i ces, and  ev en tu ally call th e   Li nu x ke r n el , passi n g  i n fo rm at i on t o  t h ker n el . B S P   com p one nt s can  be s e l ect ed usi n g l a t e st  Kernel  ve rsi o n .   Ker n el  so u r ce  con s i s t  t h e b o a rd s u pp o r t i n g  ro ut i n es,  re qu i r ed c o m pone n t s can be  sel ect ed, by   usi n m a ke   m e nuco n f i g w h i c di spl a y s  t h e co ns ol e wi nd o w ;  sel ect  requi red c o m ponent s f o r t a rge t  boar d . T h e l i s t  o f   wh at software  n eeds to go  i n to  th ke rnel  and what  ca n be com p iled  as  modules ca be  specified using this   step At th e end   o f  t h is step k b u ild   reco rd th is in form at io n  in a set  o f  kno wn   files so that th e rest  of  kb u ild is  aware  of the s e lected com p on en ts. Ob tain ed  boo tlo ad er an d   k e rn el im a g e is  p o rted   on  targ et bo ard u s i ng  deb u gge r.  S A M - B A   In  sy st em  prog ram m er  i s  use d  t o   po rt   t h e i m ages.     Evaluation Warning : The document was created with Spire.PDF for Python.
I J RES I S SN 208 8-8 7 0 8     Developme nt  of BSP f o r A R M 9  Ev aluation B oar d   (San ket Dessa i)  16 3     Fi gu re  1.  AT 9 1 S A M 9 26 0 0  E v al uat i o Ki t           Fi gu re  2.  De ve l opm ent  St eps       2. 2.  GN U T o o l  Setup          One  of t h e i n i t i a l  st eps i n  t h e em bedde d Li nu x m ovem e nt i s  set t i ng up t h e t ool c h ai ns  f o bui l d i n g   the kernel and the applications. T h e t ool ch ai n t h at  i s  used o n  em bedde d sy st em s i s  kno w n  as t h e cross - pl at fo rm  t ool chai n.  T h e t o ol  chai n  we  nee d  t o  p u t  t o get h er t o  c r os s- d e vel o p a ppl i c a t i ons  fo r a n y   t a rget   in clu d e s th e b i n a ry  u tilities, su ch as l d g a s,  an d ar, th e C co m p iler, g cc, an d th e C  lib rary, g lib c.  The fi rst  st ep  i n  b u i l d i n g t h e t ool  chai n i s  sel ect i ng t h e  com pone nt  v e rsi o ns we  wi l l  use. Thi s   involves selecting a  binutils ve rsio n, a  gcc ve rsion, a n d a  glibc  ve rsion. Because  these  pac k ages are   main tain ed  and  released  ind e p e nd en tly from o n e  an o t h e r,  n o t  all v e rsions o f   on p ack ag e will bu ild   prop erly   wh en  co m b in ed  with   d i fferent v e rsion s   o f  the o t h e r p a ck ages.  Here  we h a v e   u s ed  b i nu tils-2.16 ,  g cc  com p i l er   Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 089 -48 64  I J RES Vo l. 4 ,  N o . 3 ,  No v e m b er  201  1 61   17 16 4 ( g cc- 3 .4.4) ,  lib r a r y  (g lib c- 2.3 . 5 )  and   k e r n el v e r s i o n ( l i n ux- 2.6.22 .6 ). Do wn lo ad   all r e qu ir ed  t o ol ch ain  packa g e from   f t p . gnu .o rg   . M o st too l  ch ain   bu ild  step s invo lv e carrying   o u t  th fo llowing   actio n s :-  1.   Un pac k  t h e  pa ckage .   2.   C o n f i g ure   t h e packa g e f o c r oss pl at f o rm   devel o pm ent   3 .   Bu ild  th e p a ckag e.  4. Install  the  pac k age.  Cro s s p l atfo rm  env i ron m en t will read y after too l ch ai n   in stallatio n .  Figu re 3  and  Figure 4  sho w s th bin a ry   u tilities an d   k e rn el im ag es.          Fig u re  3 .  Bin a ry Utility W i ndo         Fig u re  4 .  Kernel Im ag e an d Lib  Utility  W i ndo Evaluation Warning : The document was created with Spire.PDF for Python.
I J RES I S SN 208 8-8 7 0 8     Developme nt  of BSP f o r A R M 9  Ev aluation B oar d   (San ket Dessa i)  16 5 3.   A T 91 SA M BOOTSTRA FR AM EWOR         Fi gu re 5.   B o ot st rap Fram ewo r k       AT 91B oot st ra p a ppl i cat i o n i s  co nsi d e r e d  a s  a fi rst  l e vel   bo ot l o a d er A T 9 1 B o ot st rap   i s  a m odul ar   application s o  it becom e s easy to s p ecialize the fra m e wor k  fo r a  part i c ul ar d e pl oy m e nt   st rat e gy .   AT 91B oot st ra p al so  pr o v i d e s  cl ear exam pl es, f o r a  part i c ul ar  devi ce,  o n  ho w t o   pe rf or m  som e  basi st at i c   con f i g urat i o ns   suc h  as  PM C   or  PI Os AT9 1 B oot st ra p ca be easi l y  co n f i g u r e d   usi n g a   hi g h er  l e vel   pr ot oc ol   as sh o w n  i n   Fi gu re  5.  AT 9 1 B oot st ra p i n t e g r at es di f f ere n t  s e t s  of  al g o ri t h m s   Dev i ce i n itializ atio n  su ch  as C l o c k   Sp eed  configu r ation ,   PIO settin g s   Peripheral drivers  s u c h   as PIO, PMC  or  S D RAMC.    Physical m e dia  algorithm  suc h  as  Data Flas h,  Na ndFlash, Pa rallel Flash. ..     File Syste m  drivers  such as JFFS2 or FAT .     Co m p ressio n  an d Ciph er al g o rith m s     Ap pl i cat i o n  La unc he r f o r EL F, Li nu x.   Using  th is set  o f  al g o rith m s , it b eco m e s easy to  g e t a b a sic b o o tlo ad er  which ,  fo r ex am p l e, is lo cated  in  DataFlash  an d   will b e  copied  to   in tern al  SRAM b y   SAM-BA Boo t . Th at boo tlo ad er co u l d ,   fo r ex am p l e,   p e rform  th e pro cessor in itializati o n  (PLLs, PIOs, SDR A MC, an d SPI) th en  co u l d  lo ad   U-Boot fro m   DataFlash secto r s to   SDR A M  and   fin a lly jum p  to  it.    3 . 1 .  Co mpiling  a n  AT91   B o o t stra Project           To  co m p ile AT91 Boo t strap  GNU too l  ch ain  is m u st in stall.  On ce y o ur  to o l ch ai n  is installed ,  in stal  AT 91B oot st ra p i n  a  di rect o r y  an d c d  i n t o  i t   Ma ke  Co mma n d   To c o m p i l e  an  AT 91B oot st ra pr o j ect :   •  Go in to th board d i rect o r y     Sel ect  y o u r   bo ard  by   g o i n g i n t o  co rre sp o ndi ng  b o a r d  di rect ory   •  Select yo ur   p r oj ect b y   go ing  i n to  cor r e spo ndin g   pr oj ect  d i r e cto r y   •  Co nf igu r e you r pr oj ect ( M ak ef ile and   h ead er f ile)   Ty pe  m a ke  > cd  b o ar d/ at 9 1 sam 926 0e k/ n a nd fl ash   > m a ke     3. 2.  A R M  B o o t l o ader            Whe n  system  i s  powe re d on,  the first  piece  of c o de called  bootstra ppi ng in itializes basic hardware   an d  th en  brings u p   OS k e rn el . It can  b e  in cl u d e d  in  a boo tlo ad er or in  OS  d i rectly. First o f  all, to  m a k e   an  OS,  l i k e Li n u x ,   bo ot we m u st  co py  t h ke rnel  i n  m e m o ry   and put the m achine in a st ate t h at allo w it to wo rk  properly in t h e  first c r itical st eps.  Th e  little  piece of soft ware that is i n  c h ar ge on  this job  is  the boot loade r Classical boot  loa d ers  like  LIL O  a n GRUB a r de sig n e fo r m o re c o m p lex m achines.  F o r  ARM  bas e d   pl at fo rm , few   bo ot  l o ade r s a r e a v ai l a bl e,  b u t  o u r  c hoi ce   was t o  t a ke  a  bo ot  l o ade r   na m e d das  U - B o ot fo r   u n i v e r s al  boo t. U- Boo t  su ppor ts th e A R In tegr ato r /CP.  In   o u r   pr oj ect  U - b o o t -1 .1 .5   ver s ion  is cho s en   f o r   firm ware desi g n .   There  are m a ny Bootloa d er i s  av ailab l e for arm  targ et. ARMb oo t, Redbo o t U-boo t etc. fo llo wi n g   poi nt s t o  be  co nsi d e r ed  f o r  b o o t l o ade r  sel ect i on:     The Process o r architectures  a n d p l atfo rm s that it su ppo rts    Th OS th at it  su ppo rts  Debug g i n g  ab ilities, Stab ility an d Po rtab ility Fu n c tio n a lities:   Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 089 -48 64  I J RES Vo l. 4 ,  N o . 3 ,  No v e m b er  201  1 61   17 16 6   Si m p le b o o t up , or wit h  m o n ito ri n g  cap ab ility an d lo ts  o f  driv ers  supp ort.    Th e m e d i u m  th ey are in stalled in   u s u a lly ROM, EEPR O o r  Flash    The st ora g de vice from  whic h the  ke rnel image is  do wnloa d ed --  host PC, local Flas h,  di sk, C F , etc.    The  de vi ce an d  p r ot ocol   by   w h i c h t h ker n el  im age i s   tra n s m itted Serial  port, USB ,  Et he rnet, IDE, etc.    Th e 'ho s t-sid e so ft ware u s ed  t o  tran sm it th e k e rn el im ag B a sed o n  t h ese  have sel ect e d  das U - B o ot  f o r  Uni v ersal   bo o t . U- bo ot  st an d s  “Uni versal  B oot l o a d e r ,   i t s an  ope n s o u r ce  b oot l o a d e r  a v ai l a bl e un de r GPL  license. Source  code  available at  h ttp ://so u rceforg e .n et/proj ect s/u - b o o t It sup ports m a n y  CPU arch itect u r es and   p l atfo rm  typ e s lik e ARM,  PPC, a n d MIPS etc.  AR M  Li n u x  c a nn ot   be  st art e on  a m achi n e wi t h o u t  a s m al l  am ount   o f  m achi n e s p e c i f i c  co de t o   in itialize th e syste m . Mo st bo o t  l o ad ers start fro m  th e flash .   Th ey  do  the in itial p r o cesso r in itializatio n  su ch  as configuri ng  the cache, setting  up som e  basic registers,  a nd  verifyi ng the onboa rd  RAM. Also they run the   POST  r out i n es  t o  d o   val i d at i on  o f  t h har d ware  re qui re fo r t h b oot   pr oced u r e s u ch a s  val i d at i n g m e m o ry ,   flash ,   b u ses, an d  so  on In  t h e first stag e co n t ro seq u e n c e will set th ex cep tion   v ecto r  an d   h a nd lers, n e x t   reset th e con t ro l sign al an d set th e CPU to fo llo wi n g  m o d e   Set SVC  Mode     Tu rno f f Watchd og   tim ers    Disable IRQs     Set the system   clock  Once  it is  done control is  gi ven to  cpu_init _crit, i n  t h is it  has t o   flus h t h e I and  D cache as  well as  flus h the T L and MM U stuff. Furt her  we  need to  set t h me m o ry according to t h e CPU m e m o ry  m a ppi ng.   After settin g  t h e m e m o ry co n t ro l sig n a l is  retu rn  to   st art . s   fo r f u rt her  execut i o n.  Set up C  e nvi ro nm ent  an d   run   on  RAM  an d cop y   U-B o o t  cod e / in itialized   d a ta to RAM.    3. 3.  So ftw are  Co nfi g ur ati o n              C o n f i g urat i o i s  us ual l y  do n e  usi n g  C  p r e p r o cess o r   d e fi n e s; th e rationale b e h i nd  th at is to  av o i dead code  whe n eve r   possible. The r e a r two   classes of co nfig uratio n v a riab les:    C o n f i g urat i o n _O PTI O NS _:   These a r e sel e c t abl e  by  t h us er a n d  ha ve  na m e s begi nni ng   wi t h     "C O N F I G_" .     C o n f i g urat i o n _SET TI NG S_:   These de pen d  on   t h e ha rd wa re  et c.  s h oul d not  be  m e ddl e d  wi t h   i f   y o u  do n' t   kn o w  wh at   y ou' re doi n g ;   t h ey   have  nam e s be gi n n i n wi t h  “ C FG_" . C o n f i g u r at i o depe n d on  t h e c o m b i n at i o of  b o a rd a n d C P U t y pe;  al l   su ch  inform ati o n is  k e p t  i n  a  co nfigu r ation file "in c lu d e /con fi g s /<bo ard_ na m e >.h "   3. 4. I n serti n BSP in Ker n el M o dule               The Li nu x B S P so urce c o de  resi des  u nde arch/  a nd i n cl ude/ < asm - arm  di rect o r i e s. T hus  arc h / a rm   will co n t ain  the so urce files fo r th e arm - b a sed  bo ard  an d   i n clud e/asm - arm will co n t ain   th e h e ad er  files. Un der  pr ocess o di re ct ory ,   boa rd base d o n  t h at  C P U are cat egorized a g ain into subd irec tories. T h e important   directories  under eac h s u bdire c tory are:   Kernel Th is  directo r y co n t ai n s  t h e CPU- specific rou tin es  for in itializin g ,   IRQ set - up , in t e rru p t s, an d trap rou tin es.  mm C ont ai n s   t h e ha r d wa re-s peci fi c TLB  se t - u p  a n d  exce p t i on- ha ndl i n g c ode   For e x am pl e,  AR M  B SP has  t h e t w o su bdi r ect ori e arc h /arm /kernel and  arch/arm /mm that hol d the  above c o de.  Along wit h  thes e two  direct ories there is  a  host   of  ot her  sub d i r ect ori e s;  t h ese are  t h e  B S P   d i r ector ies that ho ld th bo ard - sp ecif i c code on ly. Th u s er   n eeds to create a su bd ir ecto r y  tr ee under  the  appropriate process o directory that c ontains the files nece ssary for the B SP.  Th e n e x t  step  is to  in teg r ate th BSP wit h  th e bu ild   p r o cess so th at th e bo ard-sp ecific  files can   b e  ch osen  wh en  t h k e rnel i m ag e is bu ilt. Th is  m a y  requi re  t h at  t h e ke rn el  com pone nt  sel e ct i on  pr ocess  d one  usi n g  t h e “ m ake m e nucon fi g” c o m m and whi l e   th e k e rn el is  bu ilt is aware  o f  th bo ard .   Linu x k e rn el  co m p on en ts are sel ected   u s ing  th e m a k e  co nfig (o r th m a ke  m e nuco n fi g/ m a ke xco n fi g) c o m m a nd. T h e h eart  o f  t h e c o n f i g ura t i on p r ocess i s  t h e co nfi g u r at i on  fi l e   placed under t h process o directory.  You  need to edit the file arc h /arm /k confi g .in (for th e  2.6 ke rne l ) for  i n cl udi ng  A T 9 1 S A M  ba sed  b o ar d c o m pone nt s i n  t h ker n e l  bui l d  p r ocess.     3.5. Kernel Component Selection  a nd  C o mpilation                Once al l  abo v e  con f i g urat i o n i s  do ne, w e  have t o  sel e c t  t h e kernel  c o m pone nt s by  usi ng m a ke  m e nuconfig, which displays  the  cons ole wi ndow; you can  select requi re d com pone nts for your target boa rd.  The l i s t  of  wh at  soft wa re ne eds t o   go i n t o   t h e ke rnel  a nd  what  ca n be c o m p il ed as m odul es can  be s p eci fi ed   Evaluation Warning : The document was created with Spire.PDF for Python.
I J RES I S SN 208 8-8 7 0 8     Developme nt  of BSP f o r A R M 9  Ev aluation B oar d   (San ket Dessa i)  16 7 u s ing  th is step . At th e end   o f   th is step k b u ild  reco rd s t h is in fo rm atio n  in   a set o f   k nown files so  th at the rest   of kbuild is a w are  of t h e selec t ed com p one n ts.  Com p onent selection objec t are norm ally:  a. Processor  s e lection  b.  B o ar sel ect i o n   c. Dri v er  selection  d.   Som e   gene ri c ker n el  opt i o ns   There a r e m a n y  front ends t o  the confi g uration pr o c edu r e; th e fo llo wi ng  fi gu r e  sh ows th e k e rn el  co nfigu r ation file. Th e top - lev e l Mak e file i n  t h k e rn el so urces is respo n s i b le  for  bu ild in b o t h  th e k e rn el   im age and t h m odul es. It  d o e s so by  rec u rs i v el y  descen di ng i n t o  t h e su b d i r ect o r i e s o f  t h e ke rnel  s o u r ce t r ee.  Every  a r chi t e c t ure (t he p r oc essor  p o rt ) ne eds t o  e x po rt  a l i s t  of co m ponent s f o sel ect i on d u r i ng t h e   co nfigu r ation   p r o cess; th is in clud es:  An p r o cesso fl avor. For exam ple, if your  a r chitecture is defined as   ARM, th en  y o u   will b e   p r o m p t ed  as to wh ich   ARM flav or  n eeds to b e  cho s en   The har d ware  boa r d     A n y bo ard - sp ecif ic  h a rdw a r e  co nf igu r ation    The  kernel s ubsyste m  co m p onents wh ich  mo re or less  remain  un ifo r m   Once t h e com pone nt s sel ect i o n i s  do ne c o n f i g u r at i o n i s  sav e d t o  co nfi g ura t i on fi l e . The n   zIm a ge can  be  gene rat i n by  usi n g m a ke zIm a ge.     3 . 6 .  M e mo ry  M a p p i ng                   The f o l l o wi ng  Fi gu re 6 sh o w s t h e co nt r o l l e m e m o ry   m a p a fi rst  l e ve l  of ad dress  d ecodi ng i s   per f o r m e d by  t h e B u s M a t r i x ,  i . e., t h e i m pl em ent a t i on o f  t h Ad va nced   Hi g h  Pe rf orm a nce B u s ( A HB ) f o r  i t s   Master and  Slave inte rfaces  with a dd itional  features. Dec o ding  brea ks up th e 4G bytes of  addre ss  spa ce  into  16  ban k of  25 6 M b y t es. The  ban k s 1 t o  7 a r e di rect e d  t o  the EBI that as sociates th ese  banks to the external   chip selects E B I_ NCS0 t o  E B I_ NCS7 . Ban k  0 is  reser v e d  for the a d dres sing  of t h e inte rnal m e m o ries, and  a   seco nd l e vel  o f  dec odi ng p r o v i d es 1 M b y t e of i n t e r n al  m e m o ry  area. B a nk  15 i s  rese rv ed fo r t h e pe ri phe ral s   and provi des a ccess to t h Advance d   Peri pheral Bus  (A PB ).  Othe r a r eas a r unuse d  a n perform i ng an  access   within t h em  provi des a n  a b ort  to th e  m a ster reque sting suc h  an acce ss.    Each M a st er h a s i t s  own  b u s  and i t s  o w d ecode r, t h us al l o wi n g  a di ffe r e nt  m e m o ry   mappi ng  per   M a st er.  Ho we ver ,  i n  o r der   t o  si m p l i f y  t h e m a ppi ngs , a l l  t h e m a st ers ha ve a  si m ilar a d d r ess  de codi ng .   R e gar d i n g M a st er 0 a nd M a s t er 1 ( A R M 9 2 6  I n st r u ct i o n a nd  Dat a ) ,  t h re e  di ffe re nt  Sl av es are assi g n e d  t o  t h me m o ry space decode d at address  0x0:   one  for internal boot,  one for e x ternal boot,  one after  rem a p. The   syste m  always bo o t at add r ess 0x0 . To   en sure a m a x i m u m  n u m b er  o f   po ssib ilities for  bo o t , th me m o ry  l a y out  can  be   con f i g ure d   wi t h  t w param e ters.   REMAP allo ws th e user  to  lay ou t th first in tern al SRAM   ban k  t o  0 x 0  t o  ease devel o p m ent .  Thi s  i s   do ne by  so ft w a re onc e t h e sy st em  has bo o t ed. R e fer t o  t h e B u s   Matrix  Section  fo r m o re  details. Wh en   REMAP =  0 ,   BMS allo ws th e u s er to  l a y o u t  to   0x 0, at h i conve n ience ,  t h e R O M or a n  external  m e mo ry. Th is is don v i a hard ware at reset. Th e fo llo wi n g  fl owch art  depi ct s t h e i n t e rnal   AT 91 SA M   m e m o ry   m a p.  If  B M S =  1,  B oot   o n  Em bedde d   R O M T h e syste m  boots usi ng  th e Boo t  Pro g ra m . I f  BMS =  0 ,  B o o t   o n   Ex t e r n al Mem o r y  Bo o t   o n  sl o w   clo c k   ( O n - ch i p  RC o r   3 2 ,768 H z ).  Bo o t   with  th e d e fau lt con f i g uration  fo r the Static Me m o ry  C o nt r o l l e r,  by t e  sel ect   m ode , 1 6 - bi t   dat a  bu s ,   Read / W rite con t ro lled   b y  Ch i p  Select, all o ws bo o t  on   16 -b it n on-vo latile me m o ry.   The i n t e r n al  m e m o ry  i s   m a pped  fr om  0x0 0 00  0 0 0 0  t o   0x 0FF F  FFF F. B oot  m e m o ry  i s  st art  from   0 x00 00   00 00  ad dr ess t o   0 x100 000 32 k Bytes RO M is m a p p e d   f r o m  0 x10   0 000  to   0x 10 20 00  is sho w n. Two  4 KB  Fast  SR AM 0 an d SR AM 1 are al so  m a pped .  Fo r m o re det a i l  refer dat a s h eet  o f  t h i s  cont r o l l e r. The   syste m  always bo o t at add r ess 0x0 . To   en sure a m a x i m u m  n u m b er  o f   po ssib ilities for  bo o t , th me m o ry  l a y out  can  be  con f i g ure d   wi t h  t w o pa ram e ters. R E M A allo ws th u s er  to  lay o u t  th first in tern al SRAM  ban k  t o  0 x 0  t o  ease devel o p m ent .  Thi s  i s   do ne by  so ft w a re onc e t h e sy st em  has bo o t ed. R e fer t o  t h e B u s   Matrix  Section  fo r m o re  details. Wh en   REMAP =  0 ,   BMS allo ws th e u s er to  l a y o u t  to   0x 0, at h i co nv en ien c e, th e RO or  an  ex tern al m e m o r y . Th is is  d o n e   v i h a rdw a r e  at  r e set.  Th A T 9 1 SAM9 260  m a t r i x   m a nage s a bo ot  m e m o ry  t h at  depe n d s  on t h e l e vel  on t h e B M S pi n at  reset .  T h i n t e rnal  m e m o ry  area  m a pped bet w e e n address  0x0 and 0x000F  F FFF is re serve d  fo r this  purpose.  If BMS is  detected at 1, t h e boot  me m o ry is the em bedded ROM. If BMS is  detected at  0,  t h bo ot  m e m o ry  i s  t h e m e m o ry  c o nnect e d   on  t h e   Chip Select  0 of  the   Exte rnal Bus  Interface.  The  6 4  M B   o f  S D R A M  i s   m a de avai l a bl e f o r u n n i n bot h t h e  b o o t   l o ade r  a n d  Li nu ke rnel Norm all y  th b o o t  lo ad er is  mad e  to  run  fro m  th e b o tto m o f  th e av ailable  m e m o ry so  th at o n ce it tran sfers  cont rol  t o  t h Li nu ker n el , t h e Li n u x   ker n e l  can easi l y  rec l aim  it m e m o ry . The Li nu m e m o ry   m a p set up i s   di vi de d i n t o  f o ur  st ages .     The Li nu ke r n el  l a y out   — t h e l i n ker  scri pt     The  boot m e mory allocat or    C r eat i ng m e m o ry  a n d I O  m a ppi ng s i n  t h v i rt ual  ad dr ess s p ace   Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 089 -48 64  I J RES Vo l. 4 ,  N o . 3 ,  No v e m b er  201  1 61   17 16 8   C r eat i on  o f   var i ous  m e m o ry  al l o cat or z o nes  by  t h ke rnel           Fi gu re  6.  I n t e r n al  M e m o ry  M a ppi ng       3. 7. R o o t   Fi l e  Sys t ems   A j o ur nal i n g f l ash fi l e sy st em  (JFF S2 ) can  be ch ose n  t o  s t ore  ou r t a r g et ’s r oot   fi l e sy st em  on fl a s h   me m o ry. W e   m u st  h a v e  to  create th e JFFS2  im ag e b y   u s ing  th e m k fs.jffs2  u tility  an d  a d i recto r y tree  cont ai ni ng  t h e  fi l e sy st em  t h at  we  want  t o  l o ad  i n t o  fl as h. T h Jo ur na l i ng Fl as h Fi l e sy st em , Versi o n  2 ,   (JFF S2 ) i s  a  fi l e sy st em  speci al l y  desi gne f o use  o n  em bedde de vi ces,  t h o u g h  i t  can  al so be  u s ed  i n  ot he envi ro nm ent s . JFFS feat ure s  aut o m a t i c  com p ressi on a n decom p ressi on  as fi l e s a r e w r i t t e n t o  a n d  rea d  f r o m   th e filesyste m Jo urn a lin g  m e an s th at up d a tes to  files a n d  the filesyste m  its elf (kn o wn  as filesyste m   m e ta d a ta)  are first stored in a s p ecial portion  o f  th filesyste m , calle d  a  jo urn a o r  lo g,  b e fo re actually b e in g   writ ten  t o   t h e fi l e  sy st em . Jo u r nal i n fi l e  sy st em s gene ral l y  pr ovi de  h i ghe r pe rf o r m a nce a nd  re qui r e  l e ss t i m e  at  rest art  than  non-journaled file system s b ecause they  m i nimize the  need  for t h ope rating s y ste m  to verify the  in teg r ity of its  file syste m s wh ile th e system is reb o o ting .   In  or di na ry , n o n - jo ur nal e f i l e  sy st em s, chan ges are m a de di rect l y  t o  fi l e s and t h e f i l e  sy st em Applications must typically wait until  update s are successfully co m p leted befo re  they ca n c ontinue e x e c ution.  Thi s  can re d u c e  ove ral l  sy st em  perfo rm ance and ca n al so  resul t  i n  i n co m p l e t e  updat e s  i f  a sy st em  crashes   wh ile an   app licatio n  is in  th m i d d l e o f   up datin g  files.  T h e  defa ul t  ke rnel  con f i g urat i on  fi l e  i n cl ude s s u p p o r t   fo r t h e JF FS 2 f i l e sy st em . If you  ha ve m odi fi ed o r  rec r eat ed  t h i s  fi l e  and  pl an t o   use a JFF S 2 fi l e  sy st em   wi t h   yo ur d i stri b u t i o n, you  sho u l d   v e rify th at JFFS2  su ppo rt   is still activ in  you k e rn el  con f iguratio n. Th is  support is acti v ated  by select ing  filesy stem >  Jo urna ling Fla s h file sy stem  v ersi o n 2  (E X P ERIMENTAL fr om  t h e con f i g u r at i on m e n u . T o   use a J FFS 2 r o ot  f ilesyste m , you fi rst nee d  to create a directory and  p opu late it with  th e ap p licatio n s  you   wan t  to  in cl u d in you r JFFS2 roo t   filesyste m . You  m u st th en cop y  the  co n t en ts in to  a JFFS2  file syste m  i m ag e. Creatin g  a JF FS2 filesyste m   is  d o n e   b y  u s ing   th e m k fs.j ffs2   u tility   Because of ARM9 architecture ,  J FFS2 implem ents garbage  collection  on MT D bloc ks. This schem e  works   fi ne i n  m o st  cases.  Whe n  t h fi l e  sy st em  app r oac h es i t s  l i m i t s , ho we ver ,  J FFS 2 s p en ds a n  i n c r easi n g a m ount   Evaluation Warning : The document was created with Spire.PDF for Python.
I J RES I S SN 208 8-8 7 0 8     Developme nt  of BSP f o r A R M 9  Ev aluation B oar d   (San ket Dessa i)  16 9 of tim e  garbage collecting. Furt herm or e, as   the file system reac hes its lim its, th e system   is un ab le t o  trun cate  or m ove files and the access  to files is  slowed  down.  If  you are usi n g JFFS2, m a ke  s u re your a ppli cation' d a ta  d o e s no g r o w  to fill the en tire file syste m . In   o t h e words, m a k e  sure y o ur app licatio n s  ch eck   for  available file syste m  space be fore  writing to  it in orde r t o  a voi d se vere  slow  down a n d syste m  crashes.    Th e creation   o f  a JFFS2 im ag e is fairly sim p le:-  $  cd ${PR JROOT}  $ mk fs. j f f s 2   -r  ro ot fs/ - o  im a g es/ro o t f s - j ffs 2.im g   We u s e t h e -r  o p tion  to  sp eci fy th e lo catio n   o f  th d i rectory containing the ro ot  fi l e sy st em , and t h e - o   o p tion  t o  specify th n a me of th e ou tput file wh er e  the file system  image s hou ld   be sto r ed . Th JFFS2  co m p ression  ratio  is m u ch  smaller th an  C R AMFS.  For a  ro ot  fi l e  sy st e m  cont ai ni ng  7 8 4 0   KB fo r e x am pl e,  the res u lting J FFS 2 im age is 6850  KB in size. T h e c o m p ression ratio is  a l ittle above  10%.      4.   CO NFIG U R I N G T H E TA RGET               Fi gu re  7.  C o nfi g u r i n g t h e B o a r d  an d i t s  Set u p       Fi gu re  7 sh o w s t h e b o a r d c o nfi g u r at i o n  an d set u p, C o nn ect  t h e p o we r  su ppl y  i n cl u d e d wi t h  t h e   AT 91S AM 92 6 0  co nnect  t h AT 91S AM 92 6 0  t o  t h e h o st  co m put er by  pl ug gi n g  t h e seri al  cabl e  i n t o  t h boa r d .   Before  p o rtin g bo o tlo ad er,  kern el im ag e into  Data Flas S A MBA-IS P (In System  Program m e r) is re quire d th is software i s  freely av ailab l e, down l o a d   th is fro m   atm e l  web si t e Her e  we ha ve  use d   W i nd o w op erat i n g   syste m  to  p o rt  th e im ag es.    4. 1.  B o oti n S t ra teg y  o f  AT 91 SA M Pro d u c t   Seve ral pieces  of s o ft ware a r e  involve d  to  boot a  Linux kernel  on  SAM9 products. First is  the  ROM  code  whi c h i s  i n  char ge t o  chec k i f  a  val i d  ap pl i cat i on i s  prese n t  on s u pp o r t e d m e di a (FLAS H ,   DAT AF LA SH , N A N D F LA S H , a n d S D C A R D ).  T h bo ot   seq u ence  o f  Li nu f o SAM 9 26 0 i s  d o n e i n   several   steps:  1.   B oot  P r o g ram  - C h ec k i f  a v a l i d  appl i cat i o n i s  pr esen t in FLASH an d  i f  it is th e case d o wn lo ad  it in to  in tern al SRAM   2.   AT 91B oot st ra p -  I n  c h ar ge  of  ha r d wa re  co nfi g u r at i o n ,  d o w nl oad  U - B o ot  bi nary   fr om  FLASH   t o   SDRAM ,  start  th e boo tlo ad er  3.   U-B oot  -  T h e bo ot l o a d er i n  char ge of   d o w nl oa d ker n el  b i nari es fr om   FLAS H, net w o r k, USB  key ,   e t c.  Start the  kernel 4.   Li nu x ker n el  - The o p erat i n g sy st em   kernel .   5.   R oot   Fi l e sy st em  - C ont ai ns a ppl i cat i o ns  whi c h a r e e x ecut e on  t h e t a rget ,  usi n g  t h OS   ker n el  se rvi ces   Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 089 -48 64  I J RES Vo l. 4 ,  N o . 3 ,  No v e m b er  201  1 61   17 17 0 4. 2. L o ad  AT 9 1 B o ots t r a on  SA M 9  b o ard     AT 91B oot st ra p i s  a fi rst  st ep b oot l o a d er  pr ovi di n g  a set  of al g o ri t h m s  t o   m a nage ha rd wa r e   in itializat io n  (GPIO, Clo c k ,   SDRAM ,  etc),  to  d o wn lo ad  yo ur m a in  ap p licatio n  fro m  sp ecified  FLASH m e d i a   to  m a in   m e m o ry an d to   start it.           Fi gu re 8.   B o ot st rap Exec ut i o n W i n d o w       4. 3. L o ad  AT 9 1 B o ots t r a on  SA M 9  b o ard     Th is section   d e scrib e s How to lo ad u-b o o t  in t o  th boo t m e d i a with  SAM-BA. C o p y  t h U-B o o t   file in t o   DataFlash  as fo llo ws:   1 .   In th Send   File Nam e  field ,  click  th e Browse bu tto n.    2.   Sel ect  u- b oot -9 26 0 - en v- dat a fl ash. bi n  an d cl i c Ope n .     3 .   I n  th Ad dr ess  tex t  f i eld ,  en ter 0x 800 0, an d th en click  t h e Sen d  File bu tton is show n in   Fig u r e   9 .           Fig u re 9 .   Boo tlo ad er Installati o n       Evaluation Warning : The document was created with Spire.PDF for Python.