NXPs32k312 HSE reset issue

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

NXPs32k312 HSE reset issue

Jump to solution
1,955 Views
Anitha7
Contributor III

Hi, @lukaszadrapa 

Solved: Re: NXP s32k312 HSE Reset Issue - NXP Community

We are currently using RTD 4.0.0 and do not have the option to upgrade to a newer version. To address the HSE reset issue occurring without a debugger connection, we implemented the following solution 1 based on your earlier suggestion:

Solution 1:

/* Before configuring HSE_CLK and accessing the CONFIG_REG_GPR register,
the driver should wait for Secure BAF to enter WFI state by checking
the PRTN0_CORE2_STAT register. */
do {
WfiStatus = (BOARD_MC_ME->prtn0_core2_stat & MC_ME_PRTN0_CORE2_STAT_WFI_MASK);
} while (WfiStatus != MC_ME_PRTN0_CORE2_STAT_WFI_MASK);


This solution is implemented during clock initialization to ensure proper reset behavior without the debugger.

However, the NXP community also suggests an alternate approach:

Solution 2:

#define MU_FSR_ADDRESS (volatile os_uint32_t*)0x4038c104U
#define HSE_INIT_OK_SHIFT 24U
#define UTEST_HSE_ENABLED_ADDRESS (volatile os_uint32_t*)0x1B000000U
#define UTEST_HSE_ENABLED_DEFAULT 0xFFFFFFFFU

if (UTEST_HSE_ENABLED_ADDRESS != UTEST_HSE_ENABLED_DEFAULT)
{
board_waitforHSEinit();
}

void board_waitforHSEinit(void)
{
volatile os_uint32_t* Mu_FSR_Address = MU_FSR_ADDRESS;
while (((*Mu_FSR_Address >> HSE_INIT_OK_SHIFT) & 0x01) != 0x01U);
}


Although both solutions resolve the reset issue without a debugger, we are concerned that in Solution 2, if the HSE status bit is unexpectedly corrupted or never set (e.g., due to hardware fault), the software could get stuck indefinitely in the while loop.

Could you please advise which of these two approaches is more appropriate and robust for handling HSE reset issues without debugger support?

Tags (1)
0 Kudos
Reply
1 Solution
1,753 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport
  1. If we apply Solution 1 and Solution 2 externally with RTD 4.0.0, could this lead to any additional issues?

    - I can’t see other issues.  

  2. In the case of HSE firmware corruption, is there any automatic recovery mechanism available without relying on external recovery methods or debugger intervention?

    - This can be still solved by software without debugger. The software should follow handshake procedure (in fact, it’s just a triggering of several resets while checking if HSE works). If handshake procedure is not successful, the firmware must be installed again which can be also done by software only.  

  3. Is the reset issue (without using a debugger) addressed internally as part of the improvements in RTD 5.0.0?

    - This is not a known problem, first we have to identify the source of your troubles.  

  4. We are using the EB stack, which implements its own clock configuration using RTD 4.0.0.

    - What is your HSE_CLK? If you do not use secure boot, it should be set to 60MHz.  

  5. Even when a valid HSE image is present, if the HSE status flag bit is cleared (we observed this issue), Solution 2 causes the code to get stuck in a loop.

    - If HSE_STATUS_INIT_OK is not set, there’s something wrong with HSE firmware and handshake procedure must be started.  

  6. we added WFI and HSE status Flag checking solutions during clock initialization stage

    - Ok.  

 

Let me ask again what I already asked in previous thread:
Have you tried to attach your debugger (I mean hot-sync without reset) after the fail to see what happened? Just reset the MCU externally, so it does not run in debug mode and try to attach the debugger afterwards.

View solution in original post

0 Kudos
Reply
3 Replies
1,889 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Anitha7 

You should do both. The WFI says if it is already possible to configure clocks. HSE_STATUS_INIT_OK says, if HSE was successfully started and you can start using HSE services. If the status bit is not set, HSE firmware may be corrupted and user's action is required. Read section "14.6.7 HSE Firmware Handshake" in HSE firmware reference manual for details. 

Use a timeout when waiting for HSE_STATUS_INIT_OK. It may take up to approximately 1s after AB SWAP until the flag is set. That's because HSE takes backup of itself to passive partition. I recommend timeout about 1.3s.

Regards,

Lukas

0 Kudos
Reply
1,790 Views
Anitha7
Contributor III

Hi, @lukaszadrapa 

Thank you for your response.

I have a few points that I would like to clarify:

  1. If we apply Solution 1 and Solution 2 externally with RTD 4.0.0, could this lead to any additional issues?

  2. In the case of HSE firmware corruption, is there any automatic recovery mechanism available without relying on external recovery methods or debugger intervention?

  3. Is the reset issue (without using a debugger) addressed internally as part of the improvements in RTD 5.0.0?

  4. We are using the EB stack, which implements its own clock configuration using RTD 4.0.0.

  5. Even when a valid HSE image is present, if the HSE status flag bit is cleared (we observed this issue), Solution 2 causes the code to get stuck in a loop.

  6. we added WFI and HSE status Flag checking solutions during clock initialization stage

Could you please provide a clear and stable solution for handling the reset issue without a debugger, specifically for RTD 4.0.0, as we currently do not have the option to upgrade to a newer RTD version?

Tags (1)
0 Kudos
Reply
1,754 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport
  1. If we apply Solution 1 and Solution 2 externally with RTD 4.0.0, could this lead to any additional issues?

    - I can’t see other issues.  

  2. In the case of HSE firmware corruption, is there any automatic recovery mechanism available without relying on external recovery methods or debugger intervention?

    - This can be still solved by software without debugger. The software should follow handshake procedure (in fact, it’s just a triggering of several resets while checking if HSE works). If handshake procedure is not successful, the firmware must be installed again which can be also done by software only.  

  3. Is the reset issue (without using a debugger) addressed internally as part of the improvements in RTD 5.0.0?

    - This is not a known problem, first we have to identify the source of your troubles.  

  4. We are using the EB stack, which implements its own clock configuration using RTD 4.0.0.

    - What is your HSE_CLK? If you do not use secure boot, it should be set to 60MHz.  

  5. Even when a valid HSE image is present, if the HSE status flag bit is cleared (we observed this issue), Solution 2 causes the code to get stuck in a loop.

    - If HSE_STATUS_INIT_OK is not set, there’s something wrong with HSE firmware and handshake procedure must be started.  

  6. we added WFI and HSE status Flag checking solutions during clock initialization stage

    - Ok.  

 

