Issue with FLASH_Write Not Programming CMAC Tag in S32K344 Advanced Secure Boot Example

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

Issue with FLASH_Write Not Programming CMAC Tag in S32K344 Advanced Secure Boot Example

343 Views
Luu_Nghia_308
Contributor II

Dear NXP Support Team,

I am currently running the example S32K3_HSE_DemoExamples_1_0_0\S32K3_HSE_DemoExamples\Secure_Boot\S32K344_Advanced_SecureBoot on the S32K344EVB-T172 board.

However, I have observed an issue where the following function call:

FLASH_Write(pCmacTag, Cmac_Tag, sizeof(Cmac_Tag))

does not program the CMAC tag into flash memory at the address defined by CmacTagFlashAddress.

The returned status is 0xC100, which indicates no error, but after dumping the flash memory, I can confirm that the CMAC tag has not been written to the expected flash location.

Luu_Nghia_308_0-1767780900598.png

 

Could you please help me debug this issue?

 

0 Kudos
Reply
4 Replies

215 Views
Luu_Nghia_308
Contributor II

I have executed the S32K344_Advanced_SecureBoot application, and the execution completed successfully without any errors. do you have anyway to debug or trace the secure boot process after a system reset?

Luu_Nghia_308_1-1767949217968.png

 

0 Kudos
Reply

195 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

One more thing is necessary - once configuration is done, BOOT_SEQ bit in boot configuration word in flash should reprogrammed to '1'. This enables the secure boot. Then SecureBootBlinky application should be executed after reset instead of configuration project. Once BOOT_SEQ is set to '1', normal reset vector (which is pointing to configuration project) is not taken into account. 

I saw that there's a difference between Basic Secure Boot example and Advanced Secure Boot example:

lukaszadrapa_0-1767971770671.png

Basic SB example has BOOT_SEQ already set in the boot header, Advanced SB example does not have BOOT_SEQ set. Either set it here or reprogram the flash manually once the configuration of secure boot is done. I described how it works here:

https://community.nxp.com/t5/S32K/S32K344-Secure-Boot-HSE-VerifyBootImage-issue/m-p/2171055/highligh...

So, as I said above, if secure boot is successful, SecureBootBlinky application will be executed. If secure boot fails, the device will go to recovery mode. That means it will end up in endless loop in RAM at JTAG_RECOVERY_START_ADDRESS which is 0x20400100.

Regards,

Lukas

 

 

0 Kudos
Reply

268 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Luu_Nghia_308 

Is that original project or did you modify it? I was playing with this example several times and it worked on my side. 

I'm not familiar with that debugger, but it looks like it could be caused by the debugger. Take a look at:

https://forum.segger.com/thread/7245-solved-ozone-memory-view-refresh/

https://kb.segger.com/UM08001_J-Link_/_J-Trace_User_Guide#Debugging_applications_that_change_flash_c...

Regards,

Lukas

0 Kudos
Reply

221 Views
Luu_Nghia_308
Contributor II

