port linux & ramdisk

来源:互联网 发布:mac可以加硬盘吗 编辑:程序博客网 时间:2024/05/18 00:47


呆着无聊,写个linux配置和ramdisk相关的笔记。


由于 Linux 内核源代码是按照树形结构组织的,所以 Makefile 也被分布在目录树中。Linux 内核中的 Makefile 以及与 Makefile 直接相关的文件有:

  1. Makefile:顶层 Makefile,是整个内核配置、编译的总体控制文件。
  2. .config:内核配置文件,包含由用户选择的配置选项,用来存放内核配置后的结果(如 make config)。
  3. arch/*/Makefile:位于各种 CPU 体系目录下的 Makefile,如 arch/arm/Makefile,是针对特定平台的 Makefile。
  4. 各个子目录下的 Makefile:比如 drivers/Makefile,负责所在子目录下源代码的管理。
  5. Rules.make:规则文件,被所有的 Makefile 使用。

用户通过 make config 配置后,产生了 .config。顶层 Makefile 读入 .config 中的配置选择。顶层 Makefile 有两个主要的任务:产生 vmlinux 文件和内核模块(module)。为了达到此目的,顶层 Makefile 递归的进入到内核的各个子目录中,分别调用位于这些子目录中的 Makefile。至于到底进入哪些子目录,取决于内核的配置。在顶层 Makefile 中,有一句:include arch/$(ARCH)/Makefile,包含了特定 CPU 体系结构下的 Makefile,这个 Makefile 中包含了平台相关的信息。

鄙人之前还写过一篇文章: 

linux make menuconfig\Makefile\Kconfig 详解

http://blog.csdn.net/codectq/article/details/9797031

获取linux源码:

sudo git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

获取交叉编译工具

sudo apt-get install gcc-arm-linux-gnueabi

解决缺库的问题

*** Unable to find the ncurses libraries or the
*** required header files.
*** ‘make menuconfig’ requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.

解决办法:

sudo apt-get install ncurses-dev

解决直接编译报错的问题

 HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  HOSTLD  arch/x86/tools/relocs
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'.  Stop.

方法是需要配置ARCH和CROSS_COMPILE,设置正确值

配置ramdisk




2 0
原创粉丝点击