How to read code from chip?

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

How to read code from chip?

Jump to solution
1,945 Views
arthurhsu
Contributor I

Hi there

As title,I would like to read the code in the kinetis chip and backup using codewarrior 10.2.

Anyone know how to do it ?

 

Best regards

Arthur

Labels (1)
0 Kudos
1 Solution
1,058 Views
arthurhsu
Contributor I

Dear Evgeni

Much thanks your reply

The answear is not what I want;but I have to thank you

It's a a useful program

Let me describe the question

There is already a code in my kinetis chip,if I lost the original code

I would like to read back the binary code from chip

The answear is

I have to build a emtry project and get in debug mode by RAM

then I can export binary code from memory panel

This is method I know

Best regards

View solution in original post

0 Kudos
2 Replies
1,058 Views
evgenik
Contributor IV

Hi Arthur.

I have the next for get information about the MCU:

/*******************************************************************************

* FUNCTION NAME: KBDH_Cpu_Identify

* DESCRIPTION: This is primary a reporting function that displays information

* about the specific CPU to the default terminal including:

* - Kinetis family

* - package

* - die revision

* - P-flash size

* - Ram size

* INPUTS: none

* RETURN: none

* NOTES:            none

*******************************************************************************/

void KBDH_Cpu_Identify (void)

{

    // Determine the Kinetis family

    switch((SIM_SDID & SIM_SDID_FAMID(0x7))>>SIM_SDID_FAMID_SHIFT)

    { 

    case 0x0:

    printf("\nK10-");

    break;

    case 0x1:

    printf("\nK20-");

    break;

    case 0x2:

    printf("\nK30-");

    break;

    case 0x3:

    printf("\nK40-");

    break;

    case 0x4:

    printf("\nK60-");

    break;

    case 0x5:

    printf("\nK70-");

    break;

    case 0x6:

    printf("\nK50-");

    break;

    case 0x7:

    printf("\nK53-");

    break;

  default:

  printf("\nUnrecognized Kinetis family device.\n"); 

  break; 

    }

    // Determine the package size

    switch((SIM_SDID & SIM_SDID_PINID(0xF))>>SIM_SDID_PINID_SHIFT)

    { 

    case 0x2:

    printf("32pin       ");

    break;

    case 0x4:

    printf("48pin       ");

    break;

    case 0x5:

    printf("64pin       ");

    break;

    case 0x6:

    printf("80pin       ");

    break;

    case 0x7:

    printf("81pin       ");

    break;

    case 0x8:

    printf("100pin      ");

    break;

    case 0x9:

    printf("104pin      ");

    break;

    case 0xA:

    printf("144pin      ");

    break;

    case 0xC:

    printf("196pin      ");

    break;

    case 0xE:

    printf("256pin      ");

    break;

  default:

  printf("\nUnrecognized Kinetis package code.      "); 

  break; 

    }               

    /* Determine the revision ID */

   

    switch((SIM_SDID & SIM_SDID_REVID(0xF))>>SIM_SDID_REVID_SHIFT)

    {

  

    case 0x0:

    printf("Silicon rev 1.0   \n ");

    break;

    case 0x1:

    printf("Silicon rev 1.1  \n ");

    break;

    case 0x2:

    printf("Silicon rev 1.2  \n ");

    break;

    default:

  printf("\nThis version of software doesn't recognize the revision code."); 

  break; 

    }

   

    // Determine the flash revision

    KBDH_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:

    printf("512 kBytes of P-flash ");

    break;

  default:

  printf("ERR!! Undefined P-flash size\n"); 

  break; 

    }

   

    // Determine if the part has P-flash only or P-flash and FlexNVM

    if (SIM_FCFG2 & SIM_FCFG2_PFLSH_MASK) 

      printf("P-flash only\n");

    else

      // if part has FlexNVM determine the FlexNVM size

      switch((SIM_FCFG1 & SIM_FCFG1_NVMSIZE(0xF))>>SIM_FCFG1_NVMSIZE_SHIFT)

      {

      case 0x0:

      printf("0 kBytes of FlexNVM\n");

      break;

    case 0x7:

      printf("128 kBytes of FlexNVM\n");

    break;

        case 0x9:

      printf("256 kBytes of FlexNVM\n");

    break;

    case 0xF:

      printf("256 kBytes of FlexNVM\n");

    break;

  default:

  printf("ERR!! Undefined FlexNVM size\n"); 

  break; 

      }

    // Determine the RAM size

    switch((SIM_SOPT1 & SIM_SOPT1_RAMSIZE(0xF))>>SIM_SOPT1_RAMSIZE_SHIFT)

    {

    case 0x5:

    printf("32 kBytes of RAM\n\n");

    break;

    case 0x7:

    printf("64 kBytes of RAM\n\n");

    break;

    case 0x8:

    printf("96 kBytes of RAM\n\n");

    break;

    case 0x9:

    printf("128 kBytes of RAM\n\n");

    break;

  default:

  printf("ERR!! Undefined RAM size\n\n"); 

  break; 

    }

}

/*******************************************************************************

* FUNCTION NAME: KBDH_Flash_Identify

* DESCRIPTION: This is primary a reporting function that displays information

* about the specific flash parameters and flash version ID for

* the current device. These parameters are obtained using a special

* flash command call "read resource." The first four bytes returned

* are the flash parameter revision, and the second four bytes are

* the flash version ID.

* INPUTS: none

* RETURN: none

* NOTES:            none

*******************************************************************************/

void KBDH_Flash_Identify(void)

{

    // Get the flash parameter version

    // Write the flash FCCOB registers with the values for a read resource command

    FCCOB0 = 0x03;

    FCCOB1 = 0x00;

    FCCOB2 = 0x00;

    FCCOB3 = 0x00;

    FCCOB8 = 0x01;

    // All required FCCOBx registers are written, so launch the command

    FSTAT = FSTAT_CCIF_MASK;

    // Wait for the command to complete

    while(!(FSTAT & FSTAT_CCIF_MASK));

#ifdef DEBUG_PRINT  

    printf("Flash parameter version %d.%d.%d.%d\n",FTFL_FCCOB4,FTFL_FCCOB5,FTFL_FCCOB6,FTFL_FCCOB7);

#endif

    // Get the flash version ID   

    // Write the flash FCCOB registers with the values for a read resource command

    FCCOB0 = 0x03;

    FCCOB1 = 0x00;

    FCCOB2 = 0x00;

    FCCOB3 = 0x04;

    FCCOB8 = 0x01;

    // All required FCCOBx registers are written, so launch the command

    FSTAT = FSTAT_CCIF_MASK;

    // Wait for the command to complete

    while(!(FSTAT & FSTAT_CCIF_MASK));

#ifdef DEBUG_PRINT

    printf("Flash version ID %d.%d.%d.%d\n",FTFL_FCCOB4,FTFL_FCCOB5,FTFL_FCCOB6,FTFL_FCCOB7);

#endif

    // Clear all of the flags in the flash status register

    FSTAT = 0xFF;

}

If you need any other information, describe it.

Have a good day.

Evgeni.

0 Kudos
1,059 Views
arthurhsu
Contributor I

Dear Evgeni

Much thanks your reply

The answear is not what I want;but I have to thank you

It's a a useful program

Let me describe the question

There is already a code in my kinetis chip,if I lost the original code

I would like to read back the binary code from chip

The answear is

I have to build a emtry project and get in debug mode by RAM

then I can export binary code from memory panel

This is method I know

Best regards

0 Kudos