pFlashCommandSequence RAM Function resets board

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

pFlashCommandSequence RAM Function resets board

Jump to solution
1,998 Views
jasonphilippi
Contributor III

Hello,

I have a custom board using a MK24FN1M0VLQ12 with freeRTOS, and KSDK 1.3.0.

If I step through the RAM Function called by pFlashCommandSequence using Instruction Stepping Mode, with Interrupts Disabled/Enabled, I can execute these functions. Though when I Step Over or Resume I can not get to the next break point.

I saw this Can't get flash erasing and writing on MK22FN128VLH10 to work.

My Flash Clock on my board is set to 10.48576 MHz

The Flash Clock in Run Mode works up to 25MHz.

The Flash Clock in VLPR Mode works up to 800kHz

I think I should be in the clear for that. I am not running VLPR (Very Low Power Run) mode. 

Is alignment an issue?

The Flash Demo projects in K64F and K22F boards don't use any alignments in their RAM Functions that I can see.

Why would my board reset when running these RAM Functions?

Regards,

Jason Philippi

Labels (1)
0 Kudos
1 Solution
1,467 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jason Philippi,

      Sorry for my later reply, it caused a lot of time to test your project.

     Now, I found the root problem which caused your reset problem, it is the flash_task stack size is too small.

     Please do the following modification:

1. flash_callback definition changed to:

bool SIZE_OPTIMIZATION flash_callback(uint8_t currentSwapMode)

2.  CALLBACK_SIZE changed to

#define LAUNCH_CMD_SIZE 0x80 //0x200
#define CALLBACK_SIZE 0x130 //0x200 //0x1a0

3. ProcessorExpert.ld file

HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x4000;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;

4.FRTOS1_xTaskCreate stack size changed to 1000.

void flash_initTask()
{
    //flash1_InitConfig0.CallBack = (PCALLBACK)RelocateFunction((uint32_t)ramForCallback , CALLBACK_SIZE , (uint32_t)flash_callback);

        if(FRTOS1_xTaskCreate(
                flash_task, /* pointer to the task */
                "flash_task", /* task name for kernal awareness debugging */
                1000, /* task stack size */ //configMINIMAL_STACK_SIZE
                (void*)NULL, /* optional task startup argument */
                tskIDLE_PRIORITY, /* initial priority */
                &flash_taskHandle /* optional task handle to create */
        ) != pdPASS)
        {
            for(;;){} //Ran out of heap
        }
        else
        {
        }
}

After debug, you can find the code can run over PFlashSwapCtl function.

pastedImage_2.png

I also attached my modified project.

After you add it and build it, please modify ProcessorExpert.ld stack and heap size.

View solution in original post

0 Kudos
12 Replies
1,467 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jason,

    Your problem should be caused by the interrupt, the flash operation command can't be interrupted.

    So, before you do the flash operation, please disable the global interrupt, after the flash operation is finished, enable the global interrupt again.

    Please disable the global interrupt, and try again.

#define EnableInterrupt  asm("cpsie i");
#define DisableInterrupt  asm("cpsid i");

Wish it helps you!

If you still have question, please contact me!

Have a great day,
Kerry

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

0 Kudos
1,467 Views
jasonphilippi
Contributor III

Kerry,

I was using INT_SYS_DisableIRQGlobal() and INT_SYS_EnableIRQGlobal() from fsl_interrupt_manager.c which is the same as what you defined. I used your version and that didn't work either.

The board still resets after stepping over the command sequence.

Regards,

Jason

0 Kudos
1,467 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jason,

    If you are convenient, could you upload your problem project? If the project have the important code, you can delete it, just leave the flash operation code which can reflect the problem, I will test it on my FRDM-K64 board, this will be useful to find the root problem.

   Waiting for your reply!


Have a great day,
Kerry

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

0 Kudos
1,467 Views
jasonphilippi
Contributor III

Kerry,

I am currently porting it over to my FRDM-K64 board. I have to strip out things I don't want public.

I'll have 3 tasks running the tri color LED and 1 task running the Flash Swap. 

Hopefully I'll have it up next week.

Thanks,

Jason

0 Kudos
1,467 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jason,

      I understand you!

     After you porting it to the FRDM-K64, and reproduce your problem, just send me your project.

     I would like to help you to check it!

Waiting for your updated information!

Best Regards

Kerry

0 Kudos
1,467 Views
jasonphilippi
Contributor III

Kerry,

I attached the project zip and a set of components I use from https://mcuoneclipse.com/ .

You will have to import and link the components with processor expert.

