Linux驅動學習之篇外

2021-09-26 13:29:36 字數 1141 閱讀 2221

一些有用的tricks(隨時補充):

/sys/firmware/devicetree/base, 這個節點也會被鏈結到 /proc/device-tree

/proc/interrupts

/proc/irq/irq_num

/sys/class/gpio

需要通過gpio_export()或者gpio_export_link()將自己用到的gpio給export;

也可以通過該目錄下的export給export?

/sys/class/devices

以乙個i2c為例,可以看到driver的路徑,以及device tree的資訊

(***x):/sys/devices/platform/soc/884000.i2c # ls -la

total 0

drwxr-xr-x   4 root root    0 1970-02-23 06:36 .

drwxr-xr-x 509 root root    0 1970-02-23 06:36 ..

lrwxrwxrwx   1 root root    0 2018-01-26 21:35 driver -> ../../../../bus/platform/drivers/i2c_geni

-rw-r--r--   1 root root 4096 2018-01-26 21:35 driver_override

drwxr-xr-x   6 root root    0 1970-02-23 06:36 i2c-1

-r--r--r--   1 root root 4096 2018-01-26 21:35 modalias

lrwxrwxrwx   1 root root    0 2018-01-26 21:35 of_node -> ../../../../firmware/devicetree/base/soc/i2c@884000

drwxr-xr-x   2 root root    0 1970-02-23 06:36 power

lrwxrwxrwx   1 root root    0 2018-01-26 21:35 subsystem -> ../../../../bus/platform

cat /proc/kmsg

或者dmesg,如果log會斷,可以加 -w;

linux驅動學習之LED篇(二)

上篇講了下led的原理,這篇就開始寫 如果是新手我建議先把 linux裝置驅動開發詳解 的裝置驅動那章看下或者網上了解下裝置驅動的模版,不然驅動的整體結構不懂的話就比較糾結了。include 所有核心模組必須有的標頭檔案 include 所有 核心模組必須有的標頭檔案 include printk ...

Linux驅動篇之hello

一 環境 a ubuntu18.04 b arm linux gnueabi gcc 7.5.0 gcc 7.5.0 c friendlyarm tiny4412 標準版 d linux 5.5 二 目標 a hello驅動 b hello應用 三 步驟 a hello驅動 1 在drivers目錄...

Linux 驅動篇 字元驅動裝置01(框架篇)

定義乙個file operations結構體型別的變數 並填充owner函式 open函式 write函式 static int drvledopen struct inode inode,struct file file static ssize t drvledwrite struct file...