Mike Frysinger | b375ad9 | 2013-12-03 16:43:27 -0700 | [diff] [blame] | 1 | Sandbox SPI/SPI Flash Implementation |
| 2 | ==================================== |
| 3 | |
Robert P. J. Day | 8c60f92 | 2016-05-04 04:47:31 -0400 | [diff] [blame] | 4 | U-Boot supports SPI and SPI flash emulation in sandbox. This must be enabled |
AKASHI Takahiro | 8200d3a | 2020-04-27 15:46:45 +0900 | [diff] [blame] | 5 | via a device tree. |
Mike Frysinger | b375ad9 | 2013-12-03 16:43:27 -0700 | [diff] [blame] | 6 | |
| 7 | For example: |
| 8 | |
AKASHI Takahiro | 8200d3a | 2020-04-27 15:46:45 +0900 | [diff] [blame] | 9 | spi@0 { |
| 10 | #address-cells = <1>; |
| 11 | #size-cells = <0>; |
| 12 | reg = <0 1>; |
| 13 | compatible = "sandbox,spi"; |
| 14 | cs-gpios = <0>, <&gpio_a 0>; |
| 15 | spi.bin@0 { |
| 16 | reg = <0>; |
| 17 | compatible = "spansion,m25p16", "jedec,spi-nor"; |
| 18 | spi-max-frequency = <40000000>; |
| 19 | sandbox,filename = "spi.bin"; |
| 20 | }; |
| 21 | }; |
Mike Frysinger | b375ad9 | 2013-12-03 16:43:27 -0700 | [diff] [blame] | 22 | |
| 23 | Supported chips are W25Q16 (2MB), W25Q32 (4MB) and W25Q128 (16MB). Once |
| 24 | U-Boot it started you can use 'sf' commands as normal. For example: |
| 25 | |
AKASHI Takahiro | 8200d3a | 2020-04-27 15:46:45 +0900 | [diff] [blame] | 26 | $ dd if=/dev/zero of=spi.bin bs=1M count=2 |
| 27 | $ u-boot -T |
Mike Frysinger | b375ad9 | 2013-12-03 16:43:27 -0700 | [diff] [blame] | 28 | |
| 29 | Since the SPI bus is fully implemented as well as the SPI flash connected to |
| 30 | it, you can also use low-level SPI commands to access the flash. For example |
| 31 | this reads the device ID from the emulated chip: |
| 32 | |
| 33 | => sspi 0 32 9f |
AKASHI Takahiro | 8200d3a | 2020-04-27 15:46:45 +0900 | [diff] [blame] | 34 | SF: Detected m25p16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB |
| 35 | FF202015 |
Mike Frysinger | b375ad9 | 2013-12-03 16:43:27 -0700 | [diff] [blame] | 36 | |
| 37 | |
| 38 | Simon Glass |
| 39 | sjg@chromium.org |
| 40 | 7/11/2013 |
| 41 | Note that the sandbox SPI implementation was written by Mike Frysinger |
| 42 | <vapier@gentoo.org>. |