1. 添加文件

待添加的文件我放到了文章的最后
板子是rk356的,系统是安卓11版本的

  • 首先将can-utils文件夹添加到device/rockchip/rk356x/rk66_tms(这里根据你个人的项目来确定,这里是我copy的一个工程目录用的是,拷贝的是rk3566_r然后进行添加自己的工程的)下
  • 你可以在在源码顶层目录下进行source、lunch后再进入到can-utils使用mm命令进行单独编译。
  • 编译好后会在源码顶层目录out/target/product/rk66_tms/system/bin/下生成can-utils目录下Android.mk文件指定生成的命令,这里以candump为例子:
#
# candump
#

include $(CLEAR_VARS)

LOCAL_SRC_FILES := candump.c
LOCAL_MODULE := candump
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_LIBRARIES := libcan
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
LOCAL_CFLAGS := $(PRIVATE_LOCAL_CFLAGS)

include $(BUILD_EXECUTABLE)

这里的LOCAL_MODULE就是指定生成的MODULE,编译后就被拷贝到源码顶层目录out/target/product/rk66_tms/system/bin/下面。然后可以通过adb push命令将命令push到启动后的板子上,然后就可以在adb shell终端上使用该命令了

adb push candump /system/bin/
  • 如果需要在编译源码的时候就把编好的MODULE放在system/bin/下,可以修改device/rockchip/rk356x/rk66_tms下的rk66_tms.mk(这个文件也是在添加工程时复制后更改名字了的,它会被device/rockchip/rk356x下的AndroidProducts.mk包含),关于AndroidProducts.mk包含rk66_tms.mk如下:
#
# Copyright 2014 The Android Open-Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.A
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

PRODUCT_MAKEFILES := \
        $(LOCAL_DIR)/rk3566_rgo/rk3566_rgo.mk \
	...
	$(LOCAL_DIR)/rk66_tms/rk66_tms.mk

COMMON_LUNCH_CHOICES := \
    rk3566_32bit-userdebug \
    rk3566_32bit-user \
    ...
	rk66_tms-userdebug \
    rk66_tms-user

rk66_tms.mk添加MODULE放在system/bin/的修改如下:

  PRODUCT_PACKAGES += canplayer \
                      candump \
                      cansend   

这上面的candump和cansend都是can-utils目录下的Android.mk文件中LOCAL_MODULE指定的,添加修改并编译后将镜像烧录到板子上就可以使用这些命令了.

文件:can收发工具

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