Transplant uClinux Based on S3C44B0X Through UBoot 通过

Transcription

Transplant uClinux Based on S3C44B0X Through UBoot 通过
第 8卷第 4期
2008年 12月
南京师范大学学 报 (工程技术版 )
JOU RNAL O F NAN JING NO RM AL UN IVERS ITY ( ENG INEER ING AN D TECHNO LOGY ED IT ION )
Vo.l 8 No. 4
Dec, 2008
Transplant uC linux Based on S3C44B0X Through U Boot
W ang L iw e,i Y ang H oujun, Fan Y anb ing
( College of In form at ion Eng ineering, Q ingdao U n ivers ity, Q ingdao 266071, Ch ina)
Abstrac t: In the developm ent of an embedded system, it is necessary to build a com plete embedded operation system to
achieve a faster deve lopm ent pe riod of applica tion prog ram and dev ice driver. A bove al,l it is im perative to construct U
Boot lead program. Once a U Boo t lead prog ram for the ope ration system kerne l is prepa red, the se lf conta ined starting
environm ent is used to carry out the transplant o f uC linux. T h is is based on a S3C44B0 bo ard. F inally, from the aspect
o f a transp lant onto a board, the transp lanting pro cess is sy stem atica lly analyzed and descr ibed by comb in ing w ith a hard
w are p la tform.
K ey word s: U Boo t, S3C44B0, uC linux, transplant
CLC num ber: T P 316,
Docum en t cod e: A,
Artic le ID: 1672 1292( 2008) 04 0150 05
通过 U Boot实现基于 S3C44B0X的 uC linux移植
王丽伟, 杨厚俊, 范延滨
( 青岛大学 信息工程学院, 山东 青岛 266071)
[ 摘要 ]
在嵌入式系统开发中, 为了加快应用程序以及设备驱动的开发周期, 需要建立一个完备 的嵌入式操作系 统. 首先, 建
立 U Boot引导程序是必不可少的. 在 U Boot引导程序为操作系统内核准备好环境之后, 利用它实现了 uC linux基于 S3C44B0开
发的移植. 最后, 从板级移植的角度, 结合硬件平台结构系统地分析和讲解了移植过程.
[ 关键词 ]
U B oot, S3C44B0, uC linux, 移植
S3C44B0X deve lo ped by Sam sung is a 16 /32 b it R ISC em beddedMPU. It is based on ARM 7TDM I kerne,l
and isw id ely app lied in Ch in a. The ARM 7TDM I functio n m odu le integ rates lo ts of periphery function m odu le. In
add ition, it is a low cos,t high pow ered MPU wh ich is developed for handho ld equ ipm ent and other all purpose
equ ipm ents. Due to the low cost and brief design, it is useful for an applicatio n w ith h ig h requ irem ent of cost and
[ 1]
pow er consum ption .
Th is sub ject uses processor S3C44B0X, wh ich is com
posed of th e core board and ex tensiv e fu nct ion modules. The
core board in cludes processor S3C44b0X, a F lash( 2M B) and
a SDRAM ( 8M B ) . T he extensive m odu les in clude a F lash
( 16M B) , tw o U ar,t a Jtag interface, a E thernet interface,
and d isp la y.
The fu nct ion structure is shown in F ig. 1.
P resently, uC /OS and uC linux are tw o m ain em bedded
[ 2]
operatin g system s wh ich are based on non MMU MPU . Deriv ed from L inux, uC linux keeps most advantages of
L inux operatin g system, and supports m ultitask. B esides th is, uC linux is rew rited in order to be the sam e w ith
non MMU MPU, so its kernel is sm al,l comm only be in g used in S3C44B0 processo r. T herefo re, th is sub je ct
R eceived date: 2008 06 18.
Foundation item: 863 Program ( 2006AA 01Z110) .
C orresponding auther: Y ang H ou jun, associate professor, f ield of study: com puter system structu re. E ma i:l h jyang666666@ 126. com
150
W ang L iw e,i et a:l T ransp lant uC linux Based on S3C44B0X T hrough U Boot
chooses uC linux as the operating system o f em bedded system.
1 C ross Com p ile Env ironm ent
1 1
Introductio n
C ross com pile is a process of creating a target code that is created in a com puter and run in another one,
th rough the w ay o f using com piler to cross com pile a program. C ross developm ent too l m a in ly in clu des IDE inte
[ 3]
grated developm ent env ironm en t and M akefile m ethod . No rm ally, the app lic ation explo itat io n uses in tegrated
explo itat io n env ironm en,t kerne l com piling uses the later one. T he fin al purpose of th is sub ject is com piling
uC linux kerne,l so M akef ile m ethod is chosen.
The deve lo pm ent env ironm en t in cludes b inut ils, gdb, gcc and g lib c wh ich w ill be used fo r kernel com
[ 4]
pile . C ross com pile too l cha in can be bo th self m ade and dow nloaded. M ak ing a cross com p ile too l cha in is a
com p licated process and easily m ake m istakes. In order to succeed in com pile kerne,l this sub ject chooses to
dow nload a finished cross com pile too l cha in from in terne.t
1 2 Construct cross com pile env ironm ent
Because uC linux is the operating system w hich is needed to transplan,t it is necessary to in sta ll a co rre
spond ing cross comp ile too l before th e transp la n.t Arm elf too ls- 20030314. sh is used here. Execute com
m and. / arm - elf- too ls- 20030314. sh, and an uC linux arm cross comp ile env ironm ent can be autom at ic ally set
[ 5]
up in the host .
W ith the in stalled too l H - Jtag, the successful com p iled boo tlo ader can be loaded in to F lash.
2 B ootloader Transp lant
Bootloader is the first prog ram after em bedded system be e lectrif ie d, w hich is a very im portant com ponent of
embedded system. C onstructin g or transplanting a Bootloader w ill bring lots o f conven ience to continue exploita
t io n. T hrough Bootloader, it can initialize hardw are equ ipm en,t set up interna l spatia lm ap, adju st hardw are and
softw are to appropriate situat io n and prepare proper env ironm ent fo r th e transp lanting kerne.l The m a in ro le of
Bootloader is to lo ad kernel im age from host in to board, then go to the kernel portal and startup th e kerne.l
A ctua lizat io n of Bootloader depends on the hardware, and d ifferent processors w ith d ifferent structures have
different Bootloaders. In add it ion, Boo tloader actually relies on th e specific config uration o f board, so transp lant
Bootloader a im ed at deve lo ping board is becom ing m ore im portan.t A t presen,t Bootloader m a in ly have B lob, v i
vi and U Boot in comm on use. Th is subject chooses U Boot to transplan .t
2 1
Introductio n of U Boot
U Boot is an open source pro je ct fo llow s GPL term s. In additio n to all un iv ersal functions of Bootloader, U
Boot also has severa l advan tages such as supportin g m u ltiple em bedded operating system kerne,l supporting m u l
t ip le processor, h ig h reliab ility and stability, and p lenty o f dev ice driver source code.
2 2 M em ory space partition
Seek T able 1.
2 3 T ransp la nt U Boot
2 3 1 Startu p flow analysis
U Boot startup in clu des w
t o phases, code of phase 1 is
def ined in f ile
star.t S , wh ich in clu des the part of electrif
T able 1 M emory spa ce partition
Con tent
S tarting address
Storage m edium
B ootload er
0x00000000
Flash
Im age load add ress
0x00040000
Flash
K ernel start address
0 x0c008000
SDRAM
Fs load address
0 x0c600000
SDRAM
ying system that executes at 0x0, conf igure reg is ters and copy
phase 2 to RAM. Phase 2 starts at m a in c, and it is to exam in e m em ory m appin g o f system, read kerne l im age
and roo t f ile system im age from F lash to RAM, set up the startup param eter and transfer kerne.l
By th is token, transplant ing U Boo t in allu sio n to S3C44B0 m ostly ju st need to modify th e hardware con
fig ure of S3C44B0, and set up the startu p param eter for kerne.l Besides, in o rder to ensure the kerne l w orks
151
南京师范大学学报 (工程技术版 )
第 8卷第 4期 ( 2008年 )
successfully, it is necessary to do som e specific m odificat io ns.
2 3 2 T ransp lant analysis
Due to B2 board in U Boot 1 1 4 adopts S3C44B0X processor. The transplant of U Boot w ill be consu lted
of B2 board.
1. Construct the board head file w lw 44b0. h
Change S3C44B0 m ain frequency to 66
Append RTL8019 netw ork card
# de fin e CONF IG - DR IV ER- RTL8019
# de fin e RTL 8019- BASE 0x0a000600
In o rder to save environm ent variab le into F lash, append F lash param eters
# de fin e CFG- ENV - IS- IN - FLASH
1
# undef CFG - ENV - IS- IN - NOWHERE
Configure the size o f storage space and start address for SDRAM and F lash
2. M odify hardw are configurat io n
A ccord in g to S3C44B0 hardw are configuration, m od ify register va lu e in function board- in .t
3. M odify startu p file star.t S
S tart. S is the first file that the CPU processes, so it is im portant to ensure its stab ility. In order to ensure its
stability and reliab ility, som e m od if ication should be done as follow s:
De lete seven interrupt jum p sentences, append jum p sentences for seven abnorm al interrupts: ld r pc, ab
norm a l in terrupt address
M odify cpu- init- criti par,t change the valu e PLLCON w hich correspond to MCLK 66 to 0x7c041
4. M odify low leve l- in i.t S
Change REFRESH reg ister va lu e to 0x9603 fd, refresh reg ister, and im proper configure w ill im pact serial
outpu.t
5. M odify the f ile conf ig. mk w hich under the board d irectory
In order to avo id conflict o f startup param eter and kerne l reflection, change TEXT - BASE to 0xc700000, let
it at the h ig h address o f m em ory.
6. M odify the f ile M akef ile wh ich under roo t d irectory
Con fig ure CROSS- COM P ILE
to arm - e lf- , so it w ill be com piled by th e cross com pile too.l
Thus, it has basica lly fin ished th e transplant o f U Boo.t F in ally, execute m ake B2- con fig and m ake
comm and, then get u- boo .t b in f ile.
2 4 Down lo ad u- boo.t bin to board
Com pile and create u- boo.t bin f ile, and then use
H - Jtag too,l dow nload it in to the board at 0x0. T he seri
al has ou tp ut and a ll fu nct io ns it prov id ed are usab le,
v iz. , transplant ing U Boo t is successfu.l
F ig. 2. show s how U Boo t w orks.
3 T ransp lant uC linux
3 1
Instruction o f uC linux
uC linux is a m odificat io n of L inux, it is developed for nonMMU m icroprocessor and have been app lied
broad ly to non MMU m ic roprocessor such as ARM and M IPS. In o rder to app ly to non MMU m icroprocessor, it
has been rew ritten, so it ism uch sm a lle r than L inux. In add it io n it keeps the advantages o f L inux lik e stability,
excellent netw ork ab ility and supporting file system.
152
W ang L iw e,i et a:l T ransp lant uC linux Based on S3C44B0X T hrough U Boot
3 2 T ransp la nt uC lin ux
T ransp lant uC lin ux generally inc ludes th ree leve ls: structure leve l transplan,t platform level transplant and
board level transp la n.t
If the structu re o f CPU wh ich is go in g to be transp lanted is d ifferent from any CPU tha t uC linux supports,
th en m od ify related CPU structure f ile under
linux / arch , this is called structure le vel transplan.t If uC linux
supports th e CPU, create directory and w rite code under re lated system structu re directory, this is called p latform
level transplan.t L astly, if uC linux supports the CPU, only board level transplant is enough. Board leve l trans
plant is creat ing re lated develop ing board d irectory under
linux / arch , then m odify it according to board.
uC linux has already suppo rted S3C44B0X processo r, so ju st need to do board level transp lan.t
Th is subject chooses uC linux d ist- 20040408 to transp la n.t The linux 2 4. x in it is actually the kernel
2 4 20. A lthough it supports s3c44b0 m uch w e l,l the patch uC linux 20040408- ARM SYS. patch
is st ill nec
essary, w hich is m ade according to s3c44b0.
Now presen t the transp lant process of uC linux in details.
1. Append 44B0 directory and file
C reate 44B0 d irecto ry under vendors/ Sam sung , copy all the file from d irectory 4510 to 44B0.
2. Pa tch the file
Copy the patch file to uC linux d ist root f ile, and then execute the comm and
patch
p1 < uC lin ux
20040408- ARM SYS. patch .
3. Append the im age file
M od ify M ake file under vendor/ Sam sung /44B0 , append th e related content about im age file, so im
age. rom and im age. ram can be go.t
4. M odify kernel config ure file
A ccord in g to the id io graph ic configuration o f S3C44B0, m od ify the address and size of SDRAM and F la sh,
m a in frequency and ex ternal c lo ck, and startup param eter CONF IG - CMDL IN E . N eg lecting these w ill cause
kerne l runs irregu la rly.
5. Append rom fs file system
Because of the shortage o f linux 2 4 20 for support ing rom fs f ile system, it is im portant to add rom fs file
system m anua lly.
Append related f ile im age infom ation
In order to create the rom fs file system, m od ify M ake file w hich under vendor /Sam sung / 44B0 :
( CROSS- COM P ILE ) ld r o $ ( ROOTDIR) /$ ( L INUXDIR) / rom fs. o
M odify th e file blkm em. c under lin ux 2 4. x / driv ers/ b lo ck
b bin ary $ ( ROM FSIM G )
Append variab les rom fs- data[ ]
{ 0, rom fs- data, - 1}
and
rom fs- data- end[ ] . A nd append
order to po in t the address rom fs p laced.
M odify file vm linux arm v. ld s. in w hich under
in
linux 2 4. x / arch / arm nmm u
Append rom fs. o, and capture its start and end address
rom fs- data and rom fs- data- end .
6. Append seria l driv er
L inux2 4 20 kernel only im plem ents sim p le seria l driver fo r S3C44B0X, so append in g seria l driv er program
is m
i portan.t
Append configure option of seria l
Append seria l in terface opt io n in the f ile C onfig. in under
sure that it has the option w hen com pilin g the kerne.l
linux 2 4. x /driver/ serial , in order to m ake
Def in e serial port num ber
Append definit io n of PORT - S3C44B0
in
Append ob ject iv e file in M akefile under
seria l- core. h , define the valu e to 38.
linux 2 4. x /driver / serial :
153
南京师范大学学报 (工程技术版 )
第 8卷第 4期 ( 2008年 )
ob j- $ ( CONF IG- SERIA L- S3C44B0X) + = seria l- s3c44b0. o
3 3 Con fig ure and com pile kerne l
Com pile and configure kerne l after finish the basic transp lan.t F irs,t execute comm and m ake m enucon fig
under directory uC linux d ist , choose Sam sung
and uC lib c
as producer and board
44B0 , use
linux2 4. x kernel
library.
And it s necessary to se le ct th e opt io ns Custom ize Kerne l Sett ings and Custom ize Vendor /U ser Set
t ings , wh ich m eans that the kerne l and vendor /user option w ill be configured m anua lly.
Con fig ure file w ill be set to config. linux. 2 4. x
and
config. vendor. 2 4. x , then m ake sure the con
fig ure and append other functio ns needed, m ain ly as fo llow s:
T he base address and size o f SDRAM and F lash de fin ed in the System T ype options.
Not ice de fin itions o f m a in frequency and external clock frequency w hich under System Type options.
Another point needed to pay attent io n to is Defau lt kerne l comm and strin g
in General setup optio ns.
Set up param eters w hich are used when startup kerne.l Set up it as root= / dev / ram 0 init= / linux rc ,
root designates root file system on / dev / ram 0 , set in it= / linuxrc in o rder to load roo t file system correct
ly.
Thus, con fig ure of kernel is basica lly finished, accordin g to pract ical circum stance to do other conf ig ures.
A fter th a,t execute comm ands o f m ake dep , m ake lib- on ly , m ake user- only , m ake rom fs , m ake
linux ,
m ake im age orderly, then th e im age file w ill be generated.
3 4 Debug and down lo ad
U Boot prov ides tw o different operat ing m odes: startup and load m ode, down load m ode. U nder startup and
load m ode, U Boot loads and run operatin g system in to RAM, users can t intervene the process; under down
lo ad m ode, U Boot down lo ads kernel im age and root file system into RAM from H ost through commun icat io n
m ethod such as serial or netw ork. T his m ode w ill not eng ross too m uch m em ory space, th is sub je ct use netw ork
in terface to dow nload executab le file.
Insta ll tftp server in hos,t use the
dow nload
im age. ram
and
rom fs. im g
tftp
fu nct ion,
to RAM at
0xc008000 and 0xc600000 , then im plem ent
0xc008000 order and startup kerne.l
go
4 C onclusions
Th is paper describ es transplant u boo t lead ing proce
dure and transp lant process of uC linux kernel th at based on
s3c44b0, be in g m aster of the transplant process o f u boot
and uC linux is im portant for subsequent equ ipm ent drive
transp lanting and w rit ing.
A ccord in g to the transp la nt in clu des three leve ls, th is
paper particu larly presents th e transplant process of uC linux from
transplant based on board po in t o f v iew. In
add ition, pay attention to the relat io nship betw een so ftw are and hardw are during the process, it e licits subsequent
transp lant of other board, and m akes it easie r.
(下转第 172页 )
154
南京师范大学学报 (工程技术版 )
第 8卷第 4期 ( 2008年 )
[ 5] 求是科技. V isua l C+ + 数字图像处理典型算法及实现 [ M ]. 北京: 人民邮电出版社, 2006: 315 333.
Q iush iK e j.i V isual C + + typical a lgor ithm & im p lenm entation in d ig ita l im age process ing [ M ]. Be jing: Posts & T elecom
P ress, 2006: 315 333. ( in Chinese)
[ 6] 刘瑞祯, 于仕琪. O penCV 教程 基础篇 [M ]. 北京: 北京航空航天大学 出版社, 2007: 243 326.
L iu R u izhen, Yu Sh iq.i O penCV course( part 1: fundamenta l) [M ]. Be jing: Be ijing U n iversity of A eronau tics and A stronautics
P ress, 2007: 243 326. ( in Chinese)
[ 7] 程军娜, 姬光荣, 冯晨. 基于数学形态学的藻细胞图像预处理 [ J] . 中国海洋大学学报, 2008, 38( 3): 513 516.
Cheng Ju na, Y iG uang R ong, F eng Chen. A lgae cell im age prepro cessing based on m a them aticalm orpho logy [ J]. P eriodical o f
O cean U n iversity o f China, 2008, 38( 3): 513 516. ( in Ch inese)
[ 8] K um ar S, O ng S H, R anganath S, et a .l A lum inance and contrast invar iant edge sim ilar ity m easure[ J]. IEEE T rans Pattern
A nalM achInte l,l 2006, 28( 12): 2 042 2 048.
[ 9] Serra J, V incent L. A n overv iew o fm orpholog ica l filter ing [ J]. C ircuits System S ignal P rocess, 1992. 11( 1): 47 108.
[ 责任编辑: 孙德泉 ]
( 上接第 154页 )
[ Referen ces]
[ 1] T ian Ze. The D evelopment and A pplica tion o f Embedded Sy stem [M ]. Be ijing: BeiH ang U n iversity P ress, 2005.
[ 2] X iong Chunjie, Zhong Jiaq,i Chen Q ioum e.i T ransp lant uclinux based on s3c44b0 developm ent platform [ J]. Contro l& A uto
m ation, 2007, 23( 2): 46 48.
[ 3] L i Y an, W angW e ib ing, Sun Y ongchun. T ransplan t uC linux OS ke rnel based on S3C44B0X [ J]. Journal ofH arb in U n iversity
o f Science and T echno logy, 2006, 11( 2): 73 75.
[ 4] W u R u,i Zhu Jun, W ang Y uw ang, e t a.l T ransp lant uC linux based on U P NETARM 3000 platform [ J]. Com puting T echno logy
and A utom ation, 2006, 25( 4): 228 232.
[ 5] Chang Y inx ia, Zhang Zhendong, T ang Jiy ing. T ransplant uC linux to S3C44B0 through Bootloader[ J] . Journa l o fH ebe i U ni
ve rsity o f T echno logy, 2005, 34( 2): 100 104.
[ 6] Chen W e ijun, L i Zhengm ing, Sun Jun, et a.l The design and im p lem ent o f S3C44B0 leading prog ram based on U Boot[ J].
Em bedded Softw are A pplica tion, 2007, 1( 2): 113 115.
[ 责任编辑: 顾晓天 ]
172