michallenc opened a new pull request, #18564:
URL: https://github.com/apache/nuttx/pull/18564
## Summary
If power down mode is set, trying to read ID ends in an infinite loop
because `w25_waitwritecomplete` never returns as status register never
signalizes write complete. Therefore ensure the device is not in a power down
mode before trying to read from it.
This can be an issue if the board is trying to check for more NOR memories
on one SPI bus and one chip select. For example GD25 driver returns the memory
to power down state after read id is finished, therefore board initialization
is stuck in an infinite loop if it first checks for GD25 and then fallbacks to
W25.
The commit fixes the possible issue by ensuring W25 is brought back to
normal operation mode before trying to obtain the manufacturer ID.
## Impact
Fixes the possible issue on W25 NOR. None on current functionality.
## Testing
We had to switch from it to GD25 on one of our devices because of supply
shortage and this issue was discovered when I tried to support both GD25 and
W25 in one BSP, something like that:
```c
/* Use the SPI device instance to initialize the GD25 or W25 device. */
struct mtd_dev_s *mtd = gd25_initialize(spi, 0);
if (!mtd)
{
/* Some older version of the device used W25 NOR flash */
mtd = w25_initialize(spi);
if (!mtd)
{
syslog(LOG_ERR,
"ERROR: Both W25Q and GD25 flash initialization failed\n");
return ERROR;
}
}
```
GD25 fail on older devices with W25 NOR caused the memory to stick in a
power down mode, thus basically creating and infinite loop in
`w25_waitwritecomplete` causing the board init to never complete. The flash is
correctly configured with the proposed patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]