FLash driver implementation for write operation in S32K311

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

FLash driver implementation for write operation in S32K311

3,648 Views
emb-enockal
Contributor I

Hi,

I'm facing issue in writing data to PFlash, I have followed as per reference manual, but still I'm not able to write to memory. Kindly help me with this. Since its time critical.

Also I'm attaching my code for your reference.

Thank you,

0 Kudos
Reply
9 Replies

3,611 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @emb-enockal,

Can you elaborate on the description of the issues?

Do you see any error flags?

I recommend starting with a blocking method for simplicity:

danielmartynek_0-1762959571607.png

danielmartynek_1-1762959967169.png

 

The DATA registers must be aligned to the quad-page.

 

You cannot execute code from the block that is being programmed.

 

Regards,

Daniel

 

Any support, information, and technology (“Materials”) provided by NXP are provided AS IS, without any warranty express or implied, and NXP disclaims all direct and indirect liability and damages in connection with the Material to the maximum extent permitted by the applicable law. 
NXP accepts no liability for any assistance with applications or product design. Materials may only be used in connection with NXP products. Any feedback provided to NXP regarding the Materials may be used by NXP without restriction.

 

0 Kudos
Reply

3,582 Views
emb-enockal
Contributor I

Hi everyone,

I’m stuck on PFlash/DFlash programming for S32K311 (48-pin). I can now program P-Flash when I place a breakpoint at the end of the write function, but if I don’t keep that breakpoint the CPU jumps to disassembly and RWE flag is set to 1.

Also I cannot unlock D-Flash (all unlock attempts appear to be ignored). Please advise.

what I observed is:

  1. PFlash write sequence completes only when I keep a breakpoint in the write function. If I remove that breakpoint the CPU goes to disassembly immediately after the write request (looks like an interrupt/fetch fault).

  2. D-Flash remains locked despite writing the following unlock sequences:

    PFLASH.PFCBLKU_SPELOCK[0].R = 0x00000000U; /* clear UTEST block lock (tried) */

    /* clear module locks */
    FLASH.SPELOCK.R = 0x00000000U;
    FLASH.SSPELOCK.R = 0x00000000U;

    /* platform-level block unlock */
    PFLASH.PFCBLK_SPELOCK[0].R = 0x00000000U;
    PFLASH.PFCBLK_SSPELOCK[0].R = 0x00000000U;

    Also attached code for your reference.

0 Kudos
Reply

3,574 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @emb-enockal,

The flash programming code must not reside in the same flash block that is being programmed.

 

If you need to program the same flash block, ensure the execution code is placed in SRAM.


In this example, the C40_Ip APIs are located in SRAM:
For reference, see: https://community.nxp.com/t5/S32K-Knowledge-Base/S32K312-C40-Ip-SRAM-RTD-500-DS35/ta-p/2074245.

 

DFlash is located in Block_2, locked by SPELOCK[2] and SSPELOCK[2].

 

Regards,

Daniel

 

 

0 Kudos
Reply

3,519 Views
emb-enockal
Contributor I

Hi Daniel,

Thank you for the clarification.

Yes, I realized that I was trying to execute the write function from the same PFlash block that I was programming. After moving the write routine to another block, it started working.

However, I have two follow-up issues:

  1. PFlash consecutive writes
    When I write 8 bytes at address 0x00480000, it succeeds.
    But if I try to write the next 8 bytes at 0x00480008, the operation fails.
    The next address where a write is successful is 128 bytes later.

    It looks like the controller only allows programming at 128-byte (quad-page) boundaries.
    Is there any way to program smaller chunks (8 bytes) consecutively within the same quad-page, or must all 128 bytes be written at once?

  2. DFlash unlock issue
    As recommended, I tried unlocking Block_2 using SPELOCK[2] and SSPELOCK[2], but the block remains locked.
    I also attempted clearing the module-level and platform-level lock registers, but the DFlash region still does not unlock.

    Below is the unlock sequence I attempted:

    PFLASH.PFCBLK_SSPELOCK[0].R = 0x00000000U; //PFlash Block0

    PFLASH.PFCBLK_SSPELOCK[1].R = 0x00000000U; //PFlash Block1

    FLASH.SPELOCK.R = 0x00000000U;

    FLASH.SSPELOCK.R = 0x00000000U;

    FLASH.XSPELOCK.R = 0x00000000u;

    FLASH.XSSPELOCK.R = 0x00000000u;

     

    Could you please help me understand the correct way to unlock DFlash Block_2 and confirm whether consecutive writes inside the same quad-page are supported?

    Thank you for your assistance.

     

