(2)编译内核

编译内核并下载

1.将光盘里面的内核文件放入linux虚拟机(我的是直接放在服务器上面),解压内核:
tar -jxvf linux-xxx.tar.bz2
或者
tar -zxvf linux-xxxx.tar.gz

2.然后清除原有的配置文件:
make distclean

3.复制别人厂家的配置文件
cp ok210p_linux_config .config

4.修改Makefile并且要做检查

ARCH=arm
COSS_COMPILE=arm-linux-

一定做三个检查
make menuconfig
System type->
1.检查是否支持当前ARM架构
2.检查是否支持当前处理器(S5PV210)
3.检查是否支持当前开发板(OK210,smdkv210...)

5.最后编译
make zImage或者make uImage
如果出现问题:

  • 时钟
  • 串口的初始化一定要关注
    答案:在平台代码(arch/arm/mach-s5pv210/mach-smdkv210.c)(切记一定要多看!)

生成的文件在/arch/arm/boot文件夹下。
常遇到的错误:

  • Makefile没有指定内核平台:ARCH=arm

  • 缺少mkimage的工具:
    在uboot的工具文件夹下,在tools文件夹下面找到mkimage,将其复制到虚拟机Linux的bin目录下。
    命令: cp mkimage /bin/

最后我们用上一节学习的命令来试着下载内核,烧写到Flash,从Flash读出内核和启动内核:

tftp C0008000 uImage
nand erase 0x100000 0x500000
nand write C0008000 100000 500000
nand read  C0008000 100000 500000
bootm c0008000

一般按照官方编译的内核不会有任何问题,可以看到启动信息:

SMDKV210 # tftp c0008000 uImage
dm9000 i/o: 0x88000300, id: 0x90000a46
MAC: 00:22:12:34:56:90
operating at 100M full duplex mode
TFTP from server 192.168.1.2; our IP address is 192.168.1.20
Filename 'uImage'.
Load address: 0xc0008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         ######################
done
Bytes transferred = 4129476 (0x3f02c4)
SMDKV210 # mtd
Unknown command 'mtd' - try 'help'
SMDKV210 # nand erase 0x100000 0x500000

NAND erase: device 0 offset 0x100000, size 0x500000
Erasing at 0x580000 -- 100% complete.
OK
SMDKV210 # nand write C0008000 100000 500000

NAND write: device 0 offset 0x100000, size 0x500000
Main area write (10 blocks):
 5242880 bytes written: OK
SMDKV210 # nand read  C0008000 100000 500000

NAND read: device 0 offset 0x100000, size 0x500000
Main area read (10 blocks):
 5242880 bytes read: OK
SMDKV210 # bootm c0008000
get_format
-------- 1 --------
## Booting kernel from Legacy Image at c0008000 ...
   Image Name:   Linux-2.6.35.7
   Created:      2018-01-08  12:50:51 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4129412 Bytes =  3.9 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
get_format
-------- 1 --------
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 2.6.35.7 (allison@chdsz-server) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #2 PREEMPT Mon Jan 8 07:50:41 EST 2018
[    0.000000] CPU: ARMv7 Processor [412fc082] revision 2 (ARMv7), cr=10c53c7f
......

你可能感兴趣的:((2)编译内核)