天天看点

linux 内核 移植 rk3399,内核编译-内核移植.md

## ubuntu内核编译

**1、进入Ubuntu16.04 系统,打开终端界面,安装开发包:**

sudo apt-get install build-essential lzop libncurses5-dev libssl-dev

如果使用的是 64 位的 Ubuntu,还需要安装:

sudo apt-get install libc6:i386

![微信图片_20200719200404](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200404.png)

**2、安装 mkbootimg 工具**

git clone https://github.com/neo-technologies/rockchip-mkbootimg.git

cd rockchip-mkbootimg

make && sudo make install

注:若没安装git 包,先输入 sudo apt install git 进行安装

**3、获取内核源码和安装交叉编译工具链**

mkdir project

cd project

Firefly-RK3399 Linux 内核代码获取方式ː

git clone https://[email protected]/TeeFirefly/linux-kernel.git.(下载不成功,可以下载压缩包,然后解压)

获取交叉编译工具:

git clone https://[email protected]/TeeFirefly/prebuilts.git.

#内核与编译工具放在同一目录下

**4、kernel 编译**

linux 内核采用的config 文件为firefly_linux_defconfig, dts 文件为

rk3399-firefly-linux.dts

config 文件在~/linux-kernel/arch/arm64/configs/firefly_linux_defconfig,对应生成

kernel.img 文件

dts 文件在~/ linux-kernel/arch/arm64/boot/dts/rockchip/rk3399-firefly-linux.dts,

对应生成resource.img 文件

编译内核

`make ARCH=arm64 firefly_linux_defconfig`

![微信图片_20200719200407](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200407.png)

`make ARCH=arm64 rk3399-firefly-linux.img`

**出现错误,提示没有装python**

![微信图片_20200719200413](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200413.png)

装python:`sudo apt-get install python`然后再次执行`make ARCH=arm64 rk3399-firefly-linux.img`

![微信图片_20200719200416](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200416.png)

内核编译供成功

![微信图片_20200719200423](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200423.png)

## 内核移植

### **1内核下载**

### 2文件copy

将ubuntu内核源码中的firefly_linux_defconfig文件copy进openeuler内核的~/arch/arm64/configs文件夹中

将ubuntu内核源码中的rk3399-firefly-linux.dts文件copu进openeuler内核~/arch/arm64/boot/dts/rockchip文件夹中。

### 3安装依赖

`apt-get install build-essential gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu bc libssl-dev -y`

![微信图片_20200719200451](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200451.png)

### 4变量配置

```

export ARCH=arm64

export CROSS_COMPILE=aarch64-linux-gnu-

```

![微信图片_20200719200447](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200447.png)

### 5编译

``make ARCH=arm64 firefly_linux_defconfig``

![微信图片_20200719200427](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200427.png)

**报错:bison: not found** 安装bison:`sudo apt-get install bison`

``make ARCH=arm64 firefly_linux_defconfig``

![微信图片_20200719200431](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200431.png)

**报错:flex: not found** 安装flex:`sudo apt-get install flex`

``make ARCH=arm64 firefly_linux_defconfig`` 成功

![微信图片_20200719200434](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200434.png)

`make ARCH=arm64 rk3399-firefly-linux.img`

![微信图片_20200719200441](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200441.png)

报错:`make ***No rule to make targer 'rk3399-firefly-linux.img'. Stop`

***目前仍未解决,这是生成kernel.img 与 resource.img的关键一步!!***

![微信图片_20200719200455](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200455.png)

![微信图片_20200719200500](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200500.png)

执行 `make`,可以成功。

![微信图片_20200719200504](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200504.png)

![微信图片_20200719200508](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200508.png)

![微信图片_20200719200523](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200523.png)

***一些其他操作的尝试***

![微信图片_20200719200528](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200528.png)

![微信图片_20200719200531](https://gitee.com/wzqhwx/Openeuler_transplant_RK3399/raw/master/image/微信图片_20200719200531.png)

一键复制

编辑

Web IDE

原始数据

按行查看

历史