summaryrefslogtreecommitdiff
path: root/src/makefile
blob: 51a95413791c5c127c2111482149fcac1db6dd41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#compile options
TOOLCHAIN_DIR=/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64
CC=$(TOOLCHAIN_DIR)/bin/avr-gcc
INC=$(TOOLCHAIN_DIR)/avr/include
OUT=compiled_payload.elf
DEVICE=atmega2560
#DEVICE=atmega328p
F_CPU=16000000

DEBUG=1

#avrdude options
PARTNO=ATmega2560
#PARTNO=ATmega328p
PORT=/dev/ttyUSB0
DEBUG_PORT=/dev/ttyACM0 #only works on atmega2560, intented for debugging flashing
BAUD=115200


#baudrate
RUNTIME_BAUDRATE=9600

SRCFILES := $(wildcard *.c)
OBJFILES := $(patsubst %.c,build/%.o,$(SRCFILES))


make: $(OBJFILES)
	echo $(SRCFILES)
	$(CC) -DDEBUG_BUILD=$(DEBUG) -mmcu=$(DEVICE) -o $(OUT) $(OBJFILES)
	compiledb make --dry-run > /dev/null

build/%.o: %.c
	if [ ! -d "build" ]; then mkdir -p build; fi
	$(CC) $(CCOPTS) -c -I $(INC) -mmcu=$(DEVICE) -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 -o $@ $<

reset:
	doas avrdude -c usbtiny -p $(PARTNO)

eeprom_write:
	doas avrdude -c usbtiny -p $(PARTNO)
	doas ./write_eeprom.py $(PORT) $(RUNTIME_BAUDRATE)

eeprom:
	./compile_eeprom.py

#eeprom_install:
	#$(CC) -mmcu=atmega2560 -I $(INC) -o $(OUT) -DFLASH_EEPROM -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c debug.c i-DDEBUG_BUILD=$(DEBUG)2c.c ssd1306_display_driver.c uart.c br24t_eeprom_driver.c paint.c -Wall
	doas avrdude -B 1 -v -p ATmega2560 -c usbtiny -U flash:w:$(OUT):e


install: $(OUT)
	doas avrdude -B 1 -v -p $(PARTNO) -c usbtiny -U flash:w:$(OUT):e
	#doas avrdude -v -p $(PARTNO) -P $(PORT) -c wiring -b $(BAUD) -D -U flash:w:$(OUT):e

screen:
	doas avrdude -c usbtiny -p $(PARTNO)
	#doas screen $(PORT) $(RUNTIME_BAUDRATE)
	doas screen $(DEBUG_PORT) $(RUNTIME_BAUDRATE)
	
clean:
	rm -f *.o *.elf compiled_eeprom build/*