
CC=arm-none-eabi-gcc
CFLAGS=-Wall -mcpu=cortex-m0 -mthumb -nostartfiles -g -Os 
LDFLAGS=-T stm32.lnk -static 
#  some recommend -lnosys --specs=nosys.spec, but they don't seem effective

SOURCES=demo.c crt1.c 
OBJECTS=$(SOURCES:.c=.o)

.c.o:
	$(CC) $(CFLAGS) -c $< 

demo: $(OBJECTS) 
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@

all:
	klm 

clean:
	rm $(OBJECTS)
	
load: demo 
	arm-none-eabi-objcopy $< -O binary demo.bin
	# st-flash write demo.bin 0x08000000
	stm32loader -p /dev/ttyUSB0 -e -w -v -V demo.bin
