EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

i2c driver on AT91SAM7S-EK (using FreeRTOS)

Started by Gabriele Brosulo August 24, 2007
Hi all,
It's again me, whith another issue :)

I'm trying to use a eeprom with my evaluation board (the one in the subject),
so I added the code from the atmel site (AT91-AN01: Using the Two-wire
interface (TWI) in Master Mode on AT91SAM Microcontrollers) to my adjusted
version of FreeRTOS, the one we talked about just a few message below.

In order to make things working, I have added lib_AT91SAM7S256.h to my
project. This header is a set of inline functions useful to initialize and
use the processor, without directly use the processor register (correct me if
I'm wrong, I'm very new to embedded develop.. Yes, I'm a lamer :)).

At compiling time, for each inline function, I obtain the following:

[..snip..]
main.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949: multiple
definition of `AT91F_ADC_EnableIt'
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
first defined here
/usr/local/gnuarm-3.4.3/bin/../lib/gcc/arm-elf/3.4.3/../../../../arm-elf/bin/ld:
Warning: size of symbol `AT91F_ADC_EnableIt' changed from 32 in
Cstartup_SAM7.o to 24 in main.o
/usr/local/gnuarm-3.4.3/bin/../lib/gcc/arm-elf/3.4.3/../../../../arm-elf/bin/ld:
Warning: type of symbol `AT91F_ADC_EnableIt' changed from 2 to 13 in main.o

[..snip..]
UART/uart.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949: multiple
definition of `AT91F_ADC_EnableIt'
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
first defined here

[..snip..]
UART/dbgu.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949: multiple
definition of `AT91F_ADC_EnableIt'
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
first defined here

[..snip..]

Every file that include Board.h (this, in turn, include lib_AT91SAM7S256.h)
have the error 'multiple definition'.

How can I solve this? It is not sufficient, in lib_AT91SAM7S256.h, to have:

#ifndef lib_AT91SAM7S256_H
#define lib_AT91SAM7S256_H

[code with inline functions]

#endif

???

thanks a lot!
g4b0
Gabrielle,

It seems that the symbols are been defined twice. Did you try to compile without lib_AT91SAM7S256.h ?

Marcio
----- Original Message -----
From: Gabriele Brosulo
To: A...
Sent: Friday, August 24, 2007 7:35 AM
Subject: [AT91SAM] i2c driver on AT91SAM7S-EK (using FreeRTOS)
Hi all,
It's again me, whith another issue :)

I'm trying to use a eeprom with my evaluation board (the one in the subject),
so I added the code from the atmel site (AT91-AN01: Using the Two-wire
interface (TWI) in Master Mode on AT91SAM Microcontrollers) to my adjusted
version of FreeRTOS, the one we talked about just a few message below.

In order to make things working, I have added lib_AT91SAM7S256.h to my
project. This header is a set of inline functions useful to initialize and
use the processor, without directly use the processor register (correct me if
I'm wrong, I'm very new to embedded develop.. Yes, I'm a lamer :)).

At compiling time, for each inline function, I obtain the following:

[..snip..]
main.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949: multiple
definition of `AT91F_ADC_EnableIt'
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
first defined here
/usr/local/gnuarm-3.4.3/bin/../lib/gcc/arm-elf/3.4.3/../../../../arm-elf/bin/ld:
Warning: size of symbol `AT91F_ADC_EnableIt' changed from 32 in
Cstartup_SAM7.o to 24 in main.o
/usr/local/gnuarm-3.4.3/bin/../lib/gcc/arm-elf/3.4.3/../../../../arm-elf/bin/ld:
Warning: type of symbol `AT91F_ADC_EnableIt' changed from 2 to 13 in main.o

[..snip..]
UART/uart.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949: multiple
definition of `AT91F_ADC_EnableIt'
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
first defined here

[..snip..]
UART/dbgu.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949: multiple
definition of `AT91F_ADC_EnableIt'
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
first defined here

[..snip..]

Every file that include Board.h (this, in turn, include lib_AT91SAM7S256.h)
have the error 'multiple definition'.

How can I solve this? It is not sufficient, in lib_AT91SAM7S256.h, to have:

#ifndef lib_AT91SAM7S256_H
#define lib_AT91SAM7S256_H

[code with inline functions]

#endif

???

thanks a lot!
g4b0
Gabriele,

Change your gcc optimization level to Level 1 or greater (I believe
this is the -G1 option, which you have set at -G0).

gcc, with optimization disabled, doesn't inline functions (presumably
to make it easier to debug) - therefore, every time you include your
header file, it acts as if the "inline" keyword is ignored; hence the
multiple definitions.

You need to either compile with a higher level of optimization, or
else (a real hack to get you past it) put a "#define inline static"
statement in your header file (before the inline function declarations).

I sort of understand why gcc does this, but it's really bad behavior
IMHO, for exactly this reason.

--- In A..., Gabriele Brosulo wrote:
>
> Hi all,
> It's again me, whith another issue :)
>
> I'm trying to use a eeprom with my evaluation board (the one in the
subject),
> so I added the code from the atmel site (AT91-AN01: Using the Two-wire
> interface (TWI) in Master Mode on AT91SAM Microcontrollers) to my
adjusted
> version of FreeRTOS, the one we talked about just a few message below.
>
> In order to make things working, I have added lib_AT91SAM7S256.h to my
> project. This header is a set of inline functions useful to
initialize and
> use the processor, without directly use the processor register
(correct me if
> I'm wrong, I'm very new to embedded develop.. Yes, I'm a lamer :)).
>
> At compiling time, for each inline function, I obtain the following:
>
> [..snip..]
> main.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
>
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
multiple
> definition of `AT91F_ADC_EnableIt'
>
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:

> first defined here
>
/usr/local/gnuarm-3.4.3/bin/../lib/gcc/arm-elf/3.4.3/../../../../arm-elf/bin/ld:

> Warning: size of symbol `AT91F_ADC_EnableIt' changed from 32 in
> Cstartup_SAM7.o to 24 in main.o
>
/usr/local/gnuarm-3.4.3/bin/../lib/gcc/arm-elf/3.4.3/../../../../arm-elf/bin/ld:

> Warning: type of symbol `AT91F_ADC_EnableIt' changed from 2 to 13 in
main.o
>
> [..snip..]
> UART/uart.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
>
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
multiple
> definition of `AT91F_ADC_EnableIt'
>
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:

> first defined here
>
> [..snip..]
> UART/dbgu.o(.text+0x16ac): In function `AT91F_ADC_EnableIt':
>
./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:
multiple
> definition of `AT91F_ADC_EnableIt'
>
Cstartup_SAM7.o(.text+0x1db0):./FreeRTOSv4.4.0/portable/GCC/ARM7_AT91SAM7S/lib_AT91SAM7S256.h:1949:

> first defined here
>
> [..snip..]
> Every file that include Board.h (this, in turn, include
lib_AT91SAM7S256.h)
> have the error 'multiple definition'.
>
> How can I solve this? It is not sufficient, in lib_AT91SAM7S256.h,
to have:
>
> #ifndef lib_AT91SAM7S256_H
> #define lib_AT91SAM7S256_H
>
> [code with inline functions]
>
> #endif
>
> ???
>
> thanks a lot!
> g4b0
>
--- In A..., "twgbonehead" wrote:
>
> Gabriele,
>
> Change your gcc optimization level to Level 1 or greater (I believe
> this is the -G1 option, which you have set at -G0).

Oops...

It's the -O switch (not -G).

The 2024 Embedded Online Conference