第一篇:rk1808编译buildroot,增加ros支持问题

4 篇文章 0 订阅
4 篇文章 0 订阅

突然心血来潮,想在rk1808中跑ros,当前 rk1808跑的是buildroot编译的精简linux系统,也不想换debian9,就开始痛苦的过程…………

在rockchip_rk1808_defconfig文件中增加ros_kinetic.config(这个是按照官方的rk3399编译ros时一样的操作),然后就会遇到经典的问题:

error: option --single-version-externally-managed not recognized

很坑的问题,我卡在这两三天,网上说是安装setuptools,wheel什么的,都没啥用,这个问题是python-empy-3.3.3,在配置时使用setuptools进行安装,但是这个版本的setup.py文件,是使用distutils来安装的,所以要在配置文件python-empy.mk中修改安装方式:

################################################################################
#
# python-empy
#
################################################################################

PYTHON_EMPY_VERSION = 3.3.3
PYTHON_EMPY_SITE = http://www.alcyone.com/software/empy
PYTHON_EMPY_SOURCE = empy-$(PYTHON_EMPY_VERSION).tar.gz
PYTHON_EMPY_LICENSE = LGPL-3.0
PYTHON_EMPY_LICENSE_FILES = LICENSE.txt
#PYTHON_EMPY_SETUP_TYPE = setuptools

PYTHON_EMPY_SETUP_TYPE = distutils
$(eval $(host-python-package))

编译过程中,遇到tinyxml2问题:

[module] calib_xml
In file included from calibdb.cpp:26:0:
/files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/build/camera_engine_rkisp-1.0/rkisp/ia-engine/calib_xml/../include/calib_xml/calibdb.h:21:22: fatal error: tinyxml2.h: No such file or directory
 #include <tinyxml2.h>

提示找不到tinyxml2.h头文件,是由于IS_NEED_COMPILE_TINYXML2为false,不编译tinyxml2组件导致,查找:camera_engine_rkisp.mk文件,

ifeq ($(BR2_PACKAGE_TINYXML2),y)
CAMERA_ENGINE_RKISP_CONF_OPTS = \
                        IS_NEED_COMPILE_TINYXML2=false
endif

改成:

ifeq ($(BR2_PACKAGE_TINYXML2),y)
CAMERA_ENGINE_RKISP_CONF_OPTS = \
                        IS_NEED_COMPILE_TINYXML2=true
endif

pyparsing问题,提示如下:

ImportError: "from catkin_pkg.package import parse_package" failed: No module named pyparsing!
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
CMake Error at cmake/safe_execute_process.cmake:11 (message):

原因是没有安装pyparsing组件至host,解决方式是把pyparsing安装到host即可,修改的地方如下:

1.在package/python-pyparsing/中增加Config.in.host,文件内容为(我复制catkin_pkg的文件内容然后 修改的):

config BR2_PACKAGE_HOST_PYTHON_PYPARSING
	bool "pyparsing host tool for ROS"
    depends on BR2_PACKAGE_PYTHON_ROS_SET
	select BR2_PACKAGE_HOST_PYTHON_CATKIN_PKG
	help
		A CMake-based build system that is used to build all packages in ROS

2.在 python-pyparsing.mk文件中增加:

$(eval $(host-python-package))

3.添加至列表文件Config.in.host,这个文件在buildroot/package/里,添加最后一行:

source "package/python-pyparsing/Config.in.host"

4.在package/rockchip/ros/catkin/文件夹,修改Config.in.host文件:

config BR2_PACKAGE_HOST_CATKIN
	bool "catkin host tool for ROS"
    depends on BR2_PACKAGE_PYTHON_ROS_SET
	select BR2_PACKAGE_HOST_PYTHON_CATKIN_PKG
	select BR2_PACKAGE_HOST_PYTHON_PYPARSING
	select BR2_PACKAGE_HOST_PYTHON_EM
	select BR2_PACKAGE_HOST_PYTHON_EMPY
	help
		A CMake-based build system that is used to build all packages in ROS

增加依赖:select BR2_PACKAGE_HOST_PYTHON_PYPARSING,当然,要的config/ros_kinetic.config里增加BR2_PACKAGE_HOST_PYTHON_PYPARSING=y

再build.sh就可以通过了。

catkin安装位置问题,catkin安装时,是直接安装到host/opt/ros中的,正确的应该是host/aarch……/sysroot/opt/ros中,修改catkin.mk:

#HOST_CATKIN_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)$(CATKIN_ROS_DIR)
HOST_CATKIN_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(STAGING_DIR)$(CATKIN_ROS_DIR)

em问题,提示如下:

