嵌入式linux-系统移植,Linux内核编译,设备树编译,Linux内核基本概念

1,基本概念

1.1,Linux内核

从技术上说 linux 是一个内核
“内核”指的是一个提供硬件抽象层、磁盘及文件系统控制、多任务等功能的系统软件。一个内核不是一套完整的操作系统。
通常我们使用的 linux 系统是一个集 linux 内核、工具集、各种库、桌面管理器、应用程序等一体的一个发布包 (发行版)‏

1.2,主流的 Linux 发行版

Debian GNU/Linux
Red Hat Linux
Fedora Core
Ubuntu Linux
SUSE Linux
Gentoo Linux
Asianux
Slackware Linux
Turbo Linux
CentOS

1.3,Linux 内核的特性

免费开源
可以移植,支持的硬件平台广泛
arm, i386, m68k, m32r,m68knommu, mips, ppc, s390, sh, sparc
高可扩展性
可剪裁、可扩展,可以运行在大型主机,也可以运行在个人计算机上
高可靠性、稳定性
稳定性是linux鲜明特点,安装了linux系统的主机,
连续运行一年不宕机是很平常的事情
超强的网络功能
真正的多任务,多用户系统
模块化设计
模块可以动态加载,卸载,可以减少系统体积,同时可以用来解决冲突问题,模块调试

1.4,Linux内核版本

目前linux系统采用 A.B.C.D 的版本号管理方式
A 表示linux的主版本号
B 表示linux的次版本号,B 为偶数表示稳定版本,奇数表示开发中的版本(下载B 为偶数的版本
C 表示linux的发行版本号
D 表示更新版本号
主版本(X.Y)
1.0 2.0 2.2 2.4 2.6 3.x

1.5,Linux内核子系统

进程管理
内存管理
文件系统
网络协议
设备管理

  1. linux系统不是正真的实时系统(采用时间片轮转的方式做的)
  2. 美国军方的Vxwork是正真的实时系统(中断抢占)

1.6,Linux内核模块结构图

嵌入式linux-系统移植,Linux内核编译,设备树编译,Linux内核基本概念

  1. 应用访问内核要通过系统调用
  2. 内核访问硬件要通过映射

1.7,linux内核编译(移植好的)

1.7.1,拷贝到linux并解压,然后编译

[email protected]:~$ cp /mnt/hgfs/Linuxsharexiaomei/linux-3.14-fs4412.tar.xz 
[email protected]:~$ tar -vxf linux-3.14-fs4412.tar.xz 
[email protected]:~/linux-3.14-fs4412$ ls
arch      cd       crypto         firmware          include  Kbuild   lib          mm              README          scripts   tools
block     COPYING  Documentation  fs                init     Kconfig  MAINTAINERS  Module.symvers  REPORTING-BUGS  security  usr
build.sh  CREDITS  drivers        fs4412_defconfig  ipc      kernel   Makefile     net             samples         sound     virt
[email protected]:~/linux-3.14-fs4412$ make uImage 

1.7.2,编译出错make[1]: `include/generated/mach-types.h’ is up to date.

[email protected]:~/linux-3.14-fs4412$ make uImage 
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
scripts/basic/fixdep: 1: scripts/basic/fixdep: Syntax error: "(" unexpected
make[2]: *** [scripts/mod/file2alias.o] Error 2
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2

1.7.2.1,解决方案

[email protected]:~/linux-3.14-fs4412$ make clean
[email protected]:~/linux-3.14-fs4412$ make uImage 

1.7.3,编译出错"mkimage" command not found - U-Boot images will not be built

  SHIPPED arch/arm/boot/compressed/bswapsdi2.S
  AS      arch/arm/boot/compressed/bswapsdi2.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
"mkimage" command not found - U-Boot images will not be built
make[1]: *** [arch/arm/boot/uImage] Error 1
make: *** [uImage] Error 2

1.7.3.1,解决方案

[email protected]:~/linux-3.14-fs4412$ sudo apt-get install uboot-mkimage
[sudo] password for linux: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package uboot-mkimage is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  u-boot-tools

E: Package 'uboot-mkimage' has no installation candidate
[email protected]:~/linux-3.14-fs4412$ sudo apt-get install u-boot-tools 

1.7.4,编译成功

Image Name:   Linux-3.14.0
Created:      Fri Jan 11 19:41:27 2019
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3014944 Bytes = 2944.28 kB = 2.88 MB
Load Address: 40008000
Entry Point:  40008000
  Image arch/arm/boot/uImage is ready

1.7.5,测试

1.7.5.1,备份原有的,拷贝新编译的

[email protected]:~/linux-3.14-fs4412$ mv /tftpboot/uImage /tftpboot/uImage.ok
[email protected]:~/linux-3.14-fs4412$ cp arch/arm/boot/uImage /tftpboot/

1.7.5.2,开发板重新上电,在串口终端中,查看启动信息

嵌入式linux-系统移植,Linux内核编译,设备树编译,Linux内核基本概念

成功启动

2,启动分析

3,调试方法