-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
161 lines (136 loc) · 5.14 KB
/
Copy pathMakefile
File metadata and controls
161 lines (136 loc) · 5.14 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
# MIT License
# Copyright (c) 2025 Avnet / Tria
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
PL_BLD ?= petalinux-build
PL_PKG ?= petalinux-package
PL_CFG ?= petalinux-config
SYSTEM_XSA_LOC ?= project-spec/hw-description/system.xsa
LOCAL_SSTATE ?= $(HOME)/local_2025p2_aarch64
LOCAL_DL ?= $(HOME)/local_2025p2_downloads
IMAGES_DIR ?= images/linux
FIRMWARE_DIR ?= final-firmwares
# If you change VIVADO_DIR be sure to update get-git-hash.bb
VIVADO_DIR ?= vivado-hw
VIVADO_GIT_REPO ?= git@github.com:Avnet/ve2302_oob_hw
VIVADO_GIT_BRANCH_TAG ?= 2025.2
VIVADO_XSA_LOC ?= $(VIVADO_DIR)/ve2302_oob.xsa
PL_PACKAGE_LOC := $(shell which petalinux-package)
WIC_LOC ?= $(FIRMWARE_DIR)/ve2302-oob-sdimage.wic
BOOT_BIN_LOC ?= $(FIRMWARE_DIR)/BOOT.BIN
VIVADO_TOOLS := $(shell which vivado)
PL_TOOLS := $(shell which petalinux-build)
HELP_COLOR ?= 10
.PHONY: all clean realclean update_vivado_repo build_vivado realrealclean \
vivado_clean create_firmware check_tools
# Targets
all: check_tools .petalinux/metadata build_vivado $(SYSTEM_XSA_LOC) build_bsp create_firmware
@echo
@tput setaf 2 ; echo "Built $(WIC_LOC) successfully!"; tput sgr0;
@echo
# Only bother to check when user enters single 'make'
check_tools:
@$(call check_tools)
create_firmware: $(BOOT_BIN_LOC) $(WIC_LOC)
@echo "Final firmwares completed"
update_vivado_repo: | $(VIVADO_DIR)
@cd $(VIVADO_DIR) ;\
git pull
build_vivado: | $(VIVADO_DIR)
@cd $(VIVADO_DIR) ; make -f Makefile ;\
# Always execute PetaLinux and let it decide dependancies and what to do
build_bsp: | $(LOCAL_SSTATE) $(LOCAL_DL)
$(PL_BLD)
# This allows every user to modify per build
.petalinux/metadata: | .petalinux/metadata.original
cp .petalinux/metadata.original .petalinux/metadata
$(VIVADO_DIR):
git clone $(VIVADO_GIT_REPO) -b $(VIVADO_GIT_BRANCH_TAG) $(VIVADO_DIR)
$(VIVADO_XSA_LOC): | build_vivado
@if [ -f $(VIVADO_XSA_LOC) ]; then\
echo "XSA generated";\
else\
echo "XSA does not exist, check on the build under $(VIVADO_DIR)";\
fi
$(SYSTEM_XSA_LOC): $(VIVADO_XSA_LOC) | $(VIVADO_DIR)
$(PL_CFG) --silentconfig --get-hw-description $(VIVADO_DIR)
$(BOOT_BIN_LOC): $(IMAGES_DIR)/boot.scr $(IMAGES_DIR)/psmfw.elf $(IMAGES_DIR)/plm.elf \
$(IMAGES_DIR)/u-boot.elf $(IMAGES_DIR)/u-boot-dtb.elf $(IMAGES_DIR)/bl31.elf | $(FIRMWARE_DIR)
$(PL_PKG) boot --format BIN --plm --psmfw --u-boot --dtb --force
@if [ -f $(IMAGES_DIR)/BOOT.BIN ]; then\
cp $(IMAGES_DIR)/BOOT.BIN $(BOOT_BIN_LOC) ;\
cp -f $(IMAGES_DIR)/boot.scr $(FIRMWARE_DIR)/boot.scr ;\
cp -f $(IMAGES_DIR)/image.ub $(FIRMWARE_DIR)/image.ub ;\
else\
@echo "ERROR: creating $(BOOT_BIN_LOC)";\
fi
$(WIC_LOC): $(BOOT_BIN_LOC) $(IMAGES_DIR)/image.ub $(IMAGES_DIR)/system.dtb | $(FIRMWARE_DIR)
$(PL_PKG) wic --extra-bootfiles "image.ub" --size 1G,1G --outdir $(FIRMWARE_DIR)
mv $(FIRMWARE_DIR)/petalinux-sdimage.wic $(WIC_LOC)
$(FIRMWARE_DIR):
mkdir $(FIRMWARE_DIR)
$(LOCAL_SSTATE):
@echo
@echo "HINT:"
@echo "To speed up the build, use local aarch64 ..."
@echo "First download and install the aarch64 SSTATE tarball and"
@echo "then: ln -s <full path, including ./aarch64> ~/local_2025p2_aarch64"
@echo
$(LOCAL_DL):
@echo
@echo "HINT:"
@echo "To speed up the build, use local downloads ..."
@echo "First download and install the Downloads tarball and"
@echo "then: ln -s <full path, including ./downloads> ~/local_2025p2_downloads"
@echo
clean:
rm -f $(IMAGES_DIR)/BOOT.BIN
rm -rf $(FIRMWARE_DIR)
realclean:
$(MAKE) clean
$(MAKE) vivado_clean
$(PL_BLD) -x distclean
$(PL_BLD) -x mrproper
vivado_clean:
@if [ -d $(VIVADO_DIR) ]; then\
cd $(VIVADO_DIR) ; make clean;\
fi
realrealclean:
$(MAKE) clean
rm -f .petalinux/metadata
rm -rf $(VIVADO_DIR) build components .Xil
define check_tools
@if [[ -z "$(VIVADO_TOOLS)" ]]; then\
echo "ERROR: cannot find Vivado!";\
echo " Please source the Vitis/Vivado settings64.sh";\
fi;\
if [[ -z "$(PL_TOOLS)" ]]; then\
echo "ERROR: cannot find PetaLinux!";\
echo " Please source the PetaLinux settings.sh";\
fi;\
if [[ -z "$(PL_TOOLS)" ]] || [[ -z "$(VIVADO_TOOLS)" ]]; then\
exit -1;\
fi
endef
help:
@echo
@tput setaf $(HELP_COLOR);
@echo "To build the VE2302 Kit firmware just type and enter: make"
@tput sgr0;
@echo