There are 3 independent tasks running the Tri-color LED. They are set to cycle through all possible colors from OFF to White.

The flash_task will start but, will then wait for a notification to wake it up.

Press SW3 to wake up the task to start.

I have not verified the programming of the upper flash because stepping by instruction sets would take too long.

The problem occurs at the first call of pFlashCommandSequence from PFlashSwapCtl in flash_swap().

If I don't step through it by instruction set, the board will reset.

Let me know what you think.

Thank you,

Jason

0 Kudos
1,467 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jason Philippi,

    Thank you for your more details.

    Please tell me what the IDE you are using? Codewarrior?

I use CW open it, it have a lot of errors:

pastedImage_1.png

About the component you attached, please give me a picture how to import to your project.

Thank you and wait for your reply!

Kerry

0 Kudos
1,467 Views
jasonphilippi
Contributor III

Kerry,

I haven't heard any updates on this problem in 2 weeks.

I was wondering if you were able to set up the project?

Let me know if you have any other problems with the set up.

Thank you,

Jason

0 Kudos
1,468 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jason Philippi,

      Sorry for my later reply, it caused a lot of time to test your project.

     Now, I found the root problem which caused your reset problem, it is the flash_task stack size is too small.

     Please do the following modification:

1. flash_callback definition changed to:

bool SIZE_OPTIMIZATION flash_callback(uint8_t currentSwapMode)

2.  CALLBACK_SIZE changed to

#define LAUNCH_CMD_SIZE 0x80 //0x200
#define CALLBACK_SIZE 0x130 //0x200 //0x1a0

3. ProcessorExpert.ld file

HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x4000;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;

4.FRTOS1_xTaskCreate stack size changed to 1000.

void flash_initTask()
{
    //flash1_InitConfig0.CallBack = (PCALLBACK)RelocateFunction((uint32_t)ramForCallback , CALLBACK_SIZE , (uint32_t)flash_callback);

        if(FRTOS1_xTaskCreate(
                flash_task, /* pointer to the task */
                "flash_task", /* task name for kernal awareness debugging */
                1000, /* task stack size */ //configMINIMAL_STACK_SIZE
                (void*)NULL, /* optional task startup argument */
                tskIDLE_PRIORITY, /* initial priority */
                &flash_taskHandle /* optional task handle to create */
        ) != pdPASS)
        {
            for(;;){} //Ran out of heap
        }
        else
        {
        }
}

After debug, you can find the code can run over PFlashSwapCtl function.

pastedImage_2.png

I also attached my modified project.

After you add it and build it, please modify ProcessorExpert.ld stack and heap size.

0 Kudos
1,467 Views
jasonphilippi
Contributor III

Kerry,

This worked for me!

Could you give me some advice on how you figured out the sizes for HEAP_SIZE, STACK_SIZE, task Stack Size, LAUNCH_CMD_SIZE, and CALLBACK_SIZE was needed?

I am using -fstack-usage to find out how many bytes my functions are using.

Thank you,

Jason

0 Kudos
1,467 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jason,

    Sorry for my later reply, there has a lot of cases need to process before.

    I have set up your project on my side now.

   Now, I can reproduce your problem on my board, you are using the flash swap function.

   I am checking your code and working on it.

  In the meanwhile, you also can test the code, you can try to create a project  without freertos,  just add your flash swap code, make sure your flash swap code have no problem .

About the swap code, please also refer to the AN4533:

http://www.nxp.com/assets/documents/data/en/application-notes/AN4533.pdf?&fsrch=1&sr=1&pageNum=1 

and it's code:

http://cache.nxp.com/files/microcontrollers/doc/app_note/AN4533SW.zip 

   I will also test it on my side, any progress will let you know.

Best Regards,

Kerry

0 Kudos
1,467 Views
jasonphilippi
Contributor III

I am using Kinetis Design Studio 3.2.0 with KSDK 1.2.0 for the FRDM-K64F board.

You will need to install KSDK 1.2.0 for all the components except FreeRTOS.

I believe that should be possible through Help -> Install New Software...

Freescale KDS Update Site - http://freescale.com/lgfiles/updates/Eclipse/KDS

Select KSDK 1.2.0 Eclipse Update

To install FreeRTOS component from mcuoneclipse.com

Extract Components into workspace folder but not the project folder.

import-Components-1.png

Select the two beans

import-Components-2.png

Create a new component

import-Components-3.png

This is where I have the components

import-Components-4.png

If the FreeRTOS component shows a red X over it, then change the repository like this.

Change-Repository-1.png

Change-Repository-2.png

0 Kudos