S32K322 MPU MemManage handler Exception Not Reaching

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

S32K322 MPU MemManage handler Exception Not Reaching

822 Views
Thiru2483
Contributor II

Hi Team,

I have configured the MPU memory partition.

I created a stub function to intentionally violate the SRAM address region.

Thiru2483_0-1777026529330.png

Initially, I configured both read and write access to the SRAM region. After changing the region permissions to read-only and attempting to write to the TEST_SRAM_ADDRESS, a MemFault is triggered, and the location is updated as expected. However, it is entering the HardFault handler instead of the MemManage handler. I have attached the image below for your reference withe register details.

Thiru2483_1-1777026796118.png

Thiru2483_0-1777027817170.png

 

I have added the MCAL MPU option enabled similar is done for core 1.

Kindly let me know why this is happening and whether I am missing any configuration. Please provide your support on this.

S32K3

 

0 Kudos
Reply
1 Reply

709 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Thiru2483,

The root cause could be that another fault occurs during exception entry or stack usage. Even with MEMFAULTENA enabled, if the MPU violation happens while the core is stacking/unstacking registers (for example, when the stack pointer lies in or grows into a restricted SRAM MPU region), the Cortex‑M7 will force escalation directly to HardFault. In that case, MemManage_Handler is never entered. Is the stack located in the same SRAM region that you are restricting with the MPU?

 

Regards,

Daniel

 
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2355797%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K322%20MPU%20MemManage%20handler%20Exception%20Not%20Reaching%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2355797%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Team%2C%3C%2FP%3E%3CP%3EI%20have%20configured%20the%20MPU%20memory%20partition.%3C%2FP%3E%3CP%3EI%20created%20a%20stub%20function%20to%20intentionally%20violate%20the%20SRAM%20address%20region.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Thiru2483_0-1777026529330.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Thiru2483_0-1777026529330.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F383480i88A1B41939DD2301%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Thiru2483_0-1777026529330.png%22%20alt%3D%22Thiru2483_0-1777026529330.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EInitially%2C%20I%20configured%20both%20read%20and%20write%20access%20to%20the%20SRAM%20region.%20After%20changing%20the%20region%20permissions%20to%20read-only%20and%20attempting%20to%20write%20to%20the%20TEST_SRAM_ADDRESS%2C%20a%20MemFault%20is%20triggered%2C%20and%20the%20location%20is%20updated%20as%20expected.%20However%2C%20it%20is%20entering%20the%20HardFault%20handler%20instead%20of%20the%20MemManage%20handler.%20I%20have%20attached%20the%20image%20below%20for%20your%20reference%20withe%20register%20details.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Thiru2483_1-1777026796118.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Thiru2483_1-1777026796118.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F383481iE9A9613A12D7CCC4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Thiru2483_1-1777026796118.png%22%20alt%3D%22Thiru2483_1-1777026796118.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Thiru2483_0-1777027817170.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Thiru2483_0-1777027817170.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F383484iC5FBD766D1672BD3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Thiru2483_0-1777027817170.png%22%20alt%3D%22Thiru2483_0-1777027817170.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EI%20have%20added%20the%20MCAL%20MPU%20option%20enabled%20similar%20is%20done%20for%20core%201.%3C%2FP%3E%3CP%3EKindly%20let%20me%20know%20why%20this%20is%20happening%20and%20whether%20I%20am%20missing%20any%20configuration.%20Please%20provide%20your%20support%20on%20this.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fc-pwmxy87654%2FS32K3%2Fpd-p%2FS32K3%22%20class%3D%22lia-product-mention%22%20data-product%3D%221688-1%22%20target%3D%22_blank%22%3ES32K3%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2356326%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K322%20MPU%20MemManage%20handler%20Exception%20Not%20Reaching%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2356326%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%2F248796%22%20target%3D%22_blank%22%3E%40Thiru2483%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EThe%20root%20cause%20could%20be%20that%20another%20fault%20occurs%20during%20exception%20entry%20or%20stack%20usage.%20Even%20with%20MEMFAULTENA%20enabled%2C%20if%20the%20MPU%20violation%20happens%20while%20the%20core%20is%20stacking%2Funstacking%20registers%20(for%20example%2C%20when%20the%20stack%20pointer%20lies%20in%20or%20grows%20into%20a%20restricted%20SRAM%20MPU%20region)%2C%20the%20Cortex%E2%80%91M7%20will%20force%20escalation%20directly%20to%20HardFault.%20In%20that%20case%2C%20MemManage_Handler%20is%20never%20entered.%26nbsp%3BIs%20the%20stack%20located%20in%20the%20same%20SRAM%20region%20that%20you%20are%20restricting%20with%20the%20MPU%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CDIV%20style%3D%22font-family%3A%20'Segoe%20UI'%3B%20font-size%3A%2014px%3B%20font-style%3A%20normal%3B%20font-weight%3A%20400%3B%20line-height%3A%2020px%3B%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FLINGO-BODY%3E