c90tfs_flash_driver - unable to erase and program

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

c90tfs_flash_driver - unable to erase and program

Jump to solution
1,571 Views
Can_Do_bus
Contributor III

I am using S32k144 - I am using design studio to run the code in debug mode.

 

My code runs in NVM, I am executing the following commands in my code to erase and then program the P Flash area, i.e erase the same sector and  followed  by writing to that sector.

The code works if I either erase or program i.e if I run the program once with the FlashProgram command commented, it will erase the sector. When I run it subsequently to execute FlashProgram command with FlashEraseSector commented out line, this setup works.

 

However when I try to execute them together as below, it doesn't erase.  What is the issue

FlashEraseSector(&flashSSDConfig, flash_prog_address, FEATURE_FLS_PF_BLOCK_SECTOR_SIZE, FlashCommandSequence);
cycles=10000;
while(cycles--);
unsigned char testdata[] = {0xAA,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC};

FlashProgram(&flashSSDConfig, flash_prog_address, 40, testdata , FlashCommandSequence);

 

0 Kudos
Reply
1 Solution
1,536 Views
Can_Do_bus
Contributor III

The driver seems to have some bugs, it was much easier to write 5 lines of code to write to internal flash rather than trying to debug these drivers.

View solution in original post

0 Kudos
Reply
6 Replies
1,548 Views
Can_Do_bus
Contributor III

The forum seems to have some bugs, I posted a reply it appeared then after a while it disappeared, have to post it multiple times to get it on.

While on the topic, can you also let me know how to program more than 160 bytes using this flash driver. There is a method called which is disabled from compiling.

#if FSL_FEATURE_FLS_HAS_PROGRAM_SECTION_CMD

FlashProgramSection

0 Kudos
Reply
1,551 Views
Can_Do_bus
Contributor III

The following code prevents code crashing, however neither the memory is erased or reprogrammed - one of the flash operation still has to be commented out for the other one to succeed

 

	//returncode = FlashEraseSector(&flashSSDConfig, flash_prog_address, FEATURE_FLS_PF_BLOCK_SECTOR_SIZE, FlashCommandSequence);
		while (0U == (FTFx_FSTAT & FTFx_FSTAT_CCIF_MASK))
		{

		}
		int cycles = 1720000;
		while(cycles--);


	}
	unsigned char testdata[] = {0xDD,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
			0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
			0xAA,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
			0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC};



		returncode = FlashProgram(&flashSSDConfig, flash_prog_address,40 , testdata , FlashCommandSequence);
		while (0U == (FTFx_FSTAT & FTFx_FSTAT_CCIF_MASK))
		{

		}

 

0 Kudos
Reply
1,530 Views
Can_Do_bus
Contributor III

 

returncode = FlashEraseSector(&flashSSDConfig, flash_prog_address, FEATURE_FLS_PF_BLOCK_SECTOR_SIZE, FlashCommandSequence);
		while (0U == (FTFx_FSTAT & FTFx_FSTAT_CCIF_MASK))
		{

		}
		int cycles = 1720000;
		while(cycles--);


	unsigned char testdata[] = {0xDD,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
			0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
			0xAA,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
			0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xBB,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC};



		returncode = FlashProgram(&flashSSDConfig, flash_prog_address,40 , testdata , FlashCommandSequence);
		while (0U == (FTFx_FSTAT & FTFx_FSTAT_CCIF_MASK))
		{

		}
		int cycles = 1720000;
			   while(cycles--);

 

With the above code, the code doesn't crash, i.e both the lines executed however NO ERASE and NO WRITE occurs.

0 Kudos
Reply
1,562 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi 

Could you try waiting for FlashEraseSector to return FTFx_OK? It seems to be caused by too little waiting time.

Table 33 Return Values for FlashEraseSector.png

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

Tags (1)
0 Kudos
Reply
1,558 Views
Can_Do_bus
Contributor III

Can you provide me a suitable code for the call back, currently I am passing NULL CALLBACK.

 

Even otherwise the erasefunction doesn't return if both the functions are present (atleast in the debugger I am not able to get the return value)

 

 ret = pFlashCommandSequence(pSSDConfig);  <--- the code crashes here doesn't return

/*! @brief Configuration structure flashCfg_0 */
const flash_user_config_t Flash_InitConfig0 = {
		/* for the S32K144 */

		.PFlashBase  = 0x00000000U,
		.PFlashSize  = 0x00080000U,
		.DFlashBase  = 0x10000000U,
		.EERAMBase   = 0x14000000U,
		.CallBack    = NULL_CALLBACK
};

 

0 Kudos
Reply
1,537 Views
Can_Do_bus
Contributor III

The driver seems to have some bugs, it was much easier to write 5 lines of code to write to internal flash rather than trying to debug these drivers.

0 Kudos
Reply