Aosp risc-v 架构镜像编译笔记
Last Update:
优先参考文档:
https://github.com/aosp-riscv/working-group/blob/master/docs/zh/howto-build-aosp-riscv.md
CN-gitee(清华镜像源拉取):
README文件引用:
如何编译 aosp-riscv
注:提供此文档为方便国内参与小伙伴。
1. 硬件环境
本文所有操作在以下系统环境下验证通过
1
2
3
4
5
6$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic2. 安装依赖软件
1
2
3
4$ sudo apt install git-core gnupg flex bison build-essential zip curl zlib1g-dev \
gcc-multilib g++-multilib libc6-dev-i386 libncurses5 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev \
libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig python3. 安装 repo
下载(参考 清华大学开源软件镜像站 Git Repo 镜像使用帮助)
1
2$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
$ chmod +x repo为了方便可以将其拷贝到你的 PATH 里。
repo 运行过程中会尝试访问官方的 git 源更新自己,如果想使用 tuna 的镜像源进行更新,可以
将如下内容复制到你的~/.bashrc里并重启终端生效。安装好后可以运行
repo version检查效果,出现类似以下输出说明安装成功。repo 版本需要 2.15 以上。
1
2
3
4
5
6
7
8
9
10$ repo version
<repo not installed>
repo launcher version 2.17
(from /home/wangchen/bin/repo)
git 2.17.1
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0]
OS Linux 4.15.0-144-generic (#148-Ubuntu SMP Sat May 8 02:33:43 UTC 2021)
CPU x86_64 (x86_64)
Bug reports: https://bugs.chromium.org/p/gerrit/issues/entry?template=Repo+tool+issue4. 下载源码
创建一个 AOSP 的源码构建目录,这里假设为
/home/u/aosp,然后进入 aosp 目录
1
2$ mkdir -p /home/u/aosp
$ cd /home/u/aosp进入 AOSP 构建目录后执行以下命令下载 AOSP 的源码
注:由于采用的是 Gitee 上的 aosp-riscv 开发仓库,以及采用国内清华源的 AOSP 镜像作为缺省 remote,将大大方便国内用户下载代码。
1
2$ repo init -u git@gitee.com:aosp-riscv/platform_manifest.git -b riscv64-android-12.0.0_dev_cn
$ repo sync -j85. 编译
注意:因为还在开发过程中,当前还不支持完整的编译
m。下面是一个例子,编译 aosp 但不运行最终的 ninja 构建。
1
2
3
4$ cd /home/u/aosp
$ source ./build/envsetup.sh
$ lunch aosp_riscv64-eng
$ m --skip-ninja6. 构建 Clang llvm 工具链
1
2
3
4$ mkdir llvm-toolchain && cd llvm-toolchain
$ repo init -u git@github.com:aosp-riscv/platform_manifest.git -b riscv64-llvm-master
$ repo sync -c
$ python toolchain/llvm_android/build.py7. 构建 Rust 工具链
1
2
3
4$ mkdir rust-toolchain && cd rust-toolchain
$ repo init -u git@github.com:riscv-android-src/manifest.git -b riscv64-android12-rust-toolchain-dev
$ repo sync -c
$ python toolchain-android_rust/build.py
以下为我个人尝试的操作:
安装依赖:
1 | |
安装repo(官方和清华版本二选一):
1 | |
安装清华repo:
1 | |
添加到系统变量:
1 | |
基本构建命令:
1 | |
以下为报错和相关处理:
/usr/bin/env: “python”: 没有那个文件或目录——解决办法
如果没有安装Python,安装Python3.8
1 | |
如果安装了Python3.8,则没配置Python软链接
1 | |
报错:ERROR: Unable to locate libtinfo.so.5(下面还有一个解决办法)
README引用:
ubuntu19.04/Manjro编译Android Pie源码缺少libtinfo.so.5问题
背景
使用ubuntu19.04编译Android源码的时候,报缺少libtinfo.so.5
解决方法
通过find命令查看,发现确实没有这个文件,默认已经升级到libinfo.so.6版本了,搜索发现重装个包就可以了.
查看一下库:
1
2ls /lib/x86_64-linux-gnu/libtinfo.so.* #查看一下库
/lib/x86_64-linux-gnu/libtinfo.so.6 /lib/x86_64-linux-gnu/libtinfo.so.6.2安装缺少的库:
1sudo apt install libncurses5装完后,可能需要重启terminal才能生效
Manjaro
1
2
3
4sudo pacman -S ncurses5-compat-libs
#或
sudo pacman -S libtinfo5
#这两条命令会安装一样的包附软链接删除命令:
1sudo rm libtinfo.so.5 #已测试有效性未测试安全性
如果你发现你一直连不上git 说你没有权限 你可以先去生成个ssh再试试(不要像我个笨蛋一直以为自己网络有问题)
设置用户:
1 | |
生成密钥
1 | |
编译时候有可能内存不够,需要点swap来帮助一下
1 | |
/bin/bash: m4未找到命令:
1 | |
libncurses.so.5找不到:
1 | |
git:’lfs’ 不是一个 git 命令。参见 ‘git –help’:
1 | |
repo sync多线程(效果很明显 推荐使用):
1 | |
Android repo技巧:repo sync同步Android源码时减少同步时间和代码空间
在使用 repo sync 同步 Android 源码时,可以添加一些选项来减少同步时间和要下载的代码空间。具体的命令是:
1repo sync -c --no-tags --prune -j 4查看 repo help status 的帮助信息,对所给的各个选项具体说明如下:
-c, –current-branch fetch only current branch from server.
这个选项指定只获取执行 repo init 时 -b 选项所指定的分支,不会获取远端服务器的分支信息。
例如服务器上新增了其他分支,使用 -c 选项同步后,在本地 git 仓库执行git branch -r命令看不到服务器新增的分支名。如果不加 -c 选项,那么同步的时候,会打印 [new branch] 这样的信息,使用 git branch -r 命令可查看到服务器新增的分支。–no-tags don’t fetch tags.
该选项指定不获取服务器上的tag信息。
–prune delete refs that no longer exist on the remote.
如果远端服务器已经删除了某个分支,在repo sync时加上--prune选项,可以让本地仓库删除对这个分支的跟踪引用。查看 repo 的 .repo/repo/project.py 源码,这个选项实际上是作为
git fetch命令的选项来执行。查看 man git-fetch 对自身--prune选项的说明如下,可供参考:-p, –prune
After fetching, remove any remote-tracking references that no longer exist on the remote.
-j JOBS, –jobs=JOBS projects to fetch simultaneously (default 2).
指定启用多少个线程来同步。
例如上面的 -j 4 指定用4个线程来同步。如果没有提供该选项,默认是用2个线程。总的来说,在
repo sync -c --no-tags --prune -j 4命令中,使用 -c 和 –no-tags 选项可以减少需要同步的内容,从而减少要占用的本地代码空间,也可以减少一些同步时间。使用 -j 选项来指定启用多线程进行同步,可以加快执行速度,也就减少了同步时间。
使用 –prune 选项去掉已删除分支的跟踪引用,一般不会用到,这个选项可加可不加。
libstd_x86_64-unknown-linux-gnu错误:
The libtest_x86_64-unknown-linux-gnu lib is available in https://cs.android.com/android/platform/superproject/+/master:prebuilts/rust/linux-x86/1.58.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/
This lib will be downloaded as part of AOSP code in prebuilts/rust.git. Try syncing this project again
1repo sync prebuilts/rustThe sync was failing for me with below error:
1error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull functionAfter installing gnutls-bin package it synced successfully.
1sudo apt install gnutls-bin
基本的意思就是在prebuilts/rust目录下的文件并没有git同步成功,尝试重新拉取一下.以下是我的方法.
1 | |