output/rockchip_rk1808/host/bin/python: can't find '__main__' module in '/files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/host/lib/python2.7/site-packages/em'
CMake Error at cmake/safe_execute_process.cmake:11 (message):

原因是由于执行了em文件夹,没有执行对应的em.py文件,临时处理方式:

查找文件:empy.cmake,修改37行为:


  #set(EMPY_SCRIPT "${EMPY_SCRIPT}" CACHE STRING "Empy script" FORCE)
  set(EMPY_SCRIPT "${EMPY_SCRIPT}.py" CACHE STRING "Empy script" FORCE)

强制增加文件名,编译通过。

然后 ,错误又来了:

CMake Error at /files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/host/aarch64-buildroot-linux-gnu/sysroot/opt/ros/kinetic/share/cpp_common/cmake/cpp_commonConfig.cmake:148 (message):
  Project 'rostime' tried to find library '-lpthread'.  The library is
  neither a target nor built/installed properly.  Did you compile project
  'cpp_common'? Did you find_package() it before the subdirectory containing
  its code is included?
Call Stack (most recent call first):
  /files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/host/aarch64-buildroot-linux-gnu/sysroot/opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:4 (find_package)

此类的错误,是由于cmake文件里使用find_package(catkin …… cpp_common)这样的字样,(两天后新发现,这个问题是cpp_commonConfig.cmake里的错误,找到:set(libraries "cpp_common;,里面应该 有个-l-lpthread的内容,把这里替换成libpthread.so所在的绝对路径,就OK了!),后面在class_loader里出现这个错误:

CMake Error at devel/share/class_loader/cmake/class_loaderConfig.cmake:148 (message):
  Project 'class_loader' tried to find library '-lpthread'.  The library is
  neither a target nor built/installed properly.  Did you compile project
  'class_loader'? Did you find_package() it before the subdirectory
  containing its code is included?

这里的class_loaderConfig.cmake为编译时自动生成,没办法修改后再编译(修改后编译时会重新生成),输出调试信息,发现是boost_libraries这个变量里包含了"-lpthread",现在就是想办法把boost中的“-lpthread"修改成"pthread"(因为cpp_common之类的库中都引用了boost,可能之前的这个问题就是由于boost引起的),但是boost没有 Config.cmake类的文件,然后就卡在这里……,晚上12点,找到FindBoost.cmake了,这个文件其实在本机/usr/local/share/cmake-{version}/Modules/里,对应的代码:

# Report Boost_LIBRARIES
set(Boost_LIBRARIES "")
foreach(_comp IN LISTS Boost_FIND_COMPONENTS)
  string(TOUPPER ${_comp} _uppercomp)
  if(Boost_${_uppercomp}_FOUND)
    list(APPEND Boost_LIBRARIES ${Boost_${_uppercomp}_LIBRARY})
    if(_comp STREQUAL "thread")
      list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
    endif()
  endif()
endforeach()

看到这个if了不:

if(_comp STREQUAL "thread")
      list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
    endif()

在外部输出:CMAKE_THREAD_LIBS_INIT,值就是-lpthread。

来个粗暴的操作:

# Report Boost_LIBRARIES
set(Boost_LIBRARIES "")
foreach(_comp IN LISTS Boost_FIND_COMPONENTS)
  string(TOUPPER ${_comp} _uppercomp)
  if(Boost_${_uppercomp}_FOUND)
    list(APPEND Boost_LIBRARIES ${Boost_${_uppercomp}_LIBRARY})
    if(_comp STREQUAL "thread")
#      list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
      list(APPEND Boost_LIBRARIES "pthread")
    endif()
  endif()
endforeach()

编译通过……(这个问题应该是搞了三天,好久没这么苦逼了……)

ps:这个Boost的版本是1.66.0的,不知道是不是个bug,白天到公司,看了一下环境,cmake-3.10中的FindBoost.cmake,对应的代码是正确的:

# ------------------------------------------------------------------------
#  Notification to end user about what was found
# ------------------------------------------------------------------------

set(Boost_LIBRARIES "")
if(Boost_FOUND)
  if(NOT Boost_FIND_QUIETLY)
    message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
    if(Boost_FIND_COMPONENTS)
      message(STATUS "Found the following Boost libraries:")
    endif()
  endif()
  foreach( COMPONENT  ${Boost_FIND_COMPONENTS} )
    string( TOUPPER ${COMPONENT} UPPERCOMPONENT )
    if( Boost_${UPPERCOMPONENT}_FOUND )
      if(NOT Boost_FIND_QUIETLY)
        message (STATUS "  ${COMPONENT}")
      endif()
      list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY})
    endif()
  endforeach()

