[MPC5744P]how to use the debug registers to realize the "stack limit checking mechanism "

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

[MPC5744P]how to use the debug registers to realize the "stack limit checking mechanism "

2,243 Views
fyw
Contributor IV

The debug register configure code list below:

170875_170875.pngpastedImage_1.png

 

i use the Generate_Stack_error() function to test this stack checking mechanism, but nothing happened!  i wonder what's wrong with my code?   Thank you very much!

PS:(__STACK_SIZE           = 4096 )

170882_170882.pngpastedImage_2.png

Labels (1)
0 Kudos
11 Replies

1,642 Views
fyw
Contributor IV

anyone help that?

0 Kudos

1,642 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I have never tried this before, but I found, there is DAC1 and DAC2 settings in DBCR0 register. DAC1 and DAC2 should be set to 0x3, please look at the figures below:

pastedImage_1.png

pastedImage_2.png

Please try and let me know, if it helps.

Regards,

Martin

0 Kudos

1,642 Views
fyw
Contributor IV

i tried, but it seems do not work.

PS: i expect when run Generate_Stack_error()  function, the machinecheck_handler will happen

0 Kudos

1,642 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

Sorry for delay, I did not forget about this case, but I am little bit overloaded right now. I will try to create some simple example as soon as I have some time.

Regards,

Martin

0 Kudos

1,642 Views
fyw
Contributor IV

Hi Martin, have you tried this ?  Thank you very much!

0 Kudos

1,642 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

do you use debugger probe while you run the code you shared above? If yes, which debug probe you use?

I found two important points.

1) Implicitly, it is not possible to write to debug registers while debugger is attached.

2) The function Generate_Stack_error generates Machine check error by default, because you allocate more memory space than stack size is. The result of this allocation is Machine check exception before the first for loop is executed. Instruction stwux write to address 0x13fffff80 which is out of address range.

Please check, if you have set ME bit in MSR register, if yes, you have to see machine check exception. If not, set ME in MSR register.

pastedImage_1.png

Solution for the point two:

You must not allocate static array in the function and use pointer arithmetic instead of it. Check, if any machine check error does not occur while you have debug probe connected. 

In the next step, add your assembler code and also DBCR0 settings. Disconnect the debug probe, and run the code. Then attach to micro via debugger and check, if you are in IVOR1 exception.

Regards,

Martin

0 Kudos

1,642 Views
pederrogo
Contributor III

Hello Martin,

We are implementing a stack limit check for our MPC5744P based system. We are following the example above and plan to test the functionality using a function like Generate_Stack_error() above. You mention that the function Generate_Stack_error() should be modified so that pointer arithmetic is used instead. Can you please show how the function would look like after such a modification?

Best Regards,

Peder Rogö 

0 Kudos

1,642 Views
fyw
Contributor IV

Hi Martin

   Problem solved! It seems configure DBCR2 = 0xC0 0000 will work. Thank you very much!       

1,642 Views
fyw
Contributor IV

pastedImage_1.png

Hi  Martin:

   The PIC above the the read value from register.  Is there any wrong for the register's configuration?

I didn't run my program using the debugger. It is running in normal mode(Powerdown-->PowerUP---->RUN)

PS: in my program if the cpu enter IVOR1 interrupt. It will print something to the computer. But whatever i configure, the program run as Nothing happened. 

Thank you very much!

0 Kudos

1,642 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I am really sorry, but I was working on different projects. I will try to focus on this problem today.

Regards,

Martin

0 Kudos

1,642 Views
fyw
Contributor IV

Thank you very much! hope to hear good news from you

0 Kudos