Hello. I'm reading a book that has simple C source code for blinking an LED. The target IC is an AVR ATmega328p.
It appears the author's make file has no avr-gcc references. Instead it seems strictly AVRDUDE.
I don't want to use AVRDUDE.
I just want to compile the object code file with avr-gcc. Later I plan to convert my object file into Intel hex and flash my atmega328p IC with an XGecu programmer. This programmer doesn't need AVRDUDE to flash a hex file to an ATmega328P.
My IDE is microchip studio and my build is successful but I don't see avr-gcc. The author's makefile is being used. This is reflected by the directory showing in the output.
Makefiles for avr-gcc have a list of parameters at the top for fuse values as well as clock. I can see the clock parameter of 1 MHz showing in my IDE output but no use of fuse values. Doesn't avr-gcc need this initial list of parameters like clock and fuse values?
I can not glean any output showing me how to use avr-gcc. It looks like the AVRDUDE references in the makefile somehow have taken over.
----------Microchip Studio Output-------
Rebuild All started: Project: ATmel328-test, Configuration: Release AVR ------
Build started.
Project "ATmel328-test.cproj" (Clean target(s)):
Target "Clean" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\john\Documents\EMBED\AVR-Studio-Projects\test2\ATmel328-test\ATmel328-test.cproj" (entry point):
Using "RunCompilerTask" task from assembly "C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
Task "RunCompilerTask"
Shell Utils Path C:\Users\john\Documents\EMBED\gnuwin32\bin
C:\Users\john\Documents\EMBED\gnuwin32\bin\make.exe -C "C:\Users\john\Documents\EMBED\AVRW_code_030822\c02\p2" -f "Makefile" clean
make: Entering directory `C:/Users/john/Documents/EMBED/AVRW_code_030822/c02/p2'
rm -f main.hex main.elf main.o *~
rm: cannot remove `*~': Invalid argument
make: *** [clean] Error 1
make: Leaving directory `C:/Users/john/Documents/EMBED/AVRW_code_030822/c02/p2'
Done executing task "RunCompilerTask" -- FAILED.
Done building target "Clean" in project "ATmel328-test.cproj" -- FAILED.
Done building project "ATmel328-test.cproj" -- FAILED.
Build FAILED.
------ Rebuild All started: Project: ATmel328-test, Configuration: Release AVR ------
Build started.
Project "ATmel328-test.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\john\Documents\EMBED\AVR-Studio-Projects\test2\ATmel328-test\ATmel328-test.cproj" (target "Build" depends on it):
Task "RunCompilerTask"
Shell Utils Path C:\Users\john\Documents\EMBED\gnuwin32\bin
C:\Users\john\Documents\EMBED\gnuwin32\bin\make.exe -C "C:\Users\john\Documents\EMBED\AVRW_code_030822\c02\p2" -f "Makefile" all
make: Entering directory `C:/Users/john/Documents/EMBED/AVRW_code_030822/c02/p2'
avr-gcc -Wall -Os -Iusbdrv -DF_CPU=1000000 -mmcu=atmega328p -c main.c -o main.o
avr-gcc -Wall -Os -Iusbdrv -DF_CPU=1000000 -mmcu=atmega328p -o main.elf main.o
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
make: Leaving directory `C:/Users/john/Documents/EMBED/AVRW_code_030822/c02/p2'
Done executing task "RunCompilerTask".
Using "RunOutputFileVerifyTask" task from assembly "C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
Task "RunOutputFileVerifyTask"
Program Memory Usage : 166 bytes 0.5 % Full
Data Memory Usage : 0 bytes 0.0 % Full
Warning: Memory Usage estimation may not be accurate if there are sections other than .text sections in ELF file
Done executing task "RunOutputFileVerifyTask".
Done building target "CoreBuild" in project "ATmel328-test.cproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "Build" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets" from project "C:\Users\john\Documents\EMBED\AVR-Studio-Projects\test2\ATmel328-test\ATmel328-test.cproj" (entry point):
Done building target "Build" in project "ATmel328-test.cproj".
Done building project "ATmel328-test.cproj".
Build succeeded.
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped
----------------Makefile---------------------
This makefile is for an ATmega328P-PU at 1 MHz, USBasp programmer
#
# This is a prototype Makefile. Modify it according to your needs.
# You should at least check the settings for
# DEVICE ....... The AVR device you compile for
# CLOCK ........ Target AVR clock rate in Hertz
# OBJECTS ...... The object files created from your source files. This list is
# usually the same as the list of source files with suffix ".o".
# PROGRAMMER ... Options to avrdude which define the hardware you use for
# uploading to the AVR and the interface where this hardware
# is connected. I am using Arduino UNO as ISP and for this the
# programmer is avrisp
# FUSES ........ Parameters for avrdude to flash the fuses appropriately.
DEVICE = atmega328p
CLOCK = 1000000
PORT_LX = /dev/ttyACM0
PORT_MAC = /dev/tty.usbmodemfa131
PROGRAMMER = -c USBasp
OBJECTS = main.o
FUSES = -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
#
# For computing fuse byte values for other devices and options see
# the fuse bit calculator at http://www.engbedded.com/fusecalc/
# Tune the lines below only if you know what you are doing:
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -B 4
COMPILE = avr-gcc -Wall -Os -Iusbdrv -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: main.hex
.c.o:
$(COMPILE) -c $< -o $@
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $@
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.
.c.s:
$(COMPILE) -S $< -o $@
flash: all
$(AVRDUDE) -U flash:w:main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
# Xcode uses the Makefile targets "", "clean" and "install"
install: flash fuse
# if you use a bootloader, change the command below appropriately:
load: all
bootloadHID main.hex
clean:
rm -f main.hex main.elf $(OBJECTS) *~
# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS)
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
# avr-size --format=avr --mcu=$(DEVICE) main.elf
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
# Targets for code debugging and analysis:
disasm: main.elf
avr-objdump -d main.elf
cpp:
$(COMPILE) -E main.c