-
Notifications
You must be signed in to change notification settings - Fork 3
/
sunxi_env.sh
186 lines (145 loc) · 4.26 KB
/
sunxi_env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
export BUILD_TRUNK=$(pwd)
export BUILD_TRUNK_OUT=$BUILD_TRUNK/out
# envs for sunxi tools
export SUNXI_TOOLS_PATH=$(pwd)/loftq-build
export SUNXI_LINUX_PATH=$(pwd)/loftq-linux
export SUNXI_UBOOT_PATH=$(pwd)/loftq-uboot
export SUNXI_UBOOT_NEXT_PATH=$(pwd)/loftq-uboot-next
export SUNXI_TOOLCHAIN_PATH=${SUNXI_TOOLS_PATH}/toolschain/gcc-linaro/bin
export SUNXI_TOOLS_BIN_PATH=$SUNXI_TOOLS_PATH/pack/pctools/linux:$SUNXI_TOOLS_PATH/pack/pctools/linux/android
# envs for android
#export ANDROID_TRUNK=$(pwd)/ubuntu-phablet
export ANDROID_TRUNK=$(pwd)/android
export ANDROID_DEVICE=mars-loftq
export ANDROID_DEVICE_TRUNK=${ANDROID_TRUNK}/device/softwinner/${ANDROID_DEVICE}
# envs for ubuntu touch
# only used if we have android base sdk released by ubuntu touch team
# Note: now we can build this image but can't burn it to disk with PhoenixTool
export UBUNTU_OUTPUT=$BUILD_TRUNK_OUT/ubuntu
export UBUNTU_TARBALL=$UBUNTU_OUTPUT/vivid-preinstalled-touch-armhf.tar.gz
# commom env
export ANDROID_OUT=${ANDROID_TRUNK}/out
export ANDROID_DEVICE_OUT=${ANDROID_OUT}/target/product/${ANDROID_DEVICE}
export LINARO_GCC_PATH=$SUNXI_TOOLCHAIN_PATH
export PATH=$PATH:$LINARO_GCC_PATH:$SUNXI_TOOLS_BIN_PATH
export LANG=C
export LC_ALL=C
function check_toolchain()
{
if [ -d $SUNXI_TOOLCHAIN_PATH ]; then
echo "sunxi toolchain exists: $SUNXI_TOOLCHAIN_PATH"
else
tar -C $SUNXI_TOOLS_PATH/toolschain -xf $SUNXI_TOOLS_PATH/toolschain/gcc-linaro.tar.bz2
echo "extract sunxi toolchain: $SUNXI_TOOLCHAIN_PATH"
fi
}
function linux_build_uboot()
{
cd $SUNXI_UBOOT_PATH
make distclean
make sun6i_config
make -j4
cd -
}
function linux_build_uboot_next()
{
cd $SUNXI_UBOOT_NEXT_PATH
make distclean
make CROSS_COMPILE=arm-linux-gnueabi- mixtile_loftq_defconfig
make CROSS_COMPILE=arm-linux-gnueabi- -j4
cd -
}
function linux_build_kernel()
{
cd $SUNXI_LINUX_PATH
./build.sh -p sun6i
cd -
}
function linux_pack()
{
LINUX_PACK_OUT=$BUILD_TRUNK/out/linux
echo "Generating linux out directory!"
mkdir -p $LINUX_PACK_OUT
echo "Copying uboot!"
cp $SUNXI_UBOOT_PATH/u-boot.bin $LINUX_PACK_OUT
cp $SUNXI_UBOOT_PATH/u-boot-sun6i.bin $SUNXI_TOOLS_PATH/pack/chips/sun6i/bin/
echo "Copying linux kernel and modules!"
cp $SUNXI_LINUX_PATH/output/*Image $LINUX_PACK_OUT
cp $SUNXI_LINUX_PATH/output/boot.img $LINUX_PACK_OUT
cp -r $SUNXI_LINUX_PATH/output/lib $LINUX_PACK_OUT
echo "Packing final image!"
$SUNXI_TOOLS_PATH/scripts/build_pack.sh
}
function android_build_uboot()
{
CURDIR=$PWD
cd $SUNXI_UBOOT_PATH
make distclean
make sun6i_config
make -j4
cd $CURDIR
}
function android_build_kernel()
{
CURDIR=$PWD
cd $SUNXI_LINUX_PATH
./build.sh -p sun6i_fiber
cd -
}
function android_extract_bsp()
{
LINUXOUT_DIR=$SUNXI_LINUX_PATH/output
LINUXOUT_MODULE_DIR=$LINUXOUT_DIR/lib/modules/*/*
CURDIR=$PWD
cd $ANDROID_DEVICE_TRUNK
#copy uboot to referring directory
cp $SUNXI_UBOOT_PATH/u-boot-sun6i.bin $SUNXI_TOOLS_PATH/pack/chips/sun6i/bin/u-boot-sun6i.bin
#extract kernel
if [ -f kernel ]; then
rm kernel
fi
cp $LINUXOUT_DIR/bImage kernel
echo "$ANDROID_DEVICE_TRUNK/bImage copied!"
#extract linux modules
if [ -d modules ]; then
rm -rf modules
fi
mkdir -p modules/modules
cp -rf $LINUXOUT_MODULE_DIR modules/modules
echo "$ANDROID_DEVICE_TRUNK/modules copied!"
chmod 0755 modules/modules/*
# create modules.mk
(cat << EOF) > ./modules/modules.mk
# modules.mk generate by extract-files.sh , do not edit it !!!!
PRODUCT_COPY_FILES += \\
\$(call find-copy-subdir-files,*,\$(LOCAL_PATH)/modules,system/vendor/modules)
EOF
cd -
}
function android_pack()
{
export CRANE_IMAGE_OUT=$ANDROID_DEVICE_OUT
export PACKAGE=$SUNXI_TOOLS_PATH/pack
cd $PACKAGE
DEBUG="uart0"
SIGMODE="none"
if [ "$1" = "-d" -o "$2" = "-d" ]; then
echo "--------debug version, have uart printf-------------"
DEBUG="card0";
else
echo "--------release version, donnot have uart printf-------------"
fi
if [ "$1" = "-s" -o "$2" = "-s" ]; then
echo "-------------------sig version-------------------"
SIGMODE="sig";
fi
./pack -c sun6i -p android -b $ANDROID_DEVICE -d ${DEBUG} -s ${SIGMODE}
cd -
}
function android_to_ubuntu()
{
ANDROID_IMG=$ANDROID_DEVICE_OUT/system.img
TOUCH_TARBALL=$UBUNTU_TARBALL
sudo $SUNXI_TOOLS_PATH/utouch_mkimg.sh $TOUCH_TARBALL $ANDROID_IMG
}
check_toolchain