0
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 1 year has passed since last update.

Raspberry Pi 3 Model BにSPI接続のSDカードアダプタを追加しようとした

Last updated at Posted at 2022-01-16

なんでSPI接続のSDカードアダプタを増設?

本当はSDIO接続のSDカードアダプタモジュールを使う予定でした。しかし、ずいぶん前に届いていたモジュールのパッケージを開けてみたら、SPIって書いてあり落胆しました。とはいえ、使えるのかどうか位は確認すべきかと思い立ち現在に至ります。
※結論に書いてますが、現時点でSDカードの読み書きまで至っていません。

どうみてもSDIOじゃないアダプタ
image.png
買うとき確かめた気がするんだけど・・・

#準備

接続

ピン配置を「gpio readall」で調べて、
電源はPin1、GroundはPin39として、SPIのピンは19、21、23と24とした。

pi@raspberrypi:~ $ gpio readall
 +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 0 | IN   | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | IN   | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | OUT  | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+

以下のように接続した
image.png

SPIを有効にしておく

GUIのRaspberry Piの設定もしくは、rasp-configでSPIを有効にして、再起動しておく。

認識されているか確認

デバイスが検出されているか

dmesg | grep mmc

[    3.284320] mmc1: new high speed SDIO card at address 0001
[    6.037766] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    8.069818] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.raspberrypi,3-model-b.txt failed with error -2

なんかエラー出ている

調べたら(ググったら)以下に「brcmfmac43430-sdio.raspberrypi,3-model-b.txt」があった。
https://github.com/openwrt/cypress-nvram

sudo cp /home/pi/Downloads/brcmfmac43430-sdio.raspberrypi,3-model-b.txt /lib/firmware/brcm/

コピー後ラズパイを再起動した。

「mmc1: new high speed SDIO card at address 0001」が出ているので、検出までは成功した模様。

[    3.001235] mmc-bcm2835 3f300000.mmcnr: could not get clk, deferring probe
[    3.001914] sdhost-bcm2835 3f202000.mmc: could not get clk, deferring probe
[    3.028335] mmc-bcm2835 3f300000.mmcnr: mmc_debug:0 mmc_debug2:0
[    3.028352] mmc-bcm2835 3f300000.mmcnr: DMA channel allocated
[    3.092295] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[    3.093957] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    3.095624] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    3.098606] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[    3.104409] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    3.165498] mmc0: host does not support reading read-only switch, assuming write-enable
[    3.168788] mmc0: new high speed SDHC card at address 1234
[    3.169957] mmcblk0: mmc0:1234 SA32G 28.8 GiB
[    3.173102]  mmcblk0: p1 p2
[    3.211040] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    3.221040] mmc1: new high speed SDIO card at address 0001
[    6.005339] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)

デバイスが見えてない

/dev/以下にデバイスはいないし、差し込んだSDカードの情報もみえていない。
何かの手順で間違いがあるようだ。

結論

しばらく後に持ち越す。

0
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
0
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?