$ git clone git://git.rtems.org/rtems-source-builder.git
$ cd rtems-source-builder/rtems
$ ../source-builder/sb-check
RTEMS Source Builder - Check, 5 (10d3aaf467ae modified)
error: exe: not found: (__bison) /usr/bin/bison
error: exe: not found: (__flex) /usr/bin/flex
error: exe: not found: (__makeinfo) /usr/bin/makeinfo
Environment is not correctly set up
$ sudo apt-get install cmake autoconf bison flex texinfo u-boot-tools libpython2.7-dev pax
其中makeinfo命令包含在texinfo, u-boot-tools包含了mkimage命令,在生成镜像的时候用,pax和libpython2.7都会在后期编译的时候用到
$ ../source-builder/sb-set-builder --log=arm.log --prefix=$HOME/opt/rtems/5 5/rtems-arm.bset
–log表示保存编译时的Log信息,–prefix的路径是你工具链安装的位置,5/rtems-arm-bset表示构建arm平台的工具链,你也可以尝试其它bset.
下载和编译过程会比较漫长(i7,机械硬盘,编译时间大概是1个小时50分钟, 我的另外一台台式机总共只要半小时),最常遇到问题就是下载失败,每次重新下载的时候会重新编译之前已经编译的包。如果网络环境不,也可以手动下载,把文件原封不动的放在rtems-source-builder/rtems/sources目录下面。
~$ git clone git://git.rtems.org/rtems.git rtems-src
~$ cd rtems-src
rtems-src$ ./bootstrap -c && ./bootstrap
RTEMS支持ARM,MIPS等多种架构,也支持很多BSP,包括beagleboneblack, raspberry pi, stm32f4 discovery等,我以beagleboneblack为例
~$ mkdir b-beagle
~$ cd b-beagle
b-beagle$ ../rtems-src/configure --target=arm-rtems5 --enable-rtemsbsp=beagleboneblack --enable-cxx --prefix=$HOME/opt/rtems/5 --disable-networking
~$ make
~$ make install
~$ export PATH=PATH:~HOME/opt/rtems/5/bin
prefix是bsp安装路径,最好和工具链保持一致,后面会减小很多麻烦,而且一定要make install。因为我们要使用rtems-libbsd,所以需要增加选项–disbale-networking。意思就是不使用自带的network包,主要是内置的包功能太少了。export 路径之后会出现 arm-rtems5-gcc命令。
~$ git clone git://git.rtems.org/rtems-libbsd.git
~$ cd rtems-libbsd
rtems-libbsd$ git submodule init
rtems-libbsd$ git submodule update rtems_waf
rtems-libbsd使用的是waf来进行编译管理,下载waf工具:
rtems-libbsd$ git clone https://github.com/waf-project/waf
rtems-libbsd$ cd waf
waf$ ./configure
waf$ cd ../
rtems-libbsd$ ./waf/waf configre --prefix=$HOME/opt/rtems/5 --rtems-bsps=arm/beagleboneblack
rtems-libbsd$ ./waf/waf build
rtems-libbsd$ ./waf/waf install
这里的prefix是指rtems-bsp的路径,与上面的保持一致就好。
到这里,rtems的工具链,beagleboneblack的bsp包,libbsd就安装好了。
rtems-libbsd$ ./waf/waf configure --prefix=$HOME/opt/rtems/5 --rtems-bsps=arm/beagleboneblack
Setting top to : /home/figo/empty/gitwork/rtems-libbsd
Setting out to : /home/figo/empty/gitwork/rtems-libbsd/build
No valid arch/bsps found
(complete log in /home/figo/empty/gitwork/rtems-libbsd/build/config.log)
没有找到bsp包,一般情况下是在编译bsp的时候,没有make install
解决办法:
~$ cd b-beagle
b-beagle$ make && make install
RTEMS kernel contains the old network support; configure RTEMS with --disable-networking
(complete log in /home/figo/empty/gitwork/rtems-libbsd/build/config.log)
这个是在编译libbsd的时候出现的错误,原因就是在编译bsp的时候没有添加 –disable-networking选项
解决办法:
~$ cd b-beagle
~$ ../rtems-src/configure --target=arm-rtems5 --enable-rtemsbsp=beagleboneblack --enable-cxx --prefix=$HOME/opt/rtems/5 --disable-networking
~$ make -j12 && make install
RTEMS path is not valid. No lib/pkgconfig or rtems-config found.
(complete log in /home/messi/local/rtems-libbsd/build/config.log)
没有把rtems的路径添加到PATH当中去
解决办法:
export PATH=PATH:~HOME/opt/rtems/5/bin
Makefile.am:35: warning: source file 'xxx.c' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
解决办法:
~$ cd rtems-src
rtems-src$ python add_subdir-objects.py
Could not create the directory ///h
这是waf的bug
解决办法:在rtems-libbsd下面有一个隐藏文件夹“.waf-1.9.2-xxx”,在里面找到Node.py,找到
if isinstance(lst,str):
改成:
if isinstance(lst,str) or isinstance(lst, unicode):
有3处,都修改了,然后重新./waf/waf configure
# !/usr/bin/env python
# -*- coding: utf-8 -*-
""" This Script add "subdir-objects" option for configure.ac file """
import os
import os.path
def add_subdir_objects(filename):
""" find AM_INIT_AUTOMAKE line and add option
arg: configure.ac full path
"""
fd = open(filename, 'r')
lines = fd.readlines()
fd.close()
find = False
dst_index = 0
dst_line = ''
for index, line in enumerate(lines):
if line.find("AM_INIT_AUTOMAKE") >= 0:
find = True
dst_index = index
dst_line = line
break
if find:
add_option = "subdir-objects"
options_start = dst_line.find('[')
options_end = dst_line.find(']')
if options_end > options_start > 0:
options = dst_line[options_start+1:options_end].split(' ')
add_count = options.count(add_option)
if add_count == 0:
options.append(add_option)
elif add_count == 1:
return False
elif add_count > 1:
while add_count > 1:
options.remove(add_option)
add_count -= 1
new_line = "AM_INIT_AUTOMAKE([%s])\n" % ' '.join(options)
print new_line
lines[dst_index] = new_line
fd = open(filename, 'w')
fd.writelines(lines)
fd.close()
return True
def main():
""" main function, no arg
"""
dst_dir = './'
for root, dirs, files in os.walk(dst_dir):
if "configure.ac" in files:
fullname = os.path.join(root, "configure.ac")
if add_subdir_objects(fullname):
print fullname
pass
if __name__ == '__main__':
main()
executable=$1
app=rtems-app.img
base=`basename $executable`
arm-rtems4.12-objcopy $executable -O binary ./$base.bin
gzip -9 -f ./$base.bin
mkimage -A arm -O rtems -T kernel -a 0x80000000 -e 0x80000000 -n RTEMS -d ./$base.bin.gz ./$app
rm ./$base.bin.gz