AnsweredAssumed Answered

Misaligned instruction cache fetch exception on bf537

Question asked by Dazdranagorn on Jun 25, 2013
Latest reply on Oct 30, 2013 by SachinV

Hello.

 

I get problem with aligning.

On Bf537 custom board, I run simple ethernet server program based on VDK+LWIP. Only receive-transmit of small string. 

For a long time all works perfectly. But suddenly I get an exception.

Program works unstable. It can get and transmit thousands of same packages or crashed in hundred of ones.

 

I found out info about this exception:

 

TMK_ExeptionRetorEntry + 0x2e

SEQSTAT  0x0000202A (Instruction fetch misaligned address violation)

RETX 0xFFA05E64

 

There is a dump of HEXcode and disassembly:

 

_ker_set_lasterror

 

[FFA05E10] LINK 0xc ;

[FFA05E14] P1.L = 0x53c ;

[FFA05E18] P1.H = 0xff80 ;

[FFA05E1C] R1 = ROT R0 BY 0  || R0 = [ P1 ]  || NOP ;

[FFA05E24] CALL SetThreadSlotValue__3VDKFiPv ;

[FFA05E28] R1 = R1 - R1 ( NS )  || P0 = [ FP + 0x4 ]  || NOP ;

[FFA05E30] CC = R0 == 0 ;

[FFA05E32] R0 = 0xff08 ( Z ) ;

[FFA05E36] UNLINK ;

[FFA05E3A] IF ! CC R0 = R1 ;

[FFA05E3C] JUMP ( P0 ) ;

[FFA05E3E] NOP ;

 

_ker_get_systime

 

[FFA05E40] LINK 0xc ;

[FFA05E44] CALL TMK_GetUptime ;

[FFA05E48] CALL ___int32_to_float32 ;

[FFA05E4C] P1.L = 0x538 ;

[FFA05E50] P1.H = 0xff80 ;

[FFA05E54] R1 = [ P1 ] ;

[FFA05E56] CALL ___float32_mul ;

[FFA05E5A] CALL ___float32_to_int32_round_to_zero ;

[FFA05E5E] P0 = [ FP + 0x4 ] ;

[FFA05E60] UNLINK ;

[FFA05E64] JUMP ( P0 ) ;

[FFA05E66] NOP ;

 

_ker_create_tread

 

[FFA05E68] LINK 0x1c ;

[FFA05E6C] [ -- SP ] = ( R7:5 , P5:4 ) ;

[FFA05E6E] R6 = R0 ;

[FFA05E70] SP += -12 ;

[FFA05E72] R0 = 8 ;

[FFA05E74] R5 = ROT R1 BY 0  || P4 = [ FP + 0x18 ]  || NOP ;

[FFA05E7C] R7 = ROT R2 BY 0  || P5 = [ FP + 0x20 ]  || NOP ;

***

 

@@Hex32

[FFA05E10] 0003E800

[FFA05E14] 053CE109

[FFA05E18] FF80E149

[FFA05E1C] C200CE82

[FFA05E20] 00009108

[FFA05E24] E724E3FF

[FFA05E28] 4209CC04

[FFA05E2C] 0000AC78

[FFA05E30] E1800C00

[FFA05E34] E801FF08

[FFA05E38] 06010000

[FFA05E3C] 00000050

 

[FFA05E40] 0003E800

[FFA05E44] D872E3FF

[FFA05E48] EB74E3FF

[FFA05E4C] 0538E109

[FFA05E50] FF80E149

[FFA05E54] E3FF9109

[FFA05E58] E3FFEC9F

[FFA05E5C] AC78EAFB

[FFA05E60] 0000E801

[FFA05E64] 00000050

 

[FFA05E68] 0007E800

[FFA05E6C] 303005EC

[FFA05E70] 60406FA6

[FFA05E74] CA01CE82

[FFA05E78] 0000ADBC

[FFA05E7C] CE02CE82

[FFA05E80] 0000AE3D

***

 

I modify my ethernet client program on PC. After every successful transaction it disconnected from server. And I get another exception:

 

_tmk_ExeptionHendler + 0x14

SEQSTAT  0x00002024 (Data access misaligned address violation)

RETX 0xFFA04772

 

There is a dump of HEXcode and disassembly of block where I get this exception:

 

_QueueFrames

 

[FFA04754] LINK 0xc ;

[FFA04758] [ -- SP ] = ( R7:4 , P5:3 ) ;

[FFA0475A] SP += -12 ;

[FFA0475C] [ SP + 0x28 ] = R1 ;

[FFA0475E] P3 = [ SP + 0x28 ] ;

[FFA04760] [ FP + 0x10 ] = R0 ;

[FFA04762] P5 = 0 ;

[FFA04764] P1 = [ P3 + 0x8 ] ;

[FFA04766] R1 = [ P3 + 0x8 ] ;

[FFA04768] CC = R1 == 0 ;

[FFA0476A] IF CC JUMP 42 /*0xFFA04794*/ ;

[FFA0476C] NOP ;

[FFA0476E] NOP ;

[FFA04770] NOP ;

[FFA04772] R0 = [ P1 + 0x2c ] ;

[FFA04774] CC = R0 == 0 ;

[FFA04776] P5 = P1 ;

[FFA04778] IF CC JUMP 28 /*0xFFA04794*/ ;

[FFA0477A] P0 = -1 ;

[FFA0477C] P5 = P1 ;

[FFA0477E] LSETUP ( __BEGIN__.P81L6L , 16 /*0xFFA0478E*/ ) LC0 = P0 ;

[FFA04782] NOP ;

.

@@Hex32

 

 

[FFA04754] 0003E800

[FFA04758] 6FA605E3

[FFA0475C] AEB3B2B1

[FFA04760] 6805B138

[FFA04764] A099AC99

[FFA04768] 18150C01

[FFA0476C] 00000000

[FFA04770] A2C80000

[FFA04774] 32690C00

[FFA04778] 6BF8180E

[FFA0477C] E0A23269

[FFA04780] 00000008

 

I noticed when I load my program to memory there is SEQSTAT 0x0000202C (CPLB miss on an instruction fetch)

 

Please help me to align my code, and find out why it becomes misaligned.

Outcomes