Skip to main content
Post Closed as "Not suitable for this site" by Juraj, MichaelT, Greenonline, Dmitry Grigoryev, esoterik
added 260 characters in body
Source Link

LIDARBOT.h

#ifndef LIDARBOT_H_ #define LIDARBOT_H_

#include <avr/io.h> #include "drivers/motors.h"

#endif

LIDARBOT.C

#include "LIDARBOT.h" int main(){ pwmtimersetup(); while (1) { } }

motors.h

#ifndef MOTORS_H_ #define MOTORS_H_

#include <avr/io.h>

void pwmtimersetup(void);

#endif

motors.c

#include <avr/io.h> #include "motors.h"

LIDARBOT.h
-----------
#ifndef LIDARBOT_H_
#define LIDARBOT_H_

#include <avr/io.h>
#include "drivers/motors.h"

#endif

LIDARBOT.C
----------
#include "LIDARBOT.h"
int main(){
  pwmtimersetup();
    while (1) {
    }
}

motors.h
--------
#ifndef MOTORS_H_
#define MOTORS_H_

#include <avr/io.h>

void pwmtimersetup(void);

#endif

motors.c
--------
#include <avr/io.h>
#include "motors.h"

void pwmtimersetup(void){
  // Timer pre-scalar for ~490 Hz is 8
  TCCR0B &= ~((1<<CS02)||(1<<CS00));
  TCCR0B |=  (1<<CS01);
  // Set Compare Output Mode to Toggle PWM
  TCCR0A &= ~(1<<COM0A1);
  TCCR0A |=  (1<<COM0A0);
  // Waveform Generation Mode: WGM02 = 1, WGM01 = 1, WGM00 = 1
  TCCR0B |= (1<<WGM02);
  TCCR0A |= (1<<WGM01)||(1<<WGM00);
  OCR0A = 125;
  DDRD |= (1<<DDD4)||(1<<DDD2);
  PORTD |= (1<<PORTD4);
  PORTD &= (1<<PORTD2);
}

void pwmtimersetup(void){ // Timer pre-scalar for ~490 Hz is 8 TCCR0B &= ~((1<<CS02)||(1<<CS00)); TCCR0B |= (1<<CS01); // Set Compare Output Mode to Toggle PWM TCCR0A &= ~(1<<COM0A1); TCCR0A |= (1<<COM0A0); // Waveform Generation Mode: WGM02 = 1, WGM01 = 1, WGM00 = 1 TCCR0B |= (1<<WGM02); TCCR0A |= (1<<WGM01)||(1<<WGM00); OCR0A = 125; DDRD |= (1<<DDD4)||(1<<DDD2); PORTD |= (1<<PORTD4); PORTD &= (1<<PORTD2); } II can make a consolidated object file but not an elf file to load onto my board. Output below: avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -Wa,-ahlmns=LIDARBOT.lst -o objects/LIDARBOT.o
source/LIDARBOT.c
source/drivers/motors.c
-I/home/manu/C/Arduino/LIDARBOT/libraries/

avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -o elf/LIDARBOT.elf objects/LIDARBOT.o objects/LIDARBOT.o: In function __vector_22': (.text+0x7c): multiple definition of __bad_interrupt' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.text+0x0): first defined here objects/LIDARBOT.o: In function __vectors': (.text+0x0): multiple definition of __vectors' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.vectors+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [Makefile:191: elf] Error 1

avr-gcc -g -Os -Wall -Werror -Wextra  -mmcu=atmega328p -DF_CPU=1000000UL -Wa,-ahlmns=LIDARBOT.lst -o objects/LIDARBOT.o \
source/LIDARBOT.c \
source/drivers/motors.c \
-I/home/manu/C/Arduino/LIDARBOT/libraries/
                                                                      
avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -o elf/LIDARBOT.elf objects/LIDARBOT.o
objects/LIDARBOT.o: In function `__vector_22':
(.text+0x7c): multiple definition of `__bad_interrupt'
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.text+0x0): first defined here
objects/LIDARBOT.o: In function `__vectors':
(.text+0x0): multiple definition of `__vectors'
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.vectors+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:191: elf] Error 1

LIDARBOT.h

#ifndef LIDARBOT_H_ #define LIDARBOT_H_

#include <avr/io.h> #include "drivers/motors.h"

#endif

LIDARBOT.C

#include "LIDARBOT.h" int main(){ pwmtimersetup(); while (1) { } }

motors.h

#ifndef MOTORS_H_ #define MOTORS_H_

#include <avr/io.h>

void pwmtimersetup(void);

#endif

motors.c

#include <avr/io.h> #include "motors.h"

