diff --git a/module00/ex00/Makefile b/module00/ex00/Makefile index 36889ed..b7893fd 100644 --- a/module00/ex00/Makefile +++ b/module00/ex00/Makefile @@ -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 diff --git a/module00/ex01/Makefile b/module00/ex01/Makefile new file mode 100644 index 0000000..2a483b1 --- /dev/null +++ b/module00/ex01/Makefile @@ -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 \ No newline at end of file diff --git a/module00/ex01/main.c b/module00/ex01/main.c new file mode 100644 index 0000000..0eefc1c --- /dev/null +++ b/module00/ex01/main.c @@ -0,0 +1,3 @@ +int main() +{ +} \ No newline at end of file