1. 背景
废话不多说,目的就是解决Hypervisor双系统稳定通讯。
TODO
2. 资源下载
2.1 资源路径:
资源1:FDBUS-PROTOBUF
资源2:GitHub - protocolbuffers/protobuf: Protocol Buffers - Google's data interchange formatProtocol Buffers - Google's data interchange format - GitHub - protocolbuffers/protobuf: Protocol Buffers - Google's data interchange formathttps://github.com/protocolbuffers/protobuf fdbus: Fast Distributed Bus (FDBus)
https://gitee.com/jeremyczhen/fdbus
2.2 下载解压:
TODO
2.3 QNX工工具链:
2.3.1 下载:prebuilt_QNX700.tar.gz
#!/bin/env bash
# This script installs QNX 7.
set -e
targetFolder="/opt/"
sourceFile="http://ci-files01-hki.ci.local/input/qnx/qnx700.tar.xz"
sha1="949a87c5f00d0756956cb4b1b3b213ecaeee9113"
folderName="qnx700"
targetFile="qnx700.tar.xz"
wget --tries=5 --waitretry=5 --output-document="$targetFile" "$sourceFile" || echo "Failed to download '$url' multiple times"
echo "$sha1 $targetFile" | sha1sum --check || echo "Failed to check sha1sum"
if [ ! -d "$targetFolder" ]; then
mkdir -p $targetFolder
fi
if [ -d "$targetFolder/$folderName" ]; then
rm -rf $targetFolder/$folderName
fi
sudo tar -C $targetFolder -Jxf $targetFile|| echo "Failed to extract $targetFile"
sudo chown -R qt:users "$targetFolder"/"$folderName"
# Verify that we have last file in tar
if [ ! -f $targetFolder/$folderName/qnxsdp-env.sh ]; then
echo "Installation failed!"
exit -1
fi
rm -rf $targetFile
# Set env variables
echo 'export QNX_700=$targetFolder/$folderName' >> ~/.bashrc
echo "QNX SDP = 7.0.0" >> ~/versions.txt
2.3.2 BSP code中抽离
如果有环境不需要下载,BSP代码抽离出来即可
qnx_ap/qnx_bins/prebuilt_QNX700
3. 实操
3.1 Protobuf编译
3.1.1 创建/修改编译脚本 //在protobuf根目录
build_qnx.sh 文件内容如下:
#!/bin/sh
###################################
#### build script for protobuf
#### taget:qnx
#### Date: 2022-11-01
#### Author: 村里小码农
###################################
# qnx bsp dir
QNXROOT_PATH=/workspace/automotive_bsp/qnx_ap
# current dir
CURRENT_PATH=$(pwd)
# QNX prebuild toolchains dir
QNX_PREBUILT=$QNXROOT_PATH/qnx_bins/prebuilt_QNX700
QNX_PREBUILT_FIXE=$QNXROOT_PATH/qnx_bins/prebuilt_QNX700FIXME
PREFIX=$CURRENT_PATH/out/qnx
mkdir -p $PREFIX
export QNX_CONFIGURATION=$QNX_PREBUILT/.qnx
export QNX_TARGET=$QNX_PREBUILT/target/qnx7
export QNX_HOST=$QNX_PREBUILT/host/linux/x86_64
export MAKEFLAGS=-I$QNX_PREBUILT/target/qnx7/usr/include
export MAKELDFLAGS=-L$QNX_PREBUILT/target/qnx7/usr/lib,-L$QNX_PREBUILT/target/qnx7/aarch64le/lib
export QNX_CC64=$QNX_PREBUILT/host/linux/x86_64/usr/bin/ntoaarch64-gcc
export QNX_CXX64=$QNX_PREBUILT/host/linux/x86_64/usr/bin/ntoaarch64-g++
function build_ARM64
{
echo "---------------------------"
echo " > start to build ARM64."
echo "---------------------------"
./configure --prefix=${PREFIX} \
--host=arm \
--build=x86_64-pc-linux \
CC=${QNX_CC64} \
CXX=${QNX_CXX64} \
CXXFLAGS=-std=gnu++14 \
CPPFLAGS='-D_XOPEN_SOURCE=500' \
--disable-shared
make clean
make install
echo "---------------------------"
echo " > build finished."
echo "---------------------------"
}
build_ARM64
运行:./build_qnx.sh
编译生成:
├── bin
│ └── protoc
├── include
│ └── protobuf
└── lib
├── libprotobuf.a
├── libprotobuf.la
├── libprotobuf-lite.a
├── libprotobuf-lite.la
├── libprotoc.a
├── libprotoc.la
└── pkgconfig
├── protobuf-lite.pc
└── protobuf.pc
3.2 Fdbus编译
3.2.1 创建/修改编译脚本 //在fdbus根目录
build_qnx.sh 文件内容如下:
#!/bin/sh
###################################
#### build script for protobuf
#### taget:qnx
#### Date: 2022-11-01
#### Author: 村里小码农
###################################
PREFIX=$CURRENT_PATH/build/install
mkdir -p $PREFIX
cd build/
echo "---------------------------"
echo " > start to build fdbus."
echo "---------------------------"
cmake -DCMAKE_INSTALL_PREFIX=install \
-DSYSTEM_ROOT=../../protobuf-3.20.2/out/qnx/ \
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain.cmake \
-Dfdbus_SOCKET_ENABLE_PEERCRED=OFF \
-Dfdbus_PIPE_AS_EVENTFD=true \
-Dfdbus_QNX_KEEPALIVE=ON \
-Dfdbus_SOCKET_QNX_PEERCRED=ON \
-Dfdbus_LINK_SOCKET_LIB=ON \
-Dfdbus_LINK_PTHREAD_LIB=OFF \
../cmake/
make
make install
echo "---------------------------"
echo " > build finished."
echo "---------------------------"
cd ${CURRENT_PATH}
3.2.2 修改cmke 工具链
文件fdbus-v4.2.0/cmake/toolchain.cmake
SET(CMAKE_SYSTEM_NAME arm)
SET(QNXROOT_PATH /workspace/automotive_bsp/qnx_ap)
SET(QNX_PREBUILT ${QNXROOT_PATH}/qnx_bins/prebuilt_QNX700)
SET(CMAKE_CXX_COMPILER ${QNX_PREBUILT}/host/linux/x86_64/usr/bin/ntoaarch64-g++)
SET(CMAKE_C_COMPILER ${QNX_PREBUILT}/host/linux/x86_64/usr/bin/ntoaarch64-gcc)
运行:./build_qnx.sh
编译生成: // build/install目录
└── usr
├── bin
│ ├── fdbxclient
│ ├── fdbxserver
│ ├── host_server
│ ├── logsvc
│ ├── logviewer
│ ├── lsclt
│ ├── lsevt
│ ├── lshost
│ ├── lssvc
│ ├── name_server
│ └── ntfcenter
├── include
│ └── common_base
└── lib
├── libcommon_base.so
└── libfdbus-clib.so