Write MPC5604C's internal flash

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

Write MPC5604C's internal flash

762 Views
pengfei_ji
Contributor I

Can anyone provide some language C samples or resources about writing MPC5604C's internal flash (ex. CodeFlash) mainly by operating Register but not by debug interface?

0 Kudos
3 Replies

644 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here is simple piece of code I found in my repository originally written for MPC560xP (but it doesn't matter, just blocks may be different):

/* unlock */
  CFLASH.LML.R = 0xA1A11111;    //write password
  CFLASH.LML.R = 0x00000000;    //unlock all 5 blocks in low address space
  CFLASH.SLL.R = 0xC3C33333;    //write password
  CFLASH.SLL.R = 0x00000000;    //unlock all 5 blocks in low address space
 
  /* erase */  
  CFLASH.MCR.B.ERS = 1;    //erase operation
  CFLASH.LMS.R = 0x8;        //select block B0F3 for erase (0x00010000-0x00017FFF)
  *(unsigned int *)0x00010000 = 1;    //interlock write
  CFLASH.MCR.B.EHV = 1;
    while(CFLASH.MCR.B.DONE == 0);
    CFLASH.MCR.B.EHV = 0;
  CFLASH.MCR.B.ERS = 0;
 
  /* program double word at 0x00010000 */
  CFLASH.MCR.B.PGM = 1;    //program operation  
  *(unsigned int *)0x00010000 = 0xAABBCCDD;    //interlock write
  *(unsigned int *)0x00010004 = 0xABCDABCD;    //interlock write
  CFLASH.MCR.B.EHV = 1;
    while(CFLASH.MCR.B.DONE == 0);
    CFLASH.MCR.B.EHV = 0;
  CFLASH.MCR.B.PGM = 0;  
 
  /* program next double word at 0x00010008*/
  CFLASH.MCR.B.PGM = 1;    //program operation  
  *(unsigned int *)0x00010008 = 0x11223344;    //interlock write
  *(unsigned int *)0x0001000C = 0x12341234;    //interlock write
  CFLASH.MCR.B.EHV = 1;
    while(CFLASH.MCR.B.DONE == 0);
    CFLASH.MCR.B.EHV = 0;
  CFLASH.MCR.B.PGM = 0;  
 
  /* read programmed data */
    data1 = *(unsigned int *)0x00010000;
    data2 = *(unsigned int *)0x00010004;
    data3 = *(unsigned int *)0x00010008;
    data4 = *(unsigned int *)0x0001000C;

Regards,

Lukas

644 Views
pengfei_ji
Contributor I

I try to write this erea but NOK,

will it be prohibited because the code itself is executing/writing at the same area?

IC :MPC5604C

burning/programing  using JTAG port

Burning file:   .S19

burning/programing IDE:S32 Design Studio for Power Architecture Version 2017.R1

Following is the burning/programing info of IDE,(appendix is the .pcp file)

How could I know my code is burned/programed in which area of the chip?

Because we need to write data to an area of Cflash in my code, but we can't write it all the time. We suspect that our code itself may be executed in this area and using this area, which leads to the failure of writing in the program.pastedImage_3.png

Connection from "127.0.0.1" via 127.0.0.1
Copyright 2017 P&E Microcomputer Systems,Inc.
Command Line :C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\pegdbserver_power_console -device=MPC5604C -startserver -singlesession -serverport=7224 -gdbmiport=6224 -interface=USBMULTILINK -speed=5000 -?

 

CMD>RE

 

Initializing.
MPC560xx Device detected.
Target has been RESET and is active.
CMD>CM C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\gdi\P&E\nxp_mpc5604c_1x32x128k_cflash.pcp

 

Initializing.
MPC560xx Device detected.
Initialized.

 

;version 1.13, 03/30/2017, Copyright P&E Microcomputer Systems, www.pemicro.com [560x_512k_cflash]

 

;device NXP, MPC5604C, 1x32x128k, desc=CFlash

 

;begin_cs device=$00000000, length=$00080000, ram=$40000000

 

Loading programming algorithm ...

 

WARNING - Selected .PCP file has been modified. CRC16 = $8807
Done.
CMD>VC
Verifying object file CRC-16 to device ranges ...
block 00000000-00000007 ...
Ok.
block 00000010-000000E3 ...
Ok.
block 00000100-0000428B ...
Ok.
block 00008000-00008025 ...
Ok.
block 00010000-00010073 ...
Ok.
block 00010080-00038417 ...
Ok.
block 00039000-000390F3 ...
Ok.
block 000390F8-00044987 ...
Ok.
Checksum Verification Successful. (Cumulative CRC-16=$8879)
Application verified in memory. No need to reprogram.

 

CMD>RE

 

Initializing.
MPC560xx Device detected.
Target has been RESET and is active.

 

Starting reset script (C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\gdi\P&E\s32e200_mpc560xx.mac) ...
REM This script is compatible with MPC560xB, MPC560xC, MPC560xD, MPC560xE, MPC560xS, and MPC560xP devices.
REM Clean GPRs to remove residual data after using algorithm
REM Initialize all of the Main SRAM - 96KB
Initializing RAM from $40000000 to $40017FFF.

 

Reset script (C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\gdi\P&E\s32e200_mpc560xx.mac) completed.

 

MPC560xx Device detected.

0 Kudos

644 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

it's not clear to me. First you wrote that you want to program the flash using a code not JTAG interface, now you are asking about JTAG interface. Could you describe your problem in more details?

Regards,

Lukas

0 Kudos