forked from RedPitaya/RedPitaya
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.x86
More file actions
281 lines (216 loc) · 9.32 KB
/
Copy pathMakefile.x86
File metadata and controls
281 lines (216 loc) · 9.32 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
################################################################################
# versioning system
################################################################################
VER := $(shell cat apps-tools/ecosystem/info/info.json | grep version | sed -e 's/.*:\ *\"//' | sed -e 's/-.*//')
BUILD_NUMBER ?= 0
REVISION ?= $(shell git rev-parse --short HEAD)
VERSION = $(VER)-$(BUILD_NUMBER)-$(REVISION)
export BUILD_NUMBER
export REVISION
export VERSION
SUBMODULE_UBT = "redpitaya-v2016.4"
SUBMODULE_LIN = "branch-redpitaya-v2017.2"
SUBMODULE_APP = ""
define GREET_MSG
##############################################################################
# Red Pitaya GNU/Linux Ecosystem
# Version: $(VER)
# Build: $(BUILD_NUMBER)
# Branch: $(GIT_LOCAL_BRANCH)
# Commit: $(GIT_COMMIT)
# U-Boot: $(SUBMODULE_UBT)
# Linux Kernel: $(SUBMODULE_LIN)
# Pro Applications: $(SUBMODULE_APP)
##############################################################################
endef
export GREET_MSG
################################################################################
# targets
################################################################################
all: fpga devicetree u-boot linux boot
install: linux-install devicetree-install boot
################################################################################
#
################################################################################
# check if download cache directory is available
DL ?= dl
TMP = tmp
INSTALL_DIR = build
$(DL):
mkdir -p $@
$(TMP):
mkdir -p $@
$(INSTALL_DIR):
mkdir -p $@
################################################################################
# X86 build (Vivado FPGA synthesis, FSBL, devicetree, U-Boot, Linux kernel)
################################################################################
UBOOT_TAG = redpitaya-v2016.4
LINUX_TAG = branch-redpitaya-v2017.2
DTREE_TAG = xilinx-v2017.2
UBOOT_DIR = $(TMP)/u-boot-xlnx-$(UBOOT_TAG)
LINUX_DIR = $(TMP)/linux-xlnx-$(LINUX_TAG)
DTREE_DIR = $(TMP)/device-tree-xlnx-$(DTREE_TAG)
UBOOT_TAR = $(DL)/u-boot-xlnx-$(UBOOT_TAG).tar.gz
LINUX_TAR = $(DL)/linux-xlnx-$(LINUX_TAG).tar.gz
DTREE_TAR = $(DL)/device-tree-xlnx-$(DTREE_TAG).tar.gz
# it is possible to use an alternative download location (local) by setting environment variables
UBOOT_URL ?= https://github.com/RedPitaya/u-boot-xlnx/archive/$(UBOOT_TAG).tar.gz
LINUX_URL ?= https://github.com/RedPitaya/linux-xlnx/archive/$(LINUX_TAG).tar.gz
DTREE_URL ?= https://github.com/Xilinx/device-tree-xlnx/archive/$(DTREE_TAG).tar.gz
LINUX_CFLAGS = "-O2 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard"
UBOOT_CFLAGS = "-O2 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard"
KERNEL_HEADERS ?= YES
################################################################################
# FPGA build provides: $(FSBL), $(FPGA), $(DEVICETREE).
################################################################################
HWID ?=
ifeq ($(MODEL),Z10)
FPGA_PRJ_LST = stream_app classic logic v0.94 mercury axi4lite
# NEED for FSBL fpga image
FPGA_PRJ = v0.94
FPGA_MODEL ?= Z10
DTS_PATH = dts
endif
ifeq ($(MODEL),Z20)
FPGA_PRJ_LST = v0.94 stream_app
# NEED for FSBL fpga image
FPGA_PRJ = v0.94
FPGA_MODEL ?= Z20
DTS_PATH = dts
endif
ifeq ($(MODEL),Z20_250_12)
FPGA_PRJ_LST = v0.94_250
# NEED for FSBL fpga image
FPGA_PRJ = v0.94
FPGA_MODEL ?= Z20_250
DTS_PATH = dts_250
endif
.PHONY: fpga $(INSTALL_DIR)/fpga
fpga: $(INSTALL_DIR)/fpga
$(INSTALL_DIR)/fpga: $(DTREE_DIR)
mkdir -p $(INSTALL_DIR)/fpga
# compile FPGA projects
for ITM in $(FPGA_PRJ_LST); do \
make -C fpga PRJ=$$ITM MODEL=$(FPGA_MODEL) HWID=$(HWID); \
mkdir -p $(INSTALL_DIR)/fpga/$$ITM; \
cp fpga/prj/$$ITM/out/red_pitaya.bit $(INSTALL_DIR)/fpga/$$ITM/fpga.bit; \
cp fpga/prj/$$ITM/sdk/fsbl/executable.elf $(INSTALL_DIR)/fpga/$$ITM/fsbl.elf; \
cp -r fpga/prj/$$ITM/sdk/dts $(INSTALL_DIR)/fpga/$$ITM ; \
cp fpga/prj/$$ITM/dts/* $(INSTALL_DIR)/fpga/$$ITM/dts/ ; \
tools/dtc/dtc -@ -I dts -O dtb -o $(INSTALL_DIR)/fpga/$$ITM/fpga.dtbo -i fpga/prj/$$ITM/dts -i fpga/dts fpga/prj/$$ITM/dts/fpga.dtso;\
done
# copy archived FPGA bitstream images and decompress them
cp fpga/archive/*.xz $(INSTALL_DIR)/fpga
cd $(INSTALL_DIR)/fpga; xz -df *.xz
# backward compatibility, TODO, should be removed at next OS release
ifneq ($(FPGA_MODEL),Z20_250)
cp $(INSTALL_DIR)/fpga/v0.94/fpga.bit $(INSTALL_DIR)/fpga/fpga_0.94.bit
cp $(INSTALL_DIR)/fpga/stream_app/fpga.bit $(INSTALL_DIR)/fpga/fpga_streaming.bit
ifeq ($(FPGA_MODEL), Z10)
cp $(INSTALL_DIR)/fpga/logic/fpga.bit $(INSTALL_DIR)/fpga/fpga_la.bit
cp $(INSTALL_DIR)/fpga/classic/fpga.bit $(INSTALL_DIR)/fpga/fpga_classic.bit
endif
else
cp $(INSTALL_DIR)/fpga/v0.94_250/fpga.bit $(INSTALL_DIR)/fpga/fpga_0.94.bit
mv $(INSTALL_DIR)/fpga/v0.94_250 $(INSTALL_DIR)/fpga/v0.94
endif
################################################################################
# U-Boot build provides: $(UBOOT)
################################################################################
UBOOT = $(TMP)/u-boot.elf
UBOOT_SCRIPT = $(INSTALL_DIR)/u-boot.scr
.PHONY: u-boot
u-boot: $(UBOOT) $(UBOOT_SCRIPT)
$(UBOOT_TAR): | $(DL)
curl -L $(UBOOT_URL) -o $@
$(UBOOT_DIR): $(UBOOT_TAR)
mkdir -p $@
tar -zxf $< --strip-components=1 --directory=$@
# Patch
patch -t -p0 -i "${PWD}/patches/u-boot/set-extra-env.patch" -d "$@"
$(UBOOT): $(UBOOT_DIR) $(TMP)
make -C $< arch=ARM zynq_red_pitaya_defconfig
make -C $< arch=ARM CFLAGS=$(UBOOT_CFLAGS)
cp $(UBOOT_DIR)/u-boot $@
$(UBOOT_SCRIPT): $(INSTALL_DIR) $(UBOOT_DIR) $(UBOOT)
$(UBOOT_DIR)/tools/mkimage -A ARM -O linux -T script -C none -a 0 -e 0 -n "boot Debian" -d patches/u-boot/u-boot.script $@
################################################################################
# Linux build provides: $(LINUX)
################################################################################
LINUX = $(LINUX_DIR)/arch/arm/boot/uImage
.PHONY: linux linux-install $(LINUX_DIR) $(LINUX)
linux: $(LINUX)
$(LINUX_TAR): | $(DL)
curl -L $(LINUX_URL) -o $@
$(LINUX_DIR): $(LINUX_TAR)
mkdir -p $@
tar -zxf $< --strip-components=1 --directory=$@
patch -t -p1 -i "${PWD}/patches/zynq-kernel-mempry-reserve-issue.patch" -d "${PWD}/$@"
patch -t -p1 -i "${PWD}/patches/zynq-kernel-i2c.patch" -d "${PWD}/$@"
patch -t -p1 -i "${PWD}/patches/xilinx_zynq_defconfig.patch" -d "${PWD}/$@" # patch for Wifi AP mode
ifeq ($(MODEL),Z20_250_12)
patch -t -p1 -i "${PWD}/patches/zynq-kernel-lantiq_250_12.patch" -d "${PWD}/$@"
endif
$(LINUX): $(LINUX_DIR)
make -C $< mrproper
make -C $< ARCH=arm xilinx_zynq_defconfig
make -C $< ARCH=arm CFLAGS=$(LINUX_CFLAGS) -j $(shell grep -c ^processor /proc/cpuinfo) UIMAGE_LOADADDR=0x8000 uImage
ifeq ($(KERNEL_HEADERS),YES)
make -C $< headers_install ARCH=arm INSTALL_HDR_PATH=$(abspath $(INSTALL_DIR))/include/linux
endif
linux-install: linux $(INSTALL_DIR)
cp $(LINUX_DIR)/arch/arm/boot/uImage $(INSTALL_DIR)
################################################################################
# device tree processing
################################################################################
DEVICETREE = $(TMP)/dts/devicetree.dtb
.PHONY: devicetree devicetree-install
devicetree: $(DEVICETREE)
$(DTREE_TAR): | $(DL)
curl -L $(DTREE_URL) -o $@
$(DTREE_DIR): $(DTREE_TAR)
mkdir -p $@
tar -zxf $< --strip-components=1 --directory=$@
$(DEVICETREE): $(DTREE_DIR) $(INSTALL_DIR)/fpga $(TMP)
cp -r $(INSTALL_DIR)/fpga/$(FPGA_PRJ)/dts $(TMP)
cat $(TMP)/dts/fpga.dts >> $(TMP)/dts/system-top.dts
cat fpga/$(DTS_PATH)/watchdog.dtsi >> $(TMP)/dts/system-top.dts
gcc -I $(TMP)/dts -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o $(TMP)/dts/system-top.dts.tmp $(TMP)/dts/system-top.dts
tools/dtc/dtc -@ -I dts -O dtb -o $(DEVICETREE) -i $(TMP)/dts -i fpga/$(DTS_PATH) $(TMP)/dts/system-top.dts.tmp
# create device tree source from binary for reference
tools/dtc/dtc -I dtb -O dts --sort -o $(TMP)/dts/dtraw.dts $(DEVICETREE)
devicetree-install: $(DEVICETREE) $(INSTALL_DIR)
cp $(DEVICETREE) $(INSTALL_DIR)
cp $(TMP)/dts/dtraw.dts $(INSTALL_DIR)
################################################################################
# boot file generator
################################################################################
BOOT = $(INSTALL_DIR)/boot.bin
.PHONY: boot
boot: $(BOOT)
FPGA = $(INSTALL_DIR)/fpga/$(FPGA_PRJ)/fpga.bit
FSBL = $(INSTALL_DIR)/fpga/$(FPGA_PRJ)/fsbl.elf
$(BOOT): $(INSTALL_DIR)/fpga $(UBOOT) $(INSTALL_DIR)
@echo img:{[bootloader] $(FSBL) $(FPGA) $(UBOOT) } > boot_uboot.bif
bootgen -image boot_uboot.bif -w -o $@
################################################################################
# tarball
################################################################################
ZIPFILE=ecosystem-$(VERSION).zip
zip: $(ZIPFILE)
$(ZIPFILE):
cp -r OS/filesystem/* $(INSTALL_DIR)
# create version file
@echo "$$GREET_MSG" > $(INSTALL_DIR)/version.txt
# build zip file
cd $(INSTALL_DIR); zip -r ../$(ZIPFILE) *
################################################################################
#
################################################################################
clean:
-make -C $(LINUX_DIR) clean
make -C fpga clean
-make -C $(UBOOT_DIR) clean
# todo, remove downloaded libraries and symlinks
$(RM) $(INSTALL_DIR) -rf