Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
  • Groups
    • Research Collaboration and Enablement
    • DesignStart
    • Education Hub
    • Innovation
    • Open Source Software and Platforms
  • Forums
    • AI and ML forum
    • Architectures and Processors forum
    • Arm Development Platforms forum
    • Arm Development Studio forum
    • Arm Virtual Hardware forum
    • Automotive forum
    • Compilers and Libraries forum
    • Graphics, Gaming, and VR forum
    • High Performance Computing (HPC) forum
    • Infrastructure Solutions forum
    • Internet of Things (IoT) forum
    • Keil forum
    • Morello Forum
    • Operating Systems forum
    • SoC Design and Simulation forum
    • 中文社区论区
  • Blogs
    • AI and ML blog
    • Announcements
    • Architectures and Processors blog
    • Automotive blog
    • Graphics, Gaming, and VR blog
    • High Performance Computing (HPC) blog
    • Infrastructure Solutions blog
    • Innovation blog
    • Internet of Things (IoT) blog
    • Operating Systems blog
    • Research Articles
    • SoC Design and Simulation blog
    • Tools, Software and IDEs blog
    • 中文社区博客
  • Support
    • Arm Support Services
    • Documentation
    • Downloads
    • Training
    • Arm Approved program
    • Arm Design Reviews
  • Community Help
  • More
  • Cancel
中文社区
中文社区
中文社区博客 【Rayeager PX2分享】最简单helloworld驱动编写
  • Blogs
  • Forum
  • 视频和文件
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
  • New
中文社区 requires membership for participation - click to join
More blogs in 中文社区
  • ARM中国大学计划博客

  • Arm新闻

  • 中文mbed博客

  • 中文社区博客

  • 恩智浦汽车电子MCU讨论区博客

 

Tags
  • Android
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

【Rayeager PX2分享】最简单helloworld驱动编写

Jean Wang 王婧
Jean Wang 王婧
June 2, 2015
Less than one minute read time.

论坛里应该有一部分人是想学驱动,却不知道该怎么入门吧,在这里我教大家写一个helloworld的简单随linux内核加载的驱动。

1.首先在/kernel/drivers下建一个新的文件夹hello,在文件夹里添加四个文件分别是hello.c,hello.hKconfig,Makefile,

hello.c文件里也有注释,这个文件主要就是为了注册和初始化设备文件以及定义驱动接口,主要是用啦file_operations这个结构体,大家想了解驱动可以先了解这个,这个程序里的注释可以帮助大家理解下一个简单驱动的结构

2.修改Kconfig,内容如下

1.png 

3.修改Makefile,内容如下

2.png 

4.返回dirvers目录下修改Kconfig,在最后加一句:source"drivers/hello/Kconfig"

5.修改Makefle文件,在里面添加一句   obj-$(CONFIG_HELLO_TEST)       += hello/

6.返回kernel目录下,执行makemenuconfig 在/driver路径下找到设备,选定(注:这里设备的名字和我们之前写的Kconfig有一定的关系,修改Kconfig的相应的参数,可以改变menu下的名字)

3.png

,然后返回

makekernel.img

7,然后创建测试文件,在driver目录下创建目录hellotest,加入两个文件test和Android.mk

然后mm,在sdk/out/target/product/rkpx2/system/bin目录下找到测试文件,(如mm无法执行,可在根目录下执行下sourcebuild/envsetup.sh)

8.最后测试下结果,在window目录下,用adb工具把测试文件push进板中,然后在文件所在的位置给文件赋上权限,执行chmod777  test

执行./testhello 或./testgoodbye可看到结果如下,即驱动可成功加载

4.png
4987.zip
Anonymous
中文社区博客
  • Arm A-Profile构架2022扩展

    Zenon Xiu (修志龙)
    Zenon Xiu (修志龙)
    原文:Arm A-Profile Architecture Developments 2022 - Architectures and Processors blog - Arm Community blogs - Arm Community  作者:Martin Weidmann翻译:修志龙(Zenon Xiu) 与arm构架授权和生态伙伴一起,arm持续演进其构架,开发新功能以满足现有和新市场的要求…
    • October 17, 2022
  • 深入理解 Arm A-profile的non-maskable interrupt -NMI

    Zenon Xiu (修志龙)
    Zenon Xiu (修志龙)
    原文: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/a-profile-non-maskable-interrupts  翻译: 修志龙 Zenon Xiu Arm A-profile构架一个长久以来的局限性是:缺乏对non-maskable interrupt (NMI…
    • August 24, 2022
  • Arm A-Profile 构架2021扩展

    Zenon Xiu (修志龙)
    Zenon Xiu (修志龙)
    原文: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2021 Martin Weidmann September 8, 2021 翻译注释:Zenon Xiu Arm与arm构架授权公司及生态伙伴一起…
    • August 17, 2022