0 Kudos
Reply

3,319 Views
emb-enockal
Contributor I

Hi Daniel,

 

1. I attempted unlocking using all register combinations mentioned in the Reference Manual, including:

 

PFLASH.PFCBLK_SSPELOCK[0].R = 0x00000000U; //PFlash Block0

 

PFLASH.PFCBLK_SSPELOCK[1].R = 0x00000000U; //PFlash Block1

 

FLASH.SPELOCK.R = 0x00000000U;

 

FLASH.SSPELOCK.R = 0x00000000U;

 

FLASH.XSPELOCK.R = 0x00000000u;

 

FLASH.XSSPELOCK.R = 0x00000000u;

 

PFLASH.PFCBLK_SPELOCK[0].R = 0x00000000U;

 

PFLASH.PFCBLK_SPELOCK[1].R = 0x00000000U;

 

PFLASH.PFCBLK_SPELOCK[2].R = 0x00000000U;

 

PFLASH.PFCBLKU_SPELOCK[0].R = 0x00000000U; // UTEST block lock

 

However, DFlash always remains locked, and any erase/program attempt sets PES=1 .

 

Could you please clarify:

 

The correct register and register index for D-Flash block on S32K311.

 

Whether D-Flash on S32K311 requires a special unlock mechanism (UTEST fuse, FCCU, life-cycle state, etc.).

 

Any reference example showing successful D-Flash unlock + write.

 

2. Unable to unlock last 256 KB of P-Flash:

Anything at or above 0x004B0000 – 0x004FFFFF remains locked even after using all register combinations mentioned above.

Is this region controlled by a different lock block (Block 2?) or shared with D-Flash?

0 Kudos
Reply

3,125 Views
danielmartynek
NXP TechSupport
NXP TechSupport

HI @emb-enockal,

1.

Unlock just the first sector in DFLASH at 0x1000_0000:

IP_PFLASH->PFCBLK_SPELOCK[2] &= ~(1U << 0);

Can you test it?

 

 

Regards,

Daniel

Any support, information, and technology (“Materials”) provided by NXP are provided AS IS, without any warranty express or implied, and NXP disclaims all direct and indirect liability and damages in connection with the Material to the maximum extent permitted by the applicable law. 
NXP accepts no liability for any assistance with applications or product design. Materials may only be used in connection with NXP products. Any feedback provided to NXP regarding the Materials may be used by NXP without restriction.

 

0 Kudos
Reply

2,972 Views
emb-enockal
Contributor I

Hi Daniel,

Thank you — D-Flash is now working after using:

IP_PFLASH->PFCBLK_SPELOCK[2] &= ~(1U << 0);

However, I still have one remaining issue:

Unable to unlock the last 256 KB of P-Flash (0x004B0000 – 0x004FFFFF)

Everything below 0x004B0000 is working correctly.
But any write/erase attempt in the region:

0x004B0000 – 0x004FFFFF

fails with PES = 1, exactly like a locked block.

I tried clearing all P-Flash lock registers:

PFLASH.PFCBLK_SSPELOCK[0].R &= ~(1U <<0); //PFlash Block0

 

PFLASH.PFCBLK_SSPELOCK[1].R &= ~(1U <<0); //PFlash Block1

 

FLASH.SPELOCK.R &= ~(1U <<0);

 

FLASH.SSPELOCK.R &= ~(1U <<0);

 

FLASH.XSPELOCK.R &= ~(1U <<0);

 

FLASH.XSSPELOCK.R &= ~(1U <<0);

 

