* [U-Boot-Users] unexpected behaviour !!!
@ 2006-01-31 8:20 Maximus
2006-01-31 12:05 ` Peter Menzebach
0 siblings, 1 reply; 4+ messages in thread
From: Maximus @ 2006-01-31 8:20 UTC (permalink / raw)
To: u-boot
Hi,
I have designed my own protocol and am trying to include it in u-boot.
In the Recieve Handler i am trying to dereference the pkt.
struct mypacket {
unsigned int seqnum ;
char data [24] ;
} ;
struct mypacket mypacket ;
void myrecieve_handler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
int seqnum ;
uchar * q ;
if (dest != 8888)
return ;
printf ("pkt => %u\n", pkt) ;
printf ("len => %d\n", len) ;
q = pkt ;
for (i = 0 ; i < len ; i++) {
printf ("%d:%u=> %c\n", i, q, *q) ;
q++ ;
}
memcpy (&mypacket, pkt, sizeof (mypacket)) ;
printf ("seq:%u\n", mypacket.seq) ;
printf ("data:%s\n", mypacket.data) ;
printf ("before\n") ;
seqnum = * (int *) pkt ; /*
<------------------------ Abort - Board Hangs */
printf ("after\n") ;
}
I am able to access the contents of pkt
1) byte by byte
2) memcpy
But, as soon as i try to deference it either by doing
1) * (int *) pkt /***************** board hangs ********/
or
2) mp = (struct mypacket *) pkt
printf ("%u\n", mp -> seqnum) ; /************* board Hangs
*************/
I get the Error shown below.
As, soon as seqnum = * (int *) pkt - is executed my board prints the message:
Why is that ?.
I dont understand this. i am using an OMAP 5912 OSK BOARD.
Is it not possible to dereference pkt ?.
data abort
pc : [<2000d6b0>] lr : [<2000d6a8>]
sp : 1ffbfc38 ip : ffffffff fp : 20015fc8
r10: 2001dc24 r9 : 20015fb8 r8 : 1ffbffdc
r7 : 2001dc08 r6 : 0000001c r5 : 2001c40a r4 : 000022b8
r3 : 00000020 r2 : 00000001 r1 : 0000000a r0 : 00000000
Flags: nZCv IRQs off FIQs off Mode SVC_32
Resetting CPU ...
Regards,
Jo
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot-Users] unexpected behaviour !!!
2006-01-31 8:20 [U-Boot-Users] unexpected behaviour !!! Maximus
@ 2006-01-31 12:05 ` Peter Menzebach
2006-01-31 13:34 ` [U-Boot-Users] " Maximus
0 siblings, 1 reply; 4+ messages in thread
From: Peter Menzebach @ 2006-01-31 12:05 UTC (permalink / raw)
To: u-boot
Maximus wrote:
...
> void myrecieve_handler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
> {
...
>
> As, soon as seqnum = * (int *) pkt - is executed my board prints the message:
>
One idea without further investigation....
if the pointer pkt is *not* on an 4 byte aligned address, you will get
an alignment trap on arm.
Best regards
Peter
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot-Users] Re: unexpected behaviour !!!
2006-01-31 12:05 ` Peter Menzebach
@ 2006-01-31 13:34 ` Maximus
2006-02-01 14:45 ` Andreas Schweigstill
0 siblings, 1 reply; 4+ messages in thread
From: Maximus @ 2006-01-31 13:34 UTC (permalink / raw)
To: u-boot
Hi,
Thanks a lot - it took me 2 days to find it out!!!.
The address of a long int, struct should be aligned to address
which a multiple of 4.
Regards,
Jo
On 1/31/06, Peter Menzebach <pm-ub@mw-itcon.de> wrote:
> Maximus wrote:
> ...
> > void myrecieve_handler (uchar * pkt, unsigned dest, unsigned src, unsigned
> len)
> > {
> ...
> >
> > As, soon as seqnum = * (int *) pkt - is executed my board prints the
> message:
> >
>
> One idea without further investigation....
>
> if the pointer pkt is *not* on an 4 byte aligned address, you will get
> an alignment trap on arm.
>
> Best regards
> Peter
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot-Users] Re: unexpected behaviour !!!
2006-01-31 13:34 ` [U-Boot-Users] " Maximus
@ 2006-02-01 14:45 ` Andreas Schweigstill
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schweigstill @ 2006-02-01 14:45 UTC (permalink / raw)
To: u-boot
Dear Maximus!
Maximus schrieb:
> Thanks a lot - it took me 2 days to find it out!!!.
Have you ever read a book or taken a course about ARM
architecture? It doesn't seem like this, but it is
extremely important to understand the processor
architecture when working with it.
With best regards
Andreas Schweigstill
--
Dipl.-Phys. Andreas Schweigstill
Schweigstill IT | Embedded Systems
Schauenburgerstra?e 116, D-24118 Kiel, Germany
Phone: (+49) 431 5606-435, Fax: (+49) 431 5606-436
Mobile: (+49) 171 6921973, Web: http://www.schweigstill.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-02-01 14:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-31 8:20 [U-Boot-Users] unexpected behaviour !!! Maximus
2006-01-31 12:05 ` Peter Menzebach
2006-01-31 13:34 ` [U-Boot-Users] " Maximus
2006-02-01 14:45 ` Andreas Schweigstill
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.