使用buildroot构建龙芯2K1000文件系统
准备工作(下载buildroot)
- https://buildroot.org/download.html
进入目录,使用make menuconfig
依次进入各级菜单目录,进行如下配置:
- Cpio 可以说是一种打包方式,它包括一个或多个成员文件的连接, 每个成员文件
- 都包含一个头,后面还可以是头中所示的文件内容。存档的结尾由另一个描述名为 TRAILER 的(空)文件的头表示。
- 由于 Qt 5.11 不再提供字体文件,所以我们还要在 buildroot 勾选上字体。
- 接下来就执行 make && make sdk
- 错误提示:
In file included from /home/ww/buildroot-2019.02.6/output/build/freetype-2.9.1/src/sfnt/sfnt.c:22:0: /home/ww/buildroot-2019.02.6/output/build/freetype-2.9.1/src/sfnt/pngshim.c: In function ‘premultiply_data’: /home/ww/buildroot-2019.02.6/output/build/freetype-2.9.1/src/sfnt/pngshim.c:54:3: internal compiler error: 段错误
- 该错误是由于freetype字库导致的,不知道如何解决,只能暂时去掉编译该项,后期如果需要用到字库,再单独编译即可。判断应该与编译器有关。
- 测试验证后,确实是编译器的关系,buildroot提供使用qt5,但是qt5会自动选用freetype,此处有bug,自动编译的freetype无法顺利编译通过,是编译链接选项的问题。所以暂时去掉qt5。可以继续编译。这一问题龙芯上没有发现,因为龙芯使用GCC版本为4.9。只有版本低于4.8的才可能会有该问题出现。
搭建SDK编译环境
可以看见输出文件大了很多(因为里面包含了支持 OpenCV 和 QT 的库文件) ,到这里支 持 QT 和 OpenCV 文件系统就做好了 ,下面我们 准备把这个文件系统(rootfs.cpio.gz) 编译到内核里。 而 mips64el-buildroot-linux-gnu_sdk-buildroot.tar.gz文件是包含了编译过程中生成的目标平台的 lib 库和头文件等,后面配置 QT 的构建套件时会使用这个文件, 先执行以下命令安装 SDK 到/opt 目录
cp output/images/mips64el-buildroot-linux-gnu_sdk-buildroot.tar.gz /opt cd /opt tar -vxf mips64el-buildroot-linux-gnu_sdk-buildroot.tar.gz cd mips64el-buildroot-linux-gnu_sdk-buildroot ./ relocate-sdk.sh
搭建QT+OpenCV开放环境
安装Qt Creator4.10.2,搭建开放环境。
如果需要linux下的qt:
下载linux下的其他qt creator:
下载安装完成后,添加之前build-linux-sdk中的/bin/qmake。
显示错误:
先添加定义编译器:
mips-linux-generic-elf-32bit
在移植后的系统下运行qt程序问题解决
在板子上运行qt程序显示:qt.qpa.plugin: Could not find thi Qt platyform plugin “eglfs” in " ", available platform plugins are : linuxfb, minimal, offscreen, vmc.
- 该问题是没有初始化qt运行环境,在/etc/profile文件中添加初始化qt环境参数:
export QTEDIR=/usr/lib/qt export LD_LIBRARY_PATH=/usr/lib/:/usr/lib64:$LD_LIBRARY_PATH export QT_QPA_GENERIC_PLUGINS=tslib export QT_QPA_FONTDIR=/usr/share/fonts export QT_QPA_PLATFORM_PLUGIN_PATH=$QTEDIR/plugins export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=1024x600:mmSize=1024x600:offset=0x0:tty=/dev/tty0 export QT_QPA_FB_TSLIB=1
添加后重启系统,执行 ./${程序名} -qws 进行测试。
- 其中exit按键响应需要调用模块自带的close();
void Dialog::on_OpenImageBtn_2_clicked() { this->close(); }
交叉编译dropbear使能SSH,在龙芯上搭建ssh服务。
准备步骤
工具下载: dropbear-2016.78.tar.bz2
地址:http://matt.ucc.asn.au/dropbear/releases/
编译zlib库。
- 准备zlib库。
- 解压库并修改Makefile。tar -xvf zlib-1.2.11.tar.gz
tar -xvf zlib-1.2.11.tar.gz ./configure --prefix=/root/loongson/source/dropbear/
- 修改Makefile
#CC=gcc CC=/opt/freescale/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-linux-gcc LDSHARED=/opt/freescale/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-linux-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map #AR=ar AR=/opt/freescale/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-linux-ar #RANLIB=ranlib RANLIB=/opt/freescale/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-linux-ranlib
- 编译安装:
make make install
- 在编译dropbear时需要修改连接路径。
开始编译
编译dropbeear:
- tar -xvf dropbear-2019.78.tar.bz2
进入dropbear目录,配置dropbear
cd dropbear-2016.74
./configure --prefix=/home/freescale/test/build/dropbear
修改生成的Makefile
CC=/opt/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-gcc(根据所使用的交叉工具链修改) AR=/opt/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-ar RANLIB=/opt/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-ranlib STRIP=/opt/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-strip CPPFLAGS=-I/root/loongson/source/dropbear/include LDFLAGS=-L/root/loongson/source/dropbear/build/lib -Wl,-pie -Wl,-z,now -Wl,-z,relro
编译并安装
- make
报错:
1、mips64el-linux-gcc: error: unrecognized command line option ‘-mfunction-return=thunk’
mips64el-linux-gcc: error: unrecognized command line option ‘-mindirect-branch=thunk’
去掉编译选择中的这两个选项。
2、includes.h:108:18: fatal error: zlib.h: No such file or directory
#include
需要交叉编译zlib的库。参考准备过程步骤。
3、explicit_bzero 、memset_s报错,在config,h中去掉宏定义HAVE_MEMSET_S或者HAVE_EXPLICIT_BZERO,重新make clean && make即可。
- make scp
- make install
得到编译好的库:
拷贝scp到安装目录
cp scp /root/loongson/source/dropbear/build/dropbear/bin
strip所有的可执行文件
aarch64-fsl-linux-strip /home/freescale/test/build/dropbear/bin/* aarch64-fsl-linux-strip /home/freescale/test/build/dropbear/sbin/*
把所有bin目录和sbin目录文件拷贝到精简文件系统对应的bin和sbin目录中,拷贝上述涉及到的lib库到精简文件系统的lib目录,创建dropbear配置目录,并生成密钥
mkdir /etc/dropbear cd /etc/dropbear dropbearkey -t rsa -f dropbear_rsa_host_key dropbearkey -t dss -f dropbear_dss_host_key ln -s /bin/dbclient /bin/ssh ln -s /lib/libz.so.1.2.8 /lib/libz.so.1 ln -s /lib/libutil-2.20-2014.11.so /lib/libutil.so.1 ln -s /lib/libcrypt-2.20-2014.11.so /lib/libcrypt.so.1 dropbear即为服务端,dbclient即为客户端,添加系统启动服务 vi /etc/init.d/rcS 添加 /usr/sbin/dropbear 到此处dropbear准备工作已经完毕,重启系统后,用PC通过ssh远程登录








