zoukankan      html  css  js  c++  java
  • 内核与驱动编译方法

    驱动编译有两种方法:

    1. 编译到内核中

    2. 编译为独立模块

    建立方法:

      1) 在linux源码树的驱动目录增加自己的驱动目录,比如:现在新增一个网络设备驱动

        mkdir linux_tree/drivers/net/poker_driver -p

        cd linux_tree/drivers/net/poker_driver

      2) 编写驱动源码

        vi  poker_drv_part1.c

        vi  poker_drv_part2.c

        vi  poker_drv_part3.c

      3) 编写源码目录Kconfig

        vi Kconfig

          config POKER_DRV
          tristate "poker_driver support"
          default n
          ---help---
          If you say Y here, the kernel will support poker_driver.
          If you say M here, the kernel not support poker_driver, must perform "insmod poker_driver.ko".
          If you say N here, the kernel not support poker_driver.

      4) 编写源码目录Makefile

        vi Makefile

          obj-$(CONFIG_POKER_DRV) += poker_drv.o
          poker_drv-objs += poker_drv_part1.o poker_drv_part2.o poker_drv_part3.o

      5) 修改上级Kconfig

        vi linux_tree/drivers/net/Kconfig

          source "drivers/net/poker_driver/Kconfig"

      6) 修改上级Makefile

         vi linux_tree/drivers/net/Makefile

          obj-$(CONFIG_POKER_DRV) += poker_driver/

      7) 配置内核

        make menuconfig

          Device Drivers  --->

             [*] Network device support  ---> 

              <>poker_driver support

    1. 编译到内核中:

      <*>poker_driver support

      linux_tree# make uImage

    2. 编译为独立模块

      <M>poker_driver support 

      linux_tree# make modules

    括号问题:

      []   可选项 * 空

      <> 可选项 * M 空

    Kconfig语法:

    Makefile语法:

    未完待续....

  • 相关阅读:
    golang 的几个入门资料
    docker 容器网络基础
    nginx 容器反向代理网址的设置
    【知乎Live】狼叔:如何正确的学习Node.js
    nginx资料汇总
    web 框架
    work behind corp proxy
    [转载] 历史上前端领域的重要技术革命
    前后端要不要分离以及如何做
    微电子工艺基础知识讲解(集成电路历史/厂商/产业链)
  • 原文地址:https://www.cnblogs.com/pokerface/p/5780159.html
Copyright © 2011-2022 走看看