linux\u5185\u6838 kconfig<\/strong>\uff0c\u5373\u6267\u884cmakemodules\u65f6\u5c31\u4f1a\u88ab\u7f16\u8bd1\u3002<\/p>\n2\u3001Kconfig<\/p>\n
\u6bcf\u4f4dconfig\u83dc\u5355\u9879\u90fd\u6709\u7c7b\u578b\u5b9a\u4e49:bool\u5e03\u5c14\u7c7b\u578b\u3001tristate\u4e09\u6001(\u5185\u5efa\u3001\u6a21\u5757\u3001\u79fb\u9664)\u3001string\u5b57\u7b26\u4e32\u3001hex\u5341\u516d\u8865\u7801\u3001integer\u6574\u578b\u3002<\/p>\n
\u4f5c\u7528\uff1a\u51b3\u5b9amakemenuconfig\u65f6\u5c55\u793a\u7684\u83dc\u5355\u9879\uff0c<\/p>\n
\u53c2\u8003\uff1alinux-3.4.2\/drivers\/leds\/kconfig\uff1a<\/p>\n
configLEDS_S3C24XX<\/p>\n
tristate\"LEDSupportforSamsungS33CC2424XXGPIOLEDs\"<\/p>\n
dependsonLEDS_CLASS<\/p>\n
dependsonARCH_S3C24XX<\/p>\n
help<\/p>\n
ThisoptionenablessupportforLEDsconnectedtoGPIOlines<\/p>\n
<\/p>\n
onSamsungS33CC2424XXseriesCPUs,suchastheS3C2410andS3C2440.<\/p>\n
LEDS_S3C24XX\uff1a\u914d\u7f6e\u9009\u9879\u7684\u540d\u79f0\uff0c\u7701\u7565\u4e86\u524d\u7f00\"CONFIG_\"<\/p>\n
Tristate\uff1a<\/p>\n
\u8868\u793a\u8be5\u9879\u662f\u5426\u7f16\u8fdb\u5185\u6838\u3001\u7f16\u6210\u6a21\u5757\u3002\u663e\u793a\u4e3a,\u5982\u679c\u9009\u62e9\u7f16\u8bd1\u6210\u5185\u6838\u6a21\u5757\uff0c\u5219\u4f1a\u5728.config\u4e2d\u751f\u6210\u4e00\u4e2aCONFIG_HELLO_MODULE=m\u7684\u914d\u7f6e\uff0c\u9009\u62e9Y\u5c31\u662f\u76f4\u63a5\u7f16\u8fdb\u5185\u6838\uff0c\u4f1a\u5728.config\u4e2d\u751f\u6210\u4e00\u4e2aCONFIG_HELLO_MODULE=y\u7684\u914d\u7f6e\u9879\u3002Tristate\u540e\u7684\u5b57\u7b26\u4e32\u662fmakemenuconfig\u65f6\u663e\u793a\u7684\u914d\u7f6e\u9879\u540d\u79f0\u3002<\/p>\n
bool\uff1a<\/p>\n
\u8fd9\u79cd\u578b\u53ea\u80fd\u9009\u4e2d\u6216\u4e0d\u9009\u4e2d\uff0cmakemenuconfig\u65f6\u663e\u793a\u4e3a[]\uff0c\u5373\u96be\u4ee5\u914d\u7f6e\u6210\u6a21\u5757\u3002<\/p>\n
dependon:<\/p>\n
\u8be5\u9009\u9879\u4f9d\u8d56\u4e8e\u53e6\u4e00\u4e2a\u9009\u9879\uff0c\u53ea\u6709\u5f53\u4f9d\u8d56\u9879\u88ab\u9009\u4e2d\u65f6\uff0c\u5f53\u524d\u914d\u7f6e\u9879\u7684\u63d0\u793a\u4fe1\u606f\u5c31\u4f1a\u51fa\u73b0\uff0c\u624d\u4f1a\u8bbe\u7f6e\u5f53\u524d\u914d\u7f6e\u9879\u3002<\/p>\n
select:<\/p>\n
\u53cd\u5411\u4f9d\u8d56\u5173\u7cfb\uff0c\u8be5\u9009\u9879\u9009\u4e2d\u65f6\uff0c\u540c\u65f6\u9009\u4e2dselect\u524d\u9762\u5b9a\u4e49\u7684\u90a3\u4e00\u9879\u3002<\/p>\n
help\uff1a<\/p>\n
\u5e2e\u52a9\u4fe1\u606f\u3002<\/p>\n
\u76ee\u5f55\u5c42\u6b21\u8fed\u4ee3\uff1a<\/p>\n
Kconfig\u4e2d\u6709\u7c7b\u4f3c\u53e5\u5b50\uff1asource\"drivers\/u***\/Kconfig\"\uff0c\u62ff\u6765\u5305\u542b\uff08\u6216\u5d4c\u5957\uff09\u65b0\u7684Kconfig\u6587\u4ef6\uff0c\u4fc3\u4f7f\u5404\u4e2a\u76ee\u5f55\u7ba1\u7406\u5404\u81ea\u7684\u914d\u7f6e\u5185\u5bb9\uff0c\u4f55\u5fc5\u628a\u8fd9\u4e9b\u914d\u7f6e\u90fd\u5199\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u91cc\uff0c\u4fbf\u6377\u66f4\u6539\u548c\u7ba1\u7406\u3002<\/p>\n
<\/p>\n
3\u3001.config<\/p>\n
\u53c2\u8003\uff1alinux-3.4.2\/.config<\/p>\n
\u901a\u8fc7\u524d\u4fe9\u4e2a\u6587\u4ef6\u7684\u5256\u6790\uff0c.config\u7684\u6db5\u4e49\u5df2\u7136\u5f88\u6e05\u6670\uff1a\u5185\u6838\u7f16\u8bd1\u53c2\u8003\u6587\u4ef6\uff0c\u67e5\u770b\u4e0a\u9762\u5185\u5bb9\u53ef\u4ee5\u6653\u5f97\u4ec0\u4e48\u9a71\u52a8\u88ab\u7f16\u8bd1\u8fdb\u5185\u6838\u3002<\/p>\n
\u914d\u7f6e\u5185\u6838\u65b9\u6cd5\u67093\u79cd(\u4efb\u9009\u5176\u4e09)\uff1a<\/p>\n
\uff081\uff09makemenuconfig<\/p>\n
\uff082\uff09makexxx_defconfig<\/p>\n
\uff083\uff09\u76f4\u63a5\u66f4\u6539.config<\/p>\n
\u6ce8\u610f:\u5018\u82e5\u76f4\u63a5\u66f4\u6539.config\uff0c\u4e0d\u4e00\u5b9a\u4f1a\u751f\u6548\uff0c\u7531\u4e8e\u6709\u4e9b\u914d\u7f6e\u53ef\u80fd\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\uff0cmake\u65f6\u4f1a\u4f9d\u7167\u4f9d\u8d56\u5173\u7cfb\uff0c\u8fdb\u884c\u89c4\u5219\u7684\u68c0\u6d4blinux\u5185\u6838 kconfig<\/strong>\uff0c\u76f4\u63a5\u66f4\u6539.config\u6709\u65f6\u65e0\u6548\uff0c\u6240\u4ee5\u4e0d\u63a8\u8350\u76f4\u63a5\u66f4\u6539\u3002<\/p>\n\u4ee5\u4e0a\u53ef\u80fd\u6709\u70b9\u5177\u8c61\uff0c\u4e0b\u8fb9\u4e3e\u4f8b\u8bf4\u660e\uff1a<\/p>\n
\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u5165\u53e3\u51fd\u6570\u8f93\u51fahelloworld\u7684\u9a71\u52a8\u5e76\u7f16\u8bd1\u8fdb\u5185\u6838\u3002<\/p>\n
\u6b65\u9aa4\uff1a<\/p>\n
\uff081\uff09\u5728drivers\u76ee\u5f55\u4e0b\u65b0\u5efahello\u6587\u4ef6\u5939\uff0c\u4e0a\u9762\u5b9e\u73b0hello.c\u3001Makefile\u3001Kconfig\u3002<\/p>\n
hello.c\uff1a<\/p>\n
#include<\/p>\n
<\/p>\n
#include<\/p>\n
#include<\/p>\n
staticintfirst_drv_init(void)<\/p>\n
printk(\"------------------helloworld!--------------------\");<\/p>\n
return0;<\/p>\n
staticvoidfirst_drv_exit(void)<\/p>\n
printk(\"------------------exithelloworld!--------------------\");<\/p>\n
module_init(first_drv_init);<\/p>\n
module_exit(first_drv_exit);<\/p>\n
MODULE_LICENSE(\"GPL\");<\/p>\n
Makefile\uff1a<\/p>\n
obj-$(CONFIG_HELLO)+=hello.o<\/p>\n
Kconfig\uff1a<\/p>\n
configHELLO<\/p>\n
tristate\"HelloWorldforfengyuwuzu\"<\/p>\n
help<\/p>\n
Helloforfengyuwuzu<\/p>\n
configHELLO\u51b3\u5b9a\u540d\u5b50\uff1aCONFIG_HELLO\u3002<\/p>\n
HelloWorldforfengyuwuzu\uff1a\u51b3\u5b9a\u4e86\u5728makemenuconfig\u65f6\u663e\u793a\u7684\u540d\u5b50<\/p>\n
\uff082\uff09\u66f4\u6539\u4e0a\u4e00\u7ea7\uff08Linux-3.4.2\/drivers\u4e0b\uff09\u7684Makefile\u3001Kconfig\u3002<\/p>\n
Makefile\uff1a<\/p>\n
obj-y+=hello\/<\/p>\n
Kconfig\uff1a<\/p>\n
source\"drivers\/hello\/Kconfig\"<\/p>\n
\uff083\uff09makemenuconfig<\/p>\n
\uff084\uff09makeuImage\u518d\u70e7\u8bb2\u5230\u5f00\u53d1\u677f\u3002<\/p>\n
\u67e5\u770b\u5185\u6838\u542f\u52a8Log\uff0c\u4f1f\u5927\u7684helloworld\u4e0b\u6765\u4e86\uff01\u8bf4\u660ehello.c\u6210\u529f\u7f16\u8fdb\u5185\u6838<\/p>\n
\u6b22\u8fce\u53c2\u8003\u672c\u6587\u5b9e\u9a8clinux \u4e0b\u8f7d\uff0c\u76f8\u4fe1\u4f60\u5bf9\u5185\u6838\u7684\u7ec4\u7ec7\u7ed3\u6784\u4f1a\u6709\u66f4\u6e05\u6670\u7684\u8ba4\u8bc6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
.config\uff1a\u7f16\u8bd1\u5185\u6838\u6240\u4f9d\u636e\u7684\u914d\u7f6e\u3002\u6839\u636e.config\u6587\u4ef6\u7684CONFIG_XXX\u6765\u51b3\u5b9a\u6587\u4ef6\u662f\u5426\u7f16\u8fdb\u5185\u6838\u3002\u53c2\u8003\uff1alinux-3.4.2\/drivers\/leds\/kconfig\uff1a3\u3001.config\u53c2\u8003\uff1alinux-3.4.2\/.config\uff083\uff09\u76f4\u63a5\u4fee\u6539.config<\/p>\n","protected":false},"author":1,"featured_media":293014,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[3033,3032,2456,1076,1642],"class_list":["post-293013","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-cwj","tag-k-9","tag-m-16","tag-nh","tag-yf"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/293013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=293013"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/293013\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/293014"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=293013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=293013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=293013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}