xref: /rk3399_rockchip-uboot/make.sh (revision 82198b5ccd31ca903c84f3d16e015ca704af852c)
1#!/bin/sh
2BOARD=$1
3DIR=${BOARD#*-}
4DSTDIR=rockdev/${DIR}
5TOOLCHAIN=arm-linux-gnueabi-
6JOB=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
7
8select_toolchain()
9{
10	local dst path
11	if grep  -q '^CONFIG_ARM64=y' ${DSTDIR}/out/.config ; then
12        	TOOLCHAIN=aarch64-linux-gnu-
13		dst=../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
14		if [ -d ${dst} ]; then
15			path=$(cd `dirname ${dst}`; pwd)
16			TOOLCHAIN=${path}/bin/aarch64-linux-android-
17		fi
18	else
19		dst=../prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin
20		if [ -d ${dst} ]; then
21			path=$(cd `dirname ${dst}`; pwd)
22			TOOLCHAIN=${path}/bin/arm-linux-androideabi-
23		fi
24	fi
25	echo toolchain: ${TOOLCHAIN}
26}
27
28pack_images()
29{
30	local sys_text_base dst
31
32	dst=../rkbin/tools
33	if [ -d ${dst} ]; then
34		path=$(cd `dirname ${dst}`; pwd)
35	else
36		echo "Can't find '../rkbin/' or '../rkbin/tools/' Responsity, please download it before pack image!"
37		exit 1
38	fi
39
40	sys_text_base=`sed -n "/CONFIG_SYS_TEXT_BASE=/s/CONFIG_SYS_TEXT_BASE=//p" ${DSTDIR}/out/include/autoconf.mk|tr -d '\r'`
41	echo U-Boot entry point address: ${sys_text_base}
42	${path}/tools/loaderimage --pack --uboot ${DSTDIR}/out/u-boot.bin uboot.img ${sys_text_base}
43}
44
45echo "make for ${BOARD}_defconfig by -j${JOB}"
46make ${BOARD}_defconfig O=${DSTDIR}/out
47select_toolchain
48make CROSS_COMPILE=${TOOLCHAIN}  all --jobs=${JOB} O=${DSTDIR}/out
49pack_images
50