rtems官网上最新发布的代码是6.1-rc4,相对于老版本,做了较大的改动, 文件目录组织方式,尤其是编译系统,移除了autoconf/automake,使用waf python脚本编译,当前使用python脚本配置编译,已称为主流,例如yacto、openbmc等,都是基于python开发的编译配置系统
rtems-6.1-rc4编译工具链编译方式与老版本类似,rtems-source-builder下载编译相关工具链等
解压到如下目录中,
/root/rtems-source-builder-6.1-rc4
新建patches sources目录,结构如下
├── bare
│ └── config
├── CODEOWNERS
├── LICENSE.md
├── README.md
├── rtems
│ ├── build
│ ├── config
│ ├── patches
│ └── sources
├── source-builder
└── VERSION
将Index of /pub/rtems/releases/6/rc/6.1-rc4/sources下载的.diff patch等文件复制到patches目录,其他 .tar.gz .tar.xz等放到sources目录下
运行如下命令,编译生成386平台的工具链
../source-builder/sb-set-builder --prefix=$HOME/development/rtems/6.1-rc4 6/rtems-i386 --no-download --rtems-bsp --keep-going
注意,上文中我们已经下载了编译需要的相关文件,所以这个地方选择不下载参数,如果有报错也继续编译
过程中遇到如下报错
config.status: linking mpn/x86_64/k8/gmp-mparam.h to gmp-mparam.h
config.status: executing libtool commands
configure: summary of build options:
Version: GNU MP 6.3.0
Host type: x86_64-pc-linux-gnu
ABI: 64
Install prefix: /root/rtems-source-builder-6.1-rc4/rtems/build/tmp/sb-0-internal
Compiler: gcc -O2 -g -pipe -I/root/rtems-source-builder-6.1-rc4/rtems/build/tmp/sb-0/devel/gmp-internal/root/development/rtems/6.1-rc4/include -I/root/rtems-source-builder-6.1-rc4/rtems/build/tmp/sb-0-internal/include -std=gnu99
Static libraries: yes
Shared libraries: no
gcc -O2 -g -pipe -I/root/rtems-source-builder-6.1-rc4/rtems/build/tmp/sb-0/devel/gmp-internal/root/development/rtems/6.1-rc4/include -I/root/rtems-source-builder-6.1-rc4/rtems/build/tmp/sb-0-internal/include `test -f 'gen-psqr.c' || echo './'`gen-psqr.c -o gen-psqr -lm
gen-sieve.c: In function 'setmask':
gen-sieve.c:99:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (unsigned i = 0; i < 2 * a * b; ++i)
^
gen-sieve.c:99:3: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [gen-sieve] Error 1
make: *** Waiting for unfinished jobs....
shell cmd failed: /bin/sh -ex /root/rtems-source-builder-6.1-rc4/rtems/build/gmp-6.3.0-x86_64-linux-gnu-1/do-build
error: building gmp-6.3.0-x86_64-linux-gnu-1[root@localhost rtems]#
添加gmp编译时的CFLAG选项-std=c99
/root/rtems-source-builder-6.1-rc4/source-builder/config/gmp.cfg中修改
%build
build_top=$(pwd)
cd gmp-%{gmp_version}
%{host_build_flags}
#wx add
CC_FOR_BUILD="${CC_FOR_BUILD} -std=c99"
#wx add
./configure \
--build=%{_build} --host=%{_host} \
--verbose \
--prefix=%{gmp_prefix} --bindir=%{gmp_bindir} \
--exec-prefix=%{gmp_exec_prefix} \
--includedir=%{gmp_includedir} --libdir=%{gmp_libdir} \
--mandir=%{gmp_mandir} --infodir=%{gmp_infodir} \
--disable-shared \
%{gmp_extra_options}
编译GDB时提示no usable python found at /usr/bin/python2
checking whether to use python... /usr/bin/python2
configure: error: no usable python found at /usr/bin/python2
checking for python... no
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory `/root/rtems-source-builder-6.1-rc4/rtems/build/i386-rtems6-gdb-14.2-x86_64-linux-gnu-1/build'
make: *** [all] Error 2
shell cmd failed: /bin/sh -ex /root/rtems-source-builder-6.1-rc4/rtems/build/i386-rtems6-gdb-14.2-x86_64-linux-gnu-1/do-build
error: building i386-rtems6-gdb-14.2-x86_64-linux-gnu-1[root@localhost rtems]#
即使安装了python2的python-devel 也无法BUILD过,临时移除GDB的编译后整体编译通过OK
修改文件 /rtems-source-builder-6.1-rc4/rtems/config/tools/rtems-default-tools.bset
#
# Build gdb first to raise the Python install error as early as
# possible.
#
# GCC and GDB need GMP and MPFR.
#
%{with_rtems_dtc}
devel/expat-internal
devel/gmp-internal
devel/mpfr-internal
%{with_rtems_gsed}
%{with_rtems_texinfo}
#%{with_rtems_gdb}
%{with_rtems_binutils}
%{with_rtems_gcc}
%{with_rtems_tools}
安装PYTHON3之后,单独编译,提示报错,需要安装 python3 的devel 包,
[root@localhost rtems]# ../source-builder/sb-set-builder --prefix=$HOME/development/rtems/6.1-rc4 6/rtems-i386 --no-download
RTEMS Source Builder - Set Builder, 6.1-rc4
Build Set: 6/rtems-i386
Build Set: tools/rtems-default-tools.bset
config: tools/rtems-gdb-14.2.cfg
error: config error: gdb-common-1.cfg:123: "gdb: python: header file not found: python3.6/Python.h, please install"
Build FAILED
Build Set: Time 0:00:00.099069
error: config error: gdb-common-1.cfg:123: "gdb: python: header file not found: python3.6/Python.h, please install"
Build Set: Time 0:00:00.101830
Build FAILED
直接下载python3.6.8源码configure 重新make, make install 之后再BUILD GDB不再报错
至此RTEMS6的 build tool chain 已build完成,目录位于
$HOME/development/rtems/6.1-rc4
编译代码
新代码的编译配置系统已经修改为 WAF,相关命令与之前版本差别较大,需要注意,
列出当前支持哪些BSP
切换到rtems-6.1-rc4的代码根目录下
列出当前支持哪些BSP.新版本的脚本执行速度非常快
[root@localhost rtems-6.1-rc4]# ./rtems-bsps
RTEMS 6 Board Support Packages
Architectures: 18
BSP Families: 93
BSPs: 222
其他省略
i386: (families:1 bsps:6)
pc386 pc386
pc486 pc386
pc586 pc386
pc586-sse pc386
pc686 pc386
pcp4 pc386
查看waf 支持的命令
[root@localhost rtems-6.1-rc4]# ./waf --help
usage: waf [commands] [options]
Main commands (example: ./waf build -j4)
bspdefaults: get all options with default values for base BSP variants
bsplist : lists base BSP variants
build : executes the build
clean : cleans the project
configure : configures the project
dist : makes a tarball for redistributing the sources
distcheck : checks if the project compiles (tarball from 'dist')
distclean : removes build folders and data
install : installs the targets on the system
list : lists the targets to execute
step : executes tasks in a step-by-step fashion, for debugging
uninstall : removes the targets installed
先生成一个默认的配置文件config.ini
[root@localhost rtems-6.1-rc4]# ./waf bspdefaults --rtems-bsps=i386/pc386 > config.ini
生成配置
[root@localhost rtems-6.1-rc4]# ./waf configure --rtems-bsps=i386/pc386 --rtems-config=./config.ini --rtems-tools=/root/development/rtems-i386-toolchain/6.1-rc4
Setting top to : /root/rtems-6.1-rc4
Setting out to : /root/rtems-6.1-rc4/build
Configure RTEMS version from file : VERSION
Regenerate build specification cache (needs a couple of seconds)...
Configure board support package (BSP) : i386/pc386
Checking for program 'i386-rtems6-gcc' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-gcc
Checking for program 'i386-rtems6-g++' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-g++
Checking for program 'i386-rtems6-ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for program 'i386-rtems6-ld' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ld
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for program 'g++, c++' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-g++
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for program 'gas, gcc' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-gcc
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for program 'gcc, cc' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-gcc
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for asm flags '-MMD' : yes
Checking for c flags '-MMD' : yes
Checking for cxx flags '-MMD' : yes
'configure' finished successfully (6.862s)
开始实质性的编译过程
[root@localhost rtems-6.1-rc4]# ./waf build
Waf: Entering directory `/root/rtems-6.1-rc4/build'
Waf: Leaving directory `/root/rtems-6.1-rc4/build'
'build' finished successfully (0.075s)
Waf: Entering directory `/root/rtems-6.1-rc4/build/i386/pc386'
[ 1/1490] Compiling bsps/i386/shared/irq/elcr.c
[ 2/1490] Compiling bsps/i386/pc386/console/serial_mouse_config.c
[ 3/1490] Compiling bsps/i386/pc386/console/console_select.c
[ 4/1490] Compiling bsps/i386/pc386/clock/ckinit.c
[ 5/1490] Compiling bsps/i386/pc386/btimer/btimer.c
[ 6/1490] Compiling bsps/i386/shared/cache/cache.c
[ 7/1490] Compiling bsps/i386/pc386/start/realmode_int.c
[ 8/1490] Compiling bsps/i386/pc386/console/rtd316.c
[ 9/1490] Compiling bsps/i386/pc386/start/page.c
中间省略过程
[1470/1490] Compiling testsuites/samples/unlimited/test1.c
[1471/1490] Compiling testsuites/samples/unlimited/test3.c
[1472/1490] Compiling testsuites/samples/unlimited/test2.c
[1473/1490] Linking build/i386/pc386/libtftpfs.a
[1474/1490] Linking build/i386/pc386/libftpd.a
[1475/1490] Linking build/i386/pc386/testsuites/samples/base_sp.exe
[1476/1490] Linking build/i386/pc386/testsuites/samples/capture.exe
[1477/1490] Linking build/i386/pc386/testsuites/samples/hello.exe
[1478/1490] Linking build/i386/pc386/testsuites/samples/minimum.norun.exe
[1479/1490] Linking build/i386/pc386/testsuites/samples/nsecs.exe
[1480/1490] Linking build/i386/pc386/testsuites/samples/ticker.exe
[1481/1490] Linking build/i386/pc386/testsuites/samples/unlimited.exe
[1482/1490] Linking build/i386/pc386/libjffs2.a
[1483/1490] Linking build/i386/pc386/testsuites/samples/fileio.exe
[1484/1490] Linking build/i386/pc386/libdebugger.a
[1485/1490] Linking build/i386/pc386/testsuites/samples/cdtest.exe
[1486/1490] Linking build/i386/pc386/testsuites/samples/iostream.exe
[1487/1490] Linking build/i386/pc386/libz.a
[1488/1490] Linking build/i386/pc386/librtemscxx.a
[1489/1490] Linking build/i386/pc386/testsuites/samples/paranoia.exe
[1490/1490] Linking build/i386/pc386/libmghttpd.a
Waf: Leaving directory `/root/rtems-6.1-rc4/build/i386/pc386'
'build_i386/pc386' finished successfully (13.941s)
编译完成
使用QEMU运行ticker.exe
命令
qemu-system-x86_64.exe -m 1024 -kernel o:\ticker.exe
效果如下:

1142

被折叠的 条评论
为什么被折叠?