PFLASH.PFCBLK_SPELOCK[0].R &= ~(1U <<0);

 

PFLASH.PFCBLK_SPELOCK[1].R &= ~(1U <<0);

 

PFLASH.PFCBLK_SPELOCK[2].R &= ~(1U <<0);

 

PFLASH.PFCBLKU_SPELOCK[0].R &= ~(1U <<0); // UTEST block lock

 

But this upper P-Flash area remains locked, even though D-Flash unlock and write are now working.

Any clarification on the correct way to unlock and program the upper 256 KB P-Flash region would be very helpful.

Thanks again for your support.

0 Kudos
Reply

2,964 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @emb-enockal,

I can unlock the supersector at 0x4B0000

IP_PFLASH->PFCBLK_SSPELOCK[1] &= ~(1U << 3);

danielmartynek_0-1763730353027.png

And reprogram it:

danielmartynek_1-1763730430470.png

 

Refer to these tables in the RM:

Table 197. Configuration details when the HSE firmware usage feature flag is disabled

Table 199. Configuration details when the HSE_B firmware usage feature flag is enabled

Table 200. AB swap configuration

 

Regards,

Daniel

 

0 Kudos
Reply

3,512 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @emb-enockal,

To program 8 bytes starting at 0x00480008, you need to write the data in DATA[2-3] registers.

Regarding the lock, I'm out of office until Tuesday, I cannot test it on HW right now. 

I would recommend that you use the RTD drivers (C40_Ip) for reference.

danielmartynek_0-1763131926248.png

 

Regards,

