makefile format

This commit is contained in:
hugogogo
2025-03-03 17:42:47 +01:00
parent 0886ef38ae
commit 4d9273cd53

View File

@@ -10,30 +10,30 @@ all: hex flash
hex: $(TARGET).hex hex: $(TARGET).hex
# 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 # 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) # -mmcu : the target microcontrolle (ATmega328P)
# -D : defines a preprocessor macro (#define F_CPU <value>) # -D : defines a preprocessor macro (#define F_CPU <value>)
# -o : output filename # -o : output filename
$(TARGET).bin: $(TARGET).c $(TARGET).bin: $(TARGET).c
$(CC) -mmcu=atmega328p -D F_CPU=$(F_CPU) $(TARGET).c -o $(TARGET).bin $(CC) -mmcu=atmega328p -D F_CPU=$(F_CPU) $(TARGET).c -o $(TARGET).bin
# avr-objcopy : man avr-jobcopy, https://linux.die.net/man/1/avr-objcopy # avr-objcopy : man avr-jobcopy, https://linux.die.net/man/1/avr-objcopy
# -O : specifies output format, Intel HEX # -O : specifies output format, Intel HEX
# some formats (list not found in any doc) : # some formats (list not found in any doc) :
# -O ihex : Used for flashing AVR chips # -O ihex : Used for flashing AVR chips
# -O binary : Raw binary file # -O binary : Raw binary file
# -O elf32-avr : Used for debugging # -O elf32-avr : Used for debugging
$(TARGET).hex: $(TARGET).bin $(TARGET).hex: $(TARGET).bin
avr-objcopy -O ihex $(TARGET).bin $(TARGET).hex avr-objcopy -O ihex $(TARGET).bin $(TARGET).hex
# 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 # 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 # -p : specifies the microcontroller -> m328p
# -c : programmer-id # -c : programmer-id
# -b : baud rate for serial communication # -b : baud rate for serial communication
# -P : the serial port, found with `ls /dev/tty*` -> /dev/ttyUSB0 # -P : the serial port, found with `ls /dev/tty*` -> /dev/ttyUSB0
# -U : Uploads (w = write) the HEX firmware file to the flash memory # -U : Uploads (w = write) the HEX firmware file to the flash memory
# (-v : verbose info dump) # (-v : verbose info dump)
flash: flash:
avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -U flash:w:$(TARGET).hex avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -U flash:w:$(TARGET).hex
# avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -v # avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -v