M5282 and OpenTCP invalid stack

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

M5282 and OpenTCP invalid stack

997 Views
caburfoot
Contributor I

I'm trying to learn how to use the coldfire 5282 EVB and OpenTCP. The first source demo builds but I have a run time error about an invalid stack type exception. This occurs after calling mcf5xxx_wr_sr. This is called from C.

The source lives in an .s file in the project.

 

mcf5xxx_wr_sr:

_mcf5xxx_wr_sr:

  move.l    4(sp),d0

  move.w  d0,sr

  rts

 

When call this we get to visit the _asm_exception

It would seem that the CW 7.2 convention for placing the data in a register instead of the stack is an issue.

 

So, how to change this code (assembly).

And where is the ColdFire V2 assembly manual. The UserManual doesn't have any reference codes.

 

Thanks

Chuck    

Labels (1)
0 Kudos
2 Replies

349 Views
vier_kuifjes
Senior Contributor I

The removal of stack parameter passing out of Codewarrior 7.2 is definitely causing problems in some cases.

My Coldfire Lite based application didn't work anymore either, because Coldfire Lite also contains some assembly language routines that assume parameter passing by stack. I had to check all those routines and modify them where necessary, making sure the right data arrives in the right register, and everything works fine now.

 

...well... not quite right! I have an issue that clearly appears to be compiler optimisation related. It only happens at levels 2 or higher and disappears at level 0 or 1. It's only there when the app is compiled with CW7.2, not with CW7.1. But as Coldfire Lite officially only is meant to be used in conjunction with CW7.1, Freescale refuses to offer any support.

 

Anyway, I will keep compiling with CW7.2 at optimisation level 1. The resulting object code is still smaller than when the app is compiled with CW7.1 at highest optimisation level, probably because of much more efficient library usage.

0 Kudos

349 Views
mjbcswitzerland
Specialist V

Hi Chuck

 

Check the Codewarrior configuration for passing parameter. The routine that you show expects parameters to be passed on the stack. If the CW configuration is set to pass parameters in registers you need to remove the line

 

  move.l    4(sp),d0

 

since the valus is already in do and will otherwise be incorrectly taken from a random value on the stack.

 

Regards

 

Mark

 

P.S. the uTasker project for the M5282 is in preparation see:

- http://www.utasker.com/docs/Coldfire/uTaskerM5282.PDF

- http://www.utasker.com/forum/index.php?topic=903.0

 

 

www.uTasker.com

 

0 Kudos