Daniel

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2203597%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFLash%20driver%20implementation%20for%20write%20operation%20in%20S32K311%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203597%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI'm%20facing%20issue%20in%20writing%20data%20to%20PFlash%2C%20I%20have%20followed%20as%20per%20reference%20manual%2C%20but%20still%20I'm%20not%20able%20to%20write%20to%20memory.%20Kindly%20help%20me%20with%20this.%20Since%20its%20time%20critical.%3C%2FP%3E%3CP%3EAlso%20I'm%20attaching%20my%20code%20for%20your%20reference.%3C%2FP%3E%3CP%3EThank%20you%2C%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2206838%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FLash%20driver%20implementation%20for%20write%20operation%20in%20S32K311%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2206838%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Daniel%2C%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E1.%20I%20attempted%20unlocking%20using%20all%20register%20combinations%20mentioned%20in%20the%20Reference%20Manual%2C%20including%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPFLASH.PFCBLK_SSPELOCK%5B0%5D.R%20%3D%200x00000000U%3B%20%2F%2FPFlash%20Block0%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPFLASH.PFCBLK_SSPELOCK%5B1%5D.R%20%3D%200x00000000U%3B%20%2F%2FPFlash%20Block1%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFLASH.SPELOCK.R%20%3D%200x00000000U%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFLASH.SSPELOCK.R%20%3D%200x00000000U%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFLASH.XSPELOCK.R%20%3D%200x00000000u%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFLASH.XSSPELOCK.R%20%3D%200x00000000u%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPFLASH.PFCBLK_SPELOCK%5B0%5D.R%20%3D%200x00000000U%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPFLASH.PFCBLK_SPELOCK%5B1%5D.R%20%3D%200x00000000U%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPFLASH.PFCBLK_SPELOCK%5B2%5D.R%20%3D%200x00000000U%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPFLASH.PFCBLKU_SPELOCK%5B0%5D.R%20%3D%200x00000000U%3B%20%2F%2F%20UTEST%20block%20lock%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EHowever%2C%20DFlash%20always%20remains%20locked%2C%20and%20any%20erase%2Fprogram%20attempt%20sets%20PES%3D1%20.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ECould%20you%20please%20clarify%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20correct%20register%20and%20register%20index%20for%20D-Flash%20block%20on%20S32K311.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EWhether%20D-Flash%20on%20S32K311%20requires%20a%20special%20unlock%20mechanism%20(UTEST%20fuse%2C%20FCCU%2C%20life-cycle%20state%2C%20etc.).%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAny%20reference%20example%20showing%20successful%20D-Flash%20unlock%20%2B%20write.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2.%26nbsp%3BUnable%20to%20unlock%20last%20256%20KB%20of%20P-Flash%3A%3C%2FP%3E%3CP%3EAnything%20at%20or%20above%20%3CSTRONG%3E0x004B0000%20%E2%80%93%200x004FFFFF%3C%2FSTRONG%3E%20remains%20locked%20even%20after%20using%20all%20register%20combinations%20mentioned%20above.%3C%2FP%3E%3CP%3EIs%20this%20region%20controlled%20by%20a%20different%20lock%20block%20(Block%202%3F)%20or%20shared%20with%20D-Flash%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205250%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FLash%20driver%20implementation%20for%20write%20operation%20in%20S32K311%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205250%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F256812%22%20target%3D%22_blank%22%3E%40emb-enockal%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3ETo%20program%208%20bytes%20starting%20at%26nbsp%3B0x00480008%2C%20you%20need%20to%20write%20the%20data%20in%20DATA%5B2-3%5D%20registers.%3C%2FP%3E%0A%3CP%3ERegarding%20the%20lock%2C%20I'm%20out%20of%20office%20until%20Tuesday%2C%20I%20cannot%20test%20it%20on%20HW%20right%20now.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20would%20recommend%20that%20you%20use%20the%20RTD%20drivers%20(C40_Ip)%20for%20reference.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_0-1763131926248.png%22%20style%3D%22width%3A%20673px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_0-1763131926248.png%22%20style%3D%22width%3A%20673px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365730iCF3C7BD6702FEE0D%2Fimage-dimensions%2F673x345%3Fv%3Dv2%22%20width%3D%22673%22%20height%3D%22345%22%20role%3D%22button%22%20title%3D%22danielmartynek_0-1763131926248.png%22%20alt%3D%22danielmartynek_0-1763131926248.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205209%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FLash%20driver%20implementation%20for%20write%20operation%20in%20S32K311%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205209%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSTRONG%3EHi%20Daniel%2C%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20clarification.%3C%2FP%3E%3CP%3EYes%2C%20I%20realized%20that%20I%20was%20trying%20to%20execute%20the%20write%20function%20from%20the%20same%20PFlash%20block%20that%20I%20was%20programming.%20After%20moving%20the%20write%20routine%20to%20another%20block%2C%20it%20started%20working.%3C%2FP%3E%3CP%3EHowever%2C%20I%20have%20two%20follow-up%20issues%3A%3C%2FP%3E%3COL%3E%3CLI%3E%3CP%3E%3CSTRONG%3EPFlash%20consecutive%20writes%3C%2FSTRONG%3E%3CBR%20%2F%3EWhen%20I%20write%208%20bytes%20at%20address%20%3CSTRONG%3E0x00480000%3C%2FSTRONG%3E%2C%20it%20succeeds.%3CBR%20%2F%3EBut%20if%20I%20try%20to%20write%20the%20next%208%20bytes%20at%20%3CSTRONG%3E0x00480008%3C%2FSTRONG%3E%2C%20the%20operation%20fails.%3CBR%20%2F%3EThe%20next%20address%20where%20a%20write%20is%20successful%20is%20%3CSTRONG%3E128%20bytes%20later%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3EIt%20looks%20like%20the%20controller%20only%20allows%20programming%20at%20128-byte%20(quad-page)%20boundaries.%3CBR%20%2F%3EIs%20there%20any%20way%20to%20program%20smaller%20chunks%20(8%20bytes)%20consecutively%20within%20the%20same%20quad-page%2C%20or%20must%20all%20128%20bytes%20be%20written%20at%20once%3F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3EDFlash%20unlock%20issue%3C%2FSTRONG%3E%3CBR%20%2F%3EAs%20recommended%2C%20I%20tried%20unlocking%20Block_2%20using%20%3CSTRONG%3ESPELOCK%5B2%5D%3C%2FSTRONG%3E%20and%20%3CSTRONG%3ESSPELOCK%5B2%5D%3C%2FSTRONG%3E%2C%20but%20the%20block%20remains%20locked.%3CBR%20%2F%3EI%20also%20attempted%20clearing%20the%20module-level%20and%20platform-level%20lock%20registers%2C%20but%20the%20DFlash%20region%20still%20does%20not%20unlock.%3C%2FP%3E%3CP%3EBelow%20is%20the%20unlock%20sequence%20I%20attempted%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CP%3E%3CSPAN%3EPFLASH.PFCBLK_SSPELOCK%5B0%5D.R%20%3D%200x00000000U%3B%20%2F%2FPFlash%20Block0%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EPFLASH.%3C%2FSPAN%3E%3CSPAN%3EPFCBLK_SSPELOCK%3C%2FSPAN%3E%3CSPAN%3E%5B1%5D.%3C%2FSPAN%3E%3CSPAN%3ER%3C%2FSPAN%3E%3CSPAN%3E%20%3D%200x00000000U%3B%20%3C%2FSPAN%3E%3CSPAN%3E%2F%2FPFlash%20Block1%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFLASH.SPELOCK.R%20%3D%200x00000000U%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFLASH.SSPELOCK.R%20%3D%200x00000000U%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFLASH.XSPELOCK.R%20%3D%200x00000000u%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFLASH.XSSPELOCK.R%20%3D%200x00000000u%3B%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%3CSPAN%3ECould%20you%20please%20help%20me%20understand%20the%20correct%20way%20to%20unlock%20DFlash%20Block_2%20and%20confirm%20whether%20consecutive%20writes%20inside%20the%20same%20quad-page%20are%20supported%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EThank%20you%20for%20your%20assistance.%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2204501%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FLash%20driver%20implementation%20for%20write%20operation%20in%20S32K311%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2204501%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F256812%22%20target%3D%22_blank%22%3E%40emb-enockal%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EThe%20flash%20programming%20code%20must%20not%20reside%20in%20the%20same%20flash%20block%20that%20is%20being%20programmed.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EIf%20you%20need%20to%20program%20the%20same%20flash%20block%2C%20ensure%20the%20execution%20code%20is%20placed%20in%20SRAM.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EIn%20this%20example%2C%20the%20C40_Ip%20APIs%20are%20located%20in%20SRAM%3A%3CBR%20%2F%3EFor%20reference%2C%20see%3A%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FS32K312-C40-Ip-SRAM-RTD-500-DS35%2Fta-p%2F2074245%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FS32K312-C40-Ip-SRAM-RTD-500-DS35%2Fta-p%2F2074245%3C%2FA%3E.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EDFlash%20is%20located%20in%20Block_2%2C%20locked%20by%20SPELOCK%5B2%5D%20and%20SSPELOCK%5B2%5D.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2204492%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FLash%20driver%20implementation%20for%20write%20operation%20in%20S32K311%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2204492%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20everyone%2C%3C%2FP%3E%3CP%3EI%E2%80%99m%20stuck%20on%20PFlash%2FDFlash%20programming%20for%20S32K311%20(48-pin).%20I%20can%20now%20%3CSTRONG%3Eprogram%20P-Flash%3C%2FSTRONG%3E%20when%20I%20place%20a%20breakpoint%20at%20the%20end%20of%20the%20write%20function%2C%20but%20%3CSTRONG%3Eif%20I%20don%E2%80%99t%3C%2FSTRONG%3E%20keep%20that%20breakpoint%20the%20CPU%20jumps%20to%20disassembly%20and%20RWE%20flag%20is%20set%20to%201.%3C%2FP%3E%3CP%3EAlso%20I%20%3CSTRONG%3Ecannot%20unlock%20D-Flash%3C%2FSTRONG%3E%20(all%20unlock%20attempts%20appear%20to%20be%20ignored).%20Please%20advise.%3C%2FP%3E%3CP%3Ewhat%20I%20observed%20is%3A%3C%2FP%3E%3COL%3E%3CLI%3E%3CP%3EPFlash%20write%20sequence%20completes%20only%20when%20I%20keep%20a%20breakpoint%20in%20the%20write%20function.%20If%20I%20remove%20that%20breakpoint%20the%20CPU%20goes%20to%20disassembly%20immediately%20after%20the%20write%20request%20(looks%20like%20an%20interrupt%2Ffetch%20fault).%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3ED-Flash%20remains%20locked%20despite%20writing%20the%20following%20unlock%20sequences%3A%3C%2FP%3E%3CP%3EPFLASH.PFCBLKU_SPELOCK%5B0%5D.R%20%3D%200x00000000U%3B%20%2F*%20clear%20UTEST%20block%20lock%20(tried)%20*%2F%3C%2FP%3E%3CP%3E%2F*%20clear%20module%20locks%20*%2F%3CBR%20%2F%3EFLASH.SPELOCK.R%20%3D%200x00000000U%3B%3CBR%20%2F%3EFLASH.SSPELOCK.R%20%3D%200x00000000U%3B%3C%2FP%3E%3CP%3E%2F*%20platform-level%20block%20unlock%20*%2F%3CBR%20%2F%3EPFLASH.PFCBLK_SPELOCK%5B0%5D.R%20%3D%200x00000000U%3B%3CBR%20%2F%3EPFLASH.PFCBLK_SSPELOCK%5B0%5D.R%20%3D%200x00000000U%3B%3C%2FP%3E%3CP%3EAlso%20attached%20code%20for%20your%20reference.%3C%2FP%3E%3C%2FLI%3E%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2203722%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FLash%20driver%20implementation%20for%20write%20operation%20in%20S32K311%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203722%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F256812%22%20target%3D%22_blank%22%3E%40emb-enockal%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3ECan%20you%20elaborate%20on%20the%20description%20of%20the%20issues%3F%3C%2FP%3E%0A%3CP%3EDo%20you%20see%20any%20error%20flags%3F%3C%2FP%3E%0A%3CP%3EI%20recommend%20starting%20with%20a%20blocking%20method%20for%20simplicity%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_0-1762959571607.png%22%20style%3D%22width%3A%20597px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_0-1762959571607.png%22%20style%3D%22width%3A%20597px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365281i8D20FED1D09917B6%2Fimage-dimensions%2F597x768%3Fv%3Dv2%22%20width%3D%22597%22%20height%3D%22768%22%20role%3D%22button%22%20title%3D%22danielmartynek_0-1762959571607.png%22%20alt%3D%22danielmartynek_0-1762959571607.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_1-1762959967169.png%22%20style%3D%22width%3A%20829px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_1-1762959967169.png%22%20style%3D%22width%3A%20829px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365282iEE89900BD4367705%2Fimage-dimensions%2F829x511%3Fv%3Dv2%22%20width%3D%22829%22%20height%3D%22511%22%20role%3D%22button%22%20title%3D%22danielmartynek_1-1762959967169.png%22%20alt%3D%22danielmartynek_1-1762959967169.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThe%20DATA%20registers%20must%20be%20aligned%20to%20the%20quad-page.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EYou%20cannot%20execute%20code%20from%20the%20block%20that%20is%20being%20programmed.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CPRE%3EAny%20support%2C%20information%2C%20and%20technology%20(%E2%80%9CMaterials%E2%80%9D)%20provided%20by%20NXP%20are%20provided%20AS%20IS%2C%20without%20any%20warranty%20express%20or%20implied%2C%20and%20NXP%20disclaims%20all%20direct%20and%20indirect%20liability%20and%20damages%20in%20connection%20with%20the%20Material%20to%20the%20maximum%20extent%20permitted%20by%20the%20applicable%20law.%20%3CBR%20%2F%3ENXP%20accepts%20no%20liability%20for%20any%20assistance%20with%20applications%20or%20product%20design.%20Materials%20may%20only%20be%20used%20in%20connection%20with%20NXP%20products.%20Any%20feedback%20provided%20to%20NXP%20regarding%20the%20Materials%20may%20be%20used%20by%20NXP%20without%20restriction.%3C%2FPRE%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E