KL02 FLASH_OnOperationComplete() does not happen

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

KL02 FLASH_OnOperationComplete() does not happen

679 Views
benjaminchang
Contributor V

Hi,

We have a long time bootloader works fine for KL25. Now we revise it for KL02.

The same program code is used, with CodeWarrior 10.6 and ProcessorExpert component.

We first tried on FRDM-KL02 (MKL02Z32VFM4), and also works fine.

But after we port it to custom target board (MKL02Z32VFG4), using MultiLink to debug in CW,

The function FLASH_OnOperationComplete() never reach, and it just keep looping and wait for complete

"while(OpStatus != TRUE)" as below code.

With CW debug, the program flash is correctly downloaded.

Please check and comment what might be the reason for this? Or what kind data/action can we check/make?

Next is the part of code:

// in event.c, hook for complete and error

void FLASH_OnOperationComplete(LDD_TUserData *UserDataPtr)

{

  /* Write your code here ... */

  uint8_t *OpStatus = (LDD_TUserData*) UserDataPtr;

   *OpStatus = TRUE;

}

void FLASH_OnError(LDD_TUserData *UserDataPtr)

{

  /* Write your code here ... */

  uint8_t *OpStatus = (LDD_TUserData*) UserDataPtr; // Bj, 140605

   *OpStatus = 8;

}

// User program file, function to perform flash

bool WriteFlash(LDD_FLASH_TAddress FromAddress, LDD_TData* DataPtr, LDD_FLASH_TDataSize Size)

{

  LDD_TError Error;

  //*OpStatus = FALSE;

   LDD_TDeviceData *FlashDevData;

  uint8_t OpStatus=FALSE;

   FlashDevData = IntFlash(&OpStatus);

  Error = FLASH_Write(FlashDevData, DataPtr, FromAddress, Size);

  if (Error) {     // no function call error found

    return FALSE;

  }

  while(OpStatus != TRUE)  // as flash never complete, so it keeps looping in this while loop!!

  {/* Wait while operation done , Bj, 0605*/

   if (OpStatus == 8)

   {

    printf ("Wf8");  // on error flag, set in event.c

    break;

   }

  }

  return TRUE;

}

// Reserve 1KB size of data on top of BootLoader as Signature

// main program will try to write a version number to the top of Bootloader for the 1st time (empty sector)

.. ..

if (BootVer1.VerBoot==0xff) { // check empty flag for the very first one

     BootVer1.VerBoot = 3;

     WriteFlash (BL_TOP, &BootVer1.VerBoot, 1); // write a new flag, << this is where the program stuck!!

}

.. ..

// We also tried to add checking in the loop

FLASH_Main(FlashDevData);

OpStatus=FLASH_GetOperationStatus (FlashDevData);

// but OpStatus is always 4 (LDD_FLASH_START)


// 2015/3/29 add:

// Before write Bootloader program, we developed AP program on this target board, and it works fine.

// We developed under CW10.6, using Multilink to download and debug, and running OK.

// The H/W is simple, checked, and nothing wrong can be found.

// We tested two boards, and both have this Flashing problem.

// We tried to revise the sample FLASH program of CW (for KL05), to KL02, only to found Erase is failed.

// Could this be a chip issue? How to identify it?

// Could the flash be locked? But CW downloading is working fine.



0 Kudos
2 Replies

429 Views
PatriciaTeran
Contributor III

Hi, Benjamin

Sorry for the late response, are you still  having problems?

Regards

Patricia

0 Kudos

428 Views
benjaminchang
Contributor V

Hi Patricia,

Actually the problem is still there.

As this is a customer's target board, and we provide tech support for the F/W. There are limited target boards for our testing. We cannot be sure if it is an issue of IC, PCBA, or software? and have to wait for the next new FAB of new target boards (it is customer's schedule).

We just wondering why this problem happened - Multilink downloading is ok, but F/W program white failed?

Is there a way to debug this problem.

Thanks!

Benjamin

0 Kudos