Let me ask again what I already asked in previous thread:
Have you tried to attach your debugger (I mean hot-sync without reset) after the fail to see what happened? Just reset the MCU externally, so it does not run in debug mode and try to attach the debugger afterwards.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2157060%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ENXPs32k312%20HSE%20reset%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2157060%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F37795%22%20target%3D%22_blank%22%3E%40lukaszadrapa%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FOther-NXP-Products%2FNXP-s32k312-HSE-Reset-Issue%2Fm-p%2F2148312%23M29567%22%20target%3D%22_blank%22%3ESolved%3A%20Re%3A%20NXP%20s32k312%20HSE%20Reset%20Issue%20-%20NXP%20Community%3C%2FA%3E%3C%2FP%3E%3CP%3EWe%20are%20currently%20using%20RTD%204.0.0%20and%20do%20not%20have%20the%20option%20to%20upgrade%20to%20a%20newer%20version.%20To%20address%20the%20HSE%20reset%20issue%20occurring%20without%20a%20debugger%20connection%2C%20we%20implemented%20the%20following%20%3CSTRONG%3Esolution%201%3C%2FSTRONG%3E%20based%20on%20your%20earlier%20suggestion%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3ESolution%201%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%2F*%20Before%20configuring%20HSE_CLK%20and%20accessing%20the%20CONFIG_REG_GPR%20register%2C%3CBR%20%2F%3Ethe%20driver%20should%20wait%20for%20Secure%20BAF%20to%20enter%20WFI%20state%20by%20checking%3CBR%20%2F%3Ethe%20PRTN0_CORE2_STAT%20register.%20*%2F%3CBR%20%2F%3Edo%20%7B%3CBR%20%2F%3EWfiStatus%20%3D%20(BOARD_MC_ME-%26gt%3Bprtn0_core2_stat%20%26amp%3B%20MC_ME_PRTN0_CORE2_STAT_WFI_MASK)%3B%3CBR%20%2F%3E%7D%20while%20(WfiStatus%20!%3D%20MC_ME_PRTN0_CORE2_STAT_WFI_MASK)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EThis%20solution%20is%20implemented%20during%20clock%20initialization%20to%20ensure%20proper%20reset%20behavior%20without%20the%20debugger.%3C%2FP%3E%3CP%3EHowever%2C%20the%20NXP%20community%20also%20suggests%20an%20alternate%20approach%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3ESolution%202%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%23define%20MU_FSR_ADDRESS%20(volatile%20os_uint32_t*)0x4038c104U%3CBR%20%2F%3E%23define%20HSE_INIT_OK_SHIFT%2024U%3CBR%20%2F%3E%23define%20UTEST_HSE_ENABLED_ADDRESS%20(volatile%20os_uint32_t*)0x1B000000U%3CBR%20%2F%3E%23define%20UTEST_HSE_ENABLED_DEFAULT%200xFFFFFFFFU%3C%2FP%3E%3CP%3Eif%20(UTEST_HSE_ENABLED_ADDRESS%20!%3D%20UTEST_HSE_ENABLED_DEFAULT)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eboard_waitforHSEinit()%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Evoid%20board_waitforHSEinit(void)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Evolatile%20os_uint32_t*%20Mu_FSR_Address%20%3D%20MU_FSR_ADDRESS%3B%3CBR%20%2F%3Ewhile%20(((*Mu_FSR_Address%20%26gt%3B%26gt%3B%20HSE_INIT_OK_SHIFT)%20%26amp%3B%200x01)%20!%3D%200x01U)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EAlthough%20both%20solutions%20resolve%20the%20reset%20issue%20without%20a%20debugger%2C%20we%20are%20concerned%20that%20in%20%3CSTRONG%3ESolution%202%3C%2FSTRONG%3E%2C%20if%20the%20HSE%20status%20bit%20is%20unexpectedly%20corrupted%20or%20never%20set%20(e.g.%2C%20due%20to%20hardware%20fault)%2C%20the%20software%20could%20get%20stuck%20indefinitely%20in%20the%20while%20loop.%3C%2FP%3E%3CP%3ECould%20you%20please%20advise%20which%20of%20these%20two%20approaches%20is%20more%20appropriate%20and%20robust%20for%20handling%20HSE%20reset%20issues%20without%20debugger%20support%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2159681%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NXPs32k312%20HSE%20reset%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2159681%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3COL%3E%0A%3CLI%3EIf%20we%20apply%20%3CSTRONG%3ESolution%201%3C%2FSTRONG%3E%20and%20%3CSTRONG%3ESolution%202%3C%2FSTRONG%3E%20externally%20with%20%3CSTRONG%3ERTD%204.0.0%3C%2FSTRONG%3E%2C%20could%20this%20lead%20to%20any%20additional%20issues%3F%3CBR%20%2F%3E%3CBR%20%2F%3E-%20I%20can%E2%80%99t%20see%20other%20issues.%20%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EIn%20the%20case%20of%20%3CSTRONG%3EHSE%20firmware%20corruption%3C%2FSTRONG%3E%2C%20is%20there%20any%20%3CSTRONG%3Eautomatic%20recovery%20mechanism%3C%2FSTRONG%3E%20available%20%3CSTRONG%3Ewithout%20relying%20on%20external%20recovery%20methods%20or%20debugger%20intervention%3C%2FSTRONG%3E%3F%3CBR%20%2F%3E%3CBR%20%2F%3E-%20This%20can%20be%20still%20solved%20by%20software%20without%20debugger.%20The%20software%20should%20follow%20handshake%20procedure%20(in%20fact%2C%20it%E2%80%99s%20just%20a%20triggering%20of%20several%20resets%20while%20checking%20if%20HSE%20works).%20If%20handshake%20procedure%20is%20not%20successful%2C%20the%20firmware%20must%20be%20installed%20again%20which%20can%20be%20also%20done%20by%20software%20only.%20%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EIs%20the%20%3CSTRONG%3Ereset%20issue%20(without%20using%20a%20debugger)%3C%2FSTRONG%3E%20addressed%20internally%20as%20part%20of%20the%20improvements%20in%20%3CSTRONG%3ERTD%205.0.0%3C%2FSTRONG%3E%3F%3CBR%20%2F%3E%3CBR%20%2F%3E-%20This%20is%20not%20a%20known%20problem%2C%20first%20we%20have%20to%20identify%20the%20source%20of%20your%20troubles.%20%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EWe%20are%20using%20the%20%3CSTRONG%3EEB%20stack%3C%2FSTRONG%3E%2C%20which%20implements%20its%20own%20%3CSTRONG%3Eclock%20configuration%3C%2FSTRONG%3E%20using%20%3CSTRONG%3ERTD%204.0.0%3C%2FSTRONG%3E.%3CBR%20%2F%3E%3CBR%20%2F%3E-%20What%20is%20your%20HSE_CLK%3F%20If%20you%20do%20not%20use%20secure%20boot%2C%20it%20should%20be%20set%20to%2060MHz.%20%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EEven%20when%20a%20%3CSTRONG%3Evalid%20HSE%20image%3C%2FSTRONG%3E%20is%20present%2C%20if%20the%20%3CSTRONG%3EHSE%20status%20flag%20bit%20is%20cleared%20(we%20observed%20this%20issue)%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ESolution%202%3C%2FSTRONG%3E%20causes%20the%20code%20to%20%3CSTRONG%3Eget%20stuck%20in%20a%20loop%3C%2FSTRONG%3E.%3CBR%20%2F%3E%3CBR%20%2F%3E-%20If%20HSE_STATUS_INIT_OK%20is%20not%20set%2C%20there%E2%80%99s%20something%20wrong%20with%20HSE%20firmware%20and%20handshake%20procedure%20must%20be%20started.%20%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3Ewe%20added%20WFI%20and%20HSE%20status%20Flag%20checking%20solutions%20during%20clock%20initialization%20stage%3CBR%20%2F%3E%3CBR%20%2F%3E-%20Ok.%20%26nbsp%3B%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CBR%20%2F%3E%0A%3CP%3ELet%20me%20ask%20again%20what%20I%20already%20asked%20in%20previous%20thread%3A%3CBR%20%2F%3EHave%20you%20tried%20to%20attach%20your%20debugger%20(I%20mean%20hot-sync%20without%20reset)%20after%20the%20fail%20to%20see%20what%20happened%3F%20Just%20reset%20the%20MCU%20externally%2C%20so%20it%20does%20not%20run%20in%20debug%20mode%20and%20try%20to%20attach%20the%20debugger%20afterwards.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2159127%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NXPs32k312%20HSE%20reset%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2159127%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSTRONG%3EHi%2C%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F37795%22%20target%3D%22_blank%22%3E%40lukaszadrapa%3C%2FA%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EThank%20you%20for%20your%20response.%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20have%20a%20few%20points%20that%20I%20would%20like%20to%20clarify%3A%3C%2FP%3E%3COL%3E%3CLI%3E%3CP%3EIf%20we%20apply%20%3CSTRONG%3ESolution%201%3C%2FSTRONG%3E%20and%20%3CSTRONG%3ESolution%202%3C%2FSTRONG%3E%20externally%20with%20%3CSTRONG%3ERTD%204.0.0%3C%2FSTRONG%3E%2C%20could%20this%20lead%20to%20any%20additional%20issues%3F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EIn%20the%20case%20of%20%3CSTRONG%3EHSE%20firmware%20corruption%3C%2FSTRONG%3E%2C%20is%20there%20any%20%3CSTRONG%3Eautomatic%20recovery%20mechanism%3C%2FSTRONG%3E%20available%20%3CSTRONG%3Ewithout%20relying%20on%20external%20recovery%20methods%20or%20debugger%20intervention%3C%2FSTRONG%3E%3F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EIs%20the%20%3CSTRONG%3Ereset%20issue%20(without%20using%20a%20debugger)%3C%2FSTRONG%3E%20addressed%20internally%20as%20part%20of%20the%20improvements%20in%20%3CSTRONG%3ERTD%205.0.0%3C%2FSTRONG%3E%3F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EWe%20are%20using%20the%20%3CSTRONG%3EEB%20stack%3C%2FSTRONG%3E%2C%20which%20implements%20its%20own%20%3CSTRONG%3Eclock%20configuration%3C%2FSTRONG%3E%20using%20%3CSTRONG%3ERTD%204.0.0%3C%2FSTRONG%3E.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EEven%20when%20a%20%3CSTRONG%3Evalid%20HSE%20image%3C%2FSTRONG%3E%20is%20present%2C%20if%20the%20%3CSTRONG%3EHSE%20status%20flag%20bit%20is%20cleared%20(we%20observed%20this%20issue)%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ESolution%202%3C%2FSTRONG%3E%20causes%20the%20code%20to%20%3CSTRONG%3Eget%20stuck%20in%20a%20loop%3C%2FSTRONG%3E.%3C%2FP%3E%3C%2FLI%3E%3CLI%3Ewe%20added%20WFI%20and%20HSE%20status%20Flag%20checking%20solutions%20during%20clock%20initialization%20stage%3C%2FLI%3E%3C%2FOL%3E%3CP%3ECould%20you%20please%20provide%20a%20%3CSTRONG%3Eclear%20and%20stable%20solution%3C%2FSTRONG%3E%20for%20handling%20the%20%3CSTRONG%3Ereset%20issue%20without%20a%20debugger%3C%2FSTRONG%3E%2C%20specifically%20for%20%3CSTRONG%3ERTD%204.0.0%3C%2FSTRONG%3E%2C%20as%20we%20currently%20%3CSTRONG%3Edo%20not%20have%20the%20option%20to%20upgrade%20to%20a%20newer%20RTD%20version%3C%2FSTRONG%3E%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2157583%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NXPs32k312%20HSE%20reset%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2157583%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%2F228025%22%20target%3D%22_blank%22%3E%40Anitha7%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20should%20do%20both.%20The%20WFI%20says%20if%20it%20is%20already%20possible%20to%20configure%20clocks.%20HSE_STATUS_INIT_OK%20says%2C%20if%20HSE%20was%20successfully%20started%20and%20you%20can%20start%20using%20HSE%20services.%20If%20the%20status%20bit%20is%20not%20set%2C%20HSE%20firmware%20may%20be%20corrupted%20and%20user's%20action%20is%20required.%20Read%20section%20%2214.6.7%20HSE%20Firmware%20Handshake%22%20in%20HSE%20firmware%20reference%20manual%20for%20details.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUse%20a%20timeout%20when%20waiting%20for%26nbsp%3BHSE_STATUS_INIT_OK.%20It%20may%20take%20up%20to%20approximately%201s%20after%20AB%20SWAP%20until%20the%20flag%20is%20set.%20That's%20because%20HSE%20takes%20backup%20of%20itself%20to%20passive%20partition.%20I%20recommend%20timeout%20about%201.3s.%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E