S32K396 HSE: GPR3[5] remains 0 in JTAG Recovery after BSB authentication failure Hello NXP team, I am testing secure boot failure recovery on an S32K396 with HSE firmware 0.2.50.0 FULL_MEM, in the CUST_DEL lifecycle. My main question is why GPR3[5] remains 0 while the application core is executing the default JTAG Recovery WFI loop after BSB AppBL authentication fails. The WFI loop itself is expected; I am asking about the recovery status indication. 1. Configuration and intended behavior - Secure boot mode: Basic Secure Boot (BSB). - ADKP is provisioned and its readback digest has been checked. - User Secure Recovery is NOT enabled. I have read back and confirmed that the corresponding OTP attribute is unprogrammed; HSE_SECURE_RECOVERY_CONFIG_ATTR_ID has not been programmed. - Both the Secure Recovery application address and length in the IVT are 0. - IVT base: 0x00400000. - BCW at 0x00400004: 0x00000009 (BOOT_SEQ = 1). - AppBL header pointer at IVT +0x30: 0x00451FC0. - BCW bit6 (DISABLE_SECURE_RECOVERY_MODE) = 0; the Secure Recovery enable OTP is nevertheless unprogrammed. - BCW bit7 (RESET_RECOVERY_MODE) = 0. My understanding is that this setting concerns recovery caused by consecutive resets, rather than being a general JTAG Recovery enable bit for a BSB authentication failure. I expect an unauthenticated AppBL not to execute and the device to use the built-in JTAG Recovery path, allowing a debugger to connect and restore the image. I do not expect a user recovery application or automatic fallback image to run. 2. Reproduction and observations The original image booted successfully and ran SecureBootApp. The two core0 status checks, coreBootStatus[0] & 1 and coreBootStatus[1] & 1, were both 1. The AppBL header is at 0x00451FC0. Its body starts at 0x00452000, with length 0x3000, extending through 0x00454FFF. The authentication tag starts at 0x00455000. After backing up the sector, I changed only byte 0x00453FF0 from 0xFF to 0xFE. This is padding inside the authenticated region. All other data bytes, the AppBL header, IVT, and original authentication tag were preserved. No new tag was generated. I fully powered the board off and on, then attached using J-Link GDB Server V9.62 (JTAG, 4000 kHz, target S32K396_M7_0). The Attach configuration does not download an image or explicitly reset the target or set PC/SP. An empty SetupTarget() callback skips connection-time ECC RAM initialization to preserve the recovery program in RAM. Values collected during the failure-state Attach session: Byte @ 0x00453FF0 = 0xFE BCW @ 0x00400004 = 0x00000009 PC = 0x2040012E Instruction @ 0x2040012C = WFI Instruction @ 0x2040012E = branch back to 0x2040012C GPR3 @ 0x4039C028 = 0x00000081 (bit5 = 0) SBAF version word @ 0x4039C020 = 0x00000F00 SBAF version word @ 0x4039C024 = 0x07000F00 MU0 FSR @ 0x4038C104 = 0x0B200000 (INIT_OK = 1, BOOT_OK = 0) MU0 GSR @ 0x4038C118 = 0x00000000 These values were read separately after connecting in the same failure-state session, rather than as an immediate atomic snapshot. I then restored only the original sector at 0x00452000-0x00453FFF, preserving the IVT and original authentication tag without re-signing. After another power cycle, SecureBootApp ran normally again. Byte 0x00453FF0 was 0xFF, BCW remained 0x00000009, both core0 status checks were 1, and HSE_BOOT_OK (raw MU0 FSR bit26) was 1. 3. Questions (1) With user Secure Recovery disabled and no recovery image specified in the IVT, is default JTAG Recovery the expected behavior after BSB authentication failure in CUST_DEL, without any separate JTAG Recovery enable operation? If another prerequisite is needed, which setting controls it? (2) GPR3[5] is described as indicating application cores booted in Recovery mode by SBAF. Does this bit cover only certain SBAF-initiated recovery paths, excluding recovery following an AppBL authentication failure handled by HSE firmware? Is GPR3 = 0x81 expected in this case? (3) Which registers, attributes, or logs reliably identify AppBL authentication failure, as distinct from another recovery cause or authentication that has not yet completed? If a capture immediately after connection is required, please provide the recommended read sequence. (4) In a separate ASB test, verification of the primary boot SMRs failed, followed by failure of the alternate boot SMRs specified by altPreBootSmrMap; the device also entered JTAG Recovery. With user Secure Recovery disabled, is this recovery state equivalent to the BSB failure case? Are the recovery handling and GPR3[5] update conditions the same, or can they differ depending on the ASB Core Reset configuration and failure sanction? My understanding of the default recovery behavior is consistent with the NXP TechSupport explanations in this public thread: https://community.nxp.com/t5/S32K/Fallback-mechanism-for-failed-AB-SWAP-update/m-p/2402604 I have also consulted the HSE-B Firmware Reference Manual v2.8. The 0.2.50.0 release notes reference v2.3, so please clarify any version-specific differences that apply to the SBAF/HSE combination shown above. Thank you for your help. Re: S32K396 HSE: GPR3[5] remains 0 in JTAG Recovery after BSB authentication failure 1) With User Secure Recovery disabled and no recovery image specified in the IVT, JTAG Recovery is the expected path after BSB AppBL authentication failure. No separate JTAG Recovery enable operation is required. BCW bit 7 controls recovery triggered by consecutive resets and does not generally disable recovery caused by a secure boot authentication failure.
2) GPR3[5] is expected to be set when the application core is released into JTAG Recovery mode. Therefore, GPR3 = 0x81 does not match the expected final recovery indication, although the PC and the WFI loop show that the core is executing the JTAG Recovery code. This discrepancy cannot currently be explained by the documented behavior and may require investigation of the specific SBAF and HSE firmware combination.
3) HSE_BOOT_OK = 0 indicates that secure boot did not complete successfully, but it does not uniquely identify an AppBL authentication failure. In this case, the controlled modification within the authenticated region, the unchanged authentication tag, entry into the recovery WFI loop, and successful boot after restoring the original byte provide strong evidence that the AppBL authentication failed.
To investigate the GPR3 discrepancy, please repeat the test from a power-on reset and connect without issuing another reset, downloading an image, or initializing RAM. After halting the core, read PC, GPR3, MU0 FSR/GSR, and the reset and recovery status registers before resuming execution.
4) ASB failure can result in the same JTAG Recovery state when both the primary and alternate boot SMRs fail. However, the path to recovery depends on the ASB Core Reset configuration and the configured failure sanction. GPR3[5] should still indicate that the application core was released into JTAG Recovery, but the preceding reset and status information may differ from the BSB case.
View full article