Electronic – SPI Slave Flash programming with two masters question

flashprogrammingspi

I'm looking to make a system that can be upgraded by a customer in the field and I need to know some conceptual thing before I try implementing my current strategy.

Say I have a USB to SPI bridge, some FTDI chip, and I want to be able to program an SPI flash using that. Cool no problem BUT my controller has to boot from the same SPI flash using SPI lines. So would I be able to just connect everything together?

Concept connection diagram

Here is a picture since I'm not good at explaining these things.

There is a typo on the picture. The controller isn't being programmed, the SPI flash is. The controller will boot from the spi flash

Best Answer

It should be possible to connect two masters to the same SPI bus provided that

  • Neither device tries to drive SCK, MOSI, or SS when the other device wants to use it (though SS should be weakly pulled up when idle, and other pins weakly pulled to some defined level).

  • The devices have some means of staying out of each other's way.

I don't know whether the FTDI bridge expects to be a master or slave; if it expects to be a master but floats its wires except when told by the PC to feed data, and if it has some means of holding the main processor in reset, a direct connection should work out very nicely. If it expects to be an SPI slave, then the microcontroller firmware will have to talk to the bridge, read data from it, and feed that data to the flash itself.