Thank you — it was caused by the debugger.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2289346%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EIssue%20with%20FLASH_Write%20Not%20Programming%20CMAC%20Tag%20in%20S32K344%20Advanced%20Secure%20Boot%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289346%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDear%20NXP%20Support%20Team%2C%3C%2FP%3E%3CP%3EI%20am%20currently%20running%20the%20example%20S32K3_HSE_DemoExamples_1_0_0%5CS32K3_HSE_DemoExamples%5CSecure_Boot%5CS32K344_Advanced_SecureBoot%20on%20the%20S32K344EVB-T172%20board.%3C%2FP%3E%3CP%3EHowever%2C%20I%20have%20observed%20an%20issue%20where%20the%20following%20function%20call%3A%3C%2FP%3E%3CP%3EFLASH_Write(pCmacTag%2C%20Cmac_Tag%2C%20sizeof(Cmac_Tag))%3C%2FP%3E%3CP%3Edoes%20not%20program%20the%20CMAC%20tag%20into%20flash%20memory%20at%20the%20address%20defined%20by%20CmacTagFlashAddress.%3C%2FP%3E%3CP%3EThe%20returned%20status%20is%200xC100%2C%20which%20indicates%20no%20error%2C%20but%20after%20dumping%20the%20flash%20memory%2C%20I%20can%20confirm%20that%20the%20CMAC%20tag%20has%20not%20been%20written%20to%20the%20expected%20flash%20location.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Luu_Nghia_308_0-1767780900598.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Luu_Nghia_308_0-1767780900598.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Luu_Nghia_308_0-1767780900598.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Luu_Nghia_308_0-1767780900598.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Luu_Nghia_308_0-1767780900598.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Luu_Nghia_308_0-1767780900598.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F371983iCC83B2ECAA1A811C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Luu_Nghia_308_0-1767780900598.png%22%20alt%3D%22Luu_Nghia_308_0-1767780900598.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ECould%20you%20please%20help%20me%20debug%20this%20issue%3F%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2290142%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Issue%20with%20FLASH_Write%20Not%20Programming%20CMAC%20Tag%20in%20S32K344%20Advanced%20Secure%20Boot%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2290142%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%2F253506%22%20target%3D%22_blank%22%3E%40Luu_Nghia_308%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIs%20that%20original%20project%20or%20did%20you%20modify%20it%3F%20I%20was%20playing%20with%20this%20example%20several%20times%20and%20it%20worked%20on%20my%20side.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20not%20familiar%20with%20that%20debugger%2C%20but%20it%20looks%20like%20it%20could%20be%20caused%20by%20the%20debugger.%20Take%20a%20look%20at%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fforum.segger.com%2Fthread%2F7245-solved-ozone-memory-view-refresh%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fforum.segger.com%2Fthread%2F7245-solved-ozone-memory-view-refresh%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fkb.segger.com%2FUM08001_J-Link_%2F_J-Trace_User_Guide%23Debugging_applications_that_change_flash_contents_at_runtime%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fkb.segger.com%2FUM08001_J-Link_%2F_J-Trace_User_Guide%23Debugging_applications_that_change_flash_contents_at_runtime%3C%2FA%3E%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-2291073%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Issue%20with%20FLASH_Write%20Not%20Programming%20CMAC%20Tag%20in%20S32K344%20Advanced%20Secure%20Boot%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291073%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EOne%20more%20thing%20is%20necessary%20-%20once%20configuration%20is%20done%2C%20BOOT_SEQ%20bit%20in%20boot%20configuration%20word%20in%20flash%20should%20reprogrammed%20to%20'1'.%20This%20enables%20the%20secure%20boot.%20Then%20SecureBootBlinky%20application%20should%20be%20executed%20after%20reset%20instead%20of%20configuration%20project.%20Once%20BOOT_SEQ%20is%20set%20to%20'1'%2C%20normal%20reset%20vector%20(which%20is%20pointing%20to%20configuration%20project)%20is%20not%20taken%20into%20account.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20saw%20that%20there's%20a%20difference%20between%20Basic%20Secure%20Boot%20example%20and%20Advanced%20Secure%20Boot%20example%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-1767971770671.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_0-1767971770671.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_0-1767971770671.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_0-1767971770671.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F372342iCF4D9B7F9079DC4C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22lukaszadrapa_0-1767971770671.png%22%20alt%3D%22lukaszadrapa_0-1767971770671.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBasic%20SB%20example%20has%20BOOT_SEQ%20already%20set%20in%20the%20boot%20header%2C%20Advanced%20SB%20example%20does%20not%20have%20BOOT_SEQ%20set.%20Either%20set%20it%20here%20or%20reprogram%20the%20flash%20manually%20once%20the%20configuration%20of%20secure%20boot%20is%20done.%20I%20described%20how%20it%20works%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K344-Secure-Boot-HSE-VerifyBootImage-issue%2Fm-p%2F2171055%2Fhighlight%2Ftrue%23M52769%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K344-Secure-Boot-HSE-VerifyBootImage-issue%2Fm-p%2F2171055%2Fhighlight%2Ftrue%23M52769%3C%2FA%3E%3C%2FP%3E%0A%3CP%3ESo%2C%20as%20I%20said%20above%2C%20if%20secure%20boot%20is%20successful%2C%26nbsp%3BSecureBootBlinky%20application%20will%20be%20executed.%20If%20secure%20boot%20fails%2C%20the%20device%20will%20go%20to%20recovery%20mode.%20That%20means%20it%20will%20end%20up%20in%20endless%20loop%20in%20RAM%20at%26nbsp%3BJTAG_RECOVERY_START_ADDRESS%20which%20is%200x20400100.%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2290757%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Issue%20with%20FLASH_Write%20Not%20Programming%20CMAC%20Tag%20in%20S32K344%20Advanced%20Secure%20Boot%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2290757%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EI%20have%20executed%20the%20%3C%2FSPAN%3E%3CSTRONG%3ES32K344_Advanced_SecureBoot%3C%2FSTRONG%3E%3CSPAN%3E%20application%2C%20and%20the%20execution%20completed%20successfully%20without%20any%20errors.%20do%20you%20have%20anyway%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eto%20debug%20or%20trace%20the%20%3C%2FSPAN%3E%3CSTRONG%3Esecure%20boot%3C%2FSTRONG%3E%3CSPAN%3E%20process%20after%20a%20system%20reset%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Luu_Nghia_308_1-1767949217968.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Luu_Nghia_308_1-1767949217968.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Luu_Nghia_308_1-1767949217968.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F372285iE0C7FB6D7A4E944E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Luu_Nghia_308_1-1767949217968.png%22%20alt%3D%22Luu_Nghia_308_1-1767949217968.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2290701%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Issue%20with%20FLASH_Write%20Not%20Programming%20CMAC%20Tag%20in%20S32K344%20Advanced%20Secure%20Boot%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2290701%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20%E2%80%94%20it%20was%20caused%20by%20the%20debugger.%3C%2FP%3E%3C%2FLINGO-BODY%3E