LPC54628 MemFault not raised when calling function via pointer

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC54628 MemFault not raised when calling function via pointer

ソリューションへジャンプ
870件の閲覧回数
mateuszkiełbasa
Contributor III

Hello, I'm working on NXP LPC54628 development board (ARM Cortex M4) and trying to configure MPU in a way that execute never (XN) flag is enabled on internal SRAM. I configured MPU and trying to call function from SRAM, e.g.

__RAMFUNC(SRAM_UPPER) static void function_to_be_executed(void)

{     

    /* do some nasty things here */

}

At this point everything works like a charm - MemFault is generated. But trying to call this function via pointer, e.g.

typedef void(*func)(void);

func f = function_to_be_executed;

f();

seems not to generate any exception. Is it normal? Am I missing something? From my POV in this case exception should also be generated,

ラベル(1)
タグ(1)
0 件の賞賛
1 解決策
854件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, mateusz

Regarding your question, I think the MPU functions no matter if you call it as a function as as a function pointer.

As you know that there is a backup or mirror in flash space for the void function_to_be_executed(void), pls check if the pointer f [which is defined as func f = function_to_be_executed] is located in flash address range or RAM range.

BR

Xiangjun Rong

元の投稿で解決策を見る

0 件の賞賛
4 返答(返信)
855件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, mateusz

Regarding your question, I think the MPU functions no matter if you call it as a function as as a function pointer.

As you know that there is a backup or mirror in flash space for the void function_to_be_executed(void), pls check if the pointer f [which is defined as func f = function_to_be_executed] is located in flash address range or RAM range.

BR

Xiangjun Rong

0 件の賞賛
847件の閲覧回数
mateuszkiełbasa
Contributor III

Hi,

According to debugger the function is actually running from SRAM. I've also tried to do second trial and moved the function to external flash (BOARD_SDRAM) via __TEXT() macro and result is the same... I mean running the function explicitly generates MemFault exception, but running the function via pointer doesn't.  That is really weird. How is it possible? I don't think there is MPU setting for that - it should simply work as is...

0 件の賞賛
838件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Regarding your question that the calling function can trigger MemManage Fault after MPU initialization, but calling function pointer can NOT trigger MemManage Fault, it is abnormal.

How about consulting ARM support? I have searched on google, no clue.

BR

XiangJun Rong

0 件の賞賛
828件の閲覧回数
mateuszkiełbasa
Contributor III

Hello,

It looks like setting correct TEX bits inside MPU->RASR register does the job. I have to study it further but basically it seems that everything works as expected. I'm marking your answer as a solution and going to invastigate it more deeply.

0 件の賞賛