(谷歌搜索 linux-3.14.tar.xz ,会很快找到有许多内核版本的列表)
( tar -xvf linux-3.14.tar.xz 注意不能在与window的共享目录解压)
linux@linux:~$ ls
deja-dup develop Downloads gcc-4.6.4 linux-3.14.79 linux-5.1.8 Music Pictures sdfuse_q u-boot-2013.01-fs4412 u-boot-fs4412.bin Videos 未命名文件夹
Desktop Documents examples.desktop gcc-4.6.4.tar.xz linux-3.14-fs4412 linux_kernel myfifo Public Templates u-boot-2013.01-fs4412.tar.gz uImage vmware-tools-distrib
linux@linux:~$ cd linux-3.14.79/
linux@linux:~/linux-3.14.79$ ls
arch COPYING crypto drivers fs init Kbuild kernel MAINTAINERS mm modules.order net REPORTING-BUGS scripts sound tools virt vmlinux.o
block CREDITS Documentation firmware include ipc Kconfig lib Makefile modules.builtin Module.symvers README samples security System.map usr vmlinux
linux@linux:~/linux-3.14.79$
(配置列表见 arch/arm/configs/ 找最类似的)
直接编译会报错,需要先选配
导入配置
导入配置,发现出错了,需要在Makefile中修改交叉编译工具链
再次导入配置
编译内核之前需要激活配置
linux@linux:~/linux-3.14.79$ make menuconfig
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
***
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2
激活时出错 Unable to find the ncurses libraries
解决方法:
linux@linux:~/linux-3.14.79$ sudo apt-get install ncurses-dev
linux@linux:~/linux-3.14.79$ make menuconfig
linux@linux:~/linux-3.14.79$ make uImage
出现如下信息表示编译成功
linux@linux:~/linux-3.14.79$ make uImage -j2
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: “include/generated/mach-types.h”是最新的。
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
Image arch/arm/boot/uImage is ready
linux@linux:~/linux-3.14.79$
linux@linux:~/linux-3.14.79$ make dtbs
原因:
因为原来的uboot里面没有电源管理单元的驱动,所以导致起不来。需要更换uboot ,现在的uboot是有电源管理驱动,可以解决卡在starting kernel的问题。
$ make menuconfig
[*] Networking support ---> //注意要先输入y 选择该菜单,再按enter键,才能看到下面的选项
Networking options --->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: BOOTP support
File systems --->
[*] Network File Systems --->
<*> NFS client support
<*> NFS client support for NFS version 2
[*] NFS client support for NFS version 3
[*] NFS client support for the NFSv3
ACL protocol extension
[*] Root file system on NFS
Device Drivers --->
[*] Network device support --->
[*] Ethernet driver support --->
<*> DM9000 support (网卡驱动里面可以只选择这个,把其他的都去掉)
$ vim arch/arm/boot/dts/exynos4412-origen.dts 在 regulators 前添加下面代码
srom-cs1@5000000 {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x5000000 0x1000000>; 对应芯片手册 3 Memory Map 的0x0500_0000 和 16 MB
ranges;
ethernet@5000000 {
compatible = "davicom,dm9000"; 内核通过该名字来匹配驱动
reg = <0x5000000 0x2 0x5000004 0x2>; 寄存器地址和数据宽度
interrupt-parent = <&gpx0>; 继承于 中断控制器gpx0
interrupts = <6 4>; 6 对应中断源 DM9000_IRQ -> XEINT6 。4对应 active high level-sensitive
davicom,no-eeprom;
mac-address = [00 0a 2d a6 55 a2];
};
};
static bool clk_ignore_unused;
改为
static bool clk_ignore_unused = true; //意思是忽略掉没有使用的时钟
修改好后,开发板上电重启
make uImage -j2表示双线程编译,加快编译时间
移植成功
最后可以找出使能1对应的是bank1
查看官方给的案例
在内核里有一个结构“struct machine_desc”,内核用这个结构表示一个实际存在的板子,而针对每个板子都会有一个文件定义这个结构体,这个文件叫平台代码;
如:arch/arm/mach-s5pv21/mach-smdkv210.c(新版本内核中没有基于Exynos4412的平台代码,这里以s5pv210为例)
MACHINE_START(SMDKV210, "SMDKV210")
/* Maintainer: Kukjin Kim */
.atag_offset = 0x100,
.init_irq = s5pv210_init_irq,
.map_io = smdkv210_map_io,
.init_machine = smdkv210_machine_init,
.init_time = samsung_timer_init,
.restart = s5pv210_restart,
.reserve = &smdkv210_reserve,
MACHINE_END
https://blog.csdn.net/m0_37542524/article/details/86373792