环境:Ubuntu16.04(VMWare)
1.准备工作
下载最新的内核,linux-4-17
便在交叉编译工具,gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2
下载完成后,解压内核和编译工具,
将编译工具的路径加入PATH变量
export PATH=$PATH:/usr/local/arm/gcc-arm-none/bin/
然后使用source /etc/profile 使环境变量生效,不过有的时候不成功,所以最好是能重启一下。
2.尝试编译内核
修改kernel最上层的Makefile文件,在文件中指定了平台的架构,architecture
ARCH ?= $(SUBARCH) arm
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) arm-none-eabi-
修改之后配置为s3c6400的配置文件进行编译,但是使用配置文件之后报错了;
msc@ubuntu:~/Desktop/linux-4.17.7$ make s3c6400_defconfig
YACC scripts/kconfig/zconf.tab.c
/bin/sh: 1: bison: not found
scripts/Makefile.lib:196: recipe for target 'scripts/kconfig/zconf.tab.c' failed
make[1]: *** [scripts/kconfig/zconf.tab.c] Error 127
Makefile:528: recipe for target 's3c6400_defconfig' failed
make: *** [s3c6400_defconfig] Error 2
Google 链接:
https://www.linuxquestions.org/questions/debian-26/compile-of-kernel-4-16-fails-4175628085/
安装了两个包,
apt-get install bison
apt-get install flex
安装之后重新执行make s3c6400_defconfig,顺利通过。
第一步只是搭建编译环境,和尝试编译。
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 4.17.7 (msc@ubuntu) (gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] (GNU Tools for Arm Embedded Processors 7-2018-q2-update)) #1 Wed Jul 18 12:42:45 CST 2018
CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: SMDK6410
Memory policy: Data cache writeback
Samsung CPU ID: 0x36410101
CPU S3C6410 (id 0x36410101)
CPU: found DTCM0 8k @ 00000000, not enabled
CPU: moved DTCM0 8k to fffe8000, enabled
CPU: found DTCM1 8k @ 00000000, not enabled
CPU: moved DTCM1 8k to fffea000, enabled
CPU: found ITCM0 8k @ 00000000, not enabled
CPU: moved ITCM0 8k to fffe0000, enabled
CPU: found ITCM1 8k @ 00000000, not enabled
CPU: moved ITCM1 8k to fffe2000, enabled
random: get_random_bytes called from start_kernel+0x80/0x3f0 with crng_init=0
Built 1 zonelists, mobility grouping on. Total pages: 65024
Kernel command line: root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 255196K/262144K available (3022K kernel code, 182K rwdata, 928K rodata, 168K init, 214K bss, 6948K reserved, 0K cma-reserved)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
DTCM : 0xfffe8000 - 0xfffec000 ( 16 kB)
ITCM : 0xfffe0000 - 0xfffe4000 ( 16 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xd0800000 - 0xff800000 ( 752 MB)
lowmem : 0xc0000000 - 0xd0000000 ( 256 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.text : 0x(ptrval) - 0x(ptrval) (3023 kB)
.init : 0x(ptrval) - 0x(ptrval) ( 168 kB)
.data : 0x(ptrval) - 0x(ptrval) ( 183 kB)
.bss : 0x(ptrval) - 0x(ptrval) ( 215 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS: 16, nr_irqs: 229, preallocated irqs: 229
S3C6410 clocks: apll = 532000000, mpll = 532000000
下载之后运行输出的信息。启动失败,但是有输出。