上篇文章(【i.MX6ULL】驱动开发3——GPIO寄存器配置原理),介绍了i.MX6ULL芯片的GPIO的工作原理与寄存器配置。
上一篇我们分享了字符设备驱动框架:嵌入式Linux驱动基础,当时分享的是hello驱动程序。学STM32我们从点灯开始,学Linux驱动我们自然也要点个灯来玩玩,尽量在从这些基础例程中榨取知识,细抠、细抠,为之后更复杂的知识打好基础。
今天和大家分享的依然是设备树,上一节里主要是介绍了设备树文件的基本格式、语法规则等,今天介绍一下如何使用设备树,以及如何动态加载设备树。
距离上一次更新有一段时间了,主要是最近更忙一些,一般来说,有时间我会尽量更新,如果比较忙的话就更新慢一些。
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huangweiqing80/article/details/83347495
前言: 简单回顾一下前文,《内存映射技术分析》描述了虚拟内存的管理、内存映射;《物理内存管理》介绍了物理内存管理。《内存回收》介绍了一下PFRA内存回收。 上述三篇,简单建立Linux的内存管理模型,下面开始分析MMIO技术。 分析: 1,MMIO MMIO,即Memory mapping I/O;在x86上,CPU如果想要和外部交互数据,一种是使用in、out类型的端口访问的指令;一种是mov类型的读写内存的指令。对于前者来讲,就是PortIO(PIO);对于后者,就是MMIO。(这里说明一下,ARM
上次跟大家分享了设备模型的一些东西,包括总线、设备、驱动等的一些概念,还有他们之间的联系。今天要分享的是platform总线驱动,platform总线是总线的一种,这是相对于物理总线来说的,这是一种虚拟的总线。
iomem=str mem=str Fio can use various types of memory as the io unit buffer. The allowed values are: malloc Use memory from malloc(3) as the buffers. shm Use shared memory as the buffers. Allocated through shmget(2). shmhuge Same as shm, but use huge pages as backing. mmap Use mmap to allocate buffers. May either be anonymous memory, or can be file backed if a filename is given after the option. The format is mem=mmap:/path/to/file. mmaphuge Use a memory mapped huge file as the buffer backing. Append filename after mmaphuge, ala mem=mmaphuge:/hugetlbfs/file mmapshared Same as mmap, but use a MMAP_SHARED mapping. The area allocated is a function of the maximum allowed bs size for the job, multiplied by the io depth given. Note that for shmhuge and mmaphuge to work, the system must have free huge pages allocated. This can normally be checked and set by reading/writing /proc/sys/vm/nr_hugepages on a Linux system. Fio assumes a huge page is 4MB in size. So to calculate the number of huge pages you need for a given job file, add up the io depth of all jobs (normally one unless iodepth= is used) and multiply by the maximum bs set. Then divide that number by the huge page size. You can see the size of the huge pages in /proc/meminfo. If no huge pages are allocated by having a non-zero number in nr_hugepages, using mmaphuge or shmhuge will fail. Also see hugepage-size. mmaphuge also needs to have hugetlbfs mounted and the file location should point there. So if it'smountedin/huge,youwouldusemem=mmaphuge:/huge/somefile.iomem_align=intThisindiciatesthememoryalignmentoftheIOmemorybuffers.NotethatthegivenalignmentisappliedtothefirstIOunitbuffer,ifusingiodepththealignmentofthefollowingbuffersaregivenbythebsused.Inotherwords,ifusingabsthatisamultipleofthepagesizedinthesystem,allbufferswillbealignedtothisvalue.Ifusingabsthatisnotpagealigned,thealignmentofsubsequentIOmemorybuffersisthesumoftheiomem_alignandbsused.hugepage-size=intDefinesthesiz
Clock 时钟就是 SoC 中的脉搏,由它来控制各个部件按各自的节奏跳动。比如,CPU主频设置,串口的波特率设置,I2S的采样率设置,I2C的速率设置等等。这些不同的clock设置,都需要从某个或某几个时钟源头而来,最终开枝散叶,形成一颗时钟树。可通过 cat /sys/kernel/debug/clk/clk_summary 查看这棵时钟树。
复制一份imx_v6_v7_defconfig,这里我命名为dfos_mini_defconfig。
1)物理地址:CPU地址总线传来的地址,由硬件电路控制其具体含义。物理地址中很大一部分是留给内存条中的内存的,但也常被映射到其他存储器上(如显存、BIOS等)。在程序指令中的虚拟地址经过段映射和页面映射后,就生成了物理地址,这个物理地址被放到CPU的地址线上。
设备驱动程序是软件概念和硬件电路之间的一个抽象层,软件操作硬件的关键就是对寄存器的操作。笔者使用的S5PV210是IO与内存统一编址的,在裸机中直接操作IO端口的物理地址,而在驱动中必须使用虚拟地址。直接基于IO的虚拟地址用指针解引用的方式来读写有两种方式,静态映射和动态映射。除了可以直接将指针解引用的方式,内核中提供了专用的读写接口来读写寄存器。考虑到GPIO作为硬件资源,存在着被多个驱动使用,还有复用的问题,所以内核提供了GPIO驱动gpiolib框架来统一管控GPIO资源,gpiolib在内核中作为一个驱动所实现。
资料下载 coding无法使用浏览器打开,必须用git工具下载: git clone https://e.coding.net/weidongshan/linux/doc_and_source_for_drivers.git 视频观看 百问网驱动大全 Framebuffer驱动程序框架 1. 怎么编写字符设备驱动程序 📷 驱动主设备号 构造file_operations结构体,填充open/read/write等成员函数 注册驱动:register_chrdev(major, name, &fops) 入
独立编址,统一编址: I/O地址空间与内存地址空间编址方式是否统一?例如51为统一编址,I/O和存储器总计64K地址空间;X86为独立编址,分为I/O地址空间和存储器地址空间。 IO空间,内存空间
usb协议是一个复杂的协议,目前涉及到的版本就有usb1.0, usb2.0, usb3.0。大家如果打开kernel usb host目录,就会发现下面包含了ohci,uhci,ehci,xhci,whci等多种形式的控制器驱动。那么,对于我们这些不是很了解usb的开发人员,如何了解usb的代码结构呢?
NXP官方linux仓库地址为:https://github.com/Freescale/linux-fslc/tree/5.4-2.1.x-imx。
Current configuration : 1239 bytes ! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model memory-size iomem 5 ip cef ! ! ! ! no ip domain lookup ! ipv6 unicast-routing ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface FastEthernet0/0 no ip address shutdown duplex auto speed auto ! interface Serial0/0 no ip address ipv6 address 2026::12:1/122 ipv6 ospf 6 area 12 clock rate 2000000 ! interface FastEthernet0/1 no ip address shutdown duplex auto speed auto ! interface Serial0/1 no ip address shutdown clock rate 2000000 ! interface Serial0/2 no ip address shutdown clock rate 2000000 ! interface Serial1/0 no ip address shutdown serial restart-delay 0 ! interface Serial1/1 no ip address shutdown serial restart-delay 0 ! interface Serial1/2 no ip address shutdown serial restart-delay 0 ! interface Serial1/3 no ip address shutdown serial restart-delay 0 ! ! ! no ip http server no ip http secure-server ! ipv6 router ospf 6 router-id 1.1.1.1 log-adjacency-changes ! ! ! ! ! control-plane ! ! ! ! ! ! ! ! ! ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 login ! ! end
1,中断类型 guest使用ubuntu 1604,在guest中执行cat /proc/interrupts 目前操作系统使用的中断有io apic,MSI,还有就是NMI,LOC等。 继续执行c
由于实在找不到MSI-X在x86上实现的教程或文档,只能分析Linux的PCI驱动程序了。希望能得到一些启发。本文基于linux 5.17.5进行分析
调用ioremap_nocache()函数之后,返回一个线性地址,此时CPU 可以访问设备的内存(已经将其映射到了线性地址空间中了),此时CPU可以使用访问内存的指令访问设备的内存空间,此时我们就可以像访问内存一样来访问设备的内存(寄存器)。
本文主要介绍了如何为树莓派开发一款支持200万像素摄像头的LCD驱动程序。首先介绍了LCD驱动的整体流程,然后重点讲解了树莓派上的LCD驱动实现。在实现过程中,详细描述了LCD驱动程序的框架设计、寄存器配置、中断处理、视频处理流程等内容。最后通过实际案例演示了该驱动程序的具体使用方法。
sdhci-pltfm是指在sdhci core的基础上,提供了统一对sdhci_host的必要属性进行解析和设置的方法。
1. /proc目录 Linux 内核提供了一种通过 /proc 文件系统,在运行时访问内核内部数据结构、改变内核设置的机制。proc文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间。它以文件系统的方式为访问系统内核数据的操作提供接口。
欲成其事先利其器。要想完成一项复杂的任务,工具的作用至关重要。要想在Linux系统上开发或研究木马病毒等特殊程序,我们需要使用一系列强大的开发和调试攻击。本节先介绍几种在Linux系统上极为强大的工具。
igb_uio 是 dpdk 内部实现的将网卡映射到用户态的内核模块,它是 uio 模块的一个实例。
建议关闭地址随机化,否则会出现gdb中无法在断点处停下来的情况(尤其是qemu中)。可以参考:https://blog.csdn.net/gatieme/article/details/104266966
Android系统的 /proc 保存的系统各种实时信息,像CPU、没存等信息。用上面这个命令可以查看CPU的相关信息,如图:
本文接上篇文章,从clock driver的角度,分析怎么借助common clock framework管理系统的时钟资源。换句话说,就是怎么编写一个clock driver。
介绍Linux 内核中基于Sunxi 硬件平台的SID 模块驱动的详细设计,为软件编码和维护提供基 础。
Linux 用户态和内核态由于 CPU 权限的限制,通信并不像想象中的使用进程间通信方式那么简单,今天这篇文章就来看看 Linux 用户态和内核态究竟有哪些通信方式。
Rust for Linux 这个项目的目的就是为了将 Rust 引入 Linux,让 Rust 成为 C 语言之后的第二语言。但它最初的目的是:实验性地支持Rust来写内核驱动。
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值
一、proc文件系统是什么? proc是一个伪文件系统,伪文件系统的定义: 它只存在内存当中,而不占用外存空间。它以文件系统的方式为访问系统内核数据的操作提供接口。用户和应用程序可以通过proc得到系统的信息,并可以改变内核的某些参数。由于系统的信息,如进程,是动态改变的,所以用户或应用程序读取proc文件时,proc文件系统是动态从系统内核读出所需信息并提交的。 我们常常用它来追踪进程的状态、内核的状态、内存信息、CPU使用率、系统启动时间(可以使用系统正常运行时间)等相应的信息; 二、proc文件系统详
TFT08006官方支持的一款MIPI屏幕,8寸,分辨率800*1280。官方套装支持触控。
单片机的IIC编程中,如果我们直接一点,只需要控制IIC硬件GPIO脚,然后根据IIC协议模拟各种电平时序实现与IIC设备的通信。但是这种编程方法,移植性较差(假如新加了一种IIC设备,同样的代码,又要重新复制一份)。这种做法完全不适应Linux的通用性的设计理念,对于Linux来讲:同样的事情我只做一遍,向外提供接口,不管你是什么IIC设备挂载那条IIC总线上,都可以用。因此,这就需要Linux在代码架构上有非常严谨的模块化设计。
随着互联网业务的快速发展,基础设施的可用性也越来越受到业界的关注。内存发生故障的故障率高、频次多、影响大,这些对于上层业务而言都是不能接受的。
/* LCD驱动程序分析 和别的驱动程序一样,首先找到模块函数的入口处 */ #include "s3c2410fb.h" /* Debugging stuff */ #ifdef CONFIG_FB_S3C2410_DEBUG static int debug = 1; #else static int debug = 0; #endif #define dprintk(msg...) if (debug) { printk(KERN_DEBUG "s3c2410fb: " msg); }
上一节讲了如何实现运行中断,这些都是系统给做好的,当我们想自己写个中断处理程序,去执行自己的代码,就需要写irq_desc->action->handler,然后通过request_irq()来向内核
看门狗是linux驱动的一个重要环节。某些特殊的设备,有时候需要放在一些环境恶劣的地方,比如电信设备。但是,任何软件都不可能100%没有bug。如何保证软件在遇到严重bug、死机的时候也能正常运行呢,那么看门狗就是有效的一种方法。看门狗一般要求用户定时喂狗,如果一段时间没有喂狗的话,那么系统就会自动重启。今天,我们就来看看这个看门狗驱动怎么编写?
proc文件系统是一个虚拟文件系统,它存储了当前内核运行状态相关文件,并且文件的内容都是动态创建的。用户可以通过查看这些文件获取系统状态以及当前正在运行的进程信息。而通过了解这些信息,能够帮助我们帮助我们定位疑难问题。本文将简单介绍通过proc文件系统能够获取哪些有用的信息。
Linux 下的 /proc 文件系统中提供了许多有用的信息,除了基本的CPU使用率、版本号等,你甚至还可以在这里直接看到内核的输出。下面这张表,简单列举 /proc 中文件的含义:
How to Use Android ADB Command Line Tool Android Debug Bridge (adb) is a tool that lets you manage the state of an emulator instance or Android phone. ADB is bundled with Android SDK package that can be downloaded from Android SDK download page. This tool
设备管理 adb devices //已连接设备列表 adb reboot //重启设备 adb reboot bootloader //重启到刷机模式 adb reboot recovery //重启到恢复模式 app管理 apkfile : apk文件完整路径,如:C:\Users\Administrator\Desktop\test.apk package: 包名,如:com.classic.core activity: 去掉包名后的Activity全称,例如:ui.activity.Ma
Procfs 是进程文件系统的缩写,包含一个伪文件系统(启动时动态生成的文件系统),用于通过内核访问进程信息。linux这个文件系统通常被挂载到 /proc 目录。
随着计算机技术的飞速发展,Linux操作系统作为开源领域的佼佼者,已经深入到了各个应用场景之中。在Linux系统中,内核与用户空间之间的交互是核心功能之一,而设备驱动则是实现这一交互的关键环节。然而,传统的设备驱动开发往往受限于内核空间的限制,无法充分发挥用户空间程序的灵活性和性能优势。为了解决这个问题,Linux内核引入了UIO(Userspace I/O)驱动模型。
Linux内核提供了一种通过/proc文件系统,在运行时访问内核内部数据结构、改变内核设置的机制。proc文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间。它以文件系统的方式为访问系统内核数据的操作提供接口。 用户和应用程序可以通过proc得到系统的信息,并可以改变内核的某些参数。由于系统的信息,如进程,是动态改变的,所以用户或应用程序读取proc文件时,proc文件系统是动态从系统内核读出所需信息并提交的。下面列出的这些文件或子文件夹,并不是都是在你的系统中存在,这取决于你的内核配置和装载的模块。另外,在/proc下还有三个很重要的目录:net,scsi和sys。 Sys目录是可写的,可以通过它来访问或修改内核的参数,而net和scsi则依赖于内核配置。例如,如果系统不支持scsi,scsi目录不存在。 除了以上介绍的这些,还有的是一些以数字命名的目录,它们是进程目录。系统中当前运行的每一个进程都有对应的一个目录在/proc下,以进程的 PID号为目录名,它们是读取进程信息的接口。而self目录则是读取进程本身的信息接口,是一个link。
在本文中,我们将介绍关于spi-mem Linux内核框架的工作,该框架将允许在SPI NOR设备和常规SPI设备以及SPI NAND设备上复用SPI控制器驱动程序。
领取专属 10元无门槛券
手把手带您无忧上云