forked from pavel-demin/red-pitaya-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
165 lines (131 loc) · 5.66 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
# 'make' builds everything
# 'make clean' deletes everything except source files and Makefile
#
# You need to set NAME, PART and PROC for your project.
# NAME is the base name for most of the generated files.
# solves problem with awk while building linux kernel
# solution taken from http://www.googoolia.com/wp/2015/04/21/awk-symbol-lookup-error-awk-undefined-symbol-mpfr_z_sub/
LD_LIBRARY_PATH =
NAME = led_blinker
PART = xc7z010clg400-1
PROC = ps7_cortexa9_0
CORES = axi_axis_reader_v1_0 axi_axis_writer_v1_0 axi_bram_reader_v1_0 \
axi_bram_writer_v1_0 axi_cfg_register_v1_0 axi_sts_register_v1_0 \
axis_accumulator_v1_0 axis_adder_v1_0 axis_alex_v1_0 axis_averager_v1_0 \
axis_bram_reader_v1_0 axis_bram_writer_v1_0 axis_constant_v1_0 \
axis_counter_v1_0 axis_decimator_v1_0 axis_fifo_v1_0 \
axis_gate_controller_v1_0 axis_gpio_reader_v1_0 axis_histogram_v1_0 \
axis_i2s_v1_0 axis_iir_filter_v1_0 axis_interpolator_v1_0 axis_keyer_v1_0 \
axis_lfsr_v1_0 axis_maxabs_finder_v1_0 axis_negator_v1_0 \
axis_oscilloscope_v1_0 axis_packetizer_v1_0 axis_pdm_v1_0 \
axis_phase_generator_v1_0 axis_pps_counter_v1_0 axis_pulse_generator_v1_0 \
axis_pulse_height_analyzer_v1_0 axis_ram_writer_v1_0 \
axis_red_pitaya_adc_v3_0 axis_red_pitaya_dac_v2_0 axis_stepper_v1_0 \
axis_tagger_v1_0 axis_timer_v1_0 axis_trigger_v1_0 axis_validator_v1_0 \
axis_variable_v1_0 axis_variant_v1_0 axis_zeroer_v1_0 dna_reader_v1_0 \
edge_detector_v1_0 gpio_debouncer_v1_0 port_selector_v1_0 port_slicer_v1_0 \
pulse_generator_v1_0 shift_register_v1_0
VIVADO = vivado -nolog -nojournal -mode batch
XSCT = xsct
RM = rm -rf
UBOOT_TAG = 2021.04
LINUX_TAG = 5.10
DTREE_TAG = xilinx-v2020.2
UBOOT_DIR = tmp/u-boot-$(UBOOT_TAG)
LINUX_DIR = tmp/linux-$(LINUX_TAG)
DTREE_DIR = tmp/device-tree-xlnx-$(DTREE_TAG)
UBOOT_TAR = tmp/u-boot-$(UBOOT_TAG).tar.bz2
LINUX_TAR = tmp/linux-$(LINUX_TAG).tar.xz
DTREE_TAR = tmp/device-tree-xlnx-$(DTREE_TAG).tar.gz
UBOOT_URL = https://ftp.denx.de/pub/u-boot/u-boot-$(UBOOT_TAG).tar.bz2
LINUX_URL = https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-$(LINUX_TAG).80.tar.xz
DTREE_URL = https://github.com/Xilinx/device-tree-xlnx/archive/$(DTREE_TAG).tar.gz
RTL8188_TAR = tmp/rtl8188eu-v5.2.2.4.tar.gz
RTL8188_URL = https://github.com/lwfinger/rtl8188eu/archive/v5.2.2.4.tar.gz
RTL8192_TAR = tmp/rtl8192cu-fixes-master.tar.gz
RTL8192_URL = https://github.com/pvaret/rtl8192cu-fixes/archive/master.tar.gz
.PRECIOUS: tmp/cores/% tmp/%.xpr tmp/%.xsa tmp/%.bit tmp/%.fsbl/executable.elf tmp/%.tree/system-top.dts
all: tmp/$(NAME).bit boot.bin uImage devicetree.dtb
cores: $(addprefix tmp/cores/, $(CORES))
xpr: tmp/$(NAME).xpr
bit: tmp/$(NAME).bit
$(UBOOT_TAR):
mkdir -p $(@D)
curl -L $(UBOOT_URL) -o $@
$(LINUX_TAR):
mkdir -p $(@D)
curl -L $(LINUX_URL) -o $@
$(DTREE_TAR):
mkdir -p $(@D)
curl -L $(DTREE_URL) -o $@
$(RTL8188_TAR):
mkdir -p $(@D)
curl -L $(RTL8188_URL) -o $@
$(RTL8192_TAR):
mkdir -p $(@D)
curl -L $(RTL8192_URL) -o $@
$(UBOOT_DIR): $(UBOOT_TAR)
mkdir -p $@
tar -jxf $< --strip-components=1 --directory=$@
patch -d tmp -p 0 < patches/u-boot-$(UBOOT_TAG).patch
cp patches/zynq_red_pitaya_defconfig $@/configs
cp patches/zynq-red-pitaya.dts $@/arch/arm/dts
$(LINUX_DIR): $(LINUX_TAR) $(RTL8188_TAR) $(RTL8192_TAR)
mkdir -p $@
tar -Jxf $< --strip-components=1 --directory=$@
mkdir -p $@/drivers/net/wireless/realtek/rtl8188eu
mkdir -p $@/drivers/net/wireless/realtek/rtl8192cu
tar -zxf $(RTL8188_TAR) --strip-components=1 --directory=$@/drivers/net/wireless/realtek/rtl8188eu
tar -zxf $(RTL8192_TAR) --strip-components=1 --directory=$@/drivers/net/wireless/realtek/rtl8192cu
patch -d tmp -p 0 < patches/linux-$(LINUX_TAG).patch
cp patches/zynq_ocm.c $@/arch/arm/mach-zynq
cp patches/cma.c $@/drivers/char
cp patches/xilinx_devcfg.c $@/drivers/char
cp patches/xilinx_zynq_defconfig $@/arch/arm/configs
$(DTREE_DIR): $(DTREE_TAR)
mkdir -p $@
tar -zxf $< --strip-components=1 --directory=$@
uImage: $(LINUX_DIR)
make -C $< mrproper
make -C $< ARCH=arm xilinx_zynq_defconfig
make -C $< ARCH=arm -j $(shell nproc 2> /dev/null || echo 1) \
CROSS_COMPILE=arm-linux-gnueabihf- UIMAGE_LOADADDR=0x8000 \
uImage modules
cp $</arch/arm/boot/uImage $@
$(UBOOT_DIR)/u-boot.bin: $(UBOOT_DIR)
mkdir -p $(@D)
make -C $< mrproper
make -C $< ARCH=arm zynq_red_pitaya_defconfig
make -C $< ARCH=arm -j $(shell nproc 2> /dev/null || echo 1) \
CROSS_COMPILE=arm-linux-gnueabihf- all
boot.bin: tmp/$(NAME).fsbl/executable.elf $(UBOOT_DIR)/u-boot.bin
echo "img:{[bootloader] tmp/$(NAME).fsbl/executable.elf [load=0x4000000,startup=0x4000000] $(UBOOT_DIR)/u-boot.bin}" > tmp/boot.bif
bootgen -image tmp/boot.bif -w -o i $@
devicetree.dtb: uImage tmp/$(NAME).tree/system-top.dts
$(LINUX_DIR)/scripts/dtc/dtc -I dts -O dtb -o devicetree.dtb \
-i tmp/$(NAME).tree tmp/$(NAME).tree/system-top.dts
tmp/cores/%: cores/%/core_config.tcl cores/%/*.v
mkdir -p $(@D)
$(VIVADO) -source scripts/core.tcl -tclargs $* $(PART)
tmp/%.xpr: projects/% $(addprefix tmp/cores/, $(CORES))
mkdir -p $(@D)
$(VIVADO) -source scripts/project.tcl -tclargs $* $(PART)
tmp/%.xsa: tmp/%.xpr
mkdir -p $(@D)
$(VIVADO) -source scripts/hwdef.tcl -tclargs $*
tmp/%.bit: tmp/%.xpr
mkdir -p $(@D)
$(VIVADO) -source scripts/bitstream.tcl -tclargs $*
tmp/%.fsbl/executable.elf: tmp/%.xsa
mkdir -p $(@D)
$(XSCT) scripts/fsbl.tcl $* $(PROC)
tmp/%.tree/system-top.dts: tmp/%.xsa $(DTREE_DIR)
mkdir -p $(@D)
$(XSCT) scripts/devicetree.tcl $* $(PROC) $(DTREE_DIR)
sed -i 's|#include|/include/|' $@
patch -d $(@D) < patches/devicetree.patch
clean:
$(RM) uImage boot.bin devicetree.dtb tmp
$(RM) .Xil usage_statistics_webtalk.html usage_statistics_webtalk.xml
$(RM) vivado*.jou vivado*.log
$(RM) webtalk*.jou webtalk*.log