For my systemprogramming class I have to program an ATmega48a µController.
At university we're using an avrmkII to program the chips, but as i don't have such a device at home so I figured I could use my Arduino as an ISP programmer.
Now when I run the avrdude command (see Makefile below) to flash a simple blink program onto the controller I get the following error:
avrdude -pm48 -P /dev/ttyACM0 -B19200 -cavrisp -Uflash:w:blink.hex:a -v
avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/home/user/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM0
Using Programmer : avrisp
Setting bit clk period : 19200.0
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0
avrdude done. Thank you.
make: *** [Makefile:40: program] Fehler 1
But I can't figure out why they are not in sync. All tutorials / questions & answers I found focused on programming the chip using the Arduino IDE which I was specifically told not to use, because the IDE does all the heavy lifting for you.
I know that the ATmega is working because I already programmed it using the avrmkII, and the blink sketch (a different one) that I uploaded then is still able to run.
Electronics:
- ATmega48a
- Arduino Mega 2560
Wiring:
- Arduino pins based on: https://docs.arduino.cc/built-in-examples/arduino-isp/ArduinoISP#how-to-wire-your-boards
- ATmega pins based on: ATmega48 datasheet page 12
- Arduino -> ATmega48a
- 50 -> 18
- 51 -> 17
- 52 -> 19
- 10 -> 1
- 10 µF between GND and RESET on Arduino Mega
software:
- OS: Parrot OS 5.1 (Electro Ara)
- avrdude version 6.3-20171130
- Arduino IDE to upload ISP sketch onto Arduino: 2.2.1
Makefile:
TARGET=blink
MCU=atmega48a
SOURCES=blink.c
MCU_dude=m48
PROGRAMMER=avrisp
PORT=-P /dev/ttyACM0
BAUD=-B19200
OBJECTS=$(SOURCES:.c=.o)
CFLAGS=-c -Og
LDFLAGS=
all: hex eeprom
hex: $(TARGET).hex
eeprom: $(TARGET)_eeprom.hex
$(TARGET).hex: $(TARGET).elf
avr-objcopy -O ihex -j .data -j .text $(TARGET).elf $(TARGET).hex
$(TARGET)_eeprom.hex: $(TARGET).elf
avr-objcopy -O ihex -j .eeprom --change-section-lma .eeprom=1 $(TARGET).elf $(TARGET)_eeprom.hex
$(TARGET).elf: $(OBJECTS)
avr-gcc $(LDFLAGS) -mmcu=$(MCU) $(OBJECTS) -o $(TARGET).elf
.c.o:
avr-gcc $(CFLAGS) -mmcu=$(MCU) $< -o $@
size:
avr-size --mcu=$(MCU) -C $(TARGET).elf
program:
avrdude -p$(MCU_dude) $(PORT) $(BAUD) -c$(PROGRAMMER) -Uflash:w:$(TARGET).hex:a -v
clean_tmp:
rm -rf *.o
rm -rf *.elf
clean:
rm -rf *.o
rm -rf *.elf
rm -rf *.hex
I hope I provided all the necessary information needed. if not I'll update my question accordingly.