void pwmtimersetup(void){ // Timer pre-scalar for ~490 Hz is 8 TCCR0B &= ~((1<<CS02)||(1<<CS00)); TCCR0B |= (1<<CS01); // Set Compare Output Mode to Toggle PWM TCCR0A &= ~(1<<COM0A1); TCCR0A |= (1<<COM0A0); // Waveform Generation Mode: WGM02 = 1, WGM01 = 1, WGM00 = 1 TCCR0B |= (1<<WGM02); TCCR0A |= (1<<WGM01)||(1<<WGM00); OCR0A = 125; DDRD |= (1<<DDD4)||(1<<DDD2); PORTD |= (1<<PORTD4); PORTD &= (1<<PORTD2); } I can make a consolidated object file but not an elf file to load onto my board. Output below: avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -Wa,-ahlmns=LIDARBOT.lst -o objects/LIDARBOT.o
source/LIDARBOT.c
source/drivers/motors.c
-I/home/manu/C/Arduino/LIDARBOT/libraries/

avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -o elf/LIDARBOT.elf objects/LIDARBOT.o objects/LIDARBOT.o: In function __vector_22': (.text+0x7c): multiple definition of __bad_interrupt' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.text+0x0): first defined here objects/LIDARBOT.o: In function __vectors': (.text+0x0): multiple definition of __vectors' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.vectors+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [Makefile:191: elf] Error 1

LIDARBOT.h
-----------
#ifndef LIDARBOT_H_
#define LIDARBOT_H_

#include <avr/io.h>
#include "drivers/motors.h"

#endif

LIDARBOT.C
----------
#include "LIDARBOT.h"
int main(){
  pwmtimersetup();
    while (1) {
    }
}

motors.h
--------
#ifndef MOTORS_H_
#define MOTORS_H_

#include <avr/io.h>

void pwmtimersetup(void);

#endif

motors.c
--------
#include <avr/io.h>
#include "motors.h"

void pwmtimersetup(void){
  // Timer pre-scalar for ~490 Hz is 8
  TCCR0B &= ~((1<<CS02)||(1<<CS00));
  TCCR0B |=  (1<<CS01);
  // Set Compare Output Mode to Toggle PWM
  TCCR0A &= ~(1<<COM0A1);
  TCCR0A |=  (1<<COM0A0);
  // Waveform Generation Mode: WGM02 = 1, WGM01 = 1, WGM00 = 1
  TCCR0B |= (1<<WGM02);
  TCCR0A |= (1<<WGM01)||(1<<WGM00);
  OCR0A = 125;
  DDRD |= (1<<DDD4)||(1<<DDD2);
  PORTD |= (1<<PORTD4);
  PORTD &= (1<<PORTD2);
}

I can make a consolidated object file but not an elf file to load onto my board. Output below:

avr-gcc -g -Os -Wall -Werror -Wextra  -mmcu=atmega328p -DF_CPU=1000000UL -Wa,-ahlmns=LIDARBOT.lst -o objects/LIDARBOT.o \
source/LIDARBOT.c \
source/drivers/motors.c \
-I/home/manu/C/Arduino/LIDARBOT/libraries/
                                                                      
avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -o elf/LIDARBOT.elf objects/LIDARBOT.o
objects/LIDARBOT.o: In function `__vector_22':
(.text+0x7c): multiple definition of `__bad_interrupt'
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.text+0x0): first defined here
objects/LIDARBOT.o: In function `__vectors':
(.text+0x0): multiple definition of `__vectors'
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.vectors+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:191: elf] Error 1
Source Link

Multiple defintion error, Linker error

Trying to create an elf file for two sets of files in different folders.

LIDARBOT.h

#ifndef LIDARBOT_H_ #define LIDARBOT_H_

#include <avr/io.h> #include "drivers/motors.h"

#endif

LIDARBOT.C

#include "LIDARBOT.h" int main(){ pwmtimersetup(); while (1) { } }

motors.h

#ifndef MOTORS_H_ #define MOTORS_H_

#include <avr/io.h>

void pwmtimersetup(void);

#endif

motors.c

#include <avr/io.h> #include "motors.h"

void pwmtimersetup(void){ // Timer pre-scalar for ~490 Hz is 8 TCCR0B &= ~((1<<CS02)||(1<<CS00)); TCCR0B |= (1<<CS01); // Set Compare Output Mode to Toggle PWM TCCR0A &= ~(1<<COM0A1); TCCR0A |= (1<<COM0A0); // Waveform Generation Mode: WGM02 = 1, WGM01 = 1, WGM00 = 1 TCCR0B |= (1<<WGM02); TCCR0A |= (1<<WGM01)||(1<<WGM00); OCR0A = 125; DDRD |= (1<<DDD4)||(1<<DDD2); PORTD |= (1<<PORTD4); PORTD &= (1<<PORTD2); } I can make a consolidated object file but not an elf file to load onto my board. Output below: avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -Wa,-ahlmns=LIDARBOT.lst -o objects/LIDARBOT.o
source/LIDARBOT.c
source/drivers/motors.c
-I/home/manu/C/Arduino/LIDARBOT/libraries/

avr-gcc -g -Os -Wall -Werror -Wextra -mmcu=atmega328p -DF_CPU=1000000UL -o elf/LIDARBOT.elf objects/LIDARBOT.o objects/LIDARBOT.o: In function __vector_22': (.text+0x7c): multiple definition of __bad_interrupt' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.text+0x0): first defined here objects/LIDARBOT.o: In function __vectors': (.text+0x0): multiple definition of __vectors' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:(.vectors+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [Makefile:191: elf] Error 1

I am kind of lost. What could be my mistake here? If I see an error like this how do i start to debug?