#author("2021-02-20T10:08:20+00:00","default:admin","admin")
#author("2021-02-22T04:59:03+00:00","default:admin","admin")
-[[The Linux driver implementer’s API guide:https://www.kernel.org/doc/html/v4.14/driver-api/index.html]]

-[[Linuxドライバのはなし:http://www.silex.jp/blog/wireless/2015/08/linux.html]]
-[[Linuxでデバイスドライバを作る:https://qiita.com/butada/items/1a230b942f264951b337]]

-組み込みLinuxデバイスドライバの作り方
--[[10回目: I2Cを使ったデバイスドライバを作る:https://qiita.com/take-iwiw/items/dbc544864f0e9873270a]]
--[[11回目: デバイスツリーにI2Cデバイスを追加する:https://qiita.com/take-iwiw/items/0d13142863d9ed064e41]]

-[[プロジェクト演習 2 Linux プログラミング:http://www.sic.shibaura-it.ac.jp/~yamaken/docs/linux.pdf]]

*Frame Buffer [#h5838474]
-[[Frame Buffer Library:https://www.kernel.org/doc/html/v4.14/driver-api/frame-buffer.html]]

***fb_info [#c2bb7cff]

***fb_var_screeninfo [#db2260bc]

***fb_fix_screeninfo [#v95949b8]

***fb_monospecs [#j445692c]

***Simple Framebuffer [#ce0becaa]
-[[Simple Framebuffer:https://www.kernel.org/doc/Documentation/devicetree/bindings/display/simple-framebuffer.txt]]
-[[simple-framebuffer.yaml:https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next/+/refs/heads/akpm-base/Documentation/devicetree/bindings/display/simple-framebuffer.yaml]]

-[[Simple framebufferを有効にする:http://se.hatenablog.jp/entry/2014/11/19/081514]]
-[[ZYBO26 (Linux + simple framebuffer でX Windowを動かすまで):https://bravo-fpga.blogspot.com/2016/12/zybo26-linux-simple-frame-buffer-x.html]]

***Deferred IO [#mbcedbe2]
-[[Kernel .config file lacks CONFIG_FB_DEFERRED_IO:https://elinux-minnowboard.elinux.narkive.com/WQXedAEJ/kernel-config-file-lacks-config-fb-deferred-io]]
-[[fbdev, mm: Deferred IO support:https://lwn.net/Articles/223751/]]

-[[Running X on a Logitech G19 LCD:https://wiki.gentoo.org/wiki/Running_X_on_a_Logitech_G19_LCD]] ... .config に CONFIG_FB_DEFERRED_IO を追加する方法が記載されている 

**fbtft [#b4a8c93a]
-液晶に合わせて派生バージョンがある

-[[notro/fbtft:https://github.com/notro/fbtft]] ... 本家?

-[[devemin/fbtft:https://github.com/devemin/fbtft]] ... 細長LCD用
--[[マジョカアイリス細長液晶をラズパイで使う:https://qiita.com/devemin/items/9a3a3d40538b782b39d2]]

***ビルド [#j3a8892a]
 INSTALLATION
   Download kernel sources
 
   From Linux 3.15  
     cd drivers/video/fbdev
     git clone https://github.com/notro/fbtft.git
     
     Add to drivers/video/fbdev/Kconfig:   source "drivers/video/fbdev/fbtft/Kconfig"
     Add to drivers/video/fbdev/Makefile:  obj-y += fbtft/


*I2C [#a8bb2fc0]
-[[Raspberry Pi でI2C:C言語プログラミング:http://d.hatena.ne.jp/penkoba/20131222/1387689702]]
-[[I2C通信の技術説明とドライバ作成方法:https://www.toppers.jp/docs/ET2016_HD-1_002.pdf]]

*プログラム [#p7c47810]
**errno [#p09764ed]
-[[エラー: UNIX プログラムでの errno:https://www.ibm.com/developerworks/jp/aix/library/au-errnovariable/index.html]]
-[[演算子/errno/シグナル/システムコール 一覧表:http://sstea.blog.jp/prg/tables.html]]

*モジュール [#c71d1697]
-[[ドライバのロード・アンロード:http://linux-dvr.biz/archives/57]]

-ドライバのロード
 # insmod hello.ko

-ドライバがロードされたか確認
 # asmod

-ドライバのアンロード
 # rmmod hello

*ライセンス [#m56ad70a]
-静的リンク → GPL
-動的リンク(insmod,modprobe) → ドライバ開発者が決められる

*開発 [#te3e342b]
-[[組み込みLinuxデバイスドライバの作り方 (1):https://qiita.com/iwatake2222/items/1fdd2e0faaaa868a2db2]] ... 1回目: ビルド環境準備と、簡単なカーネルモジュールの作成
-[[組み込みLinuxデバイスドライバの作り方 (9):https://qiita.com/iwatake2222/items/e92a950a2cf57d1a3ded]] ... 9回目: 他のカーネルモジュールの関数を呼ぶ / GPIO制御関数を使う

**コーディング規約 [#h1ca4da5]
-タブ ... 8文字
-インデント ... 8文字
-1行は80文字まで
--80文字より長い行は分割して、次の行になるべく右の方に配置
-関数はなるべく短くすべきで、長くても2画面(1画面は80x24)まで

**ビルド [#u8bfd566]
***Makefile [#c08a6308]
 obj-m += foobar.o
 
 all:
         make -C /lib/modules/$(shell uname -r)/build M=${PWD} modules
 clean:
         make -C /lib/modules/$(shell uname -r)/build M=${PWD} clean
-obj-m ... 最終的に作りたい *.ko ファイルのもととなる .o ファイルを指定
- -C オプション ... Makefileがある場所を指定(別アーキテクチャ用の場合は、そのカーネルソースのパスなどを直接指定)

***カーネルコンフィグレーションへの追加 [#be7fe215]

**コーディング [#kc4d3776]
***ヘッダファイルのinclude [#q1ec59d8]
 #include <linux/module.h>
 #include <linux/init.h>

***ライセンス指定 [#u3a663c5]
-*.c に MODULE_LICENSEマクロを記述
-例)
 MODULE_LICENSE("Dual BSD/GPL");

***printk() [#xf229cff]
-printf() は使えない。代わりに pritk() を使う。
-printk() の出力先はカーネルバッファ
-カーネルバッファは dmesg コマンドで参照できるが、ラウンドロビン形式なので一定量を超えると古い方から上書きされていく

**GPIO制御関数 [#j231f64e]
-linux/gpio.h

-int gpio_request(unsigned gpio, const char *label)
--GPIOを登録する。gpioはGPIO番号。
-int gpio_direction_output(unsigned gpio, int value)
--GPIOを出力に設定する。gpioはGPIO番号。valueは初期出力値(0 = low, 1 = high)
-int gpio_direction_input(unsigned gpio)
--GPIOを入力に設定する。gpioはGPIO番号
-void gpio_set_value(unsigned gpio, int value)
--GPIOに出力する。gpioはGPIO番号。valueは出力値(0 = low, 1 = high)
-int gpio_to_irq(unsigned gpio)
--GPIOの指定したピンの割り込み番号を取得する
-int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev)
--割り込みハンドラの登録をする。これはGPIOに限った関数ではありません


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS