diff --git a/flash/FLASH.md b/flash/FLASH.md index 3fec2e3..36e70fd 100644 --- a/flash/FLASH.md +++ b/flash/FLASH.md @@ -155,6 +155,12 @@ Arguments. In most cases only the first two mandatory args are required: 5. `sec_size=4096` Chip sector size. 6. `block_size=9` The block size reported to the filesystem. The size in bytes is `2**block_size` so is 512 bytes by default. + 7. `cmdset=None` Flash chips can support two low level command sets, an old 4 + byte set and a newer 5 byte set capable of supporting a larger address + space. By default if the size read from the chip's ID is <= 4096KiB the 4 byte + set is used oterwise the 5 byte set is adopted. This works for supported + chips. Setting `cmdset` `True` forces 5 byte commands, `False` forces 4 byte. + This override is necessary for certain chip types (e.g. WinBond W25Q64FV). Size values (KiB): | Chip | Size | diff --git a/flash/flash_spi.py b/flash/flash_spi.py index c5093ec..8e61b28 100644 --- a/flash/flash_spi.py +++ b/flash/flash_spi.py @@ -25,7 +25,8 @@ _SEC_SIZE = const(4096) # Flash sector size 0x1000 # Logical Flash device comprising one or more physical chips sharing an SPI bus. class FLASH(FlashDevice): - def __init__(self, spi, cspins, size=None, verbose=True, sec_size=_SEC_SIZE, block_size=9): + def __init__(self, spi, cspins, size=None, verbose=True, + sec_size=_SEC_SIZE, block_size=9, cmdset=None): self._spi = spi self._cspins = cspins self._ccs = None # Chip select Pin object for current chip @@ -42,7 +43,7 @@ class FLASH(FlashDevice): super().__init__(block_size, len(cspins), size * 1024, sec_size) # Select the correct command set - if size <= 4096: + if (cmdset is None and size <= 4096) or (cmdset == False): self._cmds = _CMDS3BA self._cmdlen = 4 else: