forked from havardh/geckoboot.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
142 lines (107 loc) · 4.59 KB
/
Makefile
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
LLVM_36_HOME=../llvm
ARM_GCC_TOOLCHAIN=~/bin/SimplicityStudio_v2/developer/toolchains/gnu_arm/4.8_2013q4
RUST_SRC=/home/sondre/src/rust
RUSTC=/home/sondre/bin/rustc-nightly-x86_64-unknown-linux-gnu/bin/rustc
# RUSTC=/home/sondre/bin/rustc-nightly-x86_64-unknown-linux-gnu/bin/rustc
#LLC=$(LLVM_36_HOME)/Debug+Asserts/bin/llc
#eACommander=/home/sondre/src/eACommander.app/Contents/MacOS/eACommander
DEVICE=EFM32GG990F1024
TARGET=thumbv7m-none-eabi
SIMPLICITY_STUDIO=/home/sondre/bin/SimplicityStudio_v2
LIB_PATH=$(SIMPLICITY_STUDIO)/developer/sdks/efm32/v2/
LIB_DIR=lib
OUT_DIR=out
INCLUDEPATHS += \
-I$(LIB_PATH)/CMSIS/Include \
-I$(LIB_PATH)/Device/SiliconLabs/EFM32GG/Include \
-I$(LIB_PATH)/emlib/inc \
-I$(LIB_PATH)/kits/common/drivers \
-I$(LIB_PATH)/kits/common/bsp \
-I$(LIB_PATH)/kits/EFM32GG_STK3700/config \
-I$(LIB_PATH)/emdrv/gpiointerrupt/inc
SRCS = \
$(LIB_PATH)/Device/SiliconLabs/EFM32GG/Source/system_efm32gg.c \
$(LIB_PATH)/emlib/src/em_cmu.c \
$(LIB_PATH)/emlib/src/em_emu.c \
$(LIB_PATH)/emlib/src/em_gpio.c \
$(LIB_PATH)/emlib/src/em_system.c \
$(LIB_PATH)/emlib/src/em_int.c \
$(LIB_PATH)/kits/common/drivers/retargetio.c \
$(LIB_PATH)/emdrv/gpiointerrupt/src/gpiointerrupt.c
# $(LIB_PATH)/emlib/src/em_emu.c \
# $(LIB_PATH)/kits/common/drivers/segmentlcd.c \
# $(LIB_PATH)/kits/common/bsp/bsp_bcc.c \
# $(LIB_PATH)/kits/common/bsp/bsp_stk.c \
# $(LIB_PATH)/kits/common/bsp/bsp_stk_leds.c \
# $(LIB_PATH)/kits/common/bsp/bsp_trace.c \
# $(LIB_PATH)/emlib/src/em_assert.c \
# $(LIB_PATH)/emlib/src/em_ebi.c \
# $(LIB_PATH)/emlib/src/em_lcd.c \
# $(LIB_PATH)/emlib/src/em_usart.c \
SRCS += emlib/gpio.c \
emlib/emu.c \
emlib/chip.c \
cmsis/cmsis.c \
emlib/swo.c \
emdrv/gpiointerrupt.c \
# Binaries will be generated with this name (.elf, .bin, .hex, etc)
PROJ_NAME=blinky
# Normally you shouldn't need to change anything below this line!
#######################################################################################
CC=$(ARM_GCC_TOOLCHAIN)/bin/arm-none-eabi-gcc
GDB=$(ARM_GCC_TOOLCHAIN)/bin/arm-none-eabi-gdb
OBJCOPY=$(ARM_GCC_TOOLCHAIN)/bin/arm-none-eabi-objcopy
FLASH=$(eACommander)
CFLAGS = -O0 -Wall -T$(LIB_PATH)/Device/SiliconLabs/EFM32GG/Source/GCC/efm32gg.ld
CFLAGS += -mthumb -mcpu=cortex-m3
CFLAGS += $(INCLUDEPATHS)
CFLAGS += -D$(DEVICE)
CFLAGS += -std=c99 --specs=nano.specs
CFLAGS += -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
#CFLAGS += -nostartfiles
RUSTFLAGS = --target $(TARGET) \
--crate-type lib -g \
-L $(LIB_DIR) --emit asm \
--out-dir $(OUT_DIR) \
-A non_camel_case_types \
-A dead_code \
-A non_snake_case
RUSTLIBFLAGS = -O -g --target $(TARGET) -L $(LIB_DIR) --cfg stage0 --out-dir $(LIB_DIR)
# Note: A bug in the OSX eACommander requires at least two flags to run in cli mode
FLASHFLAGS = --verify --reset
# add startup file to build
SRCS += $(LIB_PATH)/Device/SiliconLabs/EFM32GG/Source/GCC/startup_efm32gg.S
OBJS = $(SRCS:.c=.o)
.PHONY: proj
all: clean proj
proj: $(OUT_DIR)/$(PROJ_NAME).elf
$(OUT_DIR)/$(PROJ_NAME).s: $(PROJ_NAME).rs #$(OUT_DIR)/libcore.rlib $(OUT_DIR)/libcollections.rlib
$(RUSTC) $(RUSTFLAGS) $(PROJ_NAME).rs
$(OUT_DIR)/$(PROJ_NAME).elf: $(SRCS) $(OUT_DIR)/$(PROJ_NAME).s
$(CC) -O0 $(CFLAGS) $^ -o $@
$(OBJCOPY) -O ihex $(OUT_DIR)/$(PROJ_NAME).elf $(OUT_DIR)/$(PROJ_NAME).hex
$(OBJCOPY) -O binary $(OUT_DIR)/$(PROJ_NAME).elf $(OUT_DIR)/$(PROJ_NAME).bin
# Building Rust library
.PHONY: librust
librust: $(OUT_DIR)/libcore.rlib $(OUT_DIR)/libcollections.rlib
$(OUT_DIR)/libcore.rlib: $(RUST_SRC)/src/libcore/lib.rs
$(RUSTC) $(RUSTLIBFLAGS) $(RUST_SRC)/src/libcore/lib.rs
$(OUT_DIR)/libcollections.rlib: $(RUST_SRC)/src/libcollections/lib.rs $(OUT_DIR)/libunicode.rlib $(OUT_DIR)/liballoc.rlib
$(RUSTC) $(RUSTLIBFLAGS) $(RUST_SRC)/src/libcollections/lib.rs
$(OUT_DIR)/libunicode.rlib: $(RUST_SRC)/src/libunicode/lib.rs
$(RUSTC) $(RUSTLIBFLAGS) $(RUST_SRC)/src/libunicode/lib.rs
$(OUT_DIR)/liballoc.rlib: $(RUST_SRC)/src/liballoc/lib.rs $(OUT_DIR)/liblibc.rlib
$(RUSTC) $(RUSTLIBFLAGS) $(RUST_SRC)/src/liballoc/lib.rs
$(OUT_DIR)/liblibc.rlib: $(RUST_SRC)/src/liblibc/lib.rs
$(RUSTC) $(RUSTLIBFLAGS) $(RUST_SRC)/src/liblibc/lib.rs
# Rust Library
.PHONY: flash
flash: all
$(FLASH) --flash $(OUT_DIR)/$(PROJ_NAME).bin $(FLASHFLAGS)
.PHONY: debug
debug:
$(GDB) -x efm32gdbinit
clean:
rm -f out/*
test.elf: test.c
arm-none-eabi-gcc -g $(INCLUDEPATHS) --specs=nosys.specs -D$(DEVICE) -mthumb -mcpu=cortex-m3 -mlittle-endian -T$(LIB_PATH)/Device/SiliconLabs/EFM32GG/Source/GCC/efm32gg.ld $(LIB_PATH)/Device/SiliconLabs/EFM32GG/Source/system_efm32gg.c $(LIB_PATH)/Device/SiliconLabs/EFM32GG/Source/GCC/startup_efm32gg.s test.c -o test.elf