Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is not compared after the sector read #3

Open
MahendraSondagar opened this issue Jan 28, 2019 · 1 comment
Open

Data is not compared after the sector read #3

MahendraSondagar opened this issue Jan 28, 2019 · 1 comment

Comments

@MahendraSondagar
Copy link

Hey, there
Thanks for the universal driver for the Winbond flash
I'm using the driver with W25Q16 chip, for me everything works well and I'm detecting id and able to write and read read the data
for all flash operation I have commands from serial terminal the test flow is as follow
(1) Command 'F' to Fotomat the Entire flash ->Working well
(2) Command 'W' to write 1024 bytes buffer in sector 0x030000h-> Working well
(3)Command 'R' to read the 1024 bytes buffer from sector 0x030000h-> Working well
and i can compare the buffer with memcmp with the buffer that i have wrote previously

(4) Command 'A' to write 1024 byte(different from 1st one) to sector Add. 0x030000h-> working well

(5) Command 'C' to read 1024 bytes from sector 0x030000h-> working well
i can compare the 2nd bytes buffer with the derived data at 0x010000h via memcmp

(6) Now when i apply the previous Command 'R' to read the data from 0x030000h sector then the buffer that i have devised is as same as i wrote in 2nd sector location (i.e 0x030000h) and memcmp condition gets fail

I have 2 separate buffer of 1024 bytes to read and separate buffer to read. I'm also erasing the entire sector before write

result seems same at all
Here is the snippet for my code
Can you please help me here?
Tanks

