2024-07-10 03:03 PM
I have questions about SPI interfaces and the boot selection. I am not using SPI for the bootloader and I don't want it selected.
Issue 1: AN2606 says that to prevent SPI from being selected, SPI_MOSI should be at a known state (high or low) at the start of the selection process. I'm wondering if keeping SCK at a known, unchanging state (high or low) would also prevent the interface from being selected. It also seems that keeping NSS high would also prevent that interface from being selected.
Issue 2: I have a design where I use an STM32 analog input, which is connected to an op-amp output. That pin also happens to be SPI_MISO of one of the possible bootloader SPI interfaces. AN2606 says that SPI_MISO during boot mode selection is an output, which in my case would imply that the SPI_MISO pin is driving out into my op-amp output. I put a 1K resistor between the pins to prevent contention. I'm wondering if SPI_MISO is actually tri-stated, and would only drive out if NSS and SCK performed an SPI data transaction.
2024-07-10 04:35 PM
Holding NSS or SCK high will prevent the SPI bootloader from booting. Putting MOSI at a specific state is not required if those pins are controlled.
The state of the MISO pin isn't guaranteed by AN2606. I would imagine it's driven in general, but is likely chip specific as the SPI peripheral varies quite a bit between families.
2024-07-10 05:01 PM - edited 2024-07-10 05:02 PM
Issue 1: AN2606 doesn't say SPI_MOSI should be kept fixed, only that it is recommended. The appnote tells you the necessary wiring and magic bytes necessary for activating the SPI bootloader, so logically, if any of those conditions isn't met, the SPI bootloader will not activate. One way to ensure this is to keep SPI_MOSI fixed. Another would be to prevent SCK from toggling, and yet another is to tie NSS high to tell the SPI peripheral no one is talking to it.
Issue 2: Curiously, MISO tri-stating behavior is not explicitly documented. You haven't said which family you're using, but for the one I use the figures in the RM suggest that when NSS is (configured for use but) not asserted MISO is tri-stated:
Whether that's convincing enough evidence, I can't decide for you.
If you want absolute certainty about this and other issues, you can customize the bootloader to your needs:
How to use the ST Open Bootloader for STM32 Microcontrollers