-
Notifications
You must be signed in to change notification settings - Fork 100
/
Makefile
239 lines (208 loc) · 8.11 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
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
# Opsero Electronic Design Inc. 2024
#
# This Makefile can be used to build all projects and gather the boot images.
RM = rm -rf
ROOT_DIR = $(shell pwd)
BD_NAME = fpgadrv
# defaults
.DEFAULT_GOAL := bootimage
TARGET ?= none
JOBS ?= 8
# valid targets (template name, both (plnx+baremetal) or baremetal_only)
# UPDATER START
auboard_target := microblaze baremetal_only
kc705_hpc_target := microblaze baremetal_only
kc705_lpc_target := microblaze baremetal_only
kcu105_hpc_target := microblaze baremetal_only
kcu105_lpc_target := microblaze baremetal_only
pz_7015_target := zynq both
pz_7030_target := zynq both
uzev_target := zynqMP both
vc707_hpc1_target := microblaze baremetal_only
vc707_hpc2_target := microblaze baremetal_only
vc709_hpc_target := microblaze baremetal_only
vck190_fmcp1_target := versal both
vck190_fmcp2_target := versal both
vhk158_target := versal both
vmk180_fmcp1_target := versal both
vmk180_fmcp2_target := versal both
vek280_target := versal both
vek280_es_revb_target := versal both
vpk120_target := versal both
vpk180_target := versal both
vcu118_target := microblaze baremetal_only
zc706_hpc_target := zynq both
zc706_lpc_target := zynq both
zcu104_target := zynqMP both
zcu106_hpc0_target := zynqMP both
zcu106_hpc1_target := zynqMP both
zcu111_target := zynqMP both
zcu208_target := zynqMP both
zcu216_target := zynqMP both
# UPDATER END
TARGET_LIST := $(sort $(patsubst %_target,%,$(filter %_target,$(.VARIABLES))))
# petalinux paths and files
PETL_ROOT = $(ROOT_DIR)/PetaLinux
PETL_DIR = $(PETL_ROOT)/$(TARGET)
PETL_IMG_DIR = $(PETL_DIR)/images/linux
PETL_BL31_ELF = $(PETL_IMG_DIR)/bl31.elf
PETL_PMUFW_ELF = $(PETL_IMG_DIR)/pmufw.elf
PETL_ZYNQMP_FSBL_ELF = $(PETL_IMG_DIR)/zynqmp_fsbl.elf
PETL_ZYNQ_FSBL_ELF = $(PETL_IMG_DIR)/zynq_fsbl.elf
PETL_FSBOOT_ELF = $(PETL_IMG_DIR)/fs-boot.elf
PETL_UBOOT_ELF = $(PETL_IMG_DIR)/u-boot.elf
PETL_DTB = $(PETL_IMG_DIR)/system.dtb
PETL_BOOT_BIN = $(PETL_IMG_DIR)/BOOT.BIN
PETL_BOOT_SCR = $(PETL_IMG_DIR)/boot.scr
PETL_BOOT_MCS = $(PETL_IMG_DIR)/boot.mcs
PETL_BOOT_PRM = $(PETL_IMG_DIR)/boot.prm
PETL_IMAGE_ELF = $(PETL_IMG_DIR)/image.elf
PETL_SYSTEM_BIT = $(PETL_IMG_DIR)/system.bit
PETL_ROOTFS = $(PETL_IMG_DIR)/rootfs.tar.gz
PETL_IMAGE_UB = $(PETL_IMG_DIR)/image.ub
# vitis paths and files
VIT_ROOT = $(ROOT_DIR)/Vitis
VIT_BOOT = $(VIT_ROOT)/boot
VIT_BOOT_TARG = $(VIT_BOOT)/$(TARGET)
# outputs
BOOTIMAGE_DIR = $(ROOT_DIR)/bootimages
TEMPBOOT_DIR = $(BOOTIMAGE_DIR)/$(BD_NAME)_$(TARGET)
PETL_ZIP = $(BOOTIMAGE_DIR)/$(BD_NAME)_$(TARGET)_petalinux-2024-1.zip
BARE_ZIP = $(BOOTIMAGE_DIR)/$(BD_NAME)_$(TARGET)_standalone-2024-1.zip
BOOTIMAGE_LOCK = $(ROOT_DIR)/.$(TARGET).lock
# These macros return values from the valid target lists defined above
define get_template_name
$(word 1,$($(1)_target))
endef
define get_both_or_baremetal_only
$(word 2,$($(1)_target))
endef
# The name of the boot image of the baremetal app depends on the device
ifeq ($(call get_template_name,$(TARGET)), microblaze)
VIT_BOOT_FILE = $(VIT_BOOT_TARG)/$(TARGET).bit
else ifeq ($(call get_template_name,$(TARGET)), zynq)
VIT_BOOT_FILE = $(VIT_BOOT_TARG)/BOOT.BIN
else ifeq ($(call get_template_name,$(TARGET)), zynqMP)
VIT_BOOT_FILE = $(VIT_BOOT_TARG)/BOOT.BIN
else ifeq ($(call get_template_name,$(TARGET)), versal)
VIT_BOOT_FILE = $(VIT_BOOT_TARG)/BOOT.BIN
endif
.PHONY: help
help:
@echo 'Usage:'
@echo ''
@echo ' make bootimage TARGET=<val> JOBS=<val>'
@echo ' Build and gather boot image files for given target.'
@echo ''
@echo ' make all JOBS=<val>'
@echo ' Build and gather boot image files for all targets.'
@echo ''
@echo ' make clean TARGET=<val>'
@echo ' Delete boot image files for given target.'
@echo ''
@echo ' make clean_all'
@echo ' Delete boot image files for all targets.'
@echo ''
@echo 'Parameters:'
@echo ''
@echo ' TARGET: Name of the target design, must be one of the following:'
@$(foreach targ,$(TARGET_LIST),echo " - $(targ)";)
@echo ''
@echo ' JOBS: Optional param to set number of synthesis jobs (default 8)'
@echo ''
@echo 'Example usage:'
@echo ' make bootimage TARGET=$(word 1,$(TARGET_LIST))'
@echo ''
.PHONY: all
all:
@{ \
for targ in $(TARGET_LIST); do \
$(MAKE) --no-print-directory bootimage TARGET=$${targ} JOBS=$(JOBS); \
done; \
}
.PHONY: bootimage
bootimage: check_target
@if [ -f $(BOOTIMAGE_LOCK) ]; then \
echo "$(TARGET) is locked. Skipping..."; \
else \
touch $(BOOTIMAGE_LOCK); \
$(MAKE) bootimage_locked TARGET=$(TARGET) JOBS=$(JOBS); \
rm -f $(BOOTIMAGE_LOCK); \
fi
bootimage_locked: bootimage_$(call get_both_or_baremetal_only,$(TARGET))
bootimage_baremetal_only: $(BARE_ZIP)
bootimage_both: $(PETL_ZIP) $(BARE_ZIP)
ifeq ($(call get_template_name,$(TARGET)), microblaze)
$(PETL_ZIP): $(PETL_BOOT_MCS) $(PETL_BOOT_PRM) $(PETL_IMAGE_ELF) $(PETL_SYSTEM_BIT)
@echo 'Gather PetaLinux output products for $(TARGET)'
mkdir -p $(TEMPBOOT_DIR)/flash
mkdir -p $(TEMPBOOT_DIR)/jtag
cp $(PETL_BOOT_MCS) $(TEMPBOOT_DIR)/flash/.
cp $(PETL_BOOT_PRM) $(TEMPBOOT_DIR)/flash/.
cp $(PETL_IMAGE_ELF) $(TEMPBOOT_DIR)/jtag/.
cp $(PETL_SYSTEM_BIT) $(TEMPBOOT_DIR)/jtag/.
@echo 'Program the flash with this MCS file to boot from flash' > $(TEMPBOOT_DIR)/flash/readme.txt
@echo 'Load these files via JTAG to boot PetaLinux from JTAG' > $(TEMPBOOT_DIR)/jtag/readme.txt
cd $(TEMPBOOT_DIR) && zip -r $(PETL_ZIP) .
rm -r $(TEMPBOOT_DIR)
else ifeq ($(call get_template_name,$(TARGET)), zynq)
$(PETL_ZIP): $(PETL_BOOT_BIN) $(PETL_IMAGE_UB)
@echo 'Gather PetaLinux output products for $(TARGET)'
mkdir -p $(TEMPBOOT_DIR)/boot
mkdir -p $(TEMPBOOT_DIR)/root
cp $(PETL_BOOT_BIN) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_IMAGE_UB) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_BOOT_SCR) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_ROOTFS) $(TEMPBOOT_DIR)/root/.
@echo 'Copy these files to the boot (FAT32) partition of the SD card' > $(TEMPBOOT_DIR)/boot/readme.txt
@echo 'Extract contents of rootfs.tar.gz to the root partition of the SD card' > $(TEMPBOOT_DIR)/root/readme.txt
cd $(TEMPBOOT_DIR) && zip -r $(PETL_ZIP) .
rm -r $(TEMPBOOT_DIR)
else ifeq ($(call get_template_name,$(TARGET)), zynqMP)
$(PETL_ZIP): $(PETL_BOOT_BIN) $(PETL_IMAGE_UB)
@echo 'Gather PetaLinux output products for $(TARGET)'
mkdir -p $(TEMPBOOT_DIR)/boot
mkdir -p $(TEMPBOOT_DIR)/root
cp $(PETL_BOOT_BIN) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_IMAGE_UB) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_BOOT_SCR) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_ROOTFS) $(TEMPBOOT_DIR)/root/.
@echo 'Copy these files to the boot (FAT32) partition of the SD card' > $(TEMPBOOT_DIR)/boot/readme.txt
@echo 'Extract contents of rootfs.tar.gz to the root partition of the SD card' > $(TEMPBOOT_DIR)/root/readme.txt
cd $(TEMPBOOT_DIR) && zip -r $(PETL_ZIP) .
rm -r $(TEMPBOOT_DIR)
else ifeq ($(call get_template_name,$(TARGET)), versal)
$(PETL_ZIP): $(PETL_BOOT_BIN) $(PETL_IMAGE_UB)
@echo 'Gather PetaLinux output products for $(TARGET)'
mkdir -p $(TEMPBOOT_DIR)/boot
mkdir -p $(TEMPBOOT_DIR)/root
cp $(PETL_BOOT_BIN) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_IMAGE_UB) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_BOOT_SCR) $(TEMPBOOT_DIR)/boot/.
cp $(PETL_ROOTFS) $(TEMPBOOT_DIR)/root/.
@echo 'Copy these files to the boot (FAT32) partition of the SD card' > $(TEMPBOOT_DIR)/boot/readme.txt
@echo 'Extract contents of rootfs.tar.gz to the root partition of the SD card' > $(TEMPBOOT_DIR)/root/readme.txt
cd $(TEMPBOOT_DIR) && zip -r $(PETL_ZIP) .
rm -r $(TEMPBOOT_DIR)
endif
PETL_BUILD_DEPS = $(PETL_BOOT_MCS) $(PETL_BOOT_PRM) $(PETL_IMAGE_ELF) $(PETL_SYSTEM_BIT) \
$(PETL_BOOT_BIN) $(PETL_IMAGE_UB)
$(PETL_BUILD_DEPS):
$(MAKE) --no-print-directory -C $(PETL_ROOT) petalinux TARGET=$(TARGET) JOBS=$(JOBS)
$(BARE_ZIP): $(VIT_BOOT_FILE)
@echo 'Gather standalone application output products for $(TARGET)'
mkdir -p $(BOOTIMAGE_DIR)
cd $(VIT_BOOT_TARG) && zip -r $(BARE_ZIP) .
$(VIT_BOOT_FILE):
$(MAKE) --no-print-directory -C $(VIT_ROOT) workspace TARGET=$(TARGET) JOBS=$(JOBS)
@if [ ! -e $@ ]; then echo "Error: $@ was not created for $(TARGET)."; exit 1; fi
.PHONY: clean
clean: check_target
$(RM) $(PETL_ZIP) $(BARE_ZIP)
.PHONY: clean_all
clean_all:
$(RM) $(BOOTIMAGE_DIR)
check_target:
ifndef $(TARGET)_target
$(error "Please specify a TARGET. Use 'make help' to see valid targets.")
endif