1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

「ラズパイマガジン2017年10月号の拡張ボードHATを作ろう」をやってみた

Last updated at Posted at 2018-01-03

undefined
ラズパイマガジンの2017年10月号の「拡張ボードHATを作ろう」の記事をやってみた

本の通りにやると図23の通りデバイスツリーソースをコンパイルしても図24のようにならなかった。spiが認識されていない

このことを出版社に問い合わせた。しかし返事は来たがわからないとのことだった

そのため自分で対策を立てることにした

3週間に渡るトライアンドエラーの結果ついに出来た

デバイスツリーソースを以下のようにするとspiが認識されdhtカーネルドライバが動くように出来た
図23のspiのfragmentのやり方がかなり間違っていることが分かった

dht_hat.dts
/dts-v1/;

/ {
   compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";

   fragment@0 {
   	target-path = [2f 00];

   	__overlay__ {

   		dht11@0 {
   			compatible = "dht11";
   			pinctrl-names = "default";
   			pinctrl-0 = <0x1>;
   			gpios = <0xdeadbeef 0x4 0x0>;
   			status = "okay";
   			phandle = <0x2>;
   		};
   	};
   };

   fragment@1 {
   	target = <0xdeadbeef>;

   	__overlay__ {

   		dht11_pins {
   			brcm,pins = <0x4>;
   			brcm,function = <0x0>;
   			brcm,pull = <0x0>;
   			phandle = <0x1>;
   		};
   	};
   };

   fragment@2 {                 //spi0有効
   	target = <0xdeadbeef>;

   	__overlay__ {
   		cs-gpios = <0x0 0x0>;
   		status = "okay";
   	};
   };

   fragment@3 {                //spi0有効
   	target = <0xdeadbeef>;

   	__overlay__ {
   		brcm,pins = <0x8 0x7>;
   		brcm,function = <0x4>;
   	};
   };

   __overrides__ {
   	gpiopin = <0x1 0x6272636d 0x2c70696e 0x733a3000 0x2 0x6770696f 0x733a3400>;
   };

   __symbols__ {
   	dht11 = "/fragment@0/__overlay__/dht11@0";
   	dht11_pins = "/fragment@1/__overlay__/dht11_pins";
   };

   __local_fixups__ {

   	fragment@0 {
   		__overlay__ {
   			dht11@0 {
   				pinctrl-0 = <0x0>;
   			};
   		};
   	};

   	__overrides__ {
   		gpiopin = <0x0 0x10>;
   	};
   };

   __fixups__ {
   	gpio = "/fragment@0/__overlay__/dht11@0:gpios:0", "/fragment@1:target:0";
   	spi0 = "/fragment@2:target:0";
   	spi0_cs_pins = "/fragment@3:target:0";//spi0有効
   };
};

hat.jpg

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?