-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
207 lines (162 loc) · 7.88 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
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
CORE := iob_soc_opencryptolinux
SIMULATOR ?= icarus
BOARD ?= AES-KU040-DB-G
DISABLE_LINT:=1
LIB_DIR:=submodules/IOBSOC/submodules/LIB
include $(LIB_DIR)/setup.mk
INIT_MEM ?= 0
RUN_LINUX ?= 0
USE_EXTMEM := 1
BOOT_FLOW ?= CONSOLE_TO_EXTMEM
ifeq ($(INIT_MEM),1)
SETUP_ARGS += INIT_MEM
endif
ifeq ($(DMA_DEMO),1)
SETUP_ARGS += OCL_DMA_DEMO
endif
setup:
make build-setup SETUP_ARGS="$(SETUP_ARGS)"
sim-run:
nix-shell --run 'make clean setup INIT_MEM=$(INIT_MEM) && make -C ../$(CORE)_V*/ sim-run SIMULATOR=$(SIMULATOR)'
sim-test-linux:
nix-shell --run "make clean"
nix-shell --run "make setup INIT_MEM=1"
nix-shell --run "make -C ../iob_soc_o* sim-run SIMULATOR=verilator RUN_LINUX=1"
sim-test:
nix-shell --run "make clean"
nix-shell --run "make setup INIT_MEM=1"
nix-shell --run "make -C ../iob_soc_o* sim-run"
nix-shell --run "make clean"
nix-shell --run "make setup INIT_MEM=0"
nix-shell --run "make -C ../iob_soc_o* sim-run SIMULATOR=verilator"
sim-test-spi:
nix-shell --run "make -C submodules/SPI/ clean build-setup && make -C submodules/iob_spi_master_V0.10/ sim-run"
nix-shell --run "make -C submodules/SPI/ clean"
fpga-run:
nix-shell --run 'make clean setup INIT_MEM=$(INIT_MEM) USE_EXTMEM=$(USE_EXTMEM)'
nix-shell --run 'make -C ../$(CORE)_V*/ fpga-fw-build BOARD=$(BOARD) RUN_LINUX=$(RUN_LINUX)'
make -C ../$(CORE)_V*/ fpga-run BOARD=$(BOARD) RUN_LINUX=$(RUN_LINUX) BOOT_FLOW=$(BOOT_FLOW)
fpga-build:
nix-shell --run 'make clean setup INIT_MEM=$(INIT_MEM) USE_EXTMEM=$(USE_EXTMEM)'
nix-shell --run 'make -C ../$(CORE)_V*/ fpga-fw-build BOARD=$(BOARD) RUN_LINUX=$(RUN_LINUX)'
make -C ../$(CORE)_V*/ fpga-build BOARD=$(BOARD) RUN_LINUX=$(RUN_LINUX)
fpga-connect:
nix-shell --run 'make -C ../$(CORE)_V*/ fpga-fw-build BOARD=$(BOARD) RUN_LINUX=$(RUN_LINUX)'
# Should run under 'bash', running with 'fish' as a shell gives an error
make -C ../$(CORE)_V*/ fpga-run BOARD=$(BOARD) RUN_LINUX=$(RUN_LINUX) BOOT_FLOW=$(BOOT_FLOW)
fpga-test:
make clean setup fpga-run INIT_MEM=0
test-all:
make sim-test
make fpga-test BOARD=CYCLONEV-GT-DK
make fpga-test BOARD=AES-KU040-DB-G
make clean && make setup && make -C ../iob_soc_opencryptolinux_V*/ doc-test
test-linux-fpga-connect: build_dir_name
-rm $(BUILD_DIR)/hardware/fpga/test.log
-ln -fs minicom_test1.txt $(BUILD_DIR)/hardware/fpga/minicom_linux_script.txt
make fpga-connect RUN_LINUX=1 BOOT_FLOW=$(BOOT_FLOW)
dma-linux-fpga-connect: build_dir_name
-rm $(BUILD_DIR)/hardware/fpga/test.log
-ln -fs minicom_dma_test.txt $(BUILD_DIR)/hardware/fpga/minicom_linux_script.txt
make fpga-connect RUN_LINUX=1 BOOT_FLOW=$(BOOT_FLOW)
.PHONY: setup sim-run sim-test fpga-test test-all test-linux-fpga-connect dma-linux-fpga-connect
# Run this target to configure system for a DMA data transfer demo in linux and run it on a FPGA.
dma-demo:
# Try to setup, so that it generates correct linux_build_macros.txt (ignore errors as well)
-make setup DMA_DEMO=1
make build-linux-files DMA_DEMO=1
make fpga-run RUN_LINUX=0 DMA_DEMO=1
make dma-linux-fpga-connect
.PHONY: dma-demo
#
# Linux targets
#
LINUX_OS_DIR ?= submodules/OS
# Relative path from OS directory to OpenCryptoLinux (OCL) directory
REL_OS2OCL :=`realpath . --relative-to=$(LINUX_OS_DIR)`
ifeq ($(DMA_DEMO),1)
DTS_FILE_STR := DTS_FILE=$(REL_OS2OCL)/software/iob_soc_dma_demo.dts
endif
build-linux-dts:
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-dts MACROS_FILE=$(REL_OS2OCL)/hardware/simulation/linux_build_macros.txt OS_BUILD_DIR=$(REL_OS2OCL)/hardware/simulation $(DTS_FILE_STR)'
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-dts MACROS_FILE=$(REL_OS2OCL)/hardware/fpga/vivado/AES-KU040-DB-G/linux_build_macros.txt OS_BUILD_DIR=$(REL_OS2OCL)/hardware/fpga/vivado/AES-KU040-DB-G $(DTS_FILE_STR)'
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-dts MACROS_FILE=$(REL_OS2OCL)/hardware/fpga/quartus/CYCLONEV-GT-DK/linux_build_macros.txt OS_BUILD_DIR=$(REL_OS2OCL)/hardware/fpga/quartus/CYCLONEV-GT-DK $(DTS_FILE_STR)'
build-linux-opensbi:
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-opensbi MACROS_FILE=$(REL_OS2OCL)/hardware/simulation/linux_build_macros.txt OS_BUILD_DIR=$(REL_OS2OCL)/hardware/simulation'
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-opensbi MACROS_FILE=$(REL_OS2OCL)/hardware/fpga/vivado/AES-KU040-DB-G/linux_build_macros.txt OS_BUILD_DIR=$(REL_OS2OCL)/hardware/fpga/vivado/AES-KU040-DB-G'
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-opensbi MACROS_FILE=$(REL_OS2OCL)/hardware/fpga/quartus/CYCLONEV-GT-DK/linux_build_macros.txt OS_BUILD_DIR=$(REL_OS2OCL)/hardware/fpga/quartus/CYCLONEV-GT-DK'
.PHONY: build-linux-dts build-linux-opensbi
COMBINED_BUILDROOT_DIR=..
combine-buildroot:
rm -rf $(COMBINED_BUILDROOT_DIR)/buildroot
cp -r $(LINUX_OS_DIR)/software/buildroot $(COMBINED_BUILDROOT_DIR)/
cp -r ./software/buildroot $(COMBINED_BUILDROOT_DIR)/
ifeq ($(DMA_DEMO),1)
BUILDROOT_DEPS += build-linux-dma-demo
endif
build-linux-buildroot: combine-buildroot build-linux-drivers $(BUILDROOT_DEPS)
make -C $(LINUX_OS_DIR) build-buildroot OS_SUBMODULES_DIR=$(REL_OS2OCL)/.. OS_SOFTWARE_DIR=../`realpath $(COMBINED_BUILDROOT_DIR) --relative-to=..` OS_BUILD_DIR=$(REL_OS2OCL)/software/src
.PHONY: combine-buildroot build-linux-buildroot
# System peripherals
ifeq ($(DMA_DEMO),1)
MODULE_NAMES += iob_dma
MODULE_NAMES += iob_axistream_in
MODULE_NAMES += iob_axistream_out
endif
MODULE_NAMES += iob_timer
build-driver-headers:
@$(foreach module,$(MODULE_NAMES), \
./$(LINUX_OS_DIR)/scripts/drivers.py $(module) -o `realpath $(COMBINED_BUILDROOT_DIR)`/buildroot/board/IObundle/iob-soc/rootfs-overlay/root/dma_demo/; \
)
.PHONY: build-driver-headers
build-linux-drivers:
@$(foreach module,$(MODULE_NAMES), \
printf "\n\n\nMaking $(module)\n\n\n"; \
$(eval MODULE_LINUX_DIR=$(shell realpath $(shell find . -type f -name '$(module).py' -printf '%h' -quit))/software/linux) \
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-linux-drivers \
MODULE_DRIVER_DIR=$(MODULE_LINUX_DIR)/drivers \
OS_SUBMODULES_DIR=$(REL_OS2OCL)/.. \
CALLING_DIR=`realpath $(CURDIR)` \
MODULE_NAME=$(module) \
ROOTFS_OVERLAY_DIR=`realpath $(COMBINED_BUILDROOT_DIR)`/buildroot/board/IObundle/iob-soc/rootfs-overlay/ \
PYTHON_DIR=`realpath $(LIB_DIR)`/scripts'; \
)
clean-linux-drivers:
@$(foreach module,$(MODULE_NAMES), \
$(eval MODULE_LINUX_DIR=$(shell realpath $(shell find . -type f -name '$(module).py' -printf '%h' -quit))/software/linux) \
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) clean-linux-drivers \
MODULE_DRIVER_DIR=$(MODULE_LINUX_DIR)/drivers \
OS_SUBMODULES_DIR=$(REL_OS2OCL)/.. \
CALLING_DIR=`realpath $(CURDIR)` \
MODULE_NAME=$(module) \
ROOTFS_OVERLAY_DIR=`realpath $(COMBINED_BUILDROOT_DIR)`/buildroot/board/IObundle/iob-soc/rootfs-overlay/ \
PYTHON_DIR=`realpath $(LIB_DIR)`/scripts'; \
)
.PHONY: build-linux-drivers clean-linux-drivers
build-linux-kernel:
-rm ../linux-5.15.98/arch/riscv/boot/Image
nix-shell $(LINUX_OS_DIR)/default.nix --run 'make -C $(LINUX_OS_DIR) build-linux-kernel OS_SUBMODULES_DIR=$(REL_OS2OCL)/.. OS_SOFTWARE_DIR=../`realpath . --relative-to=..`/software OS_BUILD_DIR=$(REL_OS2OCL)/software/src'
.PHONY: build-linux-kernel
# Main target to build all linux related files
build-linux-files:
make build-linux-dts
make build-linux-opensbi
make build-linux-kernel
make build-linux-buildroot
.PHONY: build-linux-files
#
# Linux software targets
#
INCLUDE = -I.
SRC = *.c
FLAGS = -Wall -O2
FLAGS += -Werror
#FLAGS += -static
FLAGS += -march=rv32imac
FLAGS += -mabi=ilp32
BIN = dma_demo
CC = riscv64-unknown-linux-gnu-gcc
build-linux-dma-demo: build-driver-headers
nix-shell $(LINUX_OS_DIR)/default.nix --run 'cd $(COMBINED_BUILDROOT_DIR)/buildroot/board/IObundle/iob-soc/rootfs-overlay/root/dma_demo/ && \
$(CC) $(FLAGS) $(INCLUDE) -o $(BIN) $(SRC)'
.PHONY: build-linux-dma-demo