`uint8_t test[]="STM32 IS25LP016D Code test\r\n";
uint8_t temp;
uint8_t Dump_string[]="STM32 IS25LP016D SPI flash test HBDHVFHDVHFDSVHDSVHF DSNFBDHJSFVDSHVFDSVFDSVF DHNSFBDHSFHdfjbdhjfdhs dsfjdnsfjdbfdsbfhbhfdsbsddsfdsfdsfdsfdsfdsffhdbshfdvhfdvshfdvsfvdshvfdsvfdsvf hdsbfhdshfvdshjfvdshvfdhsvdhsvfhdvfhdsvhdvfsh bfvdhsfvdhsv hjdsbfhdsfh 1454 HBFHDBHFDVHJDVSHFVDSHFVDHSFVDHSVFDHS DSNFBDHJSFBHDSBFHDSBHDSBFHDBVFHDSVFH DSNJFNDJSFBDSHJBFDHSBFDHSBHDSBFDHS DSJFNDJSFBDJSBFDHSBDHBFDHSBFH DSFJBDSHJFBDHJSBHDSBFHDSBFHDS DSJFNJDSBDHJSBHDSBHDBF DJSFJDSBFJDSBFHDSBH DSDJFBDHJSBFDHSBHDSBF DSJFBDHJSBFDHSBFHDSB DJSBFDHJSBHDSBH DHJSBFHDBDHJSBF DSJFBJDSBFDHJS DJSBFJDSBFJDSBJ DMJSNFJDSBFJDSBJ DJSBFJDSBFHJDS JDSBFJDSBHJ DJSFJDSBJ JDSBFJDSBFJ HJDSBFDHJSB HDSBHFBDSH dhfbdhfdhsfhdsfhdvshfds gfvsdgdfvdgasvfgasvfgsvfgdsvfgdvgfdvsgfdvsgfvdsgvfdgsvfdgsvgdsvgfdvsgvdgfsvgdsvg hbdhfbdhfdhsbfhdsbfhdshfd sdfdhsbfdhsbfhdsbfhbdshfbhdsbfhdsbhfbdshfdhsfdhsbfhdsbfhdsbhfbdshdhbhfdshfdshfbdshfdh hfbvhdsavfghdvgfdvgfdvsgfvdsgvfdgsvfdgsvfdsvfgdsvgdsvfgdvsgfdvsgfvdsgfvdsgvdgsvgfdsvgfdvsgfvdgfvdsvdgfdvsgfvdsgfvdgsvdgsvgdsvgdvsgvdgsvtgvfdgds";
uint8_t Read_string[30];
uint32_t StartAddress=0x000000;
uint32_t rBuff[1024];
uint32_t rbuff2[1024];
uint8_t Dump_String2[1024]="Although flash memory is technically a type of EEPROM, the term EEPROM is generally used to refer specifically to non-flash EEPROM which is erasable in small blocks, typically bytes.[citation needed] Because erase cycles are slow, the large block sizes used in flash memory erasing give it a significant speed advantage over non-flash EEPROM when writing large amounts of data. As of 2013, flash memory costs much less than byte-programmable EEPROM and had become the dominant memory type wherever a system required a significant amount of non-volatile solid-state storage While EPROMs had to be completely erased before being rewritten, NAND-type flash memory may be written and read in blocks (or pages) which are generally much smaller than the entire device. NOR-type flash allows a single machine word (byte) to be written – to an erased location – or read independently Compared to NOR flash, replacing single transistors with serial-linked groups adds an extra level of addressing. Whereas NOR flash might Hello world";

/* USER CODE END 0 */

/**

  • @brief The application entry point.
  • @RetVal None
    /
    int main(void)
    {
    /
    USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration----------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals /
MX_GPIO_Init();
MX_SPI2_Init();
MX_USART3_UART_Init();
/
USER CODE BEGIN 2 */
HAL_Delay(100);
HAL_UART_Receive_IT(&huart3, (uint8_t *)aRXdata, 1);
HAL_UART_Transmit(&huart3, test, sizeof(test), 100);

printf("SPI Flash demo\r\n");

W25qxx_Init();

/* USER CODE END 2 */

/* Infinite loop /
/
USER CODE BEGIN WHILE */
while (1)
{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

	if(SerialAvailable==true){
			printf("--------------------------\r\n");
			printf("Command =%c\r\n", aRXdata[0]);
			printf("--------------------------\r\n");
		
		switch(aRXdata[0]){
			case ('F'):
				printf("--------------------------\r\n");
				printf("Formating Flash\r\n");
			  printf("--------------------------\r\n");
			  W25qxx_EraseChip();
			  break;
			case ('M'):
				printf("--------------------------\r\n");
				printf("Getting Menufacturer\r\n");
		  	printf("--------------------------\r\n");
			  W25qxx_GetManufacturer();
			  break;
			
			case ('W'):
				printf("--------------------------\r\n");
				printf("Writing the Flash\r\n");
			  printf("--------------------------\r\n");
			  StartAddress=0x000000;
			  W25qxx_EraseBlock(StartAddress);
			  W25qxx_WriteSector(Dump_string, StartAddress, 0, 1024);
			  break;
				
			case ('R'):
				printf("--------------------------\r\n");
				printf("Reading the Flash\r\n");
			  printf("--------------------------\r\n");
			  StartAddress=0x000000;
			  memset(rBuff, 0x00, sizeof(rBuff));
			  W25qxx_ReadSector((uint8_t *)&rBuff, StartAddress,0,1024);
			  if(memcmp(Dump_string, rBuff, 1024)==0){
					printf("\r\nBoth data identical\r\n");
				}else{
					printf("\r\nData are not identical");
				}
			  break;
			
			case ('A'):
				printf("--------------------------\r\n");
				printf("Writing the Flash\r\n");
			  printf("--------------------------\r\n");
			  StartAddress=0x030000;
			  W25qxx_EraseBlock(StartAddress);
			  W25qxx_WriteSector(Dump_String2, StartAddress, 0, sizeof(Dump_String2));
				break;
			
			case ('C'):
				printf("--------------------------\r\n");
				printf("Reading the Flash\r\n");
			  printf("--------------------------\r\n");
			  StartAddress=0x030000;
			  memset(rbuff2, 0x00, sizeof(rbuff2));
			  W25qxx_ReadSector((uint8_t *)&rbuff2, StartAddress,0,1024);
				  if(memcmp(Dump_String2, rbuff2, 1024)==0){
					printf("\r\nBoth data identical\r\n");
				}else{
					printf("\r\nData are not identical");
				}
				break;
			
			case ('G'):
				printf("Storing the Magic Number\r\n");
			  StartAddress=EXT_OTA_MAGIC_NUM_POS;
			  W25qxx_WriteSector(MAGIC_NO, StartAddress,0,4);
			  break;
			
			case ('B'):
				StartAddress=EXT_OTA_MAGIC_NUM_POS;
				printf("Reading the Magic No\r\n"); memset(rBuff, 0x00, sizeof(rBuff));
			  HAL_Delay(10);
			  W25qxx_ReadSector((uint8_t *)&rBuff, StartAddress,0,4);
				break;
			
			default:
				printf("--------------------------\r\n");
				printf("Default case!\r\n");  
			  printf("--------------------------\r\n");
		}
		SerialAvailable=false;
	}

}
/* USER CODE END 3 */

}`

