application firmware broke after installing HSE

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

application firmware broke after installing HSE

633 Views
ggreguer
Contributor I

After installing the HSE using the firmware S32K3_HSE_DemoExamples_1_0_0, I installed the full memory.

My application code no longer works. In debug mode, I probably get a fatal failure when trying to access flash.

Do I need to change something in my application to work with HSE?

I just want the HSE to generate random numbers.

Tags (1)
0 Kudos
Reply
7 Replies

621 Views
ggreguer
Contributor I
i'm also can't erase memory using my j-flash after the hse installation.
0 Kudos
Reply

589 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @ggreguer 

1. Once HSE is installed, parts of flash are allocated exclusively for HSE firmware. You can take a look at following tables in the reference manual:
Table 199. Configuration details when the HSE_B firmware usage feature flag is enabled
Table 200. AB swap configuration
https://www.nxp.com/webapp/Download?colCode=S32K3XXRM

Table 199 is actually the state of memory when FULL_MEM is installed.
For example, if Pemicro debugger is used, it's up to user to select the right flash algorithm depending on installed firmware. Such flash algorithm then avoids access to reserved areas.
I believe that Segger's tools do that automatically based on status registers. You may contact Segger directly for details.
https://kb.segger.com/NXP_S32K3xx#HSE_activated
https://www.segger.com/support/technical-support/

2. Once HSE firmware is installed, two things are needed:
- It's necessary to wait until HSE_STATUS_INIT_OK flag in FSR register in MU_0 is set. Before that, you can't trigger any HSE services. For example, you can find something like this in HSE DemoExamples:

lukaszadrapa_0-1761287124700.png

Or something like this in RTD examples:

lukaszadrapa_1-1761287139514.png


- When clocks are being initialized after reset, it's necessary to wait for WFI bit in PRTN0_CORE2_STAT register. This bit says that SBAF/HSE is in idle state and clocks can be changed. It's not possible to change the HSE_CLK while HSE is running, this can lead to unpredictable behavior. This was not done in earlier version of RTD drivers, it was up to user. Now it's fixed and implemented in clock init functions in RTD 5.0.0 and higher.

Regards,
Lukas

0 Kudos
Reply

570 Views
ggreguer
Contributor I
I have one more question: is there a way to perform a hard reset on my MCU and restore it to a previous state where I could erase all memory without errors?
I’ve already tested my application firmware by waiting for the HSE to initialize, as shown in the image you sent, but it’s still not working. When I try to write to flash using:
C40_Ip_pFlashBaseAddress->DATA[0] = 0x00U;

0 Kudos
Reply

548 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

If there’s something wrong with HSE (some fatal error caused by wrong clock configuration, ECC error in HSE memory resources…), it’s possible that the flash is locked for HSE but the operation has not been finished due to some errors. You can check HSE GPR register at 0x4039_C028, bits 16-29 (see HSE Firmware reference manual v2.6, Table 143. Status Bits on HSE_CONFIG_GPR3). If some of the bits are set permanently even after about 1s after reset then the HSE is probably in shutdown mode and it’s necessary to start handshake procedure. See “14.6.7 HSE Firmware Handshake” in the HSE FW reference manual. I also wrote some description here:

https://community.nxp.com/t5/S32K/S32K3-HSE-ERR-GENERAL/m-p/2072826/highlight/true#M47407

 

If this doesn’t help, I would need more details what is failing exactly.

 

Regards,

Lukas

0 Kudos
Reply

531 Views
ggreguer
Contributor I

Hi @lukaszadrapa , how are you? I’ll check those flags to investigate further what might be happening.

Meanwhile, is there any way to perform a master reset on these MCUs that are locking up? I need a factory reset to remove everything from the HSE and get it working normally again. I have several boards locked up and they’re really needed.

0 Kudos
Reply

494 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @ggreguer 

