summaryrefslogtreecommitdiff
path: root/bootloader/example/Makefile
blob: 886c11fe07df5a7494db0e9d609f66dbf2ad3286 (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
MCU=atmega328p
CC=avr-gcc
OBJCOPY=avr-objcopy
# optimize for size:
CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues
PORT=/dev/ttyUSB0
PART=ATmega16
UISP = uisp -dprog=stk500 -dserial=/dev/ttyUSB0 -dpart=$(PART)
#-------------------
all: main.bin
#-------------------

SRC = main.c

OBJ = ${SRC:.c=.o}

main.bin : main.out
	$(OBJCOPY) -R .eeprom -O binary main.out main.bin

main.hex : main.out
	$(OBJCOPY) -R .eeprom -O ihex main.out main.hex

main.out : $(OBJ)
	$(CC) $(CFLAGS) -o main.out -Wl,-Map,main.map $(OBJ)

.c.o:
	@echo CC $<
	@$(CC) -c $(CFLAGS) -Os -o $*.o $<

# you need to erase first before loading the program.
# load (program) the software into the eeprom:
load: main.hex
	$(UISP) --erase
	$(UISP) --upload --verify if=main.hex -v=3 --hash=32

fuse_mega16:
	$(UISP) --wr_fuse_l=0x9f --wr_fuse_h=0xd0

check_fuse:
	$(UISP) --rd_fuses

#-------------------
clean:
	rm -f *.o *.map *.out *.hex *.bin
#-------------------