git下载Android kernel 源码并进行编译

版权声明:转载请说明,谢谢。 https://blog.csdn.net/wuming_422103632/article/details/82116497

一. 如何获取Android 内核源码
1 如果能够访问Google网站,则直接访问如下网站:
https://source.android.com/setup/build/building-kernels
进行相应的Android 内核源码下载

2 如果不能访问Google网站,则 使用清华的镜像下载对应源码:

名称 清华服务器地址
common https://aosp.tuna.tsinghua.edu.cn/kernel/common.git
exynos https://aosp.tuna.tsinghua.edu.cn/kernel/exynos.git
goldfish https://aosp.tuna.tsinghua.edu.cn/kernel/goldfish.git
hikey-linaro https://aosp.tuna.tsinghua.edu.cn/kernel/hikey-linaro.git
msm https://aosp.tuna.tsinghua.edu.cn/kernel/msm.git
omap https://aosp.tuna.tsinghua.edu.cn/kernel/omap.git
samsung https://aosp.tuna.tsinghua.edu.cn/kernel/samsung.git
tegra https://aosp.tuna.tsinghua.edu.cn/kernel/tegra.git
x86_64 https://aosp.tuna.tsinghua.edu.cn/kernel/x86_64.git

我自己就git clone https://aosp.tuna.tsinghua.edu.cn/kernel/msm.git 高通source code:
使用git branch -a查看有多少可以下载的分支:

remotes/origin/android-msm-sturgeon-3.10-n-preview-2-wear-release
remotes/origin/android-msm-sturgeon-3.10-n-preview-3-wear-release
remotes/origin/android-msm-sturgeon-3.10-n-preview-4-wear-release
remotes/origin/android-msm-sturgeon-3.10-nougat-dr1-wear
remotes/origin/android-msm-sturgeon-3.10-nougat-mr1-wear-release
remotes/origin/android-msm-sundial-3.18-nougat-mr1-wear-release
remotes/origin/android-msm-sundial-3.18-oreo-wear-dr
remotes/origin/android-msm-swift-3.18-marshmallow-mr1-wear-release
remotes/origin/android-msm-swift-3.18-nougat-dr-release
remotes/origin/android-msm-swordfish-3.18-nougat-mr1-wear-release
remotes/origin/android-msm-swordfish-3.18-nougat-wear-release
remotes/origin/android-msm-swordfish-3.18-o-wear-preview-4
remotes/origin/android-msm-swordfish-3.18-oreo-wear-dr
remotes/origin/android-msm-vega-4.4-fsi-oreo
remotes/origin/android-msm-vega-4.4-oreo-daydream
remotes/origin/android-msm-wahoo-2018.07-oreo-m2
remotes/origin/android-msm-wahoo-2018.07-oreo-m4
remotes/origin/android-msm-wahoo-4.4-o-mr1-preview1
remotes/origin/android-msm-wahoo-4.4-oreo-dr1
remotes/origin/android-msm-wahoo-4.4-oreo-m2
remotes/origin/android-msm-wahoo-4.4-oreo-m4
remotes/origin/android-msm-wahoo-4.4-oreo-mr1
remotes/origin/android-msm-wahoo-4.4-oreo-mr1-preview2
remotes/origin/android-msm-wahoo-4.4-p-preview-1
remotes/origin/android-msm-wahoo-4.4-p-preview-2
remotes/origin/android-msm-wahoo-4.4-p-preview-3
remotes/origin/android-msm-wahoo-4.4-p-preview-4
remotes/origin/android-msm-wahoo-4.4-p-preview-5
remotes/origin/android-msm-wahoo-4.4-pie
remotes/origin/android-msm-wren-3.10-marshmallow-dr1-wear-release
remotes/origin/android-msm-wren-3.10-marshmallow-mr1-wear-release
remotes/origin/master

我看最新的分支,git checkout -b remotes/origin/android-msm-wahoo-4.4-pie

二 如何编译?

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-android-

配置好aarch64-linux-android-环境变量即可.下载地址:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
之后make xxx_deconfig
最后make -j8
但是出现了如下的error:

  HOSTCC  scripts/sign-file
scripts/sign-file.c:23:30: fatal error: openssl/opensslv.h: No such file or directory
 #include <openssl/opensslv.h>
                              ^
compilation terminated.
make[1]: *** [scripts/sign-file] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [scripts] Error 2
make: *** Waiting for unfinished jobs....
  CHK     include/generated/asm-offsets.h
  UPD     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

解决方案如下:sudo apt-get install libssl-dev,但是在安装的时候出现如下error:

sudo apt-get -f install libssl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.19 is to be installed
              Recommends: libssl-doc but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

解决方案入下:
先安装

sudo apt-get install aptitude
Reading package lists... Done
Building dependency tree       
Reading state information... Done
aptitude is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

使用aptitude再次安装libssl-dev,并选择降级的版本。

sudo aptitude install libssl-dev
The following NEW packages will be installed:
  libssl-dev{b} libssl-doc{a} 
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,031 kB of archives. After unpacking 7,801 kB will be used.
The following packages have unmet dependencies:
 libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.19 is installed.
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libssl-dev [Not Installed]                         


# 这里提示时,一定要选n,选Y跟apt-get install操作一样
Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

     Downgrade the following packages:                                   
1)     libssl1.0.0 [1.0.1f-1ubuntu2.19 (now) -> 1.0.1f-1ubuntu2 (trusty)]


# 接受这里的降级处理,成功安装
Accept this solution? [Y/n/q/?] y
The following packages will be DOWNGRADED:
  libssl1.0.0 
The following NEW packages will be installed:
  libssl-dev libssl-doc{a} 
0 packages upgraded, 2 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 2,857 kB of archives. After unpacking 7,784 kB will be used.
Do you want to continue? [Y/n/?] y
Get: 1 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl1.0.0 amd64 1.0.1f-1ubuntu2 [825 kB]                     
Get: 2 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl-doc all 1.0.1f-1ubuntu2 [965 kB]                        
Get: 3 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl-dev amd64 1.0.1f-1ubuntu2 [1,066 kB]                    
Fetched 2,857 kB in 50s (57.1 kB/s)                                                                                 
Preconfiguring packages ...
dpkg: warning: downgrading libssl1.0.0:amd64 from 1.0.1f-1ubuntu2.19 to 1.0.1f-1ubuntu2
(Reading database ... 234481 files and directories currently installed.)
Preparing to unpack .../libssl1.0.0_1.0.1f-1ubuntu2_amd64.deb ...
Unpacking libssl1.0.0:amd64 (1.0.1f-1ubuntu2) over (1.0.1f-1ubuntu2.19) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../libssl-dev_1.0.1f-1ubuntu2_amd64.deb ...
Unpacking libssl-dev:amd64 (1.0.1f-1ubuntu2) ...
Selecting previously unselected package libssl-doc.
Preparing to unpack .../libssl-doc_1.0.1f-1ubuntu2_all.deb ...
Unpacking libssl-doc (1.0.1f-1ubuntu2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libssl1.0.0:amd64 (1.0.1f-1ubuntu2) ...
Setting up libssl-dev:amd64 (1.0.1f-1ubuntu2) ...
Setting up libssl-doc (1.0.1f-1ubuntu2) ...
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...

至此,libssl-dev安装成功.
对于这种错误总结如下:

  • apt-get安装时会默认选择预设的依赖版本。
  • aptitude安装时会提示是否选择默认设定的依赖版本,如果选n,会对库进行依赖降级,从而安装期望的版本。
展开阅读全文

没有更多推荐了,返回首页