Difference between revisions of "SPI/zh"
From FriendlyELEC WiKi
(updated by API) |
(updated by API) |
||
Line 1: | Line 1: | ||
− | [[SPI | | + | [[SPI/zh|查看中文]] |
==S5P4418== | ==S5P4418== | ||
Line 7: | Line 7: | ||
另外,arch/arm/plat-s5p4418/asb/device.c 有 spi2 的支持,修改时可参考; <br /> | 另外,arch/arm/plat-s5p4418/asb/device.c 有 spi2 的支持,修改时可参考; <br /> | ||
+ | ==H5== | ||
+ | ===SPI Flash=== | ||
+ | FriendlyElec H5的Linux-4.14内核集成了"mxicy,mx25l12805d"的SPI Flash驱动,使用的是SPI0,但是默认并没有使能,相关的dts配置如下: | ||
+ | <syntaxhighlight lang="text"> | ||
+ | $ vi linux/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi.dtsi | ||
+ | &spi0 { | ||
+ | ... | ||
+ | spiflash: spiflash@0 { | ||
+ | #address-cells = <1>; | ||
+ | #size-cells = <1>; | ||
+ | compatible = "mxicy,mx25l12805d"; | ||
+ | reg = <0>; | ||
+ | status = "disabled"; | ||
− | == | + | spi-max-frequency = <50000000>; |
+ | mode = <0>; | ||
+ | |||
+ | partition@0 { | ||
+ | reg = <0x0 0x1000000>; | ||
+ | label = "spi-flash"; | ||
+ | }; | ||
+ | }; | ||
+ | ... | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 可以在npi-config里将其使能,如下: | ||
+ | <syntaxhighlight lang="text"> | ||
+ | $ npi-config | ||
+ | 6 Advanced Options| Configure advanced setting | ||
+ | A5 SPI| Enable/Disable SPI | ||
+ | spi0 Enable/Disable spi0[enabled] | ||
+ | spidev0.0| SPI0 char device | ||
+ | spi-2.8'tft| Matrix-2'8_SPI_Key_TFT | ||
+ | spi-flash| SPI0 flash(X) | ||
+ | </syntaxhighlight> | ||
+ | 设置完毕后需要重启系统。<br> | ||
+ | {{Linux-SPIFlash/zh}} | ||
+ | |||
+ | |||
+ | ==H3/H2+== | ||
===SPI Flash=== | ===SPI Flash=== | ||
− | <syntaxhighlight lang=" | + | FriendlyElec H3/H2+的Linux-4.14内核集成了"mxicy,mx25l12805d"的SPI Flash驱动,使用的是SPI0,但是默认并没有使能,相关的dts配置如下: |
+ | <syntaxhighlight lang="text"> | ||
+ | $ vi linux/arch/arm/boot/dts/sun8i-h3-nanopi.dtsi | ||
+ | &spi0 { | ||
+ | ... | ||
+ | spiflash: spiflash@0 { | ||
+ | #address-cells = <1>; | ||
+ | #size-cells = <1>; | ||
+ | compatible = "mxicy,mx25l12805d"; | ||
+ | reg = <0>; | ||
+ | status = "disabled"; | ||
+ | |||
+ | spi-max-frequency = <50000000>; | ||
+ | mode = <0>; | ||
+ | |||
+ | partition@0 { | ||
+ | reg = <0x0 0x1000000>; | ||
+ | label = "spi-flash"; | ||
+ | }; | ||
+ | }; | ||
+ | ... | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 可以在npi-config里将其使能,如下: | ||
+ | <syntaxhighlight lang="text"> | ||
$ npi-config | $ npi-config | ||
− | 6 Advanced Options| | + | 6 Advanced Options| Configure advanced setting |
− | A5 SPI| | + | A5 SPI| Enable/Disable SPI |
spi0 Enable/Disable spi0[enabled] | spi0 Enable/Disable spi0[enabled] | ||
− | spidev0.0| | + | spidev0.0| SPI0 char device |
spi-2.8'tft| Matrix-2'8_SPI_Key_TFT | spi-2.8'tft| Matrix-2'8_SPI_Key_TFT | ||
− | spi-flash| | + | spi-flash| SPI0 flash(X) |
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | 设置完毕后需要重启系统。<br> | |
{{Linux-SPIFlash/zh}} | {{Linux-SPIFlash/zh}} |
Revision as of 04:24, 15 January 2019
查看中文
Contents
1 S5P4418
1.1 Q: S5P4418的/dev目录下只有一个spidev0.0这个设备节点, 怎么添加spidev1.0
对于3.4内核来说,4418 需要修改 arch/arm/plat-s5p4418/nanopi2/device.c;
想要增加一路的话,可先搜索 CONFIG_SPI_SPIDEV , 然后参考已有代码增加另一路的支持;
另外,arch/arm/plat-s5p4418/asb/device.c 有 spi2 的支持,修改时可参考;
2 H5
2.1 SPI Flash
FriendlyElec H5的Linux-4.14内核集成了"mxicy,mx25l12805d"的SPI Flash驱动,使用的是SPI0,但是默认并没有使能,相关的dts配置如下:
$ vi linux/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi.dtsi &spi0 { ... spiflash: spiflash@0 { #address-cells = <1>; #size-cells = <1>; compatible = "mxicy,mx25l12805d"; reg = <0>; status = "disabled"; spi-max-frequency = <50000000>; mode = <0>; partition@0 { reg = <0x0 0x1000000>; label = "spi-flash"; }; }; ...
可以在npi-config里将其使能,如下:
$ npi-config 6 Advanced Options| Configure advanced setting A5 SPI| Enable/Disable SPI spi0 Enable/Disable spi0[enabled] spidev0.0| SPI0 char device spi-2.8'tft| Matrix-2'8_SPI_Key_TFT spi-flash| SPI0 flash(X)
设置完毕后需要重启系统。
启动Linux系统时,看到类似下面的启动信息则说明SPI Flash被成功检测到了:
m25p80 spi0.0: mx25l12805d (16384 Kbytes) 1 ofpart partitions found on MTD device spi0.0 Creating 1 MTD partitions on "spi0.0": 0x000000000000-0x000001000000 : "spi-flash"
SPI Flash在Linux系统下的使用方法如下:
$ cat /sys/class/mtd/mtd0/size # 以byte为单位 $ cat /sys/class/block/mtdblock0/size # 以sector(512 byte)为单位 $ apt-get install mtd-utils $ flash_eraseall -j /dev/mtd0 # 格式成jffs2的格式 $ mount -t jffs2 /dev/mtdblock0 /mnt $ mkfs.ext4 /dev/mtdblock0 # 也格式化为ext4 $ mount -t ext4 /dev/mtdblock0 /mnt
3 H3/H2+
3.1 SPI Flash
FriendlyElec H3/H2+的Linux-4.14内核集成了"mxicy,mx25l12805d"的SPI Flash驱动,使用的是SPI0,但是默认并没有使能,相关的dts配置如下:
$ vi linux/arch/arm/boot/dts/sun8i-h3-nanopi.dtsi &spi0 { ... spiflash: spiflash@0 { #address-cells = <1>; #size-cells = <1>; compatible = "mxicy,mx25l12805d"; reg = <0>; status = "disabled"; spi-max-frequency = <50000000>; mode = <0>; partition@0 { reg = <0x0 0x1000000>; label = "spi-flash"; }; }; ...
可以在npi-config里将其使能,如下:
$ npi-config 6 Advanced Options| Configure advanced setting A5 SPI| Enable/Disable SPI spi0 Enable/Disable spi0[enabled] spidev0.0| SPI0 char device spi-2.8'tft| Matrix-2'8_SPI_Key_TFT spi-flash| SPI0 flash(X)
设置完毕后需要重启系统。
启动Linux系统时,看到类似下面的启动信息则说明SPI Flash被成功检测到了:
m25p80 spi0.0: mx25l12805d (16384 Kbytes) 1 ofpart partitions found on MTD device spi0.0 Creating 1 MTD partitions on "spi0.0": 0x000000000000-0x000001000000 : "spi-flash"
SPI Flash在Linux系统下的使用方法如下:
$ cat /sys/class/mtd/mtd0/size # 以byte为单位 $ cat /sys/class/block/mtdblock0/size # 以sector(512 byte)为单位 $ apt-get install mtd-utils $ flash_eraseall -j /dev/mtd0 # 格式成jffs2的格式 $ mount -t jffs2 /dev/mtdblock0 /mnt $ mkfs.ext4 /dev/mtdblock0 # 也格式化为ext4 $ mount -t ext4 /dev/mtdblock0 /mnt