I am having some issues with requesting the status of the S25FL128S QSPI-flash chip on the TWR-VF65GS10 dev-kit. I initialize the chip in MQX in the following manner:
Open device
Set single IO mode
Get virtual memory base offset
Get total memory length
Get sector size
At first status request, reading status1 on S25FL128S gives:
[INFO ] QSPI0 status code: 0xAA
[INFO ] ... Write in progress ............... : False
[INFO ] ... Write enable latch .............. : True
[INFO ] ... Block protection 1 .............. : False
[INFO ] ... Block protection 2 .............. : True
[INFO ] ... Block protection 3 .............. : False
[INFO ] ... Erase error occurred ............ : True
[INFO ] ... Programming error occurred ...... : False
[INFO ] ... Status register Write Disable ... : True
This happens even after I have done a hard-reset prior to loading my program. After doing any operation (typically erase or write), the next status code is "0xFF"
I based my QSPI driver on the bundled MQX example and the MQX IO User Guide. My status read function is in the following manner:
Build flash command: QuadSPI_READ_STATUS1, QuadSPI_READ_DATA(QuadSPI_SINGLE_PAD, 1), QuadSPI_LOOKUP_STOP
Write command
Read 1 byte
Does anyone have any input on this?
Solved! Go to Solution.
Hi,
According to your original question I know you already checked the MQX I/O User Guide, but there you can find that the extra byte is needed becuase you are reading only one byte:
fwrite Usage
fwrite provides two functionalities: sending command to the external flash and programing the external flash. The format of fwrite is:
fwrite: Commands + Write Buffer Address + Write/Read Bytes (optional)
Sending a command to the flash:
ioctl(qspifd, QuadSPI_IOCTL_SET_FLASH_ADDR, &addr); (optional)
fwrite: Commands + Write Buffer Address (NULL)
Programing data to the flash:
ioctl(qspifd, QuadSPI_IOCTL_SET_FLASH_ADDR, &addr);
fwrite: Commands + Write Buffer Address + Write Bytes
Sending a read command to the flash
ioctl(qspifd, QuadSPI_IOCTL_SET_FLASH_ADDR, &addr);
fwrite: Commands + Write Buffer Address(NULL) + Read Bytes
/Alejandro
Hi,
I just tested the qspi example found in the MQX installation folder and I am not facing that behavior.
Have you tried that example? Also I wonder if have tried to erase the entire memory first.
/Alejandro
Seems I removed what I considered a "mistake" in the example. The transmit buffer in the function "int32_t memory_read_status1(MQX_FILE_PTR qspifd, uint8_t *status)" is initialized
uint8_t buffer[6 + QuadSPI_ADDR_BYTES] = {0};
But during write, fwrite seems to get one byte too many:
result = fwrite(buffer, 1, 6 + QuadSPI_ADDR_BYTES + 1, qspifd);
When I did the same thing, the status request succeeded. How come this is necessary?
Hi,
According to your original question I know you already checked the MQX I/O User Guide, but there you can find that the extra byte is needed becuase you are reading only one byte:
fwrite Usage
fwrite provides two functionalities: sending command to the external flash and programing the external flash. The format of fwrite is:
fwrite: Commands + Write Buffer Address + Write/Read Bytes (optional)
Sending a command to the flash:
ioctl(qspifd, QuadSPI_IOCTL_SET_FLASH_ADDR, &addr); (optional)
fwrite: Commands + Write Buffer Address (NULL)
Programing data to the flash:
ioctl(qspifd, QuadSPI_IOCTL_SET_FLASH_ADDR, &addr);
fwrite: Commands + Write Buffer Address + Write Bytes
Sending a read command to the flash
ioctl(qspifd, QuadSPI_IOCTL_SET_FLASH_ADDR, &addr);
fwrite: Commands + Write Buffer Address(NULL) + Read Bytes
/Alejandro
Thanks.