朝花夕拾---Kconfig的一些总结

前言

  Kconfig的一些知识,是我在17年3月份从零移植U-boot的时候学习的,今天重新看当年写的博文,竟然看不懂了。包括笔者之前写的很多文章,也有很多都忘记了。所以,遗忘很正常,博客存在的作用,就是为了像现在这样可以方便拾起来以前的东西。

原文回顾

中间的插曲 翻译之doc/readme.kconfig

  该篇文章基于内核readme,权威性自然不必说。总结下:


  • 2014年10月,内核的kconfig架构移植到了uboot中。
  • 在一些make目标上,内核和uboot的行为有所区别,但是uboot为了向后兼容性保留了一些make目标,例如:< board>_config
  • 现在uboot2018-8还是没有做到完全的使用kconfig架构,所以基于C预处理机制的配置架构和基于kconfig的配置架构将会共存。
  • 以前的板级信息boards.cfg转移到kconfig中。
  • 在Kconfig架构下,添加一个单板的步骤:

[1] Add a header file include/configs/< target>.h
[2] Make sure to define necessary CONFIG_SYS_* in Kconfig:
[3] Add a new entry to the board select menu in Kconfig.
[4] Add a MAINTAINERS file
[5] Add configs/< target>_defconfig

从零移植uboot 2017 到nuc970(第九天)
  在该篇记录中,我初探了kconfig的一些语法,语法相关信息可以在内核找到,也可以看网友总结的简单版。简单来说kconfig的菜单项大部分是由Menu结构组成,然后顶层的Kconfig会通过source来包含底层目录的Kconfig,组建成了一个完整的kconfig框架。

  Menu structure
--------------

The position of a menu entry in the tree is determined in two ways. First
it can be specified explicitly:

menu "Network device support"
    depends on NET

config NETDEVICES
    ...

endmenu

All entries within the "menu" ... "endmenu" block become a submenu of
"Network device support". All subentries inherit the dependencies from
the menu entry, e.g. this means the dependency "NET" is added to the
dependency list of the config option NETDEVICES.

从零移植uboot 2017 到nuc970(第十天)
  在该篇中又总结了一下,kconfig的一些机制。现在比较简单的复述如下:
1. make menuconfig图形化配置是Kconfig的一个优点
2. make xxx_defconfig代替了人手的选择,只要提前将需要配置的项放置在configs/xxx_defconfig文件中。(这里配置项指Kconfig中的项)
3. 现在的Kconfig框架和以前的基于C预编译的配置文件机制并存,代表了筛选编译代码的生成文件,及筛选编译文件的生成文件共存。主要生成文件为根目录下的.config.h,为之后的makefile的选择编译和C源文件的条件编译提供基础。

最后

  结合Linux 内核配置机制(make menuconfig、Kconfig、makefile)讲解更正自己上面说法不准确的地方,Uboot的Kconfig并非与内核完全一致,朝花夕拾以前的知识就这么结束了。

猜你喜欢

转载自blog.csdn.net/LoveStackover/article/details/81479611