S32K311 UTest Programming: RWE Error and Crash During Programming

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

S32K311 UTest Programming: RWE Error and Crash During Programming

286 Views
Enoch_D
Contributor I

I am working on UTest programming on the S32K311 Microcontroller, and I am encountering a Read-While-Write Error (RWE) along with a controller crash during flash programming.

Issue:
After triggering the UTest programming sequence:

The controller jumps to the default handler (crash)
The RWE (Read While Write Error) flag is set

Context:
Application is executing from PFlash @ 0x00480000
UTest programming is initiated while running from PFlash
The actual trigger function (EHV set + polling) is executed from RAM

Implementation Flow:
1. Initialization & Preparation (FLASH_gSetPublicKey_Prepare)
Unlock UTest sector: PFLASH.PFCBLKU_SPELOCK[0].R &= ~(1U << 0);
Reset operation mode bits:EHV = 0,PGM = 0,ERS = 0
Clear status flags
Load target address: PFLASH.PFCPGM_PEADR_L.R = 0x1B000100U;
Load data into flash registers:
for (i = 0U; i < FLASH_lNumOfWords; i++)
{
FLASH.DATA[i].R = FLASH_pSrc[i];
}
Enable program mode: FLASH.MCR.B.PGM = 1U;

2. Programming Execution (from RAM) (FLASH_gSetPublicKey_Trigger)
Start programming: FLASH.MCR.B.EHV = 1U;
Poll until completion: Wait for DONE = 1
Stop programming:
FLASH.MCR.B.EHV = 0U;
FLASH.MCR.B.PGM = 0U;
Re-lock UTest sector

Observations:
Even though the trigger function runs from RAM, the system still:
Encounters RWE error & Jumps to default handler

Based on the above flow, I would appreciate if you could help identify the exact cause of the RWE fault and suggest the necessary corrections to ensure reliable UTest programming.

Thanks.

0 Kudos
Reply
1 Reply

215 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Do you have disabled interrupts? Also flash prefetching and cache needs to be disabled as speculative or prefetch access to flash block 0 can occur what is same block as UTEST.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2351536%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K311%20UTest%20Programming%3A%20RWE%20Error%20and%20Crash%20During%20Programming%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2351536%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20working%20on%20UTest%20programming%20on%20the%20S32K311%20Microcontroller%2C%20and%20I%20am%20encountering%20a%20Read-While-Write%20Error%20(RWE)%20along%20with%20a%20controller%20crash%20during%20flash%20programming.%3C%2FP%3E%3CP%3EIssue%3A%3CBR%20%2F%3EAfter%20triggering%20the%20UTest%20programming%20sequence%3A%3C%2FP%3E%3CP%3EThe%20controller%20jumps%20to%20the%20default%20handler%20(crash)%3CBR%20%2F%3EThe%20RWE%20(Read%20While%20Write%20Error)%20flag%20is%20set%3C%2FP%3E%3CP%3EContext%3A%3CBR%20%2F%3EApplication%20is%20executing%20from%20PFlash%20%40%200x00480000%3CBR%20%2F%3EUTest%20programming%20is%20initiated%20while%20running%20from%20PFlash%3CBR%20%2F%3EThe%20actual%20trigger%20function%20(EHV%20set%20%2B%20polling)%20is%20executed%20from%20RAM%3C%2FP%3E%3CP%3EImplementation%20Flow%3A%3CBR%20%2F%3E1.%20Initialization%20%26amp%3B%20Preparation%20(FLASH_gSetPublicKey_Prepare)%3CBR%20%2F%3EUnlock%20UTest%20sector%3A%20PFLASH.PFCBLKU_SPELOCK%5B0%5D.R%20%26amp%3B%3D%20~(1U%20%26lt%3B%26lt%3B%200)%3B%3CBR%20%2F%3EReset%20operation%20mode%20bits%3AEHV%20%3D%200%2CPGM%20%3D%200%2CERS%20%3D%200%3CBR%20%2F%3EClear%20status%20flags%3CBR%20%2F%3ELoad%20target%20address%3A%20PFLASH.PFCPGM_PEADR_L.R%20%3D%200x1B000100U%3B%3CBR%20%2F%3ELoad%20data%20into%20flash%20registers%3A%3CBR%20%2F%3Efor%20(i%20%3D%200U%3B%20i%20%26lt%3B%20FLASH_lNumOfWords%3B%20i%2B%2B)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EFLASH.DATA%5Bi%5D.R%20%3D%20FLASH_pSrc%5Bi%5D%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3EEnable%20program%20mode%3A%20FLASH.MCR.B.PGM%20%3D%201U%3B%3C%2FP%3E%3CP%3E2.%20Programming%20Execution%20(from%20RAM)%20(FLASH_gSetPublicKey_Trigger)%3CBR%20%2F%3EStart%20programming%3A%20FLASH.MCR.B.EHV%20%3D%201U%3B%3CBR%20%2F%3EPoll%20until%20completion%3A%20Wait%20for%20DONE%20%3D%201%3CBR%20%2F%3EStop%20programming%3A%3CBR%20%2F%3EFLASH.MCR.B.EHV%20%3D%200U%3B%3CBR%20%2F%3EFLASH.MCR.B.PGM%20%3D%200U%3B%3CBR%20%2F%3ERe-lock%20UTest%20sector%3C%2FP%3E%3CP%3EObservations%3A%3CBR%20%2F%3EEven%20though%20the%20trigger%20function%20runs%20from%20RAM%2C%20the%20system%20still%3A%3CBR%20%2F%3EEncounters%20RWE%20error%20%26amp%3B%20Jumps%20to%20default%20handler%3C%2FP%3E%3CP%3EBased%20on%20the%20above%20flow%2C%20I%20would%20appreciate%20if%20you%20could%20help%20identify%20the%20exact%20cause%20of%20the%20RWE%20fault%20and%20suggest%20the%20necessary%20corrections%20to%20ensure%20reliable%20UTest%20programming.%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2352917%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K311%20UTest%20Programming%3A%20RWE%20Error%20and%20Crash%20During%20Programming%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2352917%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDo%20you%20have%20disabled%20interrupts%3F%20Also%20flash%20prefetching%20and%20cache%20needs%20to%20be%20disabled%20as%20speculative%20or%20prefetch%20access%20to%20flash%20block%200%20can%20occur%20what%20is%20same%20block%20as%20UTEST.%3C%2FP%3E%3C%2FLINGO-BODY%3E