This repository was archived by the owner on Jun 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (39 loc) · 1.3 KB
/
Makefile
File metadata and controls
59 lines (39 loc) · 1.3 KB
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
# Binaries will be generated with this name (.elf, .bin, .hex, etc)
PROJ_NAME=blinky
# Put your stlink folder here so make burn will work.
STFLASH=st-flash
RUSTC=rustc
LLC=llc-3.6
CC=arm-none-eabi-gcc
AR=arm-none-eabi-ar
OBJCOPY=arm-none-eabi-objcopy
# Put your source files here (or *.c, etc)
SRCS=sys/system_stm32f4xx.c
# add startup file to build
SRCS += sys/startup_stm32f4xx.s
OBJS = $(SRCS:.c=.o)
OBJS := $(OBJS:.s=.o)
AFLAGS = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS = -g -O0 -Wall
CFLAGS += -mlittle-endian $(AFLAGS)
CFLAGS += -Isys/inc -Isys/inc/core
LDFLAGS = -Tsys/stm32_flash.ld $(AFLAGS)
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
.s.o:
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: proj
all: proj
proj: $(PROJ_NAME).hex $(PROJ_NAME).bin
libcompiler-rt.a: $(OBJS)
$(AR) rcs $@ $(OBJS)
blinky.elf: main.rs libcompiler-rt.a
$(RUSTC) --target target.json -A non_camel_case_types -A dead_code -A non_snake_case main.rs -C link-args="$(LDFLAGS)" -L. -o $@ -Z print-link-args
$(PROJ_NAME).hex: blinky.elf
$(OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
$(PROJ_NAME).bin: blinky.elf
$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
clean:
rm -f *.o *.a sys/*.o $(PROJ_NAME).elf $(PROJ_NAME).hex $(PROJ_NAME).bin
burn: $(PROJ_NAME).bin
$(STFLASH) write $(PROJ_NAME).bin 0x8000000