[En-Nut-Discussion] ipout.c error
Ulrich Prinz
uprinz2 at netscape.net
Tue Dec 28 00:06:46 CET 2010
Hi!
Am 27.12.2010 23:36, schrieb Stefan Profanter:
> Here are the steps:
> - Download Ethernut/ NutOS 4.8.8 from http://sourceforge.net/projects/ethernut/files/ethernut/4.8.8%20stable/ethernut-4.8.8.exe/download
> - Install it on eg D:\Ethernut
> - Download the YAGARTO GNU ARM toolchain from http://www.yagarto.de/ (The newest version is from 23.12.2010. GCC Version: 4.5.2)
> - Install it on eg C:\Yagarto
> - Modify the file D:\Ethernut\nut\Makedefs.arm-gcc and change "TRGT = arm-elf-" to "TRGT = arm-none-eabi-"
> - Start Nut Configurator, select Ethernut31d.conf
> - Edit-> Settings -> Platform -> arm-gcc
> - Edit-> Settings -> Tools -> Tool Paths -> add "C:\yagarto\bin;"
> - Now go to Build-> Build Nut/OS
I just repeat that, as it is a question that appears often if you use
newlib/gcc > 4.5.x
>
> -Ok, now it tries to build, but you get first some other errors:
>
> ../../nut/os/osdebug.c: In function 'NutDumpThreadQueue':
> ../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
> ../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 7 has type 'unsigned int'
> ../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 8 has type 'unsigned int'
> ../../nut/os/osdebug.c:132:13: error: format '%08lX' expects type 'long unsigned int', but argument 9 has type 'uintptr_t'
> ../../nut/os/osdebug.c:132:13: error: format '%9lu' expects type 'long unsigned int', but argument 10 has type 'uintptr_t'
> ../../nut/os/osdebug.c: In function 'NutDumpThreadList':
> ../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
> ../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 7 has type 'unsigned int'
> ../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 8 has type 'unsigned int'
> ../../nut/os/osdebug.c:176:9: error: format '%08lX' expects type 'long unsigned int', but argument 9 has type 'uintptr_t'
> ../../nut/os/osdebug.c:176:9: error: format '%9lu' expects type 'long unsigned int', but argument 10 has type 'uintptr_t'
> ../../nut/os/osdebug.c:187:21: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
> ../../nut/os/osdebug.c: In function 'NutDumpTimerList':
> ../../nut/os/osdebug.c:226:13: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
> ../../nut/os/osdebug.c:233:13: error: format '%08lX' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
> ../../nut/os/osdebug.c: In function 'NutDumpHeap':
> ../../nut/os/osdebug.c:281:9: error: format '%08lx' expects type 'long unsigned int', but argument 3 has type 'unsigned int'
> ../../nut/os/osdebug.c:281:9: error: format '%9ld' expects type 'long int', but argument 4 has type 'size_t'
> ../../nut/os/osdebug.c:287:9: error: format '%lu' expects type 'long unsigned int', but argument 3 has type 'size_t'
> ../../nut/os/osdebug.c:287:9: error: format '%lu' expects type 'long unsigned int', but argument 4 has type 'size_t'
> ../../nut/os/osdebug.c:289:9: error: format '%lu' expects type 'long unsigned int', but argument 3 has type 'size_t'
>
We have there a very complicated way of displaying some memory related
stuff. There are some chained #ifdefs that are switched on the
architecture type and the related debugging switches. I thought about
moving that functions one level down into the architecture specific
directories. The functions are very helpful in checking and debugging a
system, even the code is not compiled with enabled debug options. So one
can check if the systems ran out of memory under real life conditions.
But it is highly architecture specific if it should be as small as
possible, as it produces lots of overhead if i.e. uses 32bit
pointers/counters on an AVR arch.
> - The reason here is, that there is a problem with the expected datatype. You have to change each '%08lX' to '%08X' and '%lu' to '%u' and so on
> -Now try again to build and you get a new error:
>
> ../../nut/net/ipout.c: In function 'NutIpOutput':
> ../../nut/net/ipout.c:226:29: error: operation on 'nif->if_pkt_id' may be undefined
> ../../nut/net/ipout.c:255:17: error: operation on 'nif->if_pkt_id' may be undefined
>
To be honest I never ran into that warning... I use nutos 4.9.x...4.10.x
with gcc 4.5.0 and 4.5.1...
> ---------------------------
>
> The problem is the following line:
> ip->ip_id = htons(nif->if_pkt_id++);
>
> nif is defined as:
> IFNET *nif;
>
> And (if_var.h):
> typedef struct ifnet IFNET;
> struct ifnet {
> ...
> uint16_t if_pkt_id; /*!< \brief Packet identifier. */
> ...
> };
>
I think there is a much more easier way to get rid of that error:
modify
IFNET *nif;
to
IFNET *nif = NULL;
In that case it is preset with a NULL pointer and doesn't cost very much
additional code, only one extra assembler line on an ARM/Cortex.
I am not sure if the other tips above work, but they will make the code
more unreadable.
Best regards
Ulrich
More information about the En-Nut-Discussion
mailing list