您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Linux学习系列四:Kernel编译下载.pdf
  所属分类: Linux
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2019-07-03
  提 供 者: qq_38******
 详细说明:Linux学习系列四:Kernel编译下载.pdfwww.topsemic.com 1.引言 本龠接上一篇,给大家介绍 Linux kerne的编译和下载运行,达到的预期效 果是都下载到板子后,可以正常通过串囗登录到 Linux系统里。 2. Linux Kerne编译 NUC972 Linux kernel下载地址为 https:/github.com/opennuvotOn/nuc970LinuxKernel 下载完成后,放到 Ubuntu虚拟机的~/nuc972/ kernel文件夹下,解压缩。 opsemicatopsemic-virtual-machine: -/nuc972s mkdir kernel copsemictopsemic-virtual-machine: -/nuc972$ opsemicgtopsemic-virtual-machine: -/nuc972/kernels ls NUC970 Linux Kernel-master zip ltopsemicgtopsemic-virtual-machine: -/nuc972/kernels unzip NUC970_Linux_Kernel-mas ter. zip 编译前还记得前两籥文章说的吧,我们先 source /home/topsemic/nuc972/toolchain/environment. sh 进入到内核目录,第一步先执行 make nuc972 defconfig生成 config文件, 这一步是不是很眼熟,和上一讲 uboot编译是类似的 topsemicatopsemic-virtual-machine:-/nuc972/kerneL/NUC970 Linux Kernel-masters ma ke nuc972_ defconfig HOSTCc scripts/basic/fixdep HOSTCc scripts/kconfig/confo SHIPPED scripts/kconfig/zconf tabc SHIPPED scripts/kconfig/zconf lexc SHIPPED scripts/kconfig/zconf hashc HOSTCc scripts/kconfig/zconf tabo HOSTLD scripts/kconfig/conf configuration written to. config # 第二步执行: make ullage,编译内核,报错了,错误是不是和编译 uboot 1也 类似啊。 topsemicatopsemic-virtual-machine: -/nuc972/kerne L/NUC970-Linux_Kernel-masters ma ke IMage nake:arn-nux-qcc:命令未找到 scripts/kconfig/conf .-silentoldconfig kconfig make:arm-linux-gcc 命令未找到 WRAP arch/arm/include/generated/ asm/auxvec h WRAP arch/arm/include/generated/ asm/bitsper long h WRAP arch/arm/include/generated / asm/cputime. h WRAP arch/arm/include /generated/asm/currenth 同样的我们也是要改 Makefile www.topsemic.com 这次我们用vm来改一次, topsemicatopsemic-virtuaL-machine: -/nuc972/kerneL/NUC970_Linux_KerneL-masters m Makefile 程序'vim'已包含在下列软件包中: vim-gnome vim-tiny vim-athena vim-athena-py2 vim-gnome -py2 vim-gtk vim-gtk-py2 vim-gtk3 im-gtk3-P Lm-noX vim-nox-py2 请尝试: sudo apt install<选定的软件包> 提示我们不支持vm这个指令,那我们安装一下吧,入家都给提示了,输入 sudo apt install vim 下面是安装过程 lL2:7.4.1689-3 ubuntu1.2[5,164kB Ex:2http://cn.archiveubuntucon/ubuntuxenial-updates/mainamd64vimamd64 9-3ub ⊙36 下载6,172kB,耗时4分4秒少(21.7kB/s) 正在选中未选择的软件包vin- runtime (正在读取数据库,系统当前共安装有181979个文件和目录。) 正准备解包.../im- runtime2%3a7.4.1689-3 ubuntu1.2aLL.deb 正在添加 vim-runtime导致7us/ share/vn/vn4/doc7 help.txt转移到/usr/ share/v m/vim74/doc/help. txt. vim-tiny 正在添加 vim- runtime导致/usr/ share/vn/vin74/doc/tags转移到/usr/ share/vin/v m74/doc/tags. vim-tiny 正在解包vin- runtime(2:7.4.1689-3 ubuntu1.2) 正在选中未选择的软件包vin 正准备解包…/Vm2%3a7.4,1689-3 Ubuntu1.2ad64,deb , 正在解包yin(2:7.4.16893 ubuntu1.2) 正在处理用于man-db(2.7.5-1)的触发器 正在设置 vim-runtime(2:7.4.1689-3 ubuntu1.2) 正在设置vin(2:7.4.1689-3 ubuntu1.2) update-alternatives:使用/usr/bn/ vim. basic来在自动模式中提供/usr/btn/vn(v update- alternatives:使用/usr/bn/ vim, basic来在自动模式中提供/usr/bin/ vimdiff update- alternatives:使用/usr/btn/ vim, basic来在自动模式中提供/usr/btn/rvtn( update- alternatives:使用/usr/btn/ vim. basic来在自动模式中提供/usr/bin/ rview rview) update-alternatives update-alternatives: 使用 /usr/bin/ vim. basic来在自动模式中提供/usr/bin/vt(vt /usr/btn/vt. basic来在自动模式中提供/usr/bn/vtew( iew update-alternatives:使用/usr/bn/vm. basic来在自动模式中提供/usr/bin/ex(ex topsemtcatopsemic-virtual-machine:-/nuc972/kernel/NUC970_Linux_Kernel-masters OK,安裝完毕,Ubun{u系统安裝个东西真是方便啊,一条指令就搞定了。 输入 vim makefile显示如下: www.topsemic.com topsemicotopsemic-virtual-machine: -/nuc972/kernel/NUC970Linux_Kernel-mas m ti 3 4)21: 48 4h VERs工oN=3 PATCHLEVEL=1⊙ SUBLEVEL =108 EXTRAVERSION= NAME END-OF-LIFE a *DOCUMENTATION* To see a list of typical targets execute "make help More info can be located in./README Comments in this file are targeted only to the deve loper, do not expect to Learn how to build the kernel reading this file Do not #o use make's built-in rules and variables (this increases performance and avoids hard-to-debug behaviour ) #o print "Enter ing directory MAKEFLAGS +=-rR--no-print-directory Avoid funny character set dependencies 围 unexport LC ALL LC COLLATE=C LC NUMERIC=C export LC COLLATE LC NUMERIC we are using a recursive build, so we need to do a little thinking to get the ordering right Most impor tantly: sub-Makefiles should only ever modify files in their own directory. If in some directory we have a dependency on a file in another dir (which doesn't happen often, but it's often unavoidable when linking the built-in o targets which finall turn into vmlinux), we will call a sub make in that other dir, and Makefile"1438L, 48552C 花花绿绿的看着不错啊,先找到设置交叉编译链的地方,貝体方法如下图1、 2、3步骤描述 F Cross compiling and selecting different set of gcc/bin-utils When per forming cross compilation for other architectures ARCH shall be set to the target architecture. (See arch/* for the possibilities) ARCH can be set during invocation of make: make ARCH=ia64 Another way is to have ARCH set in the environment The default ARCh is the host where make is executed CROSS COMPILE specify the prefix used for all executables used during compilation. Only gcc and related bin-uttls executables are prefixed with S(CROSS COMPILE) CROSS COMPILE can be set on the command line make CROSS COMPILE=ia64-Ltnux Alternative ly CRoSS COMPILE can be set in the environment A third alternative is to store a setting in config so that plain #"make"in the configured kernel build directory always uses that #f Default value for CROSs COMPILE ts not to prefix executables Note: Some architectures assign CROSS COMPILE in their arch/*/Makefile fARCH ? S(SUBARCH) ARCH s arM 2按健盘N键,往下查找 #CROSS COMPILE 2= S(CONFIG CROSS COMPILE: "%=%) CROSS COMPILE dr内- Linux 3.找到出问题的地方 #f Architecture as present tn compute h UTS MACHINE S(ARCH) SRCARCH S(ARCH) /CROSS COMPILE 输入/,表示查找,后面输入 CROSS COMPILE按Ente17,28-29 12% 修改方法第一篇博宮介绍的大家还记得吗?先输入Ⅰ,进入到插入模式,然 www.topsemic.com 后修改即可 e: some architectures assign #ARCH ?= S(SUBARCH) ARCH arm #CROSS_COMPILE ? S(CONFIG CROSS COMPILE: % =% CROSS COMPILE arm-none-linux-gnueabi Architecture as present in compile.h UTS MACHINE :=S(ARCH) SRCARCH :=S(ARCH) 插入 然后ESC退出插入模式,最后输入:w保存退出即可。 #ARCH ? S(SUBARCH) ARCH ar问 Architecture as present in compile / sc #CROSS COMPILE ? S(CONFIG CROSS COMPILE: =% CROSS COMPILE arm-none-Linux-gnue. UTS MACHINE : S(ARCH) SRCARCH S(ARCH) wq 以后大家多使用vm吧。 修改完 Makefile后,再一次 make ulma scripts/sortextable. h: 104: 6: note: relocs_ size was declared here int reloc size: In file included from scripts/sortextable. c: 160: 0: scripts/sortextable. h: 158: 3: warning: relocs size may be used uninitialized in this function [-Wmaybe -uninitialized] et(reloc, 0, reloc size); scripts/sortextable. h: 104: 6: note: reLocs_size' was declared here int reloc size CHK include/generated/compile UPD include/generated/ compile. h init/version. o init/do mounts.o init/do mounts rdo init/do mounts initrd init/mounts. o init/initr amfs.o init/calibrate o init/init tasko LD init/built-ino st. sh: Cannot open ./root /home/topsemic/nuc972/kernel/NUC970 Linux Kernel-master /usr/Makefile: 67: recipe for target usr/initramfs data cpio. gz failed make [1]: ** [usr/initramfs data cpio. gz]Error 1 Makefile: 800: recipe for target ' usr failed make: ** [usr] Error 2 靠,什么情况,又报错了,我记得之前没遇到这个错误啊。 www.topsemic.com 网上百度查了下,说是和文件系统有关,是权限的问题,使用sudo编译就行,于 是我激动的 sudo make ullage,咦 topsemlcgtopsemic-virtuaL-machine: "/nuc972/kerne L/NUC970-Linux KerneL-maste do make ake:ar-none-1tnux- gnueabi-gcc:命令未找到 CHK include/generated/ api/Linux/version. h CHK include/generated /utsrelease h make[1]:'include/generated/mach-types h' is up to date CC kernel/ bounds.s /bin/sh: 1: arm-none-linux-gnueabi-gcc: not found /home/topsemic/nuc972/kernel/ NUC970 Linux Kernel-master//kbuild: 35: recipe for target kernel/bounds. s' failed make[1]: ** [kernel/bounds. s] Error 127 Makefile: 840: recipe for target 'prepareo' failed make: ** prepared Error 这个命令找不动,不应该啊,我已经 source s,而且翰入 arm-none- Table键也 能找到, topsemicgtopsemic-virtual-machine: -/nuc972/kernel/NUC970_Linux_Kernel-masters ar 网 none-linux-gnueabi arm-none-linux-gnueabi-addr 2line arm-none-linux-gnueabi-gcc-ranlib arm-none-linux-gnueabi-ar arm-none-linux-gnueabi-gcov arm-none-Linux-gnueabl-as arm-none-Linux-gnueabi-gdb arm-none-linux-gnueabi-C++ arm-none-linux-gnueabi-gprof arm-none-linux-gnueabt-C++filt arm-none-linux-gnueabl-ld arm-none-Linux-gnueabi-cpp arm-none-linux-gnueabi-nm arm-none-linux-gnueabi-cs arm-none-linux-gnueabi-objcopy arm-none-linux-gnueabi-cs-daemon arm-none-linux-gnueabi-objdump arm-none-linux-gnueabi-elfedit arm-none-1inux-gnueabi-ranlib arm-none-Linux-gnueabL-g++ arm-none-Linux-gnueabi-readelf arm-none-Linux-gnueabi-gcc arm-none-linux-gnueabi-size arm-none-Linux-gnueabi-gcc-4.8.3 arm-none -linux -gnueabi-strings arm-none-Linux-gnueabi-gcc-ar arm-none-linux-gnueabi-strip arm-none-Linux-gnueabi-gcc-nm topsemicgtopsemic-virtual-machine:/nuc972/kerneL/NUC970_Linux_Kernel-masters ar 于是又寻求度娘,有人说 Makefile路径问题,于是我再改一次,把绝对路径加 #ARCH ? S(SUBARCH) ARCH arm #CROSS COMPILE ? S(CONFIG CROSS COMPILE: %=9 绝对路径 CROSS COMP工LE /home/topsemic/nuc972/ toolchain/arm-201405/bin/arm-none- linux gnueabi- Architecture as present in compile. h 再来一次, 这次倒是没有刚才 arm-none-linux- gnueabi-gc找不到的可题,不过还是有一开始 提示的错误 www.topsemic.com init/init task o init/built-ino HOSTcc usr/gen init cpio /home/topsemic/nuc972/kernel/NUC970-Linux Kernel- master/scripts/gen initramfs list. sh: Cannot open ./rootfs home/topsemic/nuc972/kernel/NUC970 Linux Kernel-master/usr/Makefile: 67: recipe for target use/initramfs data cnio. 07 failed Makefile: 800: recipe for target 'usr, fatleo o make[1]: ** [usr/initramfs data cpio. gz Error 1 make: ** [usr] Error 2 这是怎么回事?我灵机一动,上面提示没有./ rootfs chome/topsemic/nuc972/kernel/NUC970-_Linux_Kernel-master/scripts/gen_initramfs ist. sh: Cannot open ./rootfs /home/topsemic/nuc972/kernel/ NUC970 Linux Kernel-master/usr/Makefile: 67: recipe for target 'usr/initramfs_data cpio. gz'failed make[1]: ** [usr/initramfs_data cpio. gz] Error 1 Makefile: 800: recipe for target 'usr failed make·*±★ 于是,我cd…,回到上级目录, mkdir rootfs建了一个 rootfs文件夹,再次进入刭 内核目录,输八 sudo make lmage 这一次看起来不人一样,好像要成功的样子, SKIPPED include/generated/compile. h KSYM tmp kallsyms1o KSYM tmp kallsyms2o vmLinux SORTEX vmlinux SYSMAP Syste.門ap OBJCOPY arch/arm/boot/Image Kernel: arch/arm/boot/T s aav arch/arm/boot/Image image/970image 尢法创建晋通文件',,/nage/97 image":没有那个文件或目录 Home/topsemicnuc72/kernel/Nuc970 Linux Kernel-master/arch/arm/boot/Makefile: 4 8: recipe for target 'arch/arm/boot/Image' failed make[1]: ** [arch/arm/boot/ Image]Error 1 home/topsemic/nuc972/kernel/NUC970_ Linux Kernel-master/arch/arm/Makefile: 296:r ecipe for target ' uImage' failed make:*** [UImage]Error 2 不过最后还是有点小问题,还是目录没有的问题,我们再回到上级目录建个文件 夹 Image topsemicgtopsemic-virtual-machine: -/nuc972/kernels mkdir image topsemicgtopsemic-virtual-machine: /nuc972/kernels cd i网aqe rootfs/ NUC970 Linux Kernel-master 最后再来一次 sudo make ullage www.topsemic.com arch/arm/boot/compressed/vmlLnu OBJCOPY arch/arm/boot/zImage KerneL: arch/arm/boot/zImage is ready UTMAGE arch/arm/boot /iMage mkimage" command not found. U-Boot images will not be built /home/topsemtc/nuc972/kerne t/NUC970 Linux Kernel-master/arch/arm/boot/Makefil 4: recipe for target 'arch/arm/boot/uImage' failed make[1]: ** [arch/arm/boot/iMage] Error 1 /home/topsemic/nuc972/kernel/NUC970 Linux Kernel-master/arch/arm/Makefile: 296 ecipe for target UImage' failed make ** [UImage] Error 2 怎么还有错误,我之前编译根本没有这些问题的啊,郁闷了。。 再次百度,说这个命令是 uboot编译出来的,因为没有找到它的原因,我看了下 我的 uboot里 tools目录,果然是有这个命令的, uboot NUC970 U-Boot v2016.11-master tools Q 巨用的 kwbimage. c kwbimage h kwbimage. o kwboot.c pC32xximage.c lpc32xximage.o Makefile microcode-tool microcode-tool py mingw support. c mingw support. h mkenvimage 刂服务器 mkenvimage. c mkenvimage. o mkexynosspL. c mkimage mkimage. c mkimage. c. cwweng mkimage cora mkimage h 2出中L:--2f4774LD1 有网友说把它复制到交叉编译链的bin目录里就行了,于是我放进去尝试,还是 有问题,最后又百度,有网友说 (htts: blog.csdn. net/wangliang8888 article/details,/54906729)还得改个名字,前 面得加上交叉编泽的名字,于是加上 arm-none-linux-gnueabi www.topsemic.com 件夹nuc972 toolchain arm201405bin gnueabl-cpp gnueabi-cs gnueaDl-CS-daemon arm-none-linux arm-none-linux- arm-none-linux gnueabi-elfedit gnueabi-g++ gnueabi-gcc arm-none-InUX- arm-none-linux- arm-none-tnux. gnueabi-gcc-4.8.3 gnueabi-gcc-ar gnueabi-gcc-nm arm-none-InUX- arm-none-InuX- arm-none-linux- gnueabi-gcc-ranlib gnueabI-gcov gnueabi-gdb arm-none-linux- arm-none-linux arm-none-linux gnueabi-gprof gnueabi-ld gnueabi-mkimage arm-none-InuX- arm-none-linux arm-none-linux- gnueabI-nm gnueabi-objcopy gnueabi-objdump 确|口 最后再次编译,终于大功告成,不容易啊!
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: