init ex01
This commit is contained in:
@@ -6,7 +6,6 @@ CC = avr-gcc
|
||||
|
||||
all: hex flash
|
||||
|
||||
# ls /dev/tty* : /dev/ttyUSB0
|
||||
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
|
||||
|
||||
40
module00/ex01/Makefile
Normal file
40
module00/ex01/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
# frequency of the CPU (in Hz)
|
||||
F_CPU = 16000000UL
|
||||
TARGET = main
|
||||
CC = avr-gcc
|
||||
|
||||
AVRGCC_MCU_TYPE = atmega328p
|
||||
AVRDUDE_MCU_TYPE = m328p
|
||||
BAUD_RATE = 115200
|
||||
SERIAL_PORT = /dev/ttyUSB0
|
||||
PROGRAMMER_ID = arduino
|
||||
|
||||
|
||||
all: hex flash
|
||||
|
||||
hex: $(TARGET).hex
|
||||
|
||||
# https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
|
||||
$(TARGET).bin: $(TARGET).c
|
||||
$(CC) -mmcu=$(AVRGCC_MCU_TYPE) -D F_CPU=$(F_CPU) $(TARGET).c -o $(TARGET).bin
|
||||
|
||||
|
||||
# https://linux.die.net/man/1/avr-objcopy
|
||||
$(TARGET).hex: $(TARGET).bin
|
||||
avr-objcopy -O ihex $(TARGET).bin $(TARGET).hex
|
||||
|
||||
|
||||
# AVR Downloader/UploaDEr https://avrdudes.github.io/avrdude (v6.3 https://download-mirror.savannah.gnu.org/releases/avrdude/avrdude-doc-6.3.pdf)
|
||||
flash:
|
||||
avrdude -p $(AVRDUDE_MCU_TYPE) -c $(PROGRAMMER_ID) -b $(BAUD_RATE) -P $(SERIAL_PORT) -U flash:w:$(TARGET).hex
|
||||
|
||||
|
||||
dump:
|
||||
avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -U flash:r:dump_atmega328p.hex
|
||||
|
||||
|
||||
clean:
|
||||
rm -f main.hex main.bin
|
||||
|
||||
|
||||
.PHONY : all clean hex flash dump
|
||||
3
module00/ex01/main.c
Normal file
3
module00/ex01/main.c
Normal file
@@ -0,0 +1,3 @@
|
||||
int main()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user