Here is the logs file from my code

w25qxx Page Count: 8192
w25qxx Sector Size: 4096 Bytes
w25qxx Sector Count: 512
w25qxx Block Size: 65536 Bytes
w25qxx Block Count: 32
w25qxx Capacity: 2048 KiloBytes
w25qxx Init Done

Command =F


Formating Flash

w25qxx EraseChip Begin...
w25qxx EraseBlock done after 2994 ms!

Command =W


Writing the Flash

w25qxx EraseSector 65536 Begin...
w25qxx EraseSector done after 73 ms
+++w25qxx WriteSector:10000, Offset:0 ,Write 1024 Bytes, begin...
w25qxx WritePage:100000, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
w25qxx WritePage:100001, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
w25qxx WritePage:100002, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
w25qxx WritePage:100003, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
---w25qxx WriteSector Done

Command =R


Reading the Flash

+++w25qxx ReadSector:10000, Offset:0 ,Read 1024 Bytes, begin...
w25qxx ReadPage:100000, Offset:0 ,Read 256 Bytes, begin...
STM32 IS25LP016D SPI flash test HBDHVFHDVHFDSVHDSVHF DSNFBDHJSFVDSHVFDSVFDSVF DHNSFBDHSFHdfjbdhjfdhs dsfjdnsfjdbfdsbfhbhfdsbsddsfdsfdsfdsfdsfdsffhdbshfdvhfdvshfdvsfvdshvfdsvfdsvf hdsbfhdshfvdshjfvdshvfdhsvdhsvfhdvfhdsvhdvfsh bfvdhsfvdhsv hjdsbfhdsfh 1454 w25qxx ReadPage:100001, Offset:0 ,Read 256 Bytes, begin...
HBFHDBHFDVHJDVSHFVDSHFVDHSFVDHSVFDHS DSNFBDHJSFBHDSBFHDSBHDSBFHDBVFHDSVFH DSNJFNDJSFBDSHJBFDHSBFDHSBHDSBFDHS DSJFNDJSFBDJSBFDHSBDHBFDHSBFH DSFJBDSHJFBDHJSBHDSBFHDSBFHDS DSJFNJDSBDHJSBHDSBHDBF DJSFJDSBFJDSBFHDSBH DSDJFBDHJSBFDHSBHDSBF DSJFBDHJSBFDHSBFHDSB Dw25qxx ReadPage:100002, Offset:0 ,Read 256 Bytes, begin...
JSBFDHJSBHDSBH DHJSBFHDBDHJSBF DSJFBJDSBFDHJS DJSBFJDSBFJDSBJ DMJSNFJDSBFJDSBJ DJSBFJDSBFHJDS JDSBFJDSBHJ DJSFJDSBJ JDSBFJDSBFJ HJDSBFDHJSB HDSBHFBDSH dhfbdhfdhsfhdsfhdvshfds gfvsdgdfvdgasvfgasvfgsvfgdsvfgdvgfdvsgfdvsgfvdsgvfdgsvfdgsvgdsvgfdvsgvdgfsvgdsvg w25qxx ReadPage:100003, Offset:0 ,Read 256 Bytes, begin...
hbdhfbdhfdhsbfhdsbfhdshfd sdfdhsbfdhsbfhdsbfhbdshfbhdsbfhdsbhfbdshfdhsfdhsbfhdsbfhdsbhfbdshdhbhfdshfdshfbdshfdh hfbvhdsavfghdvgfdvgfdvsgfvdsgvfdgsvfdgsvfdsvfgdsvgdsvfgdvsgfdvsgfvdsgfvdsgvdgsvgfdsvgfdvsgfvdgfvdsvdgfdvsgfvdsgfvdgsvdgsvgdsvgdvsgvdgsvtgvfdgds
Both data identical

