Add toolchain setup with README and kernel-path argument
- setup.sh: ./setup.sh <kernel-repo-path>, unpacks to <kernel-parent>/toolchain/ - README.md: install + build instructions - clang-11.0.1 (AOSP 6443078) + binutils-2.27
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
# EEBBK S6 Kernel Toolchain
|
||||||
|
|
||||||
|
Build toolchain for the EEBBK S6 (SM7150 / sdmmagpie) Android kernel.
|
||||||
|
|
||||||
|
Contains:
|
||||||
|
- **clang-11.0.1** (AOSP prebuilt 6443078) — matches stock firmware compiler
|
||||||
|
- **binutils-2.27** (GNU) — matches stock firmware assembler/linker
|
||||||
|
|
||||||
|
The kernel source is in a separate repository:
|
||||||
|
`android_kernel_eebbk_sm6150` (CAF LA.UM.9.1.c25, kernel 4.14.190).
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone <this-repo> # e.g. android_kernel_toolchain
|
||||||
|
cd android_kernel_toolchain
|
||||||
|
./setup.sh <kernel-repo-path>
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone http://<host>:3003/huang1057/android_kernel_toolchain.git
|
||||||
|
git clone http://<host>:3003/huang1057/android_kernel_eebbk_sm6150.git
|
||||||
|
|
||||||
|
cd android_kernel_toolchain
|
||||||
|
./setup.sh ../android_kernel_eebbk_sm6150
|
||||||
|
```
|
||||||
|
|
||||||
|
This unpacks `clang` and `binutils` into `<kernel-repo-parent>/toolchain/`:
|
||||||
|
|
||||||
|
```
|
||||||
|
<parent>/
|
||||||
|
├── android_kernel_eebbk_sm6150/ <- kernel source
|
||||||
|
└── toolchain/
|
||||||
|
├── android_prebuilts_clang_host_linux-x86_clang-6443078-10.0/
|
||||||
|
└── binutils-2.27-install/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build the kernel
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd android_kernel_eebbk_sm6150
|
||||||
|
|
||||||
|
export TC=../toolchain
|
||||||
|
export ARCH=arm64
|
||||||
|
export CROSS_COMPILE=$TC/binutils-2.27-install/bin/aarch64-linux-gnu-
|
||||||
|
export CLANG=$TC/android_prebuilts_clang_host_linux-x86_clang-6443078-10.0
|
||||||
|
export PATH=$CLANG/bin:$PATH
|
||||||
|
export LOCALVERSION=-perf
|
||||||
|
|
||||||
|
make vendor/sdmsteppe-perf_defconfig
|
||||||
|
|
||||||
|
make -j$(nproc) \
|
||||||
|
CC="python3 ./scripts/gcc-wrapper.py $CLANG/bin/aarch64-linux-gnu-clang" \
|
||||||
|
HOSTCC=gcc HOSTCXX=g++
|
||||||
|
|
||||||
|
gzip -n -9 -c arch/arm64/boot/Image > Image.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
- `arch/arm64/boot/Image` — uncompressed kernel
|
||||||
|
- `Image.gz` — compressed kernel (for boot.img packing)
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- `LOCALVERSION=-perf` keeps the vermagic at `4.14.190-perf` (no trailing `+`),
|
||||||
|
required so stock vendor kernel modules load.
|
||||||
|
- Do NOT use `LLVM_IAS=1`. GNU binutils 2.27 `as` is required
|
||||||
|
(`-no-integrated-as` is handled by the toolchain).
|
||||||
|
- Requires Python 3 (for `gcc-wrapper.py`), gcc (host), on Linux x86_64.
|
||||||
@@ -1,33 +1,47 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# setup.sh - 解压工具链到母项目 (android_kernel_eebbk_sm6150) 旁边
|
# setup.sh - 解压构建工具链到内核仓库
|
||||||
#
|
#
|
||||||
# 用法:
|
# 用法:
|
||||||
# git clone <toolchain-repo> # 克隆工具链仓库
|
# ./setup.sh <内核仓库路径>
|
||||||
# cd <toolchain-repo> # 进入
|
|
||||||
# ./setup.sh # 运行, 会把工具链放到母项目同级目录
|
|
||||||
#
|
#
|
||||||
# 最终目录结构:
|
# 例:
|
||||||
|
# git clone <toolchain-repo>
|
||||||
|
# cd <toolchain-repo>
|
||||||
|
# ./setup.sh ~/android_kernel_eebbk_sm6150
|
||||||
|
#
|
||||||
|
# 效果: 工具链解压到 <内核仓库路径>/../toolchain/ (与内核仓库同级)
|
||||||
# <parent>/
|
# <parent>/
|
||||||
# ├── android_kernel_eebbk_sm6150/ <- 内核源码
|
# ├── android_kernel_eebbk_sm6150/ <- 内核仓库
|
||||||
# └── toolchain/
|
# └── toolchain/
|
||||||
# ├── android_prebuilts_clang_host_linux-x86_clang-6443078-10.0/
|
# ├── android_prebuilts_clang_host_linux-x86_clang-6443078-10.0/
|
||||||
# └── binutils-2.27-install/
|
# └── binutils-2.27-install/
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
if [ $# -lt 1 ]; then
|
||||||
# 工具链仓库目录的上一级 = 母项目目录
|
echo "用法: ./setup.sh <内核仓库路径>"
|
||||||
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
|
echo "例: ./setup.sh ~/android_kernel_eebbk_sm6150"
|
||||||
TOOLCHAIN_DIR="$PARENT_DIR/toolchain"
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
KERNEL_DIR="$(cd "$1" && pwd)"
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
TOOLCHAIN_DIR="$(dirname "$KERNEL_DIR")/toolchain"
|
||||||
|
|
||||||
|
if [ ! -d "$KERNEL_DIR/Makefile" ] && [ ! -f "$KERNEL_DIR/Makefile" ]; then
|
||||||
|
echo "错误: $KERNEL_DIR 看起来不是内核源码目录 (没有 Makefile)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== 内核仓库: $KERNEL_DIR ==="
|
||||||
echo "=== 工具链安装到: $TOOLCHAIN_DIR ==="
|
echo "=== 工具链安装到: $TOOLCHAIN_DIR ==="
|
||||||
mkdir -p "$TOOLCHAIN_DIR"
|
mkdir -p "$TOOLCHAIN_DIR"
|
||||||
|
|
||||||
echo "=== 解压 binutils-2.27 ==="
|
echo "=== 解压 binutils-2.27 (39MB) ==="
|
||||||
tar -xzf "$SCRIPT_DIR/binutils-2.27-install.tar.gz" -C "$TOOLCHAIN_DIR"
|
tar -xzf "$SCRIPT_DIR/binutils-2.27-install.tar.gz" -C "$TOOLCHAIN_DIR"
|
||||||
echo "完成"
|
echo "完成"
|
||||||
|
|
||||||
echo "=== 解压 clang-11.0.1 (较大, 请稍候) ==="
|
echo "=== 解压 clang-11.0.1 (342MB, 请稍候) ==="
|
||||||
tar -xzf "$SCRIPT_DIR/clang-6443078.tar.gz" -C "$TOOLCHAIN_DIR"
|
tar -xzf "$SCRIPT_DIR/clang-6443078.tar.gz" -C "$TOOLCHAIN_DIR"
|
||||||
echo "完成"
|
echo "完成"
|
||||||
|
|
||||||
@@ -36,8 +50,14 @@ echo "=== 工具链就绪 ==="
|
|||||||
ls -d "$TOOLCHAIN_DIR"/android_prebuilts_clang_host_linux-x86_clang-6443078-10.0
|
ls -d "$TOOLCHAIN_DIR"/android_prebuilts_clang_host_linux-x86_clang-6443078-10.0
|
||||||
ls -d "$TOOLCHAIN_DIR"/binutils-2.27-install
|
ls -d "$TOOLCHAIN_DIR"/binutils-2.27-install
|
||||||
echo ""
|
echo ""
|
||||||
echo "编译内核时设置:"
|
echo "编译内核:"
|
||||||
|
echo " cd $KERNEL_DIR"
|
||||||
echo " export TC=$TOOLCHAIN_DIR"
|
echo " export TC=$TOOLCHAIN_DIR"
|
||||||
|
echo " export ARCH=arm64"
|
||||||
echo " export CROSS_COMPILE=\$TC/binutils-2.27-install/bin/aarch64-linux-gnu-"
|
echo " export CROSS_COMPILE=\$TC/binutils-2.27-install/bin/aarch64-linux-gnu-"
|
||||||
echo " export CLANG=\$TC/android_prebuilts_clang_host_linux-x86_clang-6443078-10.0"
|
echo " export CLANG=\$TC/android_prebuilts_clang_host_linux-x86_clang-6443078-10.0"
|
||||||
echo " export PATH=\$CLANG/bin:\$PATH"
|
echo " export PATH=\$CLANG/bin:\$PATH"
|
||||||
|
echo " export LOCALVERSION=-perf"
|
||||||
|
echo " make vendor/sdmsteppe-perf_defconfig"
|
||||||
|
echo " make -j\$(nproc) CC=\"python3 ./scripts/gcc-wrapper.py \$CLANG/bin/aarch64-linux-gnu-clang\" HOSTCC=gcc HOSTCXX=g++"
|
||||||
|
echo " gzip -n -9 -c arch/arm64/boot/Image > Image.gz"
|
||||||
|
|||||||
Reference in New Issue
Block a user