QSPI flash access management
Posted: Wed Apr 23, 2025 1:24 pm
Not 100% sure whether this is a bug, or just me using things in an unintended way. Anyway, its the same in at least Chibi 20 and 21.
I have a QSPI flash device as the only component connected to the QSPI bus on a 32F767. To avoid access collisions, I set:
This should effectively regulate access to the flash as well as the QSPI bus.
However, in snor_read() [hal_serial_nor.c] we have:
Parallel accesses of snor_read() trigger an assert as labelled, where in fact they should be handled by the later bus_acquire() code.
I've changed the osalDbgAssert() to:
and on a quick test all is fine.
Probably the assert should also let through (devp->state == FLASH_PGM)
I have a QSPI flash device as the only component connected to the QSPI bus on a 32F767. To avoid access collisions, I set:
Code: Select all
#define SNOR_SHARED_BUS TRUEThis should effectively regulate access to the flash as well as the QSPI bus.
However, in snor_read() [hal_serial_nor.c] we have:
Code: Select all
static flash_error_t snor_read(void *instance, flash_offset_t offset,
size_t n, uint8_t *rp) {
SNORDriver *devp = (SNORDriver *)instance;
flash_error_t err;
osalDbgCheck((instance != NULL) && (rp != NULL) && (n > 0U));
osalDbgCheck((size_t)offset + n <= (size_t)snor_descriptor.sectors_count *
(size_t)snor_descriptor.sectors_size);
osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE)
"invalid state"); // ********** Triggers here ************
if (devp->state == FLASH_ERASE) {
return FLASH_BUSY_ERASING;
}
/* Bus acquired.*/
bus_acquire(devp->config->busp, devp->config->buscfg);
/* FLASH_READY state while the operation is performed.*/
devp->state = FLASH_READ;
Parallel accesses of snor_read() trigger an assert as labelled, where in fact they should be handled by the later bus_acquire() code.
I've changed the osalDbgAssert() to:
Code: Select all
osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE) || (devp->state == FLASH_READ),
"invalid state");
and on a quick test all is fine.
Probably the assert should also let through (devp->state == FLASH_PGM)