works but color is wrong
This commit is contained in:
21
Makefile
21
Makefile
@@ -12,6 +12,14 @@ PROGRAMMER_ID = arduino
|
||||
# original firmware dump
|
||||
DUMP_ORI = ../../ressources/dump_atmega328p_ori.hex
|
||||
|
||||
# Find all C source files in the current directory
|
||||
SRC = $(wildcard *.c)
|
||||
# Generate object file names from source file names
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS = -mmcu=$(AVRGCC_MCU_TYPE) -D F_CPU=$(F_CPU) $(INCLUDES) -Os
|
||||
|
||||
# Detect OS
|
||||
OS := $(shell uname -s)
|
||||
|
||||
@@ -30,13 +38,19 @@ all: hex flash
|
||||
|
||||
hex: $(TARGET).hex
|
||||
|
||||
# Compile each .c file to corresponding .o file
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Link all object files to create the binary
|
||||
# avr-gcc : compiler for AVR microcontrollers, https://gcc.gnu.org/wiki/avr-gcc#Using_avr-gcc, https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
|
||||
# -mmcu : the target microcontrolle (ATmega328P)
|
||||
# -D : defines a preprocessor macro (#define F_CPU <value>)
|
||||
# -o : output filename
|
||||
$(TARGET).bin: $(TARGET).c
|
||||
$(CC) -mmcu=$(AVRGCC_MCU_TYPE) -D F_CPU=$(F_CPU) $(INCLUDES) $(TARGET).c -Os -o $(TARGET).bin
|
||||
$(TARGET).bin: $(OBJ)
|
||||
$(CC) -mmcu=$(AVRGCC_MCU_TYPE) $(OBJ) -o $(TARGET).bin
|
||||
|
||||
# Convert binary to hex for flashing
|
||||
# avr-objcopy : man avr-jobcopy, https://linux.die.net/man/1/avr-objcopy
|
||||
# -O : specifies output format, Intel HEX
|
||||
# some formats (list not found in any doc) :
|
||||
@@ -46,6 +60,7 @@ $(TARGET).bin: $(TARGET).c
|
||||
$(TARGET).hex: $(TARGET).bin
|
||||
avr-objcopy -O ihex $(TARGET).bin $(TARGET).hex
|
||||
|
||||
# Flash the hex file to the microcontroller
|
||||
# avr-dude : AVR Downloader/UploaDEr, upload firmware, https://avrdudes.github.io/avrdude, v6.3 https://download-mirror.savannah.gnu.org/releases/avrdude/avrdude-doc-6.3.pdf
|
||||
# -p : specifies the microcontroller -> m328p
|
||||
# -c : programmer-id
|
||||
@@ -60,6 +75,6 @@ restore:
|
||||
avrdude -p $(AVRDUDE_MCU_TYPE) -c $(PROGRAMMER_ID) -b $(BAUD_RATE) -P $(SERIAL_PORT) -U flash:w:$(DUMP_ORI)
|
||||
|
||||
clean:
|
||||
rm -f main.hex main.bin
|
||||
rm -f main.hex main.bin $(OBJ)
|
||||
|
||||
.PHONY : all clean hex flash restore
|
||||
Reference in New Issue
Block a user