Hit a brick wall

Go To Last Post
18 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys, I'm porting a IPv4 stack to the ARM Cortex-A5 processor, it compiles okay but when it goes to LINK it displays a load of garbage.  See below.  

What direction should I take?

plained/ddram/examples/getting_started/ethernet/tcp/tcp_tx.o: In function `send_tcp_initialise':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/tcp/tcp_tx.c:83: multiple definition of `ip_length'
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/ethernet_driver.c:130: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/tcp/tcp_tx.o: In function `send_tcp_initialise':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/tcp/tcp_tx.c:83: multiple definition of `ethernet_length'
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/ethernet_driver.c:130: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/tcp/tcp_tx.o: In function `send_tcp_initialise':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/tcp/tcp_tx.c:83: multiple definition of `hdr_ethernet'
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/ethernet_driver.c:130: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/tcp/tcp_tx.o: In function `send_tcp_initialise':
F:\atmel-software-package-master\exampernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/ethernet_driver.c:130: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/tcp/tcp_tx.o: In function `send_tcp_initialise':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/tcp/tcp_tx.c:83: multiple definition of `t_ip_addr'
./build/sama5d4-xplained/ddram/examples/getting_started/ethernet/ethernet_driver.o:F

 

This topic has a solution.
Last Edited: Sat. Oct 20, 2018 - 06:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A shot in the dark, here. Do your header files have "once-only" protection? Example:

 

#ifndef HEADER_FILE
#define HEADER_FILE

the entire header file file

#endif

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes ka7ehk, they do.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Muliple definition occurs when there's more that one copy of the same function. Often because of code in .h not .c

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi Clawson, I've setup four files that show the same behaviour to make debugging easier.  There is no code in the header files, there are however structs declared in header files - is that okay?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

got it lads - Thanks

 

EDIT: shite, that never worked!

Last Edited: Wed. Oct 17, 2018 - 04:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe you should start by not discarding error messages as "garbage" and read them.

Then think about what they mean.

Then do a text search for the variables in those messages.

 

clawson wrote:
Muliple definition occurs when there's more that one copy of the same function. Often because of code in .h not .c
Does not seem to be the case here, as the error are in a .c file.

Another guess is that the .c files are included instead of the .h files.

Another guess is some files are linked twice.

Another guess that global variables are not declared as "extern" in the header files.

 

compiler / linker error messages are easier to read if you copy and paste them in a text editor and then disable line wrapping.

Also, 90+% of the text are file names

The linker is giving you names of variables for which it finds a conflict, combined with file names and line numbers.

 

This does not seem to be a valid file name:

F:\atmel-software-package-master\exampernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/ethernet/ethernet_driver.c:130: first defined here

exampernet_driver.o ???

Multiple ":" in a file name and I believe that character is used to switch between disk drives on windoze os.

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Paulvdh,  I'll try again tomorrow with your solutions.

 

I'M AWAY FOR A DRINK!  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, it appears to compile and link correctly but when it tries to create th OBJECT it fails.  Have a look below.

 

 

CC ../../target/common/bootstrap.c
LINK build/sama5d4-xplained/ddram/target/bootstrap.elf
LINK build/sama5d4-xplained/ddram/getting-started.elf
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:(.rodata.indent+0x0): multiple definition of `indent'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o:(.rodata.indent+0x0): first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o: In function `parse_ethernet':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:85: multiple definition of `icmp_code'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:87: first defined here
./

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is not linking correctly: "it fails."

Clearly something called indent is defined in two source files.

Likewise something called icmp_code .

I expect the linker gave you more than one source file name.

"Demons after money.
Whatever happened to the still beating heart of a virgin?
No one has any standards anymore." -- Giles

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Moved to ARM forum.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay lads, I'm thinking the problem is with eclipse setup - namely the Makefile.  

 

I'm right in saying that I need to add the object file to the makefile, i.e.

obj-y += examples/getting_started/fire_ip/arp_protocol.o

 

when I add that I get the error!  Any sugestions?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could one of you nice men, or women try compiling this code in Eclipse please?  I've included the files in this post!

 

Wm.

 

PS: There are some functions and includes that need removed from that example, I forgot to do it!

Attachment(s): 

Last Edited: Fri. Oct 19, 2018 - 03:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

THE ERROR MESSAGE IS:

 

04:26:38 **** Build of configuration Default for project getting_started ****
make TARGET=sama5d4-xplained 
DEP ../../examples/getting_started/fire_ip/ethernet_driver.c
CC ../../examples/getting_started/fire_ip/ethernet_driver.c
LINK build/sama5d4-xplained/ddram/getting-started.elf
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o:(.rodata.arp_response+0x0): multiple definition of `arp_response'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:(.rodata.arp_response+0x0): first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `arp_request'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `ip_length'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `ethernet_length'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `hdr_ethernet'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `arp_broacast'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `ether_broacast'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `protocol_type_ip4'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `protocol_type_arp'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `t_mac_addr'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `gateway_addr'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `t_ip_addr'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `ip_addr'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/arp_protocol.o: In function `retrieve_mac':
F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/arp_protocol.c:129: multiple definition of `seqnum'
./build/sama5d4-xplained/ddram/examples/getting_started/fire_ip/ethernet_driver.o:F:\atmel-software-package-master\examples\getting_started/../../examples/getting_started/fire_ip/ethernet_driver.c:89: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [../../scripts/Makefile.rules:103: build/sama5d4-xplained/ddram/getting-started.elf] Error 1

04:26:41 Build Finished (took 2s.545ms)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is a difference between declaring and defining, clearly you have definitions in the .h files, e.g.,

in ethernet_headers.h

const unsigned char arp_response[2] = {0x00, 0x02};

From multiple inclusions of that you get exactly this problem.

 

https://en.wikipedia.org/wiki/Declaration_(computer_programming)

 

/Lars

Last Edited: Fri. Oct 19, 2018 - 11:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi lajon, where should I declare the const variables from my ethernet_headers.h file?

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
const unsigned char arp_response[2];

In the .h

const unsigned char arp_response[2] = {0x00, 0x02};

in one .c 

 

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Lajon mate