teatotal: "Read error" building for iPAQ running Linux


Previous by date: 12 Nov 2001 05:10:44 -0000 Linuxhacker.org has been upgraded, Alex Holden
Next by date: 12 Nov 2001 05:10:44 -0000 Re: "Read error" building for iPAQ running Linux, Alex Holden
Previous in thread:
Next in thread: 12 Nov 2001 05:10:44 -0000 Re: "Read error" building for iPAQ running Linux, Alex Holden

Subject: "Read error" building for iPAQ running Linux
From: Jay Sekora ####@####.####
Date: 12 Nov 2001 05:10:44 -0000
Message-Id: <333.1005541821@js.aq.org>

Hi.  I'm trying to build Tea Total for the Compaq iPAQ running Linux.
That's a StrongARM-110r4 processor running in little-endian mode.
There's a /usr/include/asm/types.h which includes the following:

typedef __signed__ char __s8;
typedef unsigned char __u8;

typedef __signed__ short __s16;
typedef unsigned short __u16;

typedef __signed__ int __s32;
typedef unsigned int __u32;

#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif

and there's an endian.h, so I'd expect that just using "ARCH = LINUX"
in config.inc ought to work.  (I also tried "ARCH = UNKNOWN_LITTLE" 
with the same results.)

The actual compilation goes smoothly and there are no errors in "./tea
test.key test.in testout.tea", but then the ./untea dies with "Read error".

I tried debugging it under gdb.  It's been a while since I really 
understood how to use a debugger, but I *think* what gdb is telling 
me is that the line in read_header() in teaprot.c that reads
        /* Check for the TEA magic number first */
        if(memcmp(state->pkt->hdr, TEA_HEADER, HEADER_LEN)) return -1;
is in fact matching and returning -1.  (I'm afraid I don't understand 
the logic here - it looks to me like the code is checking for "TEA" 
at the beginning of a file, returning -1 when it sees it, and the 
calling code expects -1 to be an error.  But I must be missing something.)

The last part of my debugging session is below.  Anyway, if what's 
going wrong is obvious to somebody on this list, I'd be very grateful 
to hear it.  Otherwise, is this likely actually to be an architecture-related 
problem?  Or might there be something wonky with the development environment 
on the somewhat strange box I'm building this on (maybe the headers 
aren't correct, or something like that)?  I know I must sound like 
an idiot, but that's OK. :-)

In closing, thanks very much to Alex for writing the code and making 
it freely available!  I've been using Tea Total on my Agenda (another 
Linux PDA) for several months and it's been really handy.

Cheers,

-j.

     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: ####@####.#### test.key testout.tea test.out

Breakpoint 4, read_header (state=0x205f828) at teaprot.c:36
36	{
(gdb) step
45		i = safe_read(state->infd, state->pkt, HEADER_LEN + 4);
(gdb) step
safe_readwrite (fd=33554624, buf=0x14, len=33945640, r=0) at util.c:127
127		long pos = 0, bytes;
(gdb) finish
Run till exit from #0  safe_readwrite (fd=33554624, buf=0x14, len=33945640, 
    r=0) at util.c:127
read_header (state=0x205f828) at teaprot.c:46
46		if(!i) return 1;			/* End of file */
Value returned is $5 = 7
(gdb) print i
$6 = 7
(gdb) step
47		if(i != HEADER_LEN + 4) return -1;	/* Read error */
(gdb) print i
$7 = 7
(gdb) step
50		if(memcmp(state->pkt->hdr, TEA_HEADER, HEADER_LEN)) return -1;
(gdb) print i
$8 = -1
(gdb) print state
$9 = (teastate *) 0x205f828
(gdb) print state->pkt
$10 = (teapacket *) 0x205f8b8
(gdb) print state->pkt->hdr
$11 = "TEA"
(gdb) bt
#0  read_header (state=0x205f828) at teaprot.c:50
#1  0x2000af0 in decode_block (state=0x205f828) at teaprot.c:78
#2  0x20006e8 in do_tea_untea (state=0x205f828) at teauntea.c:307
#3  0x2000488 in main (argc=4, argv=0xbffffd14) at teatotal.c:212
#4  0x2002bd4 in __libc_start_main ()
(gdb) finish
Run till exit from #0  read_header (state=0x205f828) at teaprot.c:50
0x2000af0 in decode_block (state=0x205f828) at teaprot.c:78
78		if((i = read_header(state))) return i;
Value returned is $12 = -1
(gdb) step
140		return 0;	/* Success */
(gdb) step
141	}
(gdb) step
do_tea_untea (state=0x205f828) at teauntea.c:315
315		if(i == -1) die("Read error");
(gdb) step
die (msg=0x205f828 "\021dEü¥Uá\024f\226Þ\004\204\026\r\035u;\n") at util.c:88
88	{
(gdb) bt
#0  die (msg=0x205f828 "\021dEü¥Uá\024f\226Þ\004\204\026\r\035u;\n")
    at util.c:88
#1  0x2000714 in do_tea_untea (state=0x205f828) at teauntea.c:315
#2  0x2000488 in main (argc=4, argv=0xbffffd14) at teatotal.c:212
#3  0x2002bd4 in __libc_start_main ()
(gdb) finish
Run till exit from #0  die (
    msg=0x205f828 "\021dEü¥Uá\024f\226Þ\004\204\026\r\035u;\n") at util.c:88
Read error

Program exited with code 01.
(gdb) 

Previous by date: 12 Nov 2001 05:10:44 -0000 Linuxhacker.org has been upgraded, Alex Holden
Next by date: 12 Nov 2001 05:10:44 -0000 Re: "Read error" building for iPAQ running Linux, Alex Holden
Previous in thread:
Next in thread: 12 Nov 2001 05:10:44 -0000 Re: "Read error" building for iPAQ running Linux, Alex Holden


Powered by ezmlm-browse 0.20.