Difference between revisions of "SPI"

From FriendlyELEC WiKi
Jump to: navigation, search
(Created page with "查看中文")
 
(updated by API)
Line 1: Line 1:
 
[[SPI/zh|查看中文]]
 
[[SPI/zh|查看中文]]
 +
 +
==S5P4418==
 +
====Q: S5P4418的/dev目录下只有一个spidev0.0这个设备节点, 怎么添加spidev1.0====
 +
对于3.4内核来说,4418 需要修改 arch/arm/plat-s5p4418/nanopi2/device.c; <br />
 +
想要增加一路的话,可先搜索 CONFIG_SPI_SPIDEV , 然后参考已有代码增加另一路的支持;  <br />
 +
另外,arch/arm/plat-s5p4418/asb/device.c 有 spi2 的支持,修改时可参考; <br />
 +
 +
 +
==H5/H3/H2+==
 +
===SPI Flash===
 +
<syntaxhighlight lang="html4strict">
 +
$ 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>
 +
FriendlyElec H5/H3/H2+的Linux-4.14内核集成了"mxicy,mx25l12805d"的SPI Flash驱动,但是默认并没有使能,选择'spi-flash'后即可将其使能, 设置完毕后需要重启系统。<br>
 +
{{Linux-SPIFlash/zh}}

Revision as of 03:33, 15 January 2019

查看中文

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/H3/H2+

2.1 SPI Flash

$ 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)

FriendlyElec H5/H3/H2+的Linux-4.14内核集成了"mxicy,mx25l12805d"的SPI Flash驱动,但是默认并没有使能,选择'spi-flash'后即可将其使能, 设置完毕后需要重启系统。
启动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