If HSE is up and running, it's possible to use service HSE_SRV_ID_ERASE_FW if you are still in CUST_DEL life cycle. This will erase HSE firmware and SYS_IMG, so it's almost like "factory reset" from HSE point of view. I'm saying almost because it does not affect data programmed in UTEST flash which is OTP memory. That means - if HSE feature flag in UTEST is programmed and FULL_MEM firmware was installed, areas reserved for HSE will be still reserved. If AB_SWAP is installed, OTA flag in UTEST is programmed, so areas for AB_SWAP firmware will be still reserved even after HSE FW erase. So, it's not 100% factory reset. 

If there's something wrong with HSE firmware and it cannot start, it's necessary to either recover the firmware or erase the firmware by SBAF - this can be done by handshake mechanism. Unfortunately there's no other way in this situation. 

Regards,

Lukas

0 Kudos
Reply

189 Views
Sanjana_k
Contributor II

#hello @lukaszadrapa 

I am working on the S32K3X4EVB-T172 board and trying to install the HSE firmware
The HSE firmware flashing is successful, but my application always stops at:

if (FALSE == checkHseFwFeatureFlagEnabled())
{
/* Stuck here */
}

So HSE FW initialization does not proceed.

I checked the UTEST region (0x1B000080), and I am getting the value 0XFFFFFFFF
please review our project and image and help us with this problem .

