当前位置:   article > 正文

RK3399linux交叉编辑器下载,rk3399 源码下查找交叉编译工具链

can't find toolchain for unknown architecture

小伙伴突然问到 android 下交叉编译链在哪个位置,一脸发懵,所以记录一下

平台

Android版本

内核版本

rk3399

android 7.1

4.4

kernel 和android 的编译时分为两部分 所以我们需要分为两份查看

kernel

rk的编译命令基本是:

cd kernel/

make ARCH=arm64 rockchip_defconfig

make ARCH=arm64 rk3399-box-rev2.img -j

2.所以我们从kernel的Makefile入手即可

VERSION = 4 #kernel版本号

PATCHLEVEL = 4

SUBLEVEL = 103

EXTRAVERSION =

...

ifeq ($(ARCH),arm64)

ifneq ($(wildcard $(srctree)/../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9),)

CROSS_COMPILE ?= $(srctree)/../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

endif

endif

ifeq ($(ARCH),arm)

ifneq ($(wildcard $(srctree)/../prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9),)

CROSS_COMPILE ?= $(srctree)/../prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-

endif

endif

即kerenel的交叉编译链在 prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

Android

1.android 也是使用Makefile编译的,但里面改的太多,所以不从这儿入手。

在android 编译模块时我们通常

source build/envsetup.sh

lunch 22

mmm 模块

2.所以从build/envsetup.sh入手

...

function setpaths()

{

....

# and in with the new

prebuiltdir=$(getprebuilt)

gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)

# defined in core/config.mk

targetgccversion=$(get_build_var TARGET_GCC_VERSION)

targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION)

export TARGET_GCC_VERSION=$targetgccversion

# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.

export ANDROID_TOOLCHAIN=

export ANDROID_TOOLCHAIN_2ND_ARCH=

local ARCH=$(get_build_var TARGET_ARCH)

case $ARCH in

x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin

;;

x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin

;;

arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin

;;

arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin;

toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin

;;

mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin

;;

*)

echo "Can't find toolchain for unknown architecture: $ARCH"

toolchaindir=xxxxxxxxx

;;

esac

if [ -d "$gccprebuiltdir/$toolchaindir" ]; then

export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir

fi

...

}

...

所以Android的交叉编译链在$gccprebuiltdir/$toolchaindir 也就是 prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-$targetgccversion/bin

其中的$gccprebuiltdir和$targetgccversion 的变量可以从上下文赋值得到

或者在命令行使用命令得到:

~/RK3399_7.1$ get_build_var TARGET_GCC_VERSION

4.9

~/RK3399_7.1$ get_build_var ANDROID_GCC_PREBUILTS

prebuilts/gcc/linux-x86

由上面可以看到ANDROID_TOOLCHAIN也就是android toolchain的位置

使用命令行也可以直接得到

~/RK3399_7.1$get_build_var ANDROID_TOOLCHAIN

/***/RK3399_7.1/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin

~/RK3399_7.1$

查看Android编译环境变量 多使用 get_build_var get_abs_build_var

下面时命令实现

105 # Get the exact value of a build variable.

106 function get_build_var()

107 {

108 if [ "$BUILD_VAR_CACHE_READY" = "true" ]

109 then

110 eval echo \"\${var_cache_$1}\"

111 return

112 fi

113

114 T=$(gettop)

115 if [ ! "$T" ]; then

116 echo "Couldn't locate the top of the tree. Try setting TOP." >&2

117 return

118 fi

119 (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \

120 command make --no-print-directory -f build/core/config.mk dumpvar-$1)

121 }

标签:bin,x86,aarch64,linux,查找,build,rk3399,android,源码

来源: https://www.cnblogs.com/rootshaw/p/12938167.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/577029
推荐阅读
相关标签
  

闽ICP备14008679号