Hi,
I recently bought some moteinos for a home automation system I am building. Every now and then a moteinoe would hang, typically when initialising the flash device.
I noticed a few threads discussing this with several suggesting placing a pull down resistor on MISO. While this works I think the actual root cause is in the SPIFlash library.
Specifically: in the call tree: initialise()->wakeup()->command()->busy() the flash wakeup command is held up waiting for a non-busy status from a device which is already asleep. This behaviour is consistent with section 8.2.19 of the Winbond
w25x40 data sheet (i.e. ignoring all but Release from Power Down, including status requests).
To fix this I added the following
check to the SPIFlash::command() (~line 183):
// Check for the wakeup command to avoid a deadlock trying to
// read the status from a sleeping device.
if (cmd != SPIFLASH_WAKE)
while(busy());
select();