搭建编译 HW-T3568 安卓固件的环境
- 作者:吴思含(Witheart)
- 更新时间:20241127
编译环境构建
1. 安装 SDK 编译环境所需软件包
首先,更新并升级系统:
bash
sudo apt update
sudo apt upgrade
然后,安装必要的软件包:
bash
sudo apt install git git-core gnupg ssh make gcc g++ libssl-dev liblz4-tool \
expect patchelf chrpath gawk texinfo diffstat binfmt-support qemu-user-static \
live-build bison flex fakeroot cmake gcc-multilib g++-multilib unzip zip curl \
zlib1g-dev libc6-dev-i386 lib32ncurses5-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc device-tree-compiler libfdt-dev libfdt1 \
python3-pip python3-dev python3-pyelftools ncurses-dev libncurses5 libgl1-mesa-dev \
gperf build-essential
2. 常见问题及解决方法
1)软件包安装失败的解决方案
-
替换
python-pip现代系统默认使用 Python 3,请改用
python3-pip:bashsudo apt install python3-pip -
启用
universe仓库如果某些包无法找到,确保已启用
universe仓库:bashsudo add-apt-repository universe sudo apt update sudo apt install expect -
安装
qemu-user-static若安装失败,尝试启用
multiverse仓库:bashsudo add-apt-repository multiverse sudo apt update sudo apt install qemu-user-static -
安装
device-tree-compiler如果未找到该工具,可以尝试:
bashsudo apt install device-tree-compiler -
安装
pyelftools使用
pip3安装 Python 库pyelftools:bashpip3 install pyelftools
2)确保 Python2 为系统默认版本
Android 11 的编译环境要求默认使用 Python 2。执行以下命令切换默认版本:
bash
sudo rm -rf /usr/bin/python
sudo ln -s /usr/bin/python2 /usr/bin/python
3. 安装 repo
-
创建
repo所需的目录并配置环境变量:bashmkdir ~/bin export PATH=~/bin:$PATH -
下载
repo工具:bashcurl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo chmod a+x ~/bin/repo -
配置 Git 用户信息(
repo使用 Git 工作,需要提前配置用户信息):bashgit config --global user.name "your name" git config --global user.email "your email" -
验证 Git 配置信息:
bashgit config --list
注意事项
- 请确保所有依赖的软件包均已正确安装,若遇到问题可参考上述解决方案逐一排查。
- 完成上述环境配置后,即可开始编译 HW-T3568 固件。