前言:
大家购买RK3576核心板后,可以获取到相对应厂家提供的sdk源码。由于我们是直接获取瑞芯微的芯片的所以需要自己获取sdk代码。发起电脑设置32G大概以上的运行内存,1T以上的存储,Ubuntu版本最好选择在18.04以上能减少很多未知bug。
sdk获取(没redmine账号的请略过)
瑞芯微技术窗口通常会提供对应版本的SDK初始压缩包。以
Rockchip_Android14.0_SDK_RELEASE.tar.gz.*`为例,拷贝到该初始化包后,通过如下命令可检出源码:
mkdir RK3576_Android14.0_SDK_RELEASE cat RK3576_Android14.0_SDK_RELEASE.tar.gz* | tar -zx -C RK3576_Android14.0_SDK_RELEASE cd RK3576_Android14.0_SDK_RELEASE .repo/repo/repo sync -l .repo/repo/repo sync -c
获取源码后最好是搭建自己的repo代码服务器,这样能防止出现修改错误后能自己还原代码。同时也可以做版本管理,在此就不睁开了。
sdk编译
一键编译代码
请注意利用一键编译命令之前需要设置环境变量,选择好自己需要编译的平台,举例:
- source build/envsetup.sh
- lunch rk3576_u-userdebug
- ./build.sh -UKAup
- ( WHERE: -U = build uboot
- -C = build kernel with Clang
- -K = build kernel
- -A = build android
- -p = will build packaging in IMAGE
- -o = build OTA package
- -u = build update.img
- -v = build android with 'user' or 'userdebug'
- -d = huild kernel dts name
- -V = build version
- -J = build jobs
- ------------大家可以按需使用,不用记录uboot/kernel编译命令了------------------
- )
复制代码 同时为了办理编译时每次都得输入多个命令发起新建一个run.sh执行文件这样每次只要运行执行文件就能编译。
- 例如:# !/bin/sh
- source build/envsetup.sh
- lunch rk3576_u-userdebug
- ./build.sh -UCKAup
复制代码 为了办理编译慢问题可以在build.sh中做一些修改减少每次编译的时间都做了make clean
修改如下:
- # build uboot
- if [ "$BUILD_UBOOT" = true ] ; then
- echo "start build uboot: $UBOOT_DEFCONFIG"
- - cd u-boot && make clean && make mrproper && make distclean && make $UBOOT_DEFCONFIG && ./make.sh && cd -
- + cd u-boot && make mrproper && make distclean && make $UBOOT_DEFCONFIG && ./make.sh && cd -
- # build kernel
- if [ "$BUILD_KERNEL" = true ] ; then
- echo "Start build kernel"
- - cd $LOCAL_KERNEL_PATH && make clean && make $ADDON_ARGS ARCH=$KERNEL_ARCH $KERNEL_DEFCONFIG && make $ADDON_ARGS ARCH=$KERNEL_ARCH $KERNEL_DTS.img -j$BUILD_JOBS && cd -
- + cd $LOCAL_KERNEL_PATH && make $ADDON_ARGS ARCH=$KERNEL_ARCH $KERNEL_DEFCONFIG && make $ADDON_ARGS ARCH=$KERNEL_ARCH $KERNEL_DTS.img -j$BUILD_JOBS && cd -
- if [ $? -eq 0 ]; then
- # build android
- if [ "$BUILD_ANDROID" = true ] ; then
- # build OTA
- if [ "$BUILD_OTA" = true ] ; then
- INTERNAL_OTA_PACKAGE_OBJ_TARGET=obj/PACKAGING/target_files_intermediates/$TARGET_PRODUCT-target_files-*.zip
- INTERNAL_OTA_PACKAGE_TARGET=$TARGET_PRODUCT-ota-*.zip
- if [ "$BUILD_AB_IMAGE" = true ] ; then
- echo "make ab image and generate ota package"
- - make installclean
- make -j$BUILD_JOBS
复制代码 常见问题处理方法
编译步伐是出现错误
1:权限问题:
[W][2024-11-08T17:48:39-0800][114753] logParams():267 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2024-11-08T17:48:39-0800][114753] logParams():277 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
[W][2024-11-08T17:48:40-0800][114771] logParams():267 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2024-11-08T17:48:40-0800][114771] logParams():277 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
步伐不要用root权限编译,应该要用平凡用户权限去编译,办理办法就是先ls -all 看看权限问题将root权限的文件先改成平凡权限
- sudo chown user:user file_root/ -R
复制代码 2:比力常见的问题就是编译的时间出现了VNDK的兼容性问题,修改Android接口也会出现这种问题哈。在此记载下
下面以libcrypto.os为例,也是我遇到的问题,错误提示如下
FAILED: out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_arm64_armv8-a_shared/libcrypto.so.abidiff
(prebuilts/clang-tools/linux-x86/bin/header-abi-diff -target-version current -allow-unreferenced-changes -allow-unreferenced-elf-symbol-changes -lib libcrypto -arch arm64 -o out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_arm64_armv8-a_shared/libcrypto.so.abidiff -new out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_arm64_armv8-a_shared/libcrypto.so.lsdump -old prebuilts/abi-dumps/vndk/34/64/arm64/source-based/libcrypto.so.lsdump)|| (echo ‘error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto’ && (mkdir -p $DIST_DIR/abidiffs && cp out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_arm64_armv8-a_shared/libcrypto.so.abidiff $DIST_DIR/abidiffs/) && exit 1)
error: libcrypto’s ABI has EXTENDING CHANGES. Please check compatibility report at: out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_arm_armv8-a_shared/libcrypto.so.abidiff
error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto
办理方案如下:
根据上下文的意思就是先执行
- ./development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto
复制代码 会提示ANDROID_BUILD_TOP
这时我们先执行
- source build/envsetup.sh
- lunch rk3576_u-userdebug
- ./development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto
复制代码 编译又出现问题了
subprocess.CalledProcessError: Command ‘[‘build/soong/soong_ui.bash’,
‘–make-mode’, ‘-j’, ‘TARGET_PRODUCT=aosp_arm’,
‘TARGET_BUILD_VARIANT=userdebug’,
‘out/target/product/generic/lsdump_paths.txt’]’ returned non-zero exit
status 1.
看到making libs for product: aosp_arm_ab这行,这个是由于我的项目product名字不一样导致的,加上参数-product product_name即可,product_name是你的项目标product名称。
- ./development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto
- -product product_name
复制代码 product_name这个名称在你执行lunch的时间会表现出来,加粗的地方就是你的product
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=14
PRODUCT_INCLUDE_TAGS=com.android.mainline
TARGET_PRODUCT=rk3576_u
TARGET_BUILD_VARIANT=userdebug
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
HOST_CROSS_OS=windows
BUILD_ID=UQ1A.240205.004.B1
OUT_DIR=out
============================================
到此就是漫长的编译等候。编译完成后再执行我们上述的run.sh一键编译啦。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |