-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
179 lines (155 loc) · 6.2 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
CROSS_COMPILE:=arm-none-eabi-
CC:=$(CROSS_COMPILE)gcc
LD:=$(CROSS_COMPILE)gcc
AS:=$(CROSS_COMPILE)gcc
OBJCOPY:=$(CROSS_COMPILE)objcopy
SIZE:=$(CROSS_COMPILE)size
KINETIS?=$(HOME)/src/FRDM-K64F
KINETIS_DRIVERS?=$(KINETIS)/devices/MK64F12
KINETIS_CMSIS?=$(KINETIS)/CMSIS
PHY=$(KINETIS)/components/phyksz8081
FREERTOS_PORT:=freeRTOS/portable/GCC/ARM_CM4F
WOLFBOOT:=../wolfBoot
WOLFSSL_ROOT:=../wolfBoot/lib/wolfssl
WOLFSSL_BUILD:=./build/lib
DEBUG?=0
CFLAGS=-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-DFREERTOS \
-DNVM_FLASH_WRITEONCE
CFLAGS+=-mthumb -Wall -Wextra -Wno-main -Wstack-usage=1024 -ffreestanding -Wno-unused \
-Isrc \
-Ilib/bootutil/include -Iinclude/ -Ilib/wolfssl -I$(FREERTOS_PORT) -nostartfiles \
-IfreeRTOS -IfreeRTOS/include -I build/include -I$(WOLFBOOT)/include -I$(WOLFBOOT) \
-DWOLFSSL_USER_SETTINGS -I$(WOLFSSL_ROOT) -DPICO_PORT_CUSTOM \
-mthumb -mlittle-endian -mthumb-interwork -ffreestanding -fno-exceptions \
-DWOLFBOOT_HASH_SHA256
ifneq ($(DEBUG),0)
CFLAGS+=-O0 -ggdb3
else
CFLAGS+=-Os
endif
CFLAGS+=-I$(KINETIS_DRIVERS)/drivers -I$(KINETIS_DRIVERS) -DCPU_MK64FN1M0VLL12 -I$(KINETIS_CMSIS)/Include -I$(PHY) -DDEBUG_CONSOLE_ASSERT_DISABLE=1
LDFLAGS=$(CFLAGS) -Wl,-gc-sections -ffreestanding -nostartfiles -lc -lnosys -specs=nano.specs -Wl,-Map=image.map
OBJS:= \
$(KINETIS_DRIVERS)/drivers/fsl_clock.o \
$(KINETIS_DRIVERS)/drivers/fsl_ftfx_flash.o \
$(KINETIS_DRIVERS)/drivers/fsl_ftfx_cache.o \
$(KINETIS_DRIVERS)/drivers/fsl_ftfx_controller.o \
$(KINETIS_DRIVERS)/drivers/fsl_enet.o \
$(KINETIS_DRIVERS)/drivers/fsl_sysmpu.o \
$(WOLFBOOT)/src/libwolfboot.o \
$(WOLFBOOT)/hal/kinetis.o \
src/clock_config.o \
src/main.o \
src/pin_mux.o \
freeRTOS/croutine.o \
freeRTOS/event_groups.o \
freeRTOS/list.o \
freeRTOS/queue.o \
freeRTOS/stream_buffer.o \
freeRTOS/tasks.o \
freeRTOS/timers.o \
$(FREERTOS_PORT)/port.o \
freeRTOS/portable/MemMang/heap_5.o \
src/startup_mk64f12.o \
src/pico_enet_kinetis.o \
$(PHY)/fsl_phy.o \
src/server_ecc_key.o \
src/server_ecc_cert.o \
src/picotcp.o
WOLFSSL_OBJS += \
$(WOLFSSL_BUILD)/internal.o \
$(WOLFSSL_BUILD)/wolfio.o \
$(WOLFSSL_BUILD)/keys.o \
$(WOLFSSL_BUILD)/crl.o \
$(WOLFSSL_BUILD)/ssl.o \
$(WOLFSSL_BUILD)/tls.o \
$(WOLFSSL_BUILD)/wolfcrypt/aes.o \
$(WOLFSSL_BUILD)/wolfcrypt/asn.o \
$(WOLFSSL_BUILD)/wolfcrypt/chacha.o \
$(WOLFSSL_BUILD)/wolfcrypt/chacha20_poly1305.o \
$(WOLFSSL_BUILD)/wolfcrypt/coding.o \
$(WOLFSSL_BUILD)/wolfcrypt/curve25519.o \
$(WOLFSSL_BUILD)/wolfcrypt/error.o \
$(WOLFSSL_BUILD)/wolfcrypt/ecc.o \
$(WOLFSSL_BUILD)/wolfcrypt/ed25519.o \
$(WOLFSSL_BUILD)/wolfcrypt/rsa.o \
$(WOLFSSL_BUILD)/wolfcrypt/fe_low_mem.o \
$(WOLFSSL_BUILD)/wolfcrypt/fe_operations.o \
$(WOLFSSL_BUILD)/wolfcrypt/ge_low_mem.o \
$(WOLFSSL_BUILD)/wolfcrypt/ge_operations.o \
$(WOLFSSL_BUILD)/wolfcrypt/hash.o \
$(WOLFSSL_BUILD)/wolfcrypt/hmac.o \
$(WOLFSSL_BUILD)/wolfcrypt/integer.o \
$(WOLFSSL_BUILD)/wolfcrypt/logging.o \
$(WOLFSSL_BUILD)/wolfcrypt/md5.o \
$(WOLFSSL_BUILD)/wolfcrypt/memory.o \
$(WOLFSSL_BUILD)/wolfcrypt/poly1305.o \
$(WOLFSSL_BUILD)/wolfcrypt/pwdbased.o \
$(WOLFSSL_BUILD)/wolfcrypt/random.o \
$(WOLFSSL_BUILD)/wolfcrypt/sha.o \
$(WOLFSSL_BUILD)/wolfcrypt/sha256.o \
$(WOLFSSL_BUILD)/wolfcrypt/sha512.o \
$(WOLFSSL_BUILD)/wolfcrypt/wc_encrypt.o \
$(WOLFSSL_BUILD)/wolfcrypt/wc_port.o \
$(WOLFSSL_BUILD)/wolfcrypt/wolfmath.o \
$(WOLFSSL_BUILD)/tls13.o
OBJS_SPMATH:= $(WOLFSSL_BUILD)/wolfcrypt/sp_c32.o \
$(WOLFSSL_BUILD)/wolfcrypt/sp_int.o
OBJS+=$(WOLFSSL_OBJS) $(OBJS_SPMATH)
LIBS+=build/lib/libpicotcp.a
vpath %.c $(dir $(WOLFSSL_ROOT)/src)
vpath %.c $(dir $(WOLFSSL_ROOT)/wolfcrypt/src)
wolfboot:LSCRIPT:=k64f_wolfboot.ld
wolfboot: image.bin wolfboot-align.bin
python3 ../wolfBoot/tools/keytools/sign.py --ecc256 image.bin ../wolfBoot/ecc256.der 1
cat wolfboot-align.bin image_v1_signed.bin >factory.bin
sleep 1
touch image.bin
python3 ../wolfBoot/tools/keytools/sign.py --ecc256 image.bin ../wolfBoot/ecc256.der 2
wolfboot-align.bin:CFLAGS=-mthumb -Wall -Wextra -Wno-main -Wstack-usage=1024 -ffreestanding -Wno-unused \
-Isrc \
-Ilib/bootutil/include -Iinclude/ -Ilib/wolfssl -I$(FREERTOS_PORT) -nostartfiles \
-IfreeRTOS -IfreeRTOS/include -I build/include -I$(WOLFBOOT)/include -I$(WOLFBOOT) \
-DWOLFSSL_USER_SETTINGS -I$(WOLFSSL_ROOT) -DPICO_PORT_CUSTOM \
-mthumb -mlittle-endian -mthumb-interwork -ffreestanding -fno-exceptions
wolfboot-align.bin:CFLAGS+=-I$(KINETIS_DRIVERS)/drivers -I$(KINETIS_DRIVERS) -DCPU_MK64FN1M0VLL12 -I$(KINETIS_CMSIS)/Include -I$(PHY) -DDEBUG_CONSOLE_ASSERT_DISABLE=1 -mcpu=cortex-m3 -DNVM_FLASH_WRITEONCE=1
wolfboot-align.bin:LDFLAGS=$(CFLAGS) -Wl,-gc-sections -ffreestanding -nostartfiles -lc -lnosys -specs=nano.specs -Wl,-Map=image.map
wolfboot-align.bin: wolfboot_target
rm -f ../wolfBoot/hal/kinetis.o
rm -f ../wolfBoot/src/*.o
rm -f $(KINETIS_DRIVERS)/drivers/*.o
make -C ../wolfBoot wolfboot-align.bin
cp ../wolfBoot/wolfboot-align.bin .
standalone:LSCRIPT:=k64f_standalone.ld
standalone: image.bin
$(LIBS): picotcp
make -C picotcp EXTRA_CFLAGS="-DPICO_PORT_CUSTOM $(CFLAGS) -I../src -I../freeRTOS/include -I../freeRTOS -I../$(FREERTOS_PORT)" \
ARCH=cortexm4-hardfloat CROSS_COMPILE=arm-none-eabi- RTOS=1 \
AODV=0 LOOP=0 PPP=0 DHCP_SERVER=0 DNS_SD=0 FRAG=0 ICMP6=0 \
IPV6=0 NAT=0 MDNS=0 MCAST=0 TFTP=0 SNTP=0 SLAACV4=0 MD5=0 \
DEBUG=0
$(WOLFSSL_BUILD)/wolfcrypt:
mkdir -p $(@)
%.o:%.S
$(CC) -c -o $(@) $(CFLAGS) $^
%.o:%.c
$(CC) -c -o $(@) $(CFLAGS) $^
$(WOLFSSL_BUILD)/%.o: $(WOLFSSL_ROOT)/src/%.c
$(CC) -c -o $(@) $(CFLAGS) $^
$(WOLFSSL_BUILD)/wolfcrypt/%.o: $(WOLFSSL_ROOT)/wolfcrypt/src/%.c
$(CC) -c -o $(@) $(CFLAGS) $^
image.bin: image.elf wolfboot_target
$(OBJCOPY) -O binary image.elf $@
$(SIZE) image.elf
image.hex: image.elf
$(OBJCOPY) -O ihex $^ $@
wolfboot_target: FORCE
cp -f src/wolfboot.config ../wolfBoot/.config
make -C ../wolfBoot include/target.h
image.elf: wolfboot_target $(WOLFSSL_BUILD)/wolfcrypt $(LIBS) $(OBJS) $(LSCRIPT)
$(LD) $(LDFLAGS) -Wl,--start-group $(OBJS) $(LIBS) -Wl,--end-group -o $@ -T $(LSCRIPT)
clean:
rm -f *.bin *.elf $(OBJS) wolfboot.map *.bin *.hex src/*.o freeRTOS/*.o $(FREERTOS_PORT)/*.o *.map tags
make -C picotcp clean
FORCE: