Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
234 lines (215 loc) · 11.3 KB
/
Copy pathMakefile
File metadata and controls
234 lines (215 loc) · 11.3 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
# dōgu top-level Makefile
# Delegates to each subdirectory's Makefile.
# Subdirectories that have something to build right now.
# Add to this list as new components come online.
SUBDIRS := tools/dma_listen liboriinit frame_decoder
SUBDIRS := tools/dma_listen liboriinit frame_decoder tools/frame_send tools/opv_play
# -----------------------------------------------------------------------
# Cross-compile defaults — used by `make cross`.
# Override on the command line if needed:
#
# make cross SYSROOT=/path/to/aarch64/sysroot
# make cross XILINX_GNU_DIR=/opt/Xilinx/Vitis/2023.2/.../bin
# make cross CROSS_COMPILE=/some/other/toolchain/aarch64-linux-gnu-
# -----------------------------------------------------------------------
# Path to the aarch64 sysroot containing libiio runtime + headers.
SYSROOT ?= $(HOME)/petalinux-sdk/sysroots/cortexa72-cortexa53-xilinx-linux
# Cross toolchain.
#
# We deliberately use the Xilinx/Vitis-bundled aarch64 Linux GNU toolchain,
# NOT Ubuntu's gcc-aarch64-linux-gnu apt package. Reason: that apt package
# conflicts with gcc-multilib (which PetaLinux requires), so installing one
# evicts the other — every switch between "build PetaLinux" and "build dogu"
# silently uninstalled the toolchain we needed. The Vitis toolchain lives
# outside apt, so the two coexist permanently. It is also GCC 11.2 / glibc,
# ABI-matched to the PetaLinux 2022.2 target rootfs.
#
# XILINX_GNU_DIR points at the directory holding aarch64-linux-gnu-gcc.
# Override it if your Xilinx install path or version differs.
XILINX_GNU_DIR ?= /opt/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-linux/bin
# Toolchain prefix. The compiler used will be $(CROSS_COMPILE)gcc.
CROSS_COMPILE ?= $(XILINX_GNU_DIR)/aarch64-linux-gnu-
# -----------------------------------------------------------------------
# Deploy defaults — used by `make deploy`.
# Override on the command line if needed:
#
# make deploy DEPLOY_HOST=root@haifuraiya.local
# make deploy DEPLOY_PATH=/opt/ori/dogu
# -----------------------------------------------------------------------
DEPLOY_HOST ?= root@10.73.1.16
DEPLOY_PATH ?= /home/root
# The VCK190 memory-loopback board (no ADRV9002, no libiio): `make deploy-vck190`
# ships only what runs there. Override as for deploy.
VCK190_HOST ?= root@10.73.1.17
# -----------------------------------------------------------------------
# Self-test defaults — used by `make test-frame-decoder`.
# Generates a known soft-symbol fixture from the repo's own host tools,
# decodes it both on the host (golden) and on the target, and asserts the
# two agree. Override frame count / station as needed.
# -----------------------------------------------------------------------
TEST_FRAMES ?= 20
TEST_STATION ?= W5NYV
.PHONY: all native cross deploy deploy-vck190 clean install help test test-frame-decoder $(SUBDIRS)
# Default: native build for host (matches pre-existing behavior).
all: native
native: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
# Cross-compile build for the aarch64 target (ZCU102 deployment).
# Each subdir respects the SYSROOT variable; see Makefile.dma_listen
# and Makefile.liboriinit for how it's wired up.
cross:
@for d in $(SUBDIRS); do \
echo "==> cross-compiling $$d"; \
$(MAKE) -C $$d \
CC="$(CROSS_COMPILE)gcc" \
SYSROOT="$(SYSROOT)" \
|| exit 1; \
done
@echo ""
@echo "Cross-compile complete. Verify aarch64:"
@echo " file tools/dma_listen/dma_listen liboriinit/oriinit-cli liboriinit/liboriinit.so"
# Deploy cross-compiled binaries + library to a target board over scp.
# Cleans up old versioned .so symlinks/copies first to avoid the
# dynamic linker picking up stale code from previous deployments.
#
# Run `make cross` first (deploy doesn't trigger a rebuild — keeps
# the workflow explicit about what's being shipped).
deploy:
@if [ ! -x liboriinit/oriinit-cli ] || [ ! -f liboriinit/liboriinit.so ]; then \
echo "ERROR: liboriinit artifacts missing — run 'make cross' first." >&2; \
exit 1; \
fi
@if [ ! -x tools/dma_listen/dma_listen ]; then \
echo "ERROR: dma_listen missing — run 'make cross' first." >&2; \
exit 1; \
fi
@if [ ! -x frame_decoder/opv-decode ]; then \
echo "ERROR: frame_decoder/opv-decode missing — run 'make cross' first." >&2; \
exit 1; \
fi
@echo "==> Deploying to $(DEPLOY_HOST):$(DEPLOY_PATH)"
@echo "==> Removing any stale liboriinit.so* files on target"
ssh $(DEPLOY_HOST) 'rm -f $(DEPLOY_PATH)/liboriinit.so*'
@echo "==> Copying binaries + library"
scp tools/dma_listen/dma_listen $(DEPLOY_HOST):$(DEPLOY_PATH)/dma_listen
scp tools/frame_send/frame_send $(DEPLOY_HOST):$(DEPLOY_PATH)/frame_send
scp liboriinit/oriinit-cli $(DEPLOY_HOST):$(DEPLOY_PATH)/oriinit-cli
scp liboriinit/liboriinit.so $(DEPLOY_HOST):$(DEPLOY_PATH)/liboriinit.so
@file frame_decoder/opv-decode | grep -q 'aarch64' || \
{ echo "ERROR: opv-decode is not aarch64 — run 'make cross' (host build clobbered it)"; exit 1; }
scp frame_decoder/opv-decode $(DEPLOY_HOST):$(DEPLOY_PATH)/opv-decode
scp bring-up.sh $(DEPLOY_HOST):$(DEPLOY_PATH)/bring-up.sh
@if [ -d profiles ]; then \
echo "==> Copying TES profiles"; \
for f in profiles/*.bin profiles/*.json; do \
[ -f "$$f" ] && scp "$$f" $(DEPLOY_HOST):$(DEPLOY_PATH)/; \
done; \
fi
ssh $(DEPLOY_HOST) 'chmod +x $(DEPLOY_PATH)/bring-up.sh'
@echo ""
@echo "Deploy complete. Verify on the target:"
@echo " ssh $(DEPLOY_HOST) 'ls -la $(DEPLOY_PATH)/{dma_listen,oriinit-cli,liboriinit.so}'"
@echo " ssh $(DEPLOY_HOST) '$(DEPLOY_PATH)/oriinit-cli status'"
@echo " ssh $(DEPLOY_HOST) '$(DEPLOY_PATH)/opv-decode -q -r < test_soft.s16 | wc -c' # 134 bytes/frame"
@echo " make test-frame-decoder # end-to-end: host-golden vs on-target decode"
@echo " bring-up.sh tes_0231_Haifuraiya_FDD_LVDS_20Msps_10MHz"
# Deploy to the VCK190 memory-loopback board: opv_play (the player/capturer)
# and opv-decode (the A72 is aarch64 like the A53, same binary). Nothing
# ADRV9002-related goes -- there is no radio on that platform yet.
deploy-vck190:
@if [ ! -x tools/opv_play/opv_play ]; then \
echo "ERROR: opv_play missing -- run 'make cross' first." >&2; exit 1; fi
@file tools/opv_play/opv_play | grep -q 'aarch64' || \
{ echo "ERROR: opv_play is not aarch64 -- run 'make clean && make cross'"; exit 1; }
@echo "==> Deploying to $(VCK190_HOST):$(DEPLOY_PATH)"
scp tools/opv_play/opv_play $(VCK190_HOST):$(DEPLOY_PATH)/opv_play
@if [ -x frame_decoder/opv-decode ] && file frame_decoder/opv-decode | grep -q 'aarch64'; then \
scp frame_decoder/opv-decode $(VCK190_HOST):$(DEPLOY_PATH)/opv-decode; \
else echo " (opv-decode not cross-built; skipping)"; fi
@echo ""
@echo "Deploy complete. On the target:"
@echo " ssh $(VCK190_HOST) 'ls /dev/uio0 /dev/dma_proxy_tx /dev/dma_proxy_rx'"
@echo " ssh $(VCK190_HOST) '$(DEPLOY_PATH)/opv_play -i /tmp/stim.bin -o /tmp/soft.bin -q'"
# -----------------------------------------------------------------------
# Self-test: prove the deployed opv-decode runs on the A53 and produces the
# exact same frames as the host reference build.
# 1. build host opv-mod / opv-demod / opv-decode from the submodule
# 2. mod TEST_FRAMES frames -> demod (-X taps the int16 soft stream the
# fabric will emit) -> host opv-decode = golden frames
# 3. ship the soft fixture to the target, decode with the deployed aarch64
# opv-decode, pull the frames back
# 4. assert: target frame count == TEST_FRAMES AND target == host golden
# Requires `make cross && make deploy` first. The soft fixture is the same
# bytes both sides decode, so a correct cross-arch decode is bit-identical.
# -----------------------------------------------------------------------
test: test-frame-decoder
test-frame-decoder:
@echo "==> Building host reference tools from the submodule"
@$(MAKE) -s -C frame_decoder/opv-cxx-demod bin/opv-mod bin/opv-demod bin/opv-decode >/dev/null
@OPV=frame_decoder/opv-cxx-demod; \
echo "==> Generating $(TEST_FRAMES)-frame soft fixture (station $(TEST_STATION))"; \
$$OPV/bin/opv-mod -S $(TEST_STATION) -B $(TEST_FRAMES) 2>/dev/null \
| $$OPV/bin/opv-demod -s -c -q -X /tmp/dogu_fd_soft.s16 >/dev/null 2>&1; \
$$OPV/bin/opv-decode -q -r < /tmp/dogu_fd_soft.s16 > /tmp/dogu_fd_golden.bin 2>/dev/null; \
GF=$$(( $$(wc -c < /tmp/dogu_fd_golden.bin) / 134 )); \
echo " host golden: $$GF frames"; \
echo "==> Shipping fixture to $(DEPLOY_HOST) and decoding on target"; \
scp -q /tmp/dogu_fd_soft.s16 $(DEPLOY_HOST):$(DEPLOY_PATH)/test_soft.s16; \
ssh $(DEPLOY_HOST) '$(DEPLOY_PATH)/opv-decode -q -r < $(DEPLOY_PATH)/test_soft.s16 > $(DEPLOY_PATH)/test_frames.bin 2>/dev/null'; \
scp -q $(DEPLOY_HOST):$(DEPLOY_PATH)/test_frames.bin /tmp/dogu_fd_target.bin; \
TF=$$(( $$(wc -c < /tmp/dogu_fd_target.bin) / 134 )); \
echo " target: $$TF frames"; \
if cmp -s /tmp/dogu_fd_golden.bin /tmp/dogu_fd_target.bin && [ "$$TF" -eq "$(TEST_FRAMES)" ]; then \
echo "✓ frame_decoder: A53 decode is bit-identical to host reference ($$TF/$(TEST_FRAMES) frames)"; \
else \
echo "✗ frame_decoder: mismatch (host $$GF, target $$TF) — investigate"; exit 1; \
fi
clean:
@for d in $(SUBDIRS); do \
$(MAKE) -C $$d clean; \
done
install:
@for d in $(SUBDIRS); do \
$(MAKE) -C $$d install; \
done
help:
@echo "dōgu — ORI ARM-side tooling for ADRV9001/9002 SDR builds"
@echo ""
@echo "Targets:"
@echo " all / native build all subdirectories for the host (default)"
@echo " useful for syntax checking and local development"
@echo ""
@echo " cross cross-compile all subdirectories for aarch64"
@echo " uses:"
@echo " CC = \$$(CROSS_COMPILE)gcc"
@echo " SYSROOT = \$$(SYSROOT)"
@echo " defaults:"
@echo " XILINX_GNU_DIR = /opt/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-linux/bin"
@echo " CROSS_COMPILE = \$$(XILINX_GNU_DIR)/aarch64-linux-gnu-"
@echo " SYSROOT = \$$HOME/aarch64-sysroot"
@echo " (Vitis-bundled toolchain, not Ubuntu's apt cross-gcc —"
@echo " the apt one conflicts with gcc-multilib / PetaLinux)"
@echo ""
@echo " deploy ship cross-compiled binaries to the target board"
@echo " removes stale liboriinit.so* first to avoid the"
@echo " dynamic linker picking up old code"
@echo " uses:"
@echo " DEPLOY_HOST = \$$(DEPLOY_HOST)"
@echo " DEPLOY_PATH = \$$(DEPLOY_PATH)"
@echo " defaults:"
@echo " DEPLOY_HOST = root@10.73.1.16"
@echo " DEPLOY_PATH = /home/root"
@echo ""
@echo " clean clean all subdirectories"
@echo " install install all subdirectories' artifacts"
@echo " help this message"
@echo ""
@echo "Common invocations:"
@echo " make # native build for host"
@echo " make clean && make cross # cross-compile for ZCU102 (aarch64)"
@echo " make deploy # ship to the ZCU102"
@echo " make clean && make cross && make deploy # full rebuild + ship"
@echo " make deploy-vck190 # ship opv_play (+ opv-decode) to the VCK190 (VCK190_HOST)"
@echo ""
@echo "Subdirectories: $(SUBDIRS)"