So, I'm working on a project that requires me to be able to upload C code to my arduino without using the arduino IDE (I've been informed that this is called flashing, unless I'm completely mistaken). I have the example code (just a simple blink function written in C) and a makefile, which I think I have a grasp on how to use but I could also be wrong. This makefile has some functions, which I will include below, and a list of things above those functions that look a lot like variables to me, though I suppose I might not be the most informed on makefiles. Anyway, compile works just fine, but upload has a problem because I can't for the life of me figure out what to put down for Port. I have an Uno connected to COM4 on my windows laptop, but I'm using (what I believe is) an Ubuntu image hosted on WSL, and no matter what I try I can't seem to get the makefile to see the board. I know that it's a user error, I just don't know how to correct it.
I have tried:
4
COM4
com4
/dev/COM4
and none of these are the answer. Can somebody help me out?
Thank you in advance.
If you were curious, that makefile code is:
.
FILENAME = blink
#! this will change depending on your system
PORT = /dev/com4 # serial port that the board is connected to
DEVICE = atmega328p # which microcontroller is on the board (usually ATMEGA328P for arduino)
PROGRAMMER = arduino # which bootloader to use
BAUD = 115200 # speed of communication to the board
CC = avr-gcc
CFLAGS = -Wall -Os -mmcu=$(DEVICE)
# -Wall: enables warnings
# -Os: optimizes the code for size (uses optimizations from O2 that don't increase size)
# -mmcu: specifies the architecture of the board
.PHONY: compile
compile: ## compiles the C code to a hex file
$(CC) $(CFLAGS) -c $(FILENAME).c -o $(FILENAME).o $(CC) $(CFLAGS) -o $(FILENAME).elf $(FILENAME).o avr-objcopy -j .text -j .data -O ihex $(FILENAME).elf $(FILENAME).hex
.PHONY: upload
upload: ## flashes hex file to the board
avrdude -v -p $(DEVICE) -c $(PROGRAMMER) -P $(PORT) -b $(BAUD) -U flash:w:$(FILENAME).hex:i
.PHONY: update
update: compile upload ## compiles and uploads, updating code on the board
.PHONY: clean
clean: ## deletes ELF, object, and hex files (doesn't work well with Windows)
/bin/rm -f core.* *.o *.elf *.hex
help: ## show this help (does NOT work on Windows, due to egrep and awk)
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'