还有错,编译 std-msgs时,提示错误:

    interpreter = em.Interpreter(output=ofile, globals=g, options={em.RAW_OPT:True,em.BUFFERED_OPT:True})
AttributeError: 'module' object has no attribute 'Interpreter'

这个时候,到host/lib/python2.7/site-packages/下删除em相关的文件夹和egg.info,这里注意,em.py和em.pyc两个文件不要删除。如果这里还有问题,那就是可能 empy并没有安装成功,因为cat empy-3.3.3-py2.7.egg-info时,内容是错误的,是因为emlib.py不存在,要把setup.py中的emlib删除掉。再压缩成empy-3.3.3.tar.gz,./build.sh,然后 就是重新解压……安装。这样操作后,这个egg-info里就是正常的内容了。

好了,之前修改empy.cmake的后遗症来了,编译actionlib-msgs时出错:

  /files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/host/aarch64-buildroot-linux-gnu/sysroot/opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:5 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PY_em: /files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/host/usr/lib/python2.7/site-packages/em.pyc  
-- Using empy: /files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/host/usr/lib/python2.7/site-packages/em.pyc.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /files/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub/buildroot/output/rockchip_rk1808/build/actionlib-msgs-1.11.9/actionlib_msgs/test_results
-- Found gtest: gtests will be built
-- Using Python nosetests: /home/cubar/anaconda3/bin/nosetests
-- catkin 0.7.14
CMake Error at CMakeLists.txt:8 (add_message_files):
  Unknown CMake command "add_message_files".


-- Configuring incomplete, errors occurred!

Using empy这里,多了.py,得到

sysroot/opt/ros/kinetic/share/catkin/cmake

里把empy.cmake改回来。

Image: image in rockdev is ready 
Make image ok!
Make update.img
start to make update.img...
Android Firmware Package Tool v1.65
------ PACKAGE ------
Add file: ./package-file
Add file: ./Image/MiniLoaderAll.bin
Add file: ./Image/parameter.txt
Add file: ./Image/trust.img
Add file: ./Image/uboot.img
Add file: ./Image/misc.img
Add file: ./Image/boot.img
Add file: ./Image/recovery.img
Add file: ./Image/rootfs.img
Add file: ./Image/oem.img
Add file: ./Image/userdata.img
Add CRC...
Make firmware OK!
------ OK ------
********RKImageMaker ver 1.66********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
Making update.img OK.
/tools/rk1808-tb-96aiot-sdk-codes20200605/rk1808gitgithub
Make update image ok!

终于搞定,花了大概一个星期的时间,后面就是刷机,写ROS程序的事了。

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
RK3588S是瑞芯微推出的一款高性能、低功耗的处理器芯片,适用于嵌入式系统和物联网设备。Buildroot是一个开源的嵌入式Linux系统构建工具,可以帮助用户快速构建定制化的Linux系统。 要进行RK3588S的Buildroot编译,可以按照以下步骤进行操作: 1. 下载Buildroot源码:首先需要从Buildroot官方网站(https://buildroot.org/)下载最新版本的Buildroot源码包。 2. 配置Buildroot:解压下载的源码包后,进入解压后的目录,在终端中运行`make menuconfig`命令,进入配置界面。 3. 选择目标平台:在配置界面中,选择`Target options`,然后选择`Target Architecture`,找到并选择`ARM (little endian)`作为目标平台。 4. 配置目标设备:在配置界面中,选择`Target options`,然后选择`Target options`,根据实际情况选择RK3588S所在的开发板型号。 5. 配置文件系统:在配置界面中,选择`Filesystem images`,然后选择`tar the root filesystem`,选择所需的文件系统格式和压缩方式。 6. 配置内核:在配置界面中,选择`Kernel`,然后选择`Kernel version`,输入所需的内核版本号。可以选择使用已有的内核配置文件或者手动配置内核选项。 7. 配置软件包:在配置界面中,选择`Target packages`,可以选择需要的软件包和工具链。 8. 保存配置并退出:完成配置后,选择`Save`保存配置,然后选择`Exit`退出配置界面。 9. 开始编译:在终端中运行`make`命令,开始进行编译编译过程可能需要一段时间,取决于系统配置和计算机性能。 10. 获取编译结果:编译完成后,在Buildroot源码目录下的`output/images`目录中可以找到生成的镜像文件和根文件系统。 以上是RK3588S的Buildroot编译的基本步骤,具体的配置和操作可能会因实际需求和环境而有所不同。建议在进行编译前,详细阅读Buildroot的文档和相关资料,以确保正确配置和操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值