This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Running hello.c on i386


>>>>> "Philip" == Philip Teng <tcheewan@dso.org.sg> writes:

    Philip> I tried to make hello.c using the Makefile given in the /examples.
    Philip> bash.exe-2.04$ make hello.o
    Philip> i386-elf-gcc -c -o hello.o -g -Wall
    Philip> -I//c/users/philip/ecos/stub1_install/include -ffunction-sections
    Philip> -fdata-sections hello.c
    Philip> hello.c:2: stdio.h: No such file or directory
    Philip> make: *** [hello.o] Error 1

    Philip> I encountered some errors and I fixed it by adding one
    Philip> more include path...

    Philip> bash.exe-2.04$ make hello.o
    Philip> i386-elf-gcc -c -o hello.o -g -Wall
    Philip> -I//c/users/philip/ecos/stub1_install/include -I/usr/include -ffunction-sections
    Philip> -fdata-sections hello.c
    Philip> bash.exe-2.04$

    Philip> The compilation was successful. The target I used is a
    Philip> PIII machine, host is Windows NT. I started up the i386
    Philip> target using the gdb stub floppy and run the following:

No, that is wrong. The header file /usr/include/stdio.h will be for
use by cygwin applications, not eCos applications. I suspect that you
are trying to re-use the same configuration for the boot floppy and
for "hello world".

When targetting a PC, you are essentially building two different
applications. The first application is the gdb stub for the boot
floppy, and serves the same purpose as a ROM monitor on a conventional
embedded target. The second application is the "hello world" program.
The two applications run in very different environments, e.g. they
need completely separate startup code, so you need two different
configurations. 

First you need to create a configuration for building the gdb stub,
build that, and install the resulting executable on a floppy. It looks
like you have already done this. The requirements for the gdb stub are
fairly simple, e.g. there is no need for a C library, so the C library
does not get built and its header files do not get installed.

Now create a new configuration using the default template, i.e. a
configuration suitable for ordinary applications. This will include
the C library, so the <stdio.h> header file will get installed. The
two configurations should live in completely separate directories.

    Philip> bash.exe-2.04$ i386-elf-gdb -nw hello.o
    Philip> GNU gdb 5.0
    Philip> Copyright 2000 Free Software Foundation, Inc.
    Philip> GDB is free software, covered by the GNU General Public License, and you
    Philip> are
    Philip> welcome to change it and/or distribute copies of it under certain
    Philip> conditions.
    Philip> Type "show copying" to see the conditions.
    Philip> There is absolutely no warranty for GDB.  Type "show warranty" for
    Philip> details.
    Philip> This GDB was configured as "--host=i686-pc-cygwin --target=i386-elf"...
    Philip> (gdb) set remotebaud 38400
    Philip> (gdb) target remote com1
    Philip> Remote debugging using com1
    Philip> 0x37dc in ?? ()
    Philip> (gdb) continue
    Philip> Continuing.

    Philip> Program received signal SIGTRAP, Trace/breakpoint trap.
    Philip> 0x37dc in ?? ()

    Philip> Anyone has any idea why the program hit a stop?

Another mistake I am afraid. You are trying to debug hello.o, an
intermediate object file. You must first link the object file with the
appropriate libraries. This will give you an executable file a.out or
hello or hello.exe, depending on exactly how you drive the tools,
and it is this executable which can then be debugged with gdb.

Bart


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]