linux开发摘要

1.linux内核文档链接点击打开链接

2.配置文件

在out\target\product\project\obj\KERNEL_OBJ\.config中可以看到

 

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # CONFIG_MTD_LPDDR is not set  
  2. # CONFIG_MTD_UBI is not set  
  3. CONFIG_DTC=y  
  4. CONFIG_OF=y  
  5.   
  6.   
  7. #  
  8. # Device Tree and Open Firmware support  
  9. #  
  10. # CONFIG_PROC_DEVICETREE is not set  
  11. # CONFIG_OF_SELFTEST is not set  
  12. CONFIG_OF_FLATTREE=y  
  13. CONFIG_OF_EARLY_FLATTREE=y  
  14. CONFIG_OF_ADDRESS=y  
  15. CONFIG_OF_IRQ=y  
  16. CONFIG_OF_DEVICE=y  
  17. CONFIG_OF_I2C=y  
  18. CONFIG_OF_NET=y  
  19. CONFIG_OF_MDIO=y  
  20. CONFIG_OF_SPMI=y  
  21. CONFIG_OF_MTD=y  
  22. CONFIG_OF_SLIMBUS=y  
  23. CONFIG_OF_BATTERYDATA=y  
  24. CONFIG_OF_RESERVED_MEM=y  
  25. ...  

但这个文件是自动生成的,应该主要是由\kernel\arch\arm\configs下的文件汇总的,但是没有找到定义CONFIG_OF=y的源头。

对于msm8909平台user版本,.config文件是由msm8909-1gb_defconfig、kernel下Kconfig文件内容汇总在一起。每个Kconfig分别描述了所属目录源文件相关的内核配置菜单

但如果msm8909-1gb_defconfig注释了#CONFIG_QPNP_VM_BMS=y,但W:\kernel\drivers\power\Kconfig下对应的下有default=y,最后是以Kconfig的为准的

config QPNP_VM_BMS
tristate "QPNP Voltage-Mode Battery Monitoring System driver"
depends on SPMI
depends on MSM_QPNP_INT
default y
help
  Say Y here to enable support for QPNP chip vm-bms device.
  The voltage-mode (vm) BMS driver uses periodic VBATT
  readings from the battery to calculate the State of
  Charge.

如果Kconfig没有default,msm8909-1gb_defconfig的为#CONFIG_QPNP_VM_BMS=y或是CONFIG_QPNP_VM_BMS=,也就是没有选择或是没有设置,就在.config文件中插入一行注释# CONFIG_QPNP_VM_BMS is not set

3.主要的设备树文件

 \kernel\Documentation\devicetree\bindings\fb\mdss-dsi-panel.txt描述显示屏panel的配置信息
kernel\Documentation\devicetree\bindings\arm\gic.txt-----ARM Generic Interrupt Controller,ARM一般中断控制器设备树信息描述
kernel\Documentation\devicetree\bindings\interrupt-controller\interrupts.txt----Specifying interrupt information for devices

 \kernel\Documentation\input\input.txt和input-programming.txt介绍输入子系统

\kernel\Documentation\devicetree\bindings\pinctrl\msm-pinctrl.txt------------MSM TLMM pinmux controller

kernel\Documentation\devicetree\bindings\pinctrl\pinctrl-bindings.txt

 

4..CONFIG_OF

在一些驱动中经常看到#ifdef CONFIG_OF,这里的OF是Open Firmware。

Open Firmware. This was invented long time ago when Apple was producing laptops based on PowerPC CPUs. Openfirmware provides a good description of the devices connected to the platform. In Linux kernel the part that works with device data is called Device Tree (DT). More details in the Usage model.

详细参考kernel\Documentation\devicetree\usage-model.txt

 

5.mk文件(makefile)

 

 += (在现有的文件上,追加)
:= (之前的值清空,重新赋值)

 

6.fdt:flatteneddevice tree

 

7.modules.order:这个文件记录了Makefile中模块出现的顺序。modprobe通过它来确定解决多个模块匹配的别名(指定模块的绝对路径)。
如:kernel//home/cjz/Desktop/test/driver/input/vms.ko
 modules.builtin:这个文件列出了所有编译到内核的模块,通过这个当modprobe加载一些内核模块时就不会失败。

 

8.注册驱动的时候,通过对应的总线匹配到对应的设备,设备在设备树中有对应的描述,在bootloader阶段会传递设备树内容给内核,匹配到对应的设备后调用驱动的probe函数

设备树中每个表示一个设备的节点都需要一个 compatible 属性。compatible 属性是操作系统用来决定使用哪个设备驱动来绑定到一个设备上的关键因素

 

9.典型的外设、核心和主机驱动图

10.设备树英文文档链接点击打开链接

11.驱动加载顺序

优先级定义在include/linux/init.h,其中对于同一级别的 __initcall的次序 主要由MakeFile中.o文件的链接次序决定,具体看Kernel下的主Makefile ---- Build vmlinux以及kernel/driver 下的obj-y

12.linux为什么要挂载到/mnt或其它目录,直接访问/dev不行吗?

/dev是不加文件系统的,只能通过read/write命令对他进行读写。但是你看不到的。想要看到他里面有那个文件或者文件夹,只有加载了文件系统,才可以。所以你用mount命令的时候要加-t指定文件系统,例如:mount -t vfat /dev/hda1 /mnt,挂载/dev/hda1设备到/mnt,文件系统是vfat。

posted @ 2016-03-02 10:35  LoongEmbedded  阅读(1074)  评论(0编辑  收藏  举报