Mike Frysinger | ffdb20b | 2013-12-03 16:43:27 -0700 | [diff] [blame] | 1 | Sandbox SPI/SPI Flash Implementation |
| 2 | ==================================== |
| 3 | |
Robert P. J. Day | 1cc0a9f | 2016-05-04 04:47:31 -0400 | [diff] [blame] | 4 | U-Boot supports SPI and SPI flash emulation in sandbox. This must be enabled |
Mike Frysinger | ffdb20b | 2013-12-03 16:43:27 -0700 | [diff] [blame] | 5 | using the --spi_sf paramter when starting U-Boot. |
| 6 | |
| 7 | For example: |
| 8 | |
| 9 | $ make O=sandbox sandbox_config |
| 10 | $ make O=sandbox |
| 11 | $ ./sandbox/u-boot --spi_sf 0:0:W25Q128:b/chromeos_peach/out/image.bin |
| 12 | |
| 13 | The four parameters to spi_sf are: |
| 14 | |
| 15 | SPI bus number (typically 0) |
| 16 | SPI chip select number (typically 0) |
| 17 | SPI chip to emulate |
| 18 | File containing emulated data |
| 19 | |
| 20 | Supported chips are W25Q16 (2MB), W25Q32 (4MB) and W25Q128 (16MB). Once |
| 21 | U-Boot it started you can use 'sf' commands as normal. For example: |
| 22 | |
| 23 | $ ./b/sandbox/u-boot --spi_sf 0:0:W25Q128:b/chromeos_peach/out/image.bin \ |
| 24 | -c "sf probe; sf test 0 100000; sf read 0 1000 1000; \ |
| 25 | sf erase 1000 1000; sf write 0 1000 1000" |
| 26 | |
| 27 | |
| 28 | U-Boot 2013.10-00237-gd4e0fdb (Nov 07 2013 - 20:08:15) |
| 29 | |
| 30 | DRAM: 128 MiB |
| 31 | Using default environment |
| 32 | |
| 33 | In: serial |
| 34 | Out: serial |
| 35 | Err: serial |
| 36 | SF: Detected W25Q128BV with page size 256 Bytes, erase size 4 KiB, total 16 MiB |
| 37 | SPI flash test: |
| 38 | 0 erase: 1 ticks, 1024000 KiB/s 8192.000 Mbps |
| 39 | 1 check: 2 ticks, 512000 KiB/s 4096.000 Mbps |
| 40 | 2 write: 6 ticks, 170666 KiB/s 1365.328 Mbps |
| 41 | 3 read: 0 ticks, 1048576000 KiB/s -201326.-592 Mbps |
| 42 | Test passed |
| 43 | 0 erase: 1 ticks, 1024000 KiB/s 8192.000 Mbps |
| 44 | 1 check: 2 ticks, 512000 KiB/s 4096.000 Mbps |
| 45 | 2 write: 6 ticks, 170666 KiB/s 1365.328 Mbps |
| 46 | 3 read: 0 ticks, 1048576000 KiB/s -201326.-592 Mbps |
| 47 | SF: 4096 bytes @ 0x1000 Read: OK |
| 48 | SF: 4096 bytes @ 0x1000 Erased: OK |
| 49 | SF: 4096 bytes @ 0x1000 Written: OK |
| 50 | |
| 51 | |
| 52 | Since the SPI bus is fully implemented as well as the SPI flash connected to |
| 53 | it, you can also use low-level SPI commands to access the flash. For example |
| 54 | this reads the device ID from the emulated chip: |
| 55 | |
| 56 | => sspi 0 32 9f |
| 57 | FFEF4018 |
| 58 | |
| 59 | |
| 60 | Simon Glass |
| 61 | sjg@chromium.org |
| 62 | 7/11/2013 |
| 63 | Note that the sandbox SPI implementation was written by Mike Frysinger |
| 64 | <vapier@gentoo.org>. |