Buddy_Zhang1 发表于 2016-10-17 23:44

Kbuild 问题 -- tristate类型配置项无法设置为 m

我在调试 Kbuild 的时候,写了一个 Kconfig 文件,如下:
#
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/kconfig-language.txt
#
mainmenu "Linux/$ARCH $KERNELVERSION Kernel Configuration"

config BOOL_CONFIG
        bool "Use to debug bool"
        help
          You can utilize this symbol to get 'n' or 'y'

config STRING_CONFIG
        string "Use to debug string"
        help
          You can utilize this symbol to get a string

config TRISTATE_CONFIG
        tristate "Use to debug tristate"
        help
          You can utilize this symbol to get a tristate

config HEX_CONFIG
        hex "Use to debug hex"
        help
          You can utilize this symbol to get a hex value

config INT_CONFIG
        int "Use to debug int"
        help
          You can utilize this symbol to get an int value其中有个配置项目为 TRISTATE_CONFIG,其类型为 tristate, 按语法规则,其值可以是: y,m,n
但我使用 make menuconfig 进行配置的时候,该选项只能设置为 y 或者 n,无法设置为 m, 是我的配置写的有问题吗? 如何正确配置一个 tristate 配置为 m?


王楠w_n 发表于 2016-10-18 09:43

帮顶,虽然不会。

Buddy_Zhang1 发表于 2016-10-18 10:26

回复 2# 王楠w_n

依旧这么给力

Buddy_Zhang1 发表于 2016-10-18 11:43

本帖最后由 Buddy_Zhang1 于 2016-10-18 11:51 编辑

回复 2# 王楠w_n

版主,我建议在内核源码下面再增加一个板块,关于 Kbuild 的,这块对内核开发也很重要。

Kbuild 主要涉及了 Makefile 和 Kconfig 来构建内核的编译系统, 对 Kbuild 的了解有助于加深对内核组织和编译架构的了解。
Kbuild 内容涉及很广,包括 Kconfig 解析, .config 的生成过程,以及 Makefile 对各层目录的组织方式等,
涉及 C 等多种脚本语言。

希望版主能在内核源码板块下开一个新的话题来讨论这些问题。

王楠w_n 发表于 2016-10-18 13:00

回复 4# Buddy_Zhang1

好的,我跟本版版主商议下,有时间出个这方面的话题,大家一块讨论下

jeppeter 发表于 2016-10-18 23:42

#
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/kconfig-language.txt
#
mainmenu "Linux Kernel Configuration"

menuconfig MODULES
    bool "Enable loadable module support"
    option modules
    help
      Kernel modules are small pieces of compiled code which can
      be inserted in the running kernel, rather than being
      permanently built into the kernel.You use the "modprobe"
      tool to add (and sometimes remove) them.If you say Y here,
      many parts of the kernel can be built as modules (by
      answering M instead of Y where indicated): this is most
      useful for infrequently used options which are not required
      for booting.For more information, see the man pages for
      modprobe, lsmod, modinfo, insmod and rmmod.


config BOOL_CONFIG
      bool "Use to debug bool"
      help
          You can utilize this symbol to get 'n' or 'y'

config STRING_CONFIG
      string "Use to debug string"
      help
          You can utilize this symbol to get a string

config TRISTATE_CONFIG
      tristate "state with tri"
      help
          You can utilize this symbol to get a tristate

config HEX_CONFIG
      hex "Use to debug hex"
      help
          You can utilize this symbol to get a hex value

config INT_CONFIG
      int "Use to debug int"
      help
          You can utilize this symbol to get an int value
回复 1# Buddy_Zhang1
因为 tristate要依赖于MODULES这个编译选项,所以,你的原来的代码不成功,而加入了新的,可以成功运行了。

Buddy_Zhang1 发表于 2016-10-18 23:52

回复 6# jeppeter

非常谢谢你的帮助
经过你的建议,我的运行结果如下:


生成的 .config 如下


根据你提供的样板,我继续调试 Kbuild 系统,发现这样做的原因。

再次感谢!!!

nswcfd 发表于 2016-10-20 19:50

不知道是不是下面这句话的作用
@scripts/kconfig/menu.c::menu_check_dep(struct expr *e)
      case E_SYMBOL:
                /* change 'm' into 'm' && MODULES */
                if (e->left.sym == &symbol_mod)
                        return expr_alloc_and(e, expr_alloc_symbol(modules_sym));

页: [1]
查看完整版本: Kbuild 问题 -- tristate类型配置项无法设置为 m