Thank u

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2191978%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Eapplication%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2191978%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EAfter%20installing%20the%20HSE%20using%20the%20firmware%20S32K3_HSE_DemoExamples_1_0_0%2C%20I%20installed%20the%20full%20memory.%3C%2FP%3E%3CP%3EMy%20application%20code%20no%20longer%20works.%20In%20debug%20mode%2C%20I%20probably%20get%20a%20fatal%20failure%20when%20trying%20to%20access%20flash.%3C%2FP%3E%3CP%3EDo%20I%20need%20to%20change%20something%20in%20my%20application%20to%20work%20with%20HSE%3F%3C%2FP%3E%3CP%3EI%20just%20want%20the%20HSE%20to%20generate%20random%20numbers.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2194818%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20application%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2194818%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%2F256120%22%20target%3D%22_blank%22%3E%40ggreguer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20HSE%20is%20up%20and%20running%2C%20it's%20possible%20to%20use%20service%26nbsp%3BHSE_SRV_ID_ERASE_FW%20if%20you%20are%20still%20in%20CUST_DEL%20life%20cycle.%20This%20will%20erase%20HSE%20firmware%20and%20SYS_IMG%2C%20so%20it's%20almost%20like%20%22factory%20reset%22%20from%20HSE%20point%20of%20view.%20I'm%20saying%20almost%20because%20it%20does%20not%20affect%20data%20programmed%20in%20UTEST%20flash%20which%20is%20OTP%20memory.%20That%20means%20-%20if%20HSE%20feature%20flag%20in%20UTEST%20is%20programmed%20and%20FULL_MEM%20firmware%20was%20installed%2C%20areas%20reserved%20for%20HSE%20will%20be%20still%20reserved.%20If%20AB_SWAP%20is%20installed%2C%20OTA%20flag%20in%20UTEST%20is%20programmed%2C%20so%20areas%20for%20AB_SWAP%20firmware%20will%20be%20still%20reserved%20even%20after%20HSE%20FW%20erase.%20So%2C%20it's%20not%20100%25%20factory%20reset.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20there's%20something%20wrong%20with%20HSE%20firmware%20and%20it%20cannot%20start%2C%20it's%20necessary%20to%20either%20recover%20the%20firmware%20or%20erase%20the%20firmware%20by%20SBAF%20-%20this%20can%20be%20done%20by%20handshake%20mechanism.%20Unfortunately%20there's%20no%20other%20way%20in%20this%20situation.%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2193510%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20application%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2193510%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%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%2C%20how%20are%20you%3F%20I%E2%80%99ll%20check%20those%20flags%20to%20investigate%20further%20what%20might%20be%20happening.%3C%2FP%3E%3CP%3EMeanwhile%2C%20is%20there%20any%20way%20to%20perform%20a%20master%20reset%20on%20these%20MCUs%20that%20are%20locking%20up%3F%20I%20need%20a%20factory%20reset%20to%20remove%20everything%20from%20the%20HSE%20and%20get%20it%20working%20normally%20again.%20I%20have%20several%20boards%20locked%20up%20and%20they%E2%80%99re%20really%20needed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2193325%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20application%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2193325%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIf%20there%E2%80%99s%20something%20wrong%20with%20HSE%20(some%20fatal%20error%20caused%20by%20wrong%20clock%20configuration%2C%20ECC%20error%20in%20HSE%20memory%20resources%E2%80%A6)%2C%20it%E2%80%99s%20possible%20that%20the%20flash%20is%20locked%20for%20HSE%20but%20the%20operation%20has%20not%20been%20finished%20due%20to%20some%20errors.%20You%20can%20check%20HSE%20GPR%20register%20at%200x4039_C028%2C%20bits%2016-29%20(see%20HSE%20Firmware%20reference%20manual%20v2.6%2C%20Table%20143.%E2%80%87Status%20Bits%20on%20HSE_CONFIG_GPR3).%20If%20some%20of%20the%20bits%20are%20set%20permanently%20even%20after%20about%201s%20after%20reset%20then%20the%20HSE%20is%20probably%20in%20shutdown%20mode%20and%20it%E2%80%99s%20necessary%20to%20start%20handshake%20procedure.%20See%20%E2%80%9C14.6.7%20HSE%20Firmware%20Handshake%E2%80%9D%20in%20the%20HSE%20FW%20reference%20manual.%20I%20also%20wrote%20some%20description%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K3-HSE-ERR-GENERAL%2Fm-p%2F2072826%2Fhighlight%2Ftrue%23M47407%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K3-HSE-ERR-GENERAL%2Fm-p%2F2072826%2Fhighlight%2Ftrue%23M47407%3C%2FA%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EIf%20this%20doesn%E2%80%99t%20help%2C%20I%20would%20need%20more%20details%20what%20is%20failing%20exactly.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2192576%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20application%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2192576%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EI%20have%20one%20more%20question%3A%20is%20there%20a%20way%20to%20perform%20a%20hard%20reset%20on%20my%20MCU%20and%20restore%20it%20to%20a%20previous%20state%20where%20I%20could%20erase%20all%20memory%20without%20errors%3F%3CBR%20%2F%3EI%E2%80%99ve%20already%20tested%20my%20application%20firmware%20by%20waiting%20for%20the%20HSE%20to%20initialize%2C%20as%20shown%20in%20the%20image%20you%20sent%2C%20but%20it%E2%80%99s%20still%20not%20working.%20When%20I%20try%20to%20write%20to%20flash%20using%3A%3CBR%20%2F%3EC40_Ip_pFlashBaseAddress-%26gt%3BDATA%5B0%5D%20%3D%200x00U%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2192304%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20application%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2192304%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%2F256120%22%20target%3D%22_blank%22%3E%40ggreguer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Once%20HSE%20is%20installed%2C%20parts%20of%20flash%20are%20allocated%20exclusively%20for%20HSE%20firmware.%20You%20can%20take%20a%20look%20at%20following%20tables%20in%20the%20reference%20manual%3A%3CBR%20%2F%3ETable%20199.%20Configuration%20details%20when%20the%20HSE_B%20firmware%20usage%20feature%20flag%20is%20enabled%3CBR%20%2F%3ETable%20200.%20AB%20swap%20configuration%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fwebapp%2FDownload%3FcolCode%3DS32K3XXRM%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.nxp.com%2Fwebapp%2FDownload%3FcolCode%3DS32K3XXRM%3C%2FA%3E%3C%2FP%3E%0A%3CP%3ETable%20199%20is%20actually%20the%20state%20of%20memory%20when%20FULL_MEM%20is%20installed.%20%3CBR%20%2F%3EFor%20example%2C%20if%20Pemicro%20debugger%20is%20used%2C%20it's%20up%20to%20user%20to%20select%20the%20right%20flash%20algorithm%20depending%20on%20installed%20firmware.%20Such%20flash%20algorithm%20then%20avoids%20access%20to%20reserved%20areas.%20%3CBR%20%2F%3EI%20believe%20that%20Segger's%20tools%20do%20that%20automatically%20based%20on%20status%20registers.%20You%20may%20contact%20Segger%20directly%20for%20details.%20%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fkb.segger.com%2FNXP_S32K3xx%23HSE_activated%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fkb.segger.com%2FNXP_S32K3xx%23HSE_activated%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.segger.com%2Fsupport%2Ftechnical-support%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.segger.com%2Fsupport%2Ftechnical-support%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E2.%20Once%20HSE%20firmware%20is%20installed%2C%20two%20things%20are%20needed%3A%3CBR%20%2F%3E-%20It's%20necessary%20to%20wait%20until%20HSE_STATUS_INIT_OK%20flag%20in%20FSR%20register%20in%20MU_0%20is%20set.%20Before%20that%2C%20you%20can't%20trigger%20any%20HSE%20services.%20For%20example%2C%20you%20can%20find%20something%20like%20this%20in%20HSE%20DemoExamples%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22lukaszadrapa_0-1761287124700.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_0-1761287124700.png%22%20style%3D%22width%3A%20248px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_0-1761287124700.png%22%20style%3D%22width%3A%20248px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F362446iBBF608F68C9678EA%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22lukaszadrapa_0-1761287124700.png%22%20alt%3D%22lukaszadrapa_0-1761287124700.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOr%20something%20like%20this%20in%20RTD%20examples%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22lukaszadrapa_1-1761287139514.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_1-1761287139514.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_1-1761287139514.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F362447iA835EAECFFFD84D0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22lukaszadrapa_1-1761287139514.png%22%20alt%3D%22lukaszadrapa_1-1761287139514.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E-%20When%20clocks%20are%20being%20initialized%20after%20reset%2C%20it's%20necessary%20to%20wait%20for%20WFI%20bit%20in%20PRTN0_CORE2_STAT%20register.%20This%20bit%20says%20that%20SBAF%2FHSE%20is%20in%20idle%20state%20and%20clocks%20can%20be%20changed.%20It's%20not%20possible%20to%20change%20the%20HSE_CLK%20while%20HSE%20is%20running%2C%20this%20can%20lead%20to%20unpredictable%20behavior.%20This%20was%20not%20done%20in%20earlier%20version%20of%20RTD%20drivers%2C%20it%20was%20up%20to%20user.%20Now%20it's%20fixed%20and%20implemented%20in%20clock%20init%20functions%20in%20RTD%205.0.0%20and%20higher.%3C%2FP%3E%0A%3CP%3ERegards%2C%3CBR%20%2F%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2191980%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20application%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2191980%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ei'm%20also%20can't%20erase%20memory%20using%20my%20j-flash%20after%20the%20hse%20installation.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2251341%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20application%20firmware%20broke%20after%20installing%20HSE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2251341%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%23hello%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%3EI%20am%20working%20on%20the%20S32K3X4EVB-T172%20board%20and%20trying%20to%20install%20the%20HSE%20firmware%3CBR%20%2F%3EThe%20HSE%20firmware%20flashing%20is%20successful%2C%20but%20my%20application%20always%20stops%20at%3A%3C%2FP%3E%3CP%3Eif%20(FALSE%20%3D%3D%20checkHseFwFeatureFlagEnabled())%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%2F*%20Stuck%20here%20*%2F%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3ESo%20HSE%20FW%20initialization%20does%20not%20proceed.%3C%2FP%3E%3CP%3EI%20checked%20the%20UTEST%20region%20(0x1B000080)%2C%20and%20I%20am%20getting%20the%20value%200XFFFFFFFF%3CBR%20%2F%3Eplease%20review%20our%20project%20and%20image%20and%20help%20us%20with%20this%20problem%20.%3C%2FP%3E%3CP%3EThank%20u%3C%2FP%3E%3C%2FLINGO-BODY%3E