-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
249 lines (200 loc) · 7.45 KB
/
Makefile
File metadata and controls
249 lines (200 loc) · 7.45 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# Copyright (c) 2022 Manfred SCHLAEGL <manfred.schlaegl@gmx.at>
#
# SPDX-License-Identifier: BSD 3-clause "New" or "Revised" License
#
BUILDROOT_GIT=https://gitlab.com/buildroot.org/buildroot.git
BUILDROOT_VERSION=2026.02
VP_NAME=riscv-vp-plusplus
VP_GIT=https://github.com/ics-jku/$(VP_NAME).git
VP_VERSION=master
MRAM_IMAGE_DIR=runtime_mram
# VP_ARGS can be overriden by user ($ VP_ARGS="..." make run_...)
VP_ARGS?=--use-data-dmi --tlm-global-quantum=1000000 --use-dbbcache --use-lscache --tun-device tun10
LINUX_DT_GEN=$(VP_NAME)/vp/build/bin/linux-dt-gen.py
DT_BOOTARGS="earlycon=sbi root=/dev/mtdblock0 rootfstype=squashfs ro"
BR_DTC="output/host/bin/dtc"
# memory configuration (vp paramter + device tree)
MEM_SIZE_RV32=$(shell echo $$((1 * 1024*1024*1024))) # 1 GiB
MEM_SIZE_RV64=$(shell echo $$((2 * 1024*1024*1024))) # 2 GiB
.PHONY: help all get dtb build_rv32 build_rv64 build vp-rebuild buildroot-reconfigure \
buildroot_rv32-rebuild buildroot_rv64-rebuild buildroot-rebuild \
run_rv32 run_rv64 clean distclean
help:
@echo
@echo "Targets:"
@grep '^[^#[:space:]].*:' Makefile | cut -d':' -f1 | grep -v '\.\|dt/\|='
@echo
@echo "VP Arguments:"
@echo $(VP_ARGS)
@echo "Can be overriden by user"
@echo "Example: VP_ARGS=\"$(VP_ARGS)\" make run_rv32_sc"
@echo
all: build
get: .stamp/vp_get .stamp/buildroot_get
build_rv32: .stamp/vp_build .stamp/buildroot_rv32_build dt/linux-vp_rv32_sc.dtb dt/linux-vp_rv32_mc.dtb
build_rv64: .stamp/vp_build .stamp/buildroot_rv64_build dt/linux-vp_rv64_sc.dtb dt/linux-vp_rv64_mc.dtb
build: build_rv32 build_rv64
vp-rebuild:
rm -rf .stamp/vp_build
make .stamp/vp_build
buildroot-reconfigure:
rm -rf .stamp/buildroot_config
make .stamp/buildroot_config
buildroot_rv32-rebuild:
rm -rf .stamp/buildroot_rv32_build
make .stamp/buildroot_rv32_build
buildroot_rv64-rebuild:
rm -rf .stamp/buildroot_rv64_build
make .stamp/buildroot_rv64_build
buildroot-rebuild: buildroot_rv32-rebuild buildroot_rv64-rebuild
build_all_dts: dt/linux-vp_rv32_sc.dts dt/linux-vp_rv64_sc.dts dt/linux-vp_rv32_mc.dts dt/linux-vp_rv64_mc.dts
build_all_dtb: dt/linux-vp_rv32_sc.dtb dt/linux-vp_rv64_sc.dtb dt/linux-vp_rv32_mc.dtb dt/linux-vp_rv64_mc.dtb
run_rv32_sc: build_rv32
$(VP_NAME)/vp/build/bin/linux32-sc-vp \
$(VP_ARGS) \
--dtb-file=dt/linux-vp_rv32_sc.dtb \
--kernel-file buildroot_rv32/output/images/Image \
--mram-root-image $(MRAM_IMAGE_DIR)/mram_rv32_root.img \
--mram-data-image $(MRAM_IMAGE_DIR)/mram_rv32_data.img \
--memory-size $(MEM_SIZE_RV32) \
buildroot_rv32/output/images/fw_jump.elf
run_rv64_sc: build_rv64
$(VP_NAME)/vp/build/bin/linux-sc-vp \
$(VP_ARGS) \
--dtb-file=dt/linux-vp_rv64_sc.dtb \
--kernel-file buildroot_rv64/output/images/Image \
--mram-root-image $(MRAM_IMAGE_DIR)/mram_rv64_root.img \
--mram-data-image $(MRAM_IMAGE_DIR)/mram_rv64_data.img \
--memory-size $(MEM_SIZE_RV64) \
buildroot_rv64/output/images/fw_jump.elf
run_rv32_mc: build_rv32
$(VP_NAME)/vp/build/bin/linux32-vp \
$(VP_ARGS) \
--dtb-file=dt/linux-vp_rv32_mc.dtb \
--kernel-file buildroot_rv32/output/images/Image \
--mram-root-image $(MRAM_IMAGE_DIR)/mram_rv32_root.img \
--mram-data-image $(MRAM_IMAGE_DIR)/mram_rv32_data.img \
--memory-size $(MEM_SIZE_RV32) \
buildroot_rv32/output/images/fw_jump.elf
run_rv64_mc: build_rv64
$(VP_NAME)/vp/build/bin/linux-vp \
$(VP_ARGS) \
--dtb-file=dt/linux-vp_rv64_mc.dtb \
--kernel-file buildroot_rv64/output/images/Image \
--mram-root-image $(MRAM_IMAGE_DIR)/mram_rv64_root.img \
--mram-data-image $(MRAM_IMAGE_DIR)/mram_rv64_data.img \
--memory-size $(MEM_SIZE_RV64) \
buildroot_rv64/output/images/fw_jump.elf
clean:
- $(MAKE) clean -C $(VP_NAME)
- $(MAKE) clean -C buildroot_rv64
- $(MAKE) clean -C buildroot_rv32
- rm -rf dt/*.dtb
- rm -rf .stamp/buildroot_config
- rm -rf .stamp/buildroot_get_sources
- rm -rf .stamp/buildroot_rv??_build
distclean:
- rm -rf .stamp
- rm -rf buildroot_rv32 buildroot_rv64 buildroot_dl
- rm -rf $(VP_NAME)
- rm -rf dt/*.dtb
- rm -rf dt/*.dts
## MISC/HELPERS
.stamp/init:
@mkdir -p `dirname $@`
@touch $@
## VP
.stamp/vp_get: .stamp/init
@echo " + GET RISC-V VP"
rm -rf $(VP_NAME)
git clone $(VP_GIT) $(VP_NAME)
( cd $(VP_NAME) && git checkout $(VP_VERSION) )
@touch $@
.stamp/vp_build: .stamp/vp_get
@echo " + BUILD RISC-V VP"
# ensure release build
RELEASE_BUILD=ON $(MAKE) vps -C $(VP_NAME) -j$(NPROCS)
@touch $@
## BUILDROOT
.stamp/buildroot_get: .stamp/init
@echo " + GET BUILDROOT"
rm -rf buildroot_rv32 buildroot_rv64
git clone $(BUILDROOT_GIT) buildroot_rv32
( cd buildroot_rv32 && git checkout $(BUILDROOT_VERSION) )
cp -a buildroot_rv32 buildroot_rv64
@touch $@
.stamp/buildroot_config: .stamp/buildroot_get
@echo " + CONFIG BUILDROOT"
cp configs/buildroot_rv32.config buildroot_rv32/.config
cp configs/buildroot_rv64.config buildroot_rv64/.config
cp configs/busybox.config buildroot_rv32
cp configs/busybox.config buildroot_rv64
cp configs/linux_rv32.config buildroot_rv32
cp configs/linux_rv64.config buildroot_rv64
@touch $@
.stamp/buildroot_get_sources: .stamp/buildroot_config
@echo " + GET BUILDROOT PACKAGE SOURCES"
make -C buildroot_rv32 source
make -C buildroot_rv64 source
@touch $@
.stamp/buildroot_rv32_build: .stamp/buildroot_get_sources
@echo " + BUILD BUILDROOT FOR RV32"
make -C buildroot_rv32
mkdir -p $(MRAM_IMAGE_DIR)
cp buildroot_rv32/output/images/rootfs.squashfs $(MRAM_IMAGE_DIR)/mram_rv32_root.img
@touch $@
.stamp/buildroot_rv64_build: .stamp/buildroot_get_sources
@echo " + BUILD BUILDROOT FOR RV64"
make -C buildroot_rv64
mkdir -p $(MRAM_IMAGE_DIR)
cp buildroot_rv64/output/images/rootfs.squashfs $(MRAM_IMAGE_DIR)/mram_rv64_root.img
@touch $@
## DEVICETREE
dt/linux-vp_rv32_sc.dts: Makefile $(LINUX_DT_GEN)
@echo " + CREATE VP RV32 SINGLECORE DTS: $@"
@mkdir -p `dirname $@`
$(LINUX_DT_GEN) \
--quiet \
--bootargs $(DT_BOOTARGS) \
--target linux32-sc-vp \
--memory-size $(MEM_SIZE_RV32) \
--output-file $@
dt/linux-vp_rv64_sc.dts: Makefile $(LINUX_DT_GEN)
@echo " + CREATE VP RV64 SINGLECORE DTS: $@"
@mkdir -p `dirname $@`
$(LINUX_DT_GEN) \
--quiet \
--bootargs $(DT_BOOTARGS) \
--target linux-sc-vp \
--memory-size $(MEM_SIZE_RV64) \
--output-file $@
dt/linux-vp_rv32_mc.dts: Makefile $(LINUX_DT_GEN)
@echo " + CREATE VP RV32 MULTICORE DTS: $@"
@mkdir -p `dirname $@`
$(LINUX_DT_GEN) \
--quiet \
--bootargs $(DT_BOOTARGS) \
--target linux32-vp \
--memory-size $(MEM_SIZE_RV32) \
--output-file $@
dt/linux-vp_rv64_mc.dts: Makefile $(LINUX_DT_GEN)
@echo " + CREATE VP RV64 MULTICORE DTS: $@"
@mkdir -p `dirname $@`
$(LINUX_DT_GEN) \
--quiet \
--bootargs $(DT_BOOTARGS) \
--target linux-vp \
--memory-size $(MEM_SIZE_RV64) \
--output-file $@
dt/linux-vp_rv32_sc.dtb: dt/linux-vp_rv32_sc.dts .stamp/buildroot_rv32_build
@echo " + CREATE VP RV32 SINGLECORE DTB: $@"
buildroot_rv32/$(BR_DTC) $< -o $@
dt/linux-vp_rv64_sc.dtb: dt/linux-vp_rv64_sc.dts .stamp/buildroot_rv64_build
@echo " + CREATE VP RV64 SINGLECORE DTB: $@"
buildroot_rv64/$(BR_DTC) $< -o $@
dt/linux-vp_rv32_mc.dtb: dt/linux-vp_rv32_mc.dts .stamp/buildroot_rv32_build
@echo " + CREATE VP RV32 MULTICORE DTB: $@"
buildroot_rv32/$(BR_DTC) $< -o $@
dt/linux-vp_rv64_mc.dtb: dt/linux-vp_rv64_mc.dts .stamp/buildroot_rv64_build
@echo " + CREATE VP RV64 MULTICORE DTB: $@"
buildroot_rv64/$(BR_DTC) $< -o $@