Skip to content

Commit 549d7ca

Browse files
committed
kernel
1 parent e56b367 commit 549d7ca

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

_posts/2020-12-30-linux-kernel.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
layout: post
3+
title: "LinuxLab 真板开发:内核构建"
4+
author: iosdevlog
5+
date: 2020-12-30 17:09:32 +0800
6+
description: ""
7+
cover-img: /assets/images/LinuxLab/IMX6ULL/kernel.png
8+
category:
9+
tags: [LinuxLab, IMX6ULL, linux, kernel]
10+
---
11+
12+
## 切换到ebf-imx6ull
13+
14+
```bash
15+
make BOARD=arm/ebf-imx6ull
16+
git branch
17+
# * next
18+
```
19+
20+
## 修改内核
21+
22+
进入内核源码目录,做一些修改。
23+
24+
```bash
25+
vi src/linux-stable/init/main.c
26+
```
27+
28+
`kernel_init` 添加添加一条打印。
29+
30+
ubuntu@linux-lab:/labs/linux-lab/src/linux-stable$ `git diff init/main.c`
31+
32+
```diff
33+
diff --git a/init/main.c b/init/main.c
34+
index e083fac08aed..c8041fa17d6c 100644
35+
--- a/init/main.c
36+
+++ b/init/main.c
37+
@@ -1078,6 +1078,8 @@ static int __ref kernel_init(void *unused)
38+
39+
rcu_end_inkernel_boot();
40+
41+
+ printk(KERN_DEBUG "Hello, IMX6ULL from Linux Lab.");
42+
+
43+
if (ramdisk_execute_command) {
44+
ret = run_init_process(ramdisk_execute_command);
45+
if (!ret)
46+
```
47+
48+
编译安装
49+
50+
```bash
51+
$ make kernel-build
52+
$ make modules-install
53+
```
54+
55+
上传
56+
57+
```bash
58+
make kernel-upload
59+
```
60+
61+
启动新 Image
62+
63+
```bash
64+
make boot
65+
```
66+
67+
查看启动日志
68+
69+
```bash
70+
debian@npi:~$ dmesg | grep from
71+
[ 0.000000] random: get_random_bytes called from start_kernel+0xa0/0x434 wi0
72+
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
73+
[ 1.543896] sii902x bound to mxs-lcdif from 21c8000.lcdif
74+
[ 1.646126] Console IMX rounded baud rate from 114943 to 114900
75+
[ 7.438844] Hello, IMX6ULL from Linux Lab.
76+
[ 9.745109] fec 20b4000.ethernet eth2: renamed from eth0
77+
[ 15.209116] systemd-journald[206]: Received request to flush runtime journa1
78+
```
79+
80+
可以看到我们在 `init/main.c` 里添加的打印已经生效了。
81+
82+
![kernel](/assets/images/LinuxLab/IMX6ULL/kernel.png)
83+
84+
查看一下内核信息:
85+
86+
```bash
87+
debian@npi:~$ uname -a
88+
Linux npi 4.19.35+ #2 SMP PREEMPT Wed Dec 30 17:33:39 CST 2020 armv7l GNU/Linux
89+
```
90+
91+
是刚才编译的,说明我们修改的内核确实起作用了。
110 KB
Loading

0 commit comments

Comments
 (0)