Command =A


Writing the Flash

w25qxx EraseSector 196608 Begin...
w25qxx EraseSector done after 72 ms
+++w25qxx WriteSector:30000, Offset:0 ,Write 1024 Bytes, begin...
w25qxx WritePage:300000, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
w25qxx WritePage:300001, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
w25qxx WritePage:300002, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
w25qxx WritePage:300003, Offset:0 ,Writes 256 Bytes, begin...

w25qxx WritePage done after 10 ms
---w25qxx WriteSector Done

Command =C


Reading the Flash

+++w25qxx ReadSector:30000, Offset:0 ,Read 1024 Bytes, begin...
w25qxx ReadPage:300000, Offset:0 ,Read 256 Bytes, begin...
Although flash memory is technically a type of EEPROM, the term EEPROM is generally used to refer specifically to non-flash EEPROM which is erasable in small blocks, typically bytes.[citation needed] Because erase cycles are slow, the large block sizes usew25qxx ReadPage:300001, Offset:0 ,Read 256 Bytes, begin...
d in flash memory erasing give it a significant speed advantage over non-flash EEPROM when writing large amounts of data. As of 2013, flash memory costs much less than byte-programmable EEPROM and had become the dominant memory type wherever a system requiw25qxx ReadPage:300002, Offset:0 ,Read 256 Bytes, begin...
red a significant amount of non-volatile solid-state storage While EPROMs had to be completely erased before being rewritten, NAND-type flash memory may be written and read in blocks (or pages) which are generally much smaller than the entire device. NOR-tw25qxx ReadPage:300003, Offset:0 ,Read 256 Bytes, begin...
ype flash allows a single machine word (byte) to be written – to an erased location – or read independently Compared to NOR flash, replacing single transistors with serial-linked groups adds an extra level of addressing. Whereas NOR flash might Hello world
Both data identical

Command =R


Reading the Flash

+++w25qxx ReadSector:10000, Offset:0 ,Read 1024 Bytes, begin...
w25qxx ReadPage:100000, Offset:0 ,Read 256 Bytes, begin...
Although flash memory is technically a type of EEPROM, the term EEPROM is generally used to refer specifically to non-flash EEPROM which is erasable in small blocks, typically bytes.[citation needed] Because erase cycles are slow, the large block sizes usew25qxx ReadPage:100001, Offset:0 ,Read 256 Bytes, begin...
d in flash memory erasing give it a significant speed advantage over non-flash EEPROM when writing large amounts of data. As of 2013, flash memory costs much less than byte-programmable EEPROM and had become the dominant memory type wherever a system requiw25qxx ReadPage:100002, Offset:0 ,Read 256 Bytes, begin...
red a significant amount of non-volatile solid-state storage While EPROMs had to be completely erased before being rewritten, NAND-type flash memory may be written and read in blocks (or pages) which are generally much smaller than the entire device. NOR-tw25qxx ReadPage:100003, Offset:0 ,Read 256 Bytes, begin...
ype flash allows a single machine word (byte) to be written – to an erased location – or read independently Compared to NOR flash, replacing single transistors with serial-linked groups adds an extra level of addressing. Whereas NOR flash might Hello world
Data are not identical

@nimaltd
Copy link
Owner

nimaltd commented Jan 29, 2019

hello .
when you writing or reading by sector function, your address can be max (w25qxx Sector Count: 512)
StartAddress=0x030000; << wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants