2025-09-17 8:26 AM - last edited on 2025-09-17 9:20 AM by mƎALLEm
Hi all!
AGENDA: Need to verify the external QSPI flash (AT25Q128A) all sectors Write, Read and Comparing with STM32L496ZG-P using driver code.
APPROACH: For write, I am have created a buffer which comprises of page size of 256, and I am using two "for" loops one outer "for" loop for incrementing total sectors i.e. 4096 times and inner "for' loop as there are 16 pages for a single sector I am incrementing it to 16 times.
In below case I am trying to write letter O to all sectors and read and compare,
// Fill buffer with character 'O'
for (int i = 0; i < PAGE_SIZE; i++) {
page_buffer[i] = 'O';
}
for (uint32_t sector = 0; sector < TOTAL_SECTORS; sector++) {
uint32_t base_address = sector * SECTOR_SIZE;
for (uint32_t page = 0; page < PAGES_PER_SECTOR; page++) {
uint32_t page_address = base_address + (page * PAGE_SIZE);
//// Write to flash
if (CSP_QSPI_WriteMemory((uint8_t*)page_buffer, page_address, PAGE_SIZE) != HAL_OK) {
// flash_write_success = false; // Error in writing
Error_Handler();
}
//// Read back
if (CSP_QSPI_Read((uint8_t*)read_buffer, page_address, PAGE_SIZE) != HAL_OK) {
// flash_write_success = false; // Error in reading
Error_Handler();
}
// if(read_buffer[7]!='O')
// {
// Error_Handler();
// }
}
}
For reading, I am trying to read the written char from the same location I have stored in the same for loop and comparing using if condition.
BUG: During line by line debugging when verified in live expression, the read buffer is storing the written value 'O'. but if I select run in the debug session, read buffer is not storing any values it is displaying y(two dots above y with , 255). And for verification of reading i have commented the write function and erase chip function, and again i have flashed the code, this time also the read buffer is not reading the written data at the location. Using the same code(with write and read functions present inside the for loops ), when i verified with the cube programmer and on pressing the read icon, the data written data is reading at defined memory locations, even tried powering it off and on, still data is retaining, but main motive of task is to verify the memory sectors using driver not with cube programmer.
Kindly help me out sorting the bug to verify all the sectors of memory with driver code.
Thanks!!
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-09-18 1:08 AM - edited 2025-09-18 1:17 AM
Hello @Abhiram_12 ;
Could you please give more detail about the issue?
Which STM32CubeIDE version are you using?
Do you configure and run any other peripherals?
Do you use a breakpoint?
In which mode does the memory operate: memory mapped mode or indirect mode?
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-18 5:38 AM
Hi @KDJEM.1 , thanks for reaching out!!
1. I am using STM32 Cube IDE version 1.14.0.
2. No I am not using any other peripherals along with QSPI driver verification.
3. Yes I had used break point at QSPI_Read() function inside the inner for loop.
Goal is to verify all the sectors of external memory (AT25Q128A) flash using code by writing, reading and comparing whether the write buffer is equal to read buffer.
For the above goal, using the above code, if I did line by line debugging by inserting break point at QSPI Read function, simultaneously i can observe the read_buffer is reading written values (refer to the previous message's photo) in live expression.
First issue is, if I remove break point at read function and run the code in debug session, the read_buffer is not performing read, when verified with cube programmer, all address location is getting displayed 255 (y two dots above it).
Second issue, from the above code, now I had commented the QSPI write function and erase chip function (present in my code), now I am flashing the code again to read the written values, but it is not happening, instead inside read_buffer it is displaying 255(y above two dots) despite O.
Hope you got what my issue is @KDJEM.1 .
2025-09-19 8:10 AM
Hello @Abhiram_12;
I recommend you to upgrade your STM32CubeIDE toolchain.
Could you please share the memory configuration
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-19 10:34 AM
@KDJEM.1 Kindly refer to the memory configuration of NOR flash AT25Q128A
refer to the link for further references for the flash https://www.renesas.com/en/document/dst/at25qf128a-datasheet?srsltid=AfmBOorf5BWgu8polsOYEwruESDWA17LmvhnbUoboQ94GM6Qnh13A61i
could you suggest me reliable approach for developing driver which is capable of writing, reading and comparing all the sectors?
2025-09-19 10:35 AM
Sorry for name of flash, the NOR flash name is AT25QF128A, not AT25Q128A (as previously mentioned).
2025-09-22 2:23 AM
Hello @Abhiram_12 ;
To develop driver I recommend you referring to a memory driver like as GitHub - STMicroelectronics/stm32-mx25r6435f: Provides the mx25r6435f driver, part of the STM32Cube BSP Component for all STM32xx series. and get inspired.
Also, I advise you to look and start with an available STM32CubeL4/Projects/32L496GDISCOVERY/Examples/QSPI at master · STMicroelectronics/STM32CubeL4 · GitHub example.
I hope this can help you.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.