• 《Android深度探索》(卷1)HAL与驱动开发 第四章心得体会


    本书的第四章讲的是源代码的下载和编译。分为Android源代码和Linux内核源代码。Android移植主要就是Linux内核的移植。而Linux内核移植主要是Linux驱动的移植。所以为了开发和测试Linux驱动,需要在Ubuntu Linux 下搭建两套开发环境:Android应用程序开发环境和Linux内核开发环境。其中Linux内核开发环境是重点。

    一.环境搭建步骤

         下载Linux源码 

     1.~#apt-cache search linux-source

    出现:linux-source - Linux kernel source with Ubuntu patches
               linux-source-3.0.0 - Linux kernel source for version 3.0.0 with Ubuntu patches

      2.~#apt-get   install linux-source-3.0.0

                      下载完成后,在/usr/src/下会出现一个linux-source-3.0.0.tar.bz2。解压:      tar  jxvf   linux-source-3.0.0.tar.bz2

      3.然后在Linux内核源码目录/usr/src/linux-source-2.6.32目录下面用老的方法配置好Linux内核:

                     ~#make oldconfig

      4.编译内核:~#make     //大概需要一个小时

      5.编译模块:~#make modules

      6.安装模块:~#make modules_install

      以上步骤完成后,会在/lib/modules 目录下生成一个文件夹3.0.0-12-generic

    二.hello.c

     

    三.Makefile

    四.~#make   //生成文件如下

    hello.c   hello.ko     hello.mod.o  Makefile   modules.order
    hello.c~  hello.mod.c  hello.o      Makefile~  Module.symvers

    1.装载目标模块:~#insmod  ./hello.ko

         ~#lsmod  //查看目前安装的驱动模块,有hello 

    2.模块装载触发hello.cinit()方法,输出hello world,如果没有的话,是因为其将输出放到/var/log/syslog中去了。打开便可以看见你的结果!

    卸载目标模块命令是:~#rmmod ./hello.ko

    通过对第四章的学习,我知道了学好Linux驱动的移植是十分重要的。

    http://www.cnblogs.com/z378560707/

  • 相关阅读:
    针对大数据量 高并发量网站的解决方案
    session cookie 在用户登录中的使用
    彻底弄懂HTTP缓存机制及原理
    cookie 和session 的区别详解
    常见的浏览器兼容性问题
    内容分发网络(CDN)
    表现与数据分离、Web语义化
    关于bootstrap样式重写,无法覆盖的问题
    判断一个字符串中出现次数最多的字符
    [译]SQL Passion Week 10: 计划缓存
  • 原文地址:https://www.cnblogs.com/z378560707/p/5446182.html
Copyright © 2020-2023  润新知