Guidance on fsl_flash Processor Expert component usage

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

Guidance on fsl_flash Processor Expert component usage

Jump to solution
2,068 Views
MAPC
Senior Contributor I

Hello,

 

I have a customer who is developing a project based on MKL25Z128 MCU and is using Processor Expert and KDS 3.0.0 for that.

 

One of the features of the project is programming data in Flash. There is a manual explaining the KSDK 1.2 Flash driver functions and a demo, as well. But we haven't found a manual for the new KDS 3.0 Processor Expert and its beans, that are completely different from CodeWarrior 10.x ones. So we are in a struggle to learn how to use it.

 

One thing that called our attention is C90TFS register base address setting. We looked at the MKL25 reference manual for some information about this register, but we couldn't find absolutely nothing. Another find that we can't understand is why we need to define in this bean parameters like Program Flash base address and Program Flash size, since the MCU is defined through the CPU bean?

 

71750_71750.pngpastedImage_1.png 

 

We need guidelines or examples on how to correctly configure and use this bean.

 

 

Thanks and besr regards,

 

Marco Coelho

Siletec Eletronica

Labels (1)
1 Solution
1,021 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Marco:

I checked your project. It seems you are just missing to disable the interrupts before calling Flash APIs. Otherwise the SysTick interrupt triggers and the ISR function is in Flash space, so it crashes.

Please give a check to the attached main file.

Regards!

Jorge Gonzalez

View solution in original post

0 Kudos
7 Replies
1,021 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  Marco Coelho,

        fsl_flash bean in KDS 3.0 is really very different from the FLASH_LDD in CW.

      fsl_flash bean is the component for flash driver C90TFS, so the configuration should define the C90TFS items, then use the API function in C90TFS to operation the flash.

About the configuration items in fsl_flash,  please refer to the following picture:

pastedImage_0.png

It is very sample, so there has no guidance now, the above configuration is for MKL25Z128, it is just define the data for the SSD structure in C90TFS.

2.3 Configuration parameter

The configuration parameters, used for the SSD are given in this section. They are handled as structure as bellow :

typedef struct _ssd_config

{

uint32_t ftfxRegBase;

uint32_t PFlashBlockBase;

uint32_t PFlashBlockSize;

uint32_t DFlashBlockBase;

uint32_t DFlashBlockSize;

uint32_t EERAMBlockBase;

uint32_t EEEBlockSize;

bool DebugEnable;

PCALLBACK CallBack;

} FLASH_SSD_CONFIG, *PFLASH_SSD_CONFIG;

flashSSDConfig is the name, you can change the name.

After the configuration in the above picture, you will get this struct:

FLASH_SSD_CONFIG flashSSDConfig = {

    .ftfxRegBase = 1073872896U,

    .PFlashBase  = 0U,

    .PFlashSize  = 131072U,

    .DFlashBase  = 0U,

    .DFlashSize  = 0x00U,

    .EERAMBase  = 0U,

    .EEESize    = 0x00U,

    .DebugEnable        = false,

    .CallBack = NULL_CALLBACK,

};

ftfxRegBase is KL25 FTFA register base address, you can find it from KL25 reference manual,  it is 0X40020000

PFlashBlockBase = PFlashBase Pflash base address is 0x00000000;

PFlashBlockSize = PFlashSize ,  the block size of KL25, as you know KL25 have 128KB flash, so the size is 128KB= 0x00020000= 131072U

No data flash, so DflashBase =0, DFlashSize =0;

No FlexNVM, so EERAMBase =0, EEESize =0;

For more details about C90TFS, I think you can refer to the attached C90TFS document:

After you configure it, you can refer to the code in KSDK1.2.0 to write the flash code.

Wish it helps you!

If you still have question, please contact with me!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,021 Views
MAPC
Senior Contributor I

Hi, Dear Jingjing

Here it goes my code attached.

Thanks,

Marco Coelho

Siletec Eletronica

0 Kudos
1,021 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Macro,

    Just like Jorge Gonzalez have said, the flash operation failure is really caused by the systick interrupt.

    Please configure the osa1 module like this :

pastedImage_0.png

  Don't select the systick, if you select the SysTick, even you don't install interrupt, I find the systick interrupt still be enabled, the interrupt enable code can be find in

osa1.c which you can find from the Gererated_Code folder, function void OSA_TimeInit(void).

  So, don't select the timer for OS, this problem will be solved.

Wish it helps you!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,021 Views
MAPC
Senior Contributor I

Hello, Jingjing and Jorge

Thank you very much for your comments. I followed your advice and now everything is working.

This Systick interrupt should be disabled by default. It doesn't make sense to have this interrupt in a baremetal application and even in most of MQX applications. That causes problems all the time.

What is the best way to find the cause of a Reset in KDS?

I really appreciated your support, guys.

Thanks and best regards,

Marco Coelho

0 Kudos
1,022 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Marco:

I checked your project. It seems you are just missing to disable the interrupts before calling Flash APIs. Otherwise the SysTick interrupt triggers and the ISR function is in Flash space, so it crashes.

Please give a check to the attached main file.

Regards!

Jorge Gonzalez

0 Kudos
1,021 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Marco Coelho,

      Your test is really very carefully! That's very good!

     From the phenomena, it seems that there missed some configurations, local variable has been abnormally changed, and the PC pointer running abnormally.

     I will check it carefully, but it need time.

    So please wait patiently, once I find the problem, I will reply you!

    At the same time, you also can refer to : C:\Freescale\KSDK_1.2.0\examples\frdmkl25z\driver_examples\flash\kds  , and compare it with the PE project.

    Any updated information, please follow up.

Best RegardsJingjing

0 Kudos
1,021 Views
MAPC
Senior Contributor I

Hello, Jingjing Zhou

Thanks for the fast response.

I have tried to make a simple code based on the demo code, but using Processor Expert fsl_flash bean, but it is not working and I couldn't find the reason for that so far.

I debugged my code and some points called my attention:

1) In "FlashEraseSector", after it goes through the line:

        REG_WRITE(temp, FTFx_SSD_FSTAT_ERROR_BITS);

The "dest" variable, that had the value "0x1E800, assumes the value 0x31. Another point that you can see by hte screenshot bellow is that "temp" variable is not accessible at any time. So strange!

pastedImage_1.png

2) After it goes through the line:

        REG_WRITE(temp, GET_BIT_16_23(dest));

"dest" variable assumes the value 0x01, as you can see on the screenshot bellow:

pastedImage_2.png

3)   After that, it goes into a strange loop as if there is a for loop from the line:

        ret = pFlashCommandSequence(pSSDConfig);

to the line:

     dest += sectorSize;

    And does it for some times until it calls "pFlashCommandSequence" for a last time and falls into a Reset that I can't recognize the cause.

pastedImage_3.png

Jingjing, please have attached my code. Could you take a look at it and help understand where I went wrong?

Thanks and best regards,

Marco Coelho

Siletec Eletronica

0 Kudos