1
votes

I bought a new PC and now I want to develop some ECU's for my new drone project. I tried to make my new PC compile for my Arduino (later I just use the ATMEGA328P mcu without the Arduino Board). I Compiled and installed avr-gcc 9.3.0, avr-libc 2.0.0, binutils 2.34.90 and avrdude 5.10 (I know it could be quiet old but I got it precompiled laying around and it was working on my old PC).

So, I just tried to compile my sample program:

#define F_CPU 8000000UL

#include <avr/io.h>
#include <util/delay.h>

int main (void) {

   DDRD |= (1 << PD0);

   while(1) {
       PORTD ^= (1 << PD0);
       _delay_ms(500);
   }

   return 0;
}

I was compiling my program with this command:
avr-gcc -mmcu=atmega328p -Os -c ../../../main.c -o main.o

That seemed to work and I got a main.o. After that, I tried to link my program with this command:
avr-gcc main.o -o main.elf

Than I produced the .hex file with this command:
avr-objcopy -O ihex -j .text -j .data main.elf main.hex

And lastly, I just programmed my mcu with that command:
avrdude -p m328p -c arduino -P /dev/ttyACM0 flash:w:main.hex:a

Avrdude printed the following output:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f

avrdude: safemode: Fuses OK

avrdude done.  Thank you

So, till now everything looks ok. I used following graphic to find the right pin on the Arduino Board: https://www.arduino.cc/en/Hacking/PinMapping168

I put an LED on the first digital pin but it is not blinking. I tried other pins and that was also not working.

My question is, does someone got an idea why my code is not working? (Maybe it is something obvious, which I think is quiet possible) Maybe someone could compile the Code for me and I try to transfer it to my Arduino?

So here the specs in a nutshell:

MC:

  • Arduino UNO
  • ATMEGA328P

Computer:

  • ThinkPad X380
  • OS: Centos Stream (8)
  • avr-gcc 9.3.0
  • avr-libc 2.0.0
  • binutils 2.34.90
  • avrdude 5.10

Thank you guys for helping me out!

1

1 Answers

-1
votes

I would try putting your code into the Arduino IDE and enabling verbose output in the File>Preferences menu, then uploading your code to the Arduino and looking at the output. If the upload is successful and the program works, you will be able to see the commands that were used to compile and upload your program to the Arduino.