Hi Jason Jiang,
I think maybe you can read the chip's relative register, then you can identify the size of it's flash.
Actually, in our demo code KINETIS512_V2_SC, and in the start.c code, you will find some code to do this function, eg:
/* Determine the flash revision */
flash_identify();
/* Determine the P-flash size */
switch((SIM_FCFG1 & SIM_FCFG1_PFSIZE(0xF))>>SIM_FCFG1_PFSIZE_SHIFT)
{
case 0x7:
printf("128 kBytes of P-flash ");
break;
case 0x9:
printf("256 kBytes of P-flash ");
break;
case 0xB:
printf("512 kBytes of P-flash ");
break;
case 0xF:
/* Determine if the part has P-flash only or FlexNVM */
if (SIM_FCFG2 & SIM_FCFG2_PFLSH_MASK)
printf("512 kBytes of P-flash ");
else
printf("256 kBytes of P-flash ");
break;
default:
printf("ERR!! Undefined P-flash size\n");
break;
}
You can download the code from this link:
http://www.freescale.com/webapp/sps/download/license.jsp?colCode=KINETIS512_V2_SC&location=null&fpsp...
I wish it helps you!
Jing