前几年用了RK的芯片做了款产品,主要涉及到源码的下载和编译。在此简单记录下
1.安装Linux环境。
可用VirtualBox新建虚拟机。硬盘分配150G(VirtualBox的好处就是不会开启的时候就把150G的空间占满,虚拟机会按照实际需求来扩大占据的硬盘空间),内存分配2.5G左右。有条件直接使用Linux的话更好。
2.把公钥复制到已经装好的虚拟机目录(公钥可多台机器公用 .ssh文件)
3.在ubuntu上安装git:
3.1.在控制台上输入sudo apt-get install git
3.2.配置git的账户:git config --global user.name “userID”
3.3.配置git的邮箱:git config --global user.email “password”
4.创建一个存放代码的文件夹 mkdir code 然后把目录切换到这个文件夹 cd code
5.安装repo:
mkdir ~/bin
PATH=~/BIN:$PATH
sudo apt-get install curl
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
##如果上述URL不可访问可用下面的:
Curl https://storage-googleapis.proxy.ustclug.org/git-repo-downloads/repo > ~/bin/repo
给repo权限:chmod a+x ~/bin/repo
6.初始化repo:
repo init --repo-url “提供repo的url” -u “repo地址” -b “SDK版本号” -m “xml”
7.同步代码:
.repo/repo/repo sync(此过程耗时非常长,要把代码从git上同步下来,可能需要十几二十个小时)
8.下载和安装jdk,按照推荐文档上的jdk版本号下载jdk,我这边4.4的代码用的是JDK1.6
9. 配置jdk:
9.1.安装更新:sudo apt-get update
9.2.修改权限 sudo chmod 777 jdk-6u45-linux-i586.bin
9.3.把下载下来的jdk解压sudo -s ./jdk-6u45-linux-i586.bin(jdk的安装包名字)
9.4.然后把解压出来的文件夹复制到/usr/lib/jvm/目录
9.5.配置环境变量 sudo gedit /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backsoports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
(这部分带颜色的一起复制到弹出的对话框的最顶端)
等上面运行完之后再整段运行下面的
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils lib32readline-gplv2-dev lzop libswitch-perl sharutils
10. 配置jdk:(和上面标黄色的配置不同,下面的配置命令要一条条分开输)
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/bin/jar 60
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/bin/java 60
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/bin/javac 60
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/bin/javap 60
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/bin/javadoc 60
sudo update-alternatives --config jar
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javap
sudo update-alternatives --config javadoc
11.内核编译环境:
代码下载完成后cd到已经下载好代码的目录下的kernel目录下,输入 make rk3066_sdk_android-4.4_defconfig
12.开始编译内核:
make kernel.img
make -j8 (这里的-j8的意思是开启8个线程编译,开启的线程数越多编译的速度就越快。按电脑的cpu线程数而定)
13.编译代码:
回到代码的根目录在终端输入source build/envsetup.sh
然后lunch
然后 make -j8编译代码
14.打包
./mkimage.sh 生成img文件
(代码的下载和编译完成)