Repository navigation
Expand file tree
/
Copy pathlemans.mk
More file actions
1802 lines (1668 loc) · 88.7 KB
/
Copy pathlemans.mk
File metadata and controls
1802 lines (1668 loc) · 88.7 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
################################################################################
# lemans.mk — Build system for Qualcomm SA8775P Lemans EVK (QCS9075)
#
# Produces two independent boot artifacts:
#
# EFI path:
# lemans/output/efi.bin Distro FAT image updated with the new uki.efi (UKI)
#
# Boot-image path:
# lemans/output/tz.mbn qtestsign-signed U-Boot SPL (tz partition image)
# lemans/output/uefi.elf SPL_ATF boot FIT: BL31 + OP-TEE + U-Boot proper
# (uefi partition image; a FIT despite the .elf name)
#
# Boot sequence: XBL → U-Boot SPL → TF-A BL31 → OP-TEE OS → U-Boot proper → Linux
# U-Boot SPL replaces TF-A BL2 as the first open-source stage.
# TF-A BL31 (Secure Monitor) remains resident at EL3 after boot.
# Signing uses qtestsign (open-source, local — no QTI CASS access required).
#
# Main targets
# ─────────────────────────────────────────────────────────────────────────────
# all Build OP-TEE OS, TF-A BL31, U-Boot (SPL + proper), Linux, Buildroot, and efi.bin
# clean Clean all components
#
# efi (Re)build the UKI and inject it into lemans/output/efi.bin
# bootimage Build and sign lemans/output/tz.mbn + uefi.elf
#
# optee-os Build OP-TEE OS
# tfa Build TF-A BL31 (Secure Monitor only — no BL2)
# u-boot Build U-Boot SPL (qcom_lemans_spl_defconfig → tz.mbn)
# u-boot-proper Build U-Boot proper (qcom_lemans_defconfig, BL33 @ 0xaf000000)
# spl SWIV-annotate and sign the SPL via qtestsign → tz.mbn
# uefi Assemble the SPL_ATF boot FIT → uefi.elf
# linux Build the kernel Image and device trees
# linux-defconfig Configure the kernel (auto-invoked by linux if needed)
# buildroot Build the root filesystem (via common.mk)
#
# qtestsign-fetch Clone qtestsign (auto-invoked by spl)
# fetch-blobs Download QCS9100 firmware blobs directly (no Yocto build)
# yocto Clone meta-qcom and build the OE no-distro BSP image via kas
# flash-yocto Flash the complete unmodified Yocto release image (all 6 LUNs)
# flash-loader Flash the boot chain via QDL (stock FW from fetched blobs; tz/uefi from build)
# flash-kernel Flash the updated efi.bin via QDL (efi.bin from build; LUN0 tables from blobs)
# flash-sail Flash the SAIL safety-island NOR image via QDL (stock blobs, self-contained)
# flash-sail-wipe Wipe the SAIL NOR partition tables (recovery; destroys SAIL NOR layout)
# flash-ufs-provision Re-provision the UFS LUN layout (recover partitions broken by a bad flash)
# edl-package Assemble flat image dir for Windows EDL flashing (PCATApp/QFIL)
# edl-bootloader Assemble bootloader-only EDL package (LUN1–4, fast re-flash)
# *-clean Per-component clean targets
#
# Configurable variables (override on the command line or in the environment)
# ─────────────────────────────────────────────────────────────────────────────
# LINUX_DEFCONFIG Kernel defconfig (default: defconfig)
# U_BOOT_DEVICE_TREE U-Boot device tree (default: qcom/lemans-evk)
# TF_A_FLAGS Extra flags for the TF-A make invocation
# LINUX_CMDLINE Kernel command line embedded in the UKI
# SWIV_SCRIPT Path to swiv_build_utility.py
# QTESTSIGN_PATH Path to qtestsign checkout (default: $(ROOT)/qtestsign)
# UFS_PROVISION_XML UFS provision layout for flash-ufs-provision
# (default: provision_1_2.xml — grows HLOS LUN 0)
################################################################################
################################################################################
# Platform
################################################################################
PLATFORM = lemans
OPTEE_OS_PLATFORM = qcom-lemans
################################################################################
# Compilation settings
# All worlds are AArch64-only on this platform.
################################################################################
override COMPILE_NS_USER := 64
override COMPILE_NS_KERNEL := 64
override COMPILE_S_USER := 64
override COMPILE_S_KERNEL := 64
################################################################################
# OP-TEE OS settings
################################################################################
# Quiet the secure-world console. common.mk defaults CFG_TEE_CORE_LOG_LEVEL to
# 3 (DEBUG), which floods ttyMSM0 with OP-TEE trace. Drop to 1 (errors only).
# Set before the common.mk include so its ?= default does not win.
CFG_TEE_CORE_LOG_LEVEL := 1
################################################################################
# Buildroot package selection
################################################################################
# Serial console — Qualcomm MSM UART, not PL011 (overrides common.mk default)
BR2_TARGET_GENERIC_GETTY_PORT := ttyMSM0
# Networking
BR2_PACKAGE_DHCPCD ?= y
BR2_PACKAGE_ETHTOOL ?= y
BR2_PACKAGE_XINETD ?= y
# SSH
BR2_PACKAGE_OPENSSH ?= y
BR2_PACKAGE_OPENSSH_SERVER ?= y
BR2_PACKAGE_OPENSSH_KEY_UTILS ?= y
# OpenSSL CLI
BR2_PACKAGE_LIBOPENSSL_BIN ?= y
# stress-ng — CPU/thermal soak load generator. Drives the qcom-tests "CPU
# stress" option for multi-hour stability runs; the runner falls back to a
# busybox 'yes' busy-loop if this is ever disabled.
BR2_PACKAGE_STRESS_NG ?= y
# Qualcomm FastRPC test — validates the OP-TEE PAS coprocessor reset sequence.
# NOTE: upstream ships DSP skel stubs for v68/v75 only; the SA8775P CDSP is v73,
# so the bundled calculator workload may have no matching skel at runtime.
BR2_PACKAGE_FASTRPC_EXT ?= y
# QRTR userspace (libqrtr + qrtr-ns). qrtr-ns is the QMI name service the DSP
# subsystems need to register their servreg protection domains; without it the
# DSP rootPD never finishes coming up and FastRPC stalls (GLINK intent timeout).
# No systemd here, so qrtr-ns is launched from lemans/overlay/etc/init.d/.
BR2_PACKAGE_QRTR_EXT ?= y
# tqftpserv — TFTP-over-QRTR file server. The CDSP FastRPC rootPD reads its
# runtime from the apps rootfs over QRTR via this server; without it the
# fastrpc glink channel opens but the DSP never posts RX intents. Launched
# from an init script after qrtr-ns.
BR2_PACKAGE_TQFTPSERV_EXT ?= y
# Video decoder validation. v4l-utils gives v4l2-ctl for capability/format
# enumeration; GStreamer gives an end-to-end decode pipeline. The iris/venus
# codec is a V4L2 *stateful* decoder, so the elements are v4l2h264dec /
# v4l2h265dec (registered by the m2m probe), fed by h264parse/h265parse
# (videoparsers) and qtdemux (isomp4). Needs C++ (already on via the toolchain).
BR2_INSTALL_LIBSTDCPP ?= y
BR2_PACKAGE_LIBV4L ?= y
BR2_PACKAGE_LIBV4L_UTILS ?= y
BR2_PACKAGE_GSTREAMER1 ?= y
BR2_PACKAGE_GST1_PLUGINS_BASE ?= y
# Base sub-plugins default off; videotestsrc feeds the encode test and
# videoconvertscale (videoconvert) handles the NV12 conversion the encoder needs.
BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC ?= y
BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOCONVERTSCALE ?= y
BR2_PACKAGE_GST1_PLUGINS_GOOD ?= y
BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_V4L2 ?= y
BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_V4L2_PROBE ?= y
BR2_PACKAGE_GST1_PLUGINS_GOOD_PLUGIN_ISOMP4 ?= y
BR2_PACKAGE_GST1_PLUGINS_BAD ?= y
BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_VIDEOPARSERS ?= y
# Root filesystem — compressed CPIO for use as initramfs
BR2_TARGET_GENERIC_ISSUE = "OP-TEE embedded distrib for $(PLATFORM)"
BR2_TARGET_ROOTFS_CPIO = y
BR2_TARGET_ROOTFS_CPIO_GZIP = y
BR2_PACKAGE_BUSYBOX_WATCHDOG = y
# OP-TEE OS, TF-A BL31, Linux, U-Boot and OP-TEE are built outside of Buildroot
BR2_LINUX_KERNEL = n
# Overlay: DSP firmware (staged by fetch-blobs, see below). The kernel is
# CONFIG_MODULES=n (see linux-defconfig), so there are no loadable modules to
# overlay.
BR2_ROOTFS_OVERLAY = $(OVERLAY_DIR)
BR2_TARGET_ARM_TRUSTED_FIRMWARE = n
BR2_TARGET_OPTEE_OS = n
BR2_TARGET_UBOOT = n
BR2_PACKAGE_OPTEE_CLIENT = n
BR2_PACKAGE_OPTEE_TEST = n
BR2_PACKAGE_OPTEE_EXAMPLES = n
BR2_PACKAGE_OPTEE_BENCHMARK = n
################################################################################
# Paths to repositories
# These match the path= attributes in manifest.git/lemans.xml.
# OPTEE_OS_PATH and LINUX_PATH are already set by common.mk to the same values
# and are not repeated here.
################################################################################
TF_A_PATH ?= $(ROOT)/arm-trusted-firmware
U-BOOT_PATH ?= $(ROOT)/u-boot
SWIV_SCRIPT ?= $(CURDIR)/lemans/security/swiv_build_utility.py
################################################################################
# Source overlays
#
# Local DT/defconfig changes to the u-boot and linux source trees are carried
# here as patch overlays rather than committed to those repos, so the checkouts
# stay pristine. Overlays are applied idempotently to the working tree before
# each build (already-applied overlays are skipped; conflicts abort the build).
#
# lemans/patches/u-boot/*.patch applied to $(U-BOOT_PATH)
# lemans/patches/linux/*.patch applied to $(LINUX_PATH)
################################################################################
U_BOOT_OVERLAY_DIR = $(CURDIR)/lemans/patches/u-boot
LINUX_OVERLAY_DIR = $(CURDIR)/lemans/patches/linux
# apply-overlays: $(call apply-overlays,<repo-dir>,<overlay-dir>)
# Applies each *.patch idempotently using git-apply reverse-check to detect
# overlays that are already present.
define apply-overlays
@set -e; \
if [ -d "$(2)" ]; then \
for p in $$(ls "$(2)"/*.patch 2>/dev/null | sort); do \
if git -C "$(1)" apply --reverse --check "$$p" >/dev/null 2>&1; then \
echo "overlay already applied: $$p"; \
elif git -C "$(1)" apply --check "$$p" >/dev/null 2>&1; then \
git -C "$(1)" apply "$$p" && echo "applied overlay: $$p"; \
else \
echo "ERROR: cannot apply overlay $$p to $(1)"; \
exit 1; \
fi; \
done; \
fi
endef
.PHONY: u-boot-overlays u-boot-overlays-revert linux-overlays linux-overlays-revert
u-boot-overlays:
$(call apply-overlays,$(U-BOOT_PATH),$(U_BOOT_OVERLAY_DIR))
u-boot-overlays-revert:
@for p in $$(ls "$(U_BOOT_OVERLAY_DIR)"/*.patch 2>/dev/null | sort -r); do \
git -C "$(U-BOOT_PATH)" apply --reverse "$$p" 2>/dev/null && \
echo "reverted overlay: $$p" || true; \
done
linux-overlays:
$(call apply-overlays,$(LINUX_PATH),$(LINUX_OVERLAY_DIR))
linux-overlays-revert:
@for p in $$(ls "$(LINUX_OVERLAY_DIR)"/*.patch 2>/dev/null | sort -r); do \
git -C "$(LINUX_PATH)" apply --reverse "$$p" 2>/dev/null && \
echo "reverted overlay: $$p" || true; \
done
################################################################################
# Pre-built inputs
################################################################################
BOOTAA64_EFI = $(CURDIR)/lemans/input/bootaa64.efi
include common.mk
include toolchain.mk
# common.mk passes CFG_IN_TREE_EARLY_TAS to OP-TEE on the make command line,
# which turns the platform target.mk's '+= qcom_pas/...' into a no-op. Append
# the qcom_pas PAS TA here (after the include) so it is embedded as an early TA
# and advertised on the TEE bus. qcom_pas_tee (Linux) only binds when that TA
# (cff7d191) is enumerated; without it the SA8775P PAS remoteprocs
# (adsp/cdsp/gpdsp) stay stuck in deferred probe.
CFG_IN_TREE_EARLY_TAS += qcom_pas/cff7d191-7ca0-4784-af13-48223b9a4fbe
# Buildroot rejects PATH entries containing spaces (Windows paths from WSL).
# Export a sanitized PATH for all sub-makes that invoke buildroot.
export PATH := $(shell echo "$$PATH" | tr ':' '\n' | grep -v ' ' | tr '\n' ':' | sed 's/:$$//')
################################################################################
# Top-level targets
################################################################################
.PHONY: all clean
all: optee-os tfa u-boot u-boot-proper linux buildroot efi
clean: optee-os-clean tfa-clean u-boot-clean u-boot-proper-clean linux-clean buildroot-clean
.PHONY: help
help:
@echo "Qualcomm SA8775P Lemans EVK (QCS9075) build system"
@echo ""
@echo "Boot flow: XBL → U-Boot SPL (tz.mbn) → BL31 → OP-TEE → U-Boot proper → Linux"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " MAIN TARGETS"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " all Build everything (OP-TEE, TF-A, U-Boot SPL + proper,"
@echo " Linux, Buildroot) and produce efi.bin"
@echo " bootimage Build the boot chain → lemans/output/"
@echo " tz.mbn signed U-Boot SPL (tz partition)"
@echo " uefi.elf SPL_ATF FIT: BL31+OP-TEE+U-Boot (uefi part.)"
@echo " efi Build kernel UKI + rootfs → lemans/output/efi.bin (LUN 0)"
@echo " flash-loader Flash the boot chain via QDL (LUNs 1-5; needs bootimage)"
@echo " flash-kernel Flash efi.bin via QDL (LUN 0; needs efi)"
@echo " flash-lava Package a combined boot-chain + kernel tarball for LAVA"
@echo " (lemans/output/lemans-flash.qcomflash.tar.gz); flash a"
@echo " remote lab board via LAVA instead of local USB QDL."
@echo " Asks (default Y) to flash interactively + open the board"
@echo " console; answer n for a one-shot flash-only job"
@echo " flash-lava-yocto Package the COMPLETE Yocto release (all 6 LUNs +"
@echo " rootfs.img) for LAVA (lemans/output/lemans-yocto.qcomflash.tar.gz);"
@echo " the LAVA counterpart of flash-yocto (needs 'make yocto')"
@echo ""
@echo " Typical rebuild + flash:"
@echo " make bootimage && make flash-loader # boot chain"
@echo " make efi && make flash-kernel # kernel + rootfs"
@echo " make bootimage efi && make flash-lava # both, packaged for LAVA"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " COMPONENT TARGETS (sub-builds invoked by the main targets)"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " optee-os Build OP-TEE OS (secure world, BL32)"
@echo " tfa Build TF-A BL31 (Secure Monitor — no BL2)"
@echo " u-boot Build U-Boot SPL (qcom_lemans_spl_defconfig → tz.mbn)"
@echo " u-boot-proper Build U-Boot proper (qcom_lemans_defconfig, BL33 @ 0xaf000000)"
@echo " spl SWIV-annotate + qtestsign the SPL → tz.mbn"
@echo " uefi Assemble the SPL_ATF boot FIT → uefi.elf"
@echo " linux Build kernel Image + DTBs"
@echo " buildroot Build the root filesystem"
@echo " clean Clean all components"
@echo ""
@echo " Config/helpers: u-boot-defconfig, u-boot-proper-defconfig,"
@echo " linux-defconfig, qtestsign-fetch"
@echo " efi-kernel-only efi.bin with local-kernel UKI booting the on-disk"
@echo " Yocto rootfs (root=PARTLABEL=rootfs); needs flash-yocto"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " SOURCE OVERLAYS (local u-boot/linux patches under lemans/patches/)"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " u-boot-overlays / linux-overlays Apply overlays (auto-run by builds)"
@echo " u-boot-overlays-revert / linux-overlays-revert Revert overlays"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " OTHER FLASH / EDL TARGETS"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " flash-sail Flash the SAIL safety-island NOR image via QDL (needs EDL mode)"
@echo " Self-contained stock blob set from lemans/blobs (fetch-blobs)"
@echo " No local build artifacts; independent of the UFS boot chain"
@echo " flash-sail-wipe Wipe the SAIL NOR partition tables — RECOVERY ONLY (needs EDL mode)"
@echo " Zeroes MBR + GPTs on every SAIL NOR physical partition"
@echo " WARNING: destroys the SAIL NOR layout; re-run flash-sail afterward"
@echo " flash-ufs-provision Re-provision the UFS LUN layout — RECOVERY ONLY"
@echo " Use only when a firmware upgrade gone wrong broke the partitions"
@echo " so a normal flash no longer works. Device must be in EDL mode."
@echo " WARNING: reconfigures the UFS and destroys all data on it."
@echo " Layout via UFS_PROVISION_XML (default: provision_1_2.xml, grows LUN 0)"
@echo " edl-package Assemble flat image dir for Windows EDL flashing (PCATApp / QFIL)"
@echo " Output: lemans/output/edl-package/"
@echo " Contains prog_firehose_ddr.elf, all rawprogram/patch XMLs,"
@echo " GPT bins, all firmware MBNs/ELFs, efi.bin, and qupv3fw.elf"
@echo " edl-bootloader Bootloader-only EDL package (LUN1–4: XBL, CDT, SPL, U-Boot)"
@echo " Output: lemans/output/edl-bootloader/"
@echo " Fast re-flash path when only OP-TEE/U-Boot changed"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " FIRMWARE BLOB TARGETS (alternative to 'make yocto')"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " fetch-blobs Download QCS9100 firmware blobs directly — no Yocto build needed"
@echo " Sources: softwarecenter.qualcomm.com + codelinaro.org + qcom-ptool"
@echo " Output: lemans/blobs/ (flash-loader/flash-kernel stage from here exclusively)"
@echo " fetch-blobs-clean Remove lemans/blobs/"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " YOCTO TARGETS"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " yocto Clone meta-qcom (if absent) and build OE no-distro BSP image via kas"
@echo " Applies lemans/patches/ (adds fastrpc-tests to the image) before building"
@echo " Output: yocto/build/tmp/deploy/images/iq-9075-evk/"
@echo " Copy result to lemans/output/ manually before flashing"
@echo " flash-yocto Flash the complete unmodified Yocto release (all 6 LUNs) via QDL"
@echo " Verifies default hardware + released BSP; requires 'make yocto' first"
@echo " yocto-clean Remove the cloned meta-qcom directory"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " CLEAN TARGETS"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " optee-os-clean, tfa-clean, u-boot-clean, u-boot-proper-clean, spl-clean, uefi-clean,"
@echo " linux-clean, buildroot-clean, efi-clean, bootimage-clean, yocto-clean,"
@echo " linux-firmware-clean"
@echo ""
@echo "════════════════════════════════════════════════════════════════════════"
@echo " CONFIGURABLE VARIABLES (override on the command line or environment)"
@echo "════════════════════════════════════════════════════════════════════════"
@echo " LINUX_DEFCONFIG Kernel defconfig (default: defconfig)"
@echo " U_BOOT_DEVICE_TREE U-Boot device tree (default: qcom/lemans-evk)"
@echo " LINUX_CMDLINE Kernel command line in UKI (default: console=ttyMSM0 …)"
@echo " SWIV_SCRIPT Path to swiv_build_utility.py"
@echo " TF_A_FLAGS Extra flags for TF-A make (default: PLAT=lemans_evk SPD=opteed)"
@echo " QTESTSIGN_PATH Path to qtestsign checkout (default: \$$(ROOT)/qtestsign)"
@echo " UFS_PROVISION_XML UFS provision layout (default: provision_1_2.xml)"
################################################################################
# OP-TEE OS
################################################################################
.PHONY: optee-os optee-os-clean
optee-os: optee-os-common
optee-os-clean: optee-os-clean-common
################################################################################
# U-Boot
#
# Two independent builds, each into its own output dir to keep the tree clean:
#
# u-boot qcom_lemans_spl_defconfig → $(U_BOOT_OUTPUT)
# Produces the SPL:
# $(U_BOOT_OUTPUT)/spl/u-boot-spl.elf (SWIV-annotated → tz.mbn)
# The SPL is configured with SPL_LOAD_FIT + SPL_ATF, so at boot
# it reads the uefi partition as a FIT and jumps to BL31.
# (The proper "u-boot" this build incidentally emits is a
# throwaway linked at TEXT_BASE=0 and is NOT used.)
#
# u-boot-proper qcom_lemans_defconfig → $(U_BOOT_PROPER_OUTPUT)
# Produces the real U-Boot proper (BL33) linked at 0xaf000000:
# $(U_BOOT_PROPER_OUTPUT)/u-boot.bin (nodtb + control dtb)
# This is embedded into the uefi FIT (see the 'uefi' target).
#
# BL31= and TEE= are still passed to the SPL build so its own SPL_ATF plumbing
# is configured consistently; the FIT that BL31/OP-TEE/U-Boot actually ship in
# is assembled explicitly by the 'uefi' target.
################################################################################
U_BOOT_EXPORTS = CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)"
U_BOOT_DEVICE_TREE ?= qcom/lemans-evk
# SPL build (qcom_lemans_spl_defconfig): produces the SPL that is signed into
# tz.mbn. Its incidental "u-boot" proper is a throwaway (TEXT_BASE=0) and is
# NOT used for the uefi partition.
U_BOOT_OUTPUT = $(U-BOOT_PATH)/.output
# U-Boot proper build (qcom_lemans_defconfig): the real BL33, linked at
# 0xaf000000. This is what the SPL FIT (uefi partition) hands off to.
U_BOOT_PROPER_OUTPUT = $(U-BOOT_PATH)/.output-proper
BL32_BIN = $(OPTEE_OS_PATH)/out/arm/core/tee.elf
# Raw OP-TEE image (headerless pager binary linked at 0x1c300000) embedded into
# the uefi FIT as the BL32 loadable.
OPTEE_RAW_BIN = $(OPTEE_OS_PATH)/out/arm/core/tee-raw.bin
.PHONY: u-boot u-boot-defconfig u-boot-clean
.PHONY: u-boot-proper u-boot-proper-defconfig u-boot-proper-clean
u-boot-defconfig: u-boot-overlays
mkdir -p $(U_BOOT_OUTPUT)
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_OUTPUT) \
qcom_lemans_spl_defconfig
u-boot: u-boot-overlays
@if [ ! -f $(U_BOOT_OUTPUT)/.config ]; then \
mkdir -p $(U_BOOT_OUTPUT); \
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_OUTPUT) \
qcom_lemans_spl_defconfig; \
fi
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_OUTPUT) \
-j$(shell nproc) DEVICE_TREE=$(U_BOOT_DEVICE_TREE) \
BL31=$(BL31_BIN) TEE=$(BL32_BIN)
u-boot-clean:
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_OUTPUT) clean
# U-Boot proper (BL33) — built from qcom_lemans_defconfig at 0xaf000000.
# Produces u-boot.bin (nodtb + appended control dtb) which is embedded into the
# uefi FIT as the BL33 loadable.
u-boot-proper-defconfig: u-boot-overlays
mkdir -p $(U_BOOT_PROPER_OUTPUT)
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_PROPER_OUTPUT) \
qcom_lemans_defconfig
u-boot-proper: u-boot-overlays
@if [ ! -f $(U_BOOT_PROPER_OUTPUT)/.config ]; then \
mkdir -p $(U_BOOT_PROPER_OUTPUT); \
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_PROPER_OUTPUT) \
qcom_lemans_defconfig; \
fi
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_PROPER_OUTPUT) \
-j$(shell nproc) DEVICE_TREE=$(U_BOOT_DEVICE_TREE)
u-boot-proper-clean:
$(U_BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) O=$(U_BOOT_PROPER_OUTPUT) clean
################################################################################
# ARM Trusted Firmware — BL31 (Secure Monitor) only
#
# Build order: optee-os → tfa
#
# BL2 is replaced by U-Boot SPL; only BL31 is built here.
# BL31 is passed to U-Boot as BL31= so the SPL FIT image carries it for
# hand-off at EL3.
#
# Generates:
# arm-trusted-firmware/build/lemans_evk/release/bl31/bl31.elf
################################################################################
TF_A_EXPORTS = CROSS_COMPILE="$(AARCH64_CROSS_COMPILE)"
TF_A_FLAGS ?= PLAT=lemans_evk SPD=opteed
BL31_BIN = $(TF_A_PATH)/build/lemans_evk/release/bl31/bl31.elf
# Flat BL31 image (objcopy output) embedded into the uefi FIT as the ATF firmware.
BL31_BIN_FLAT = $(TF_A_PATH)/build/lemans_evk/release/bl31.bin
.PHONY: tfa tfa-clean
tfa:
$(TF_A_EXPORTS) $(MAKE) -C $(TF_A_PATH) -j$(shell nproc) $(TF_A_FLAGS) bl31
tfa-clean:
$(TF_A_EXPORTS) $(MAKE) -C $(TF_A_PATH) $(TF_A_FLAGS) clean
#
# After building U-Boot, the SPL is:
# 1. Annotated with a SWIV segment via swiv_build_utility.py
# 2. Signed locally with qtestsign (open-source — no CASS access required)
#
# Intermediate files (kept in the U-Boot output directory):
# $(U_BOOT_OUTPUT)/spl/u-boot-spl-swiv.elf SWIV-annotated SPL ELF
# $(U_BOOT_OUTPUT)/spl/u-boot-spl.mbn qtestsign output
#
# Final outputs copied to lemans/output/:
# lemans/output/tz.mbn signed SPL (flashed to tz partition)
#
# NOTE: the uefi partition image (lemans/output/uefi.elf) is NOT produced here.
# It is a FIT assembled by the 'uefi' target below (BL31 + OP-TEE + U-Boot
# proper). The SPL (tz.mbn) is configured with SPL_LOAD_FIT + SPL_ATF and
# expects exactly that FIT on the uefi partition.
################################################################################
QTESTSIGN_PATH ?= $(ROOT)/qtestsign
.PHONY: qtestsign-fetch
qtestsign-fetch:
@if [ ! -d $(QTESTSIGN_PATH) ]; then \
echo "Cloning qtestsign..."; \
git clone https://github.com/msm8916-mainline/qtestsign $(QTESTSIGN_PATH); \
fi
.PHONY: spl spl-clean
spl: qtestsign-fetch
mkdir -p $(CURDIR)/lemans/output
python3 $(SWIV_SCRIPT) \
$(U_BOOT_OUTPUT)/spl/u-boot-spl-swiv.elf \
$(U_BOOT_OUTPUT)/spl/u-boot-spl.elf \
lemans
python3 $(QTESTSIGN_PATH)/qtestsign.py -v6 tz \
-o $(U_BOOT_OUTPUT)/spl/u-boot-spl.mbn \
$(U_BOOT_OUTPUT)/spl/u-boot-spl-swiv.elf
cp $(U_BOOT_OUTPUT)/spl/u-boot-spl.mbn $(CURDIR)/lemans/output/tz.mbn
@echo "Signed SPL written to lemans/output/tz.mbn (tz partition image)"
spl-clean:
rm -f $(CURDIR)/lemans/output/tz.mbn \
$(U_BOOT_OUTPUT)/spl/u-boot-spl-swiv.elf \
$(U_BOOT_OUTPUT)/spl/u-boot-spl.mbn
################################################################################
# uefi partition image — SPL_ATF boot FIT
#
# The SPL (tz.mbn, qcom_lemans_spl_defconfig) is built with SPL_LOAD_FIT +
# SPL_ATF. It reads the "uefi" partition as a FIT image, loads each sub-image
# to its load address, then jumps to the ATF (BL31) firmware. BL31 in turn
# hands off to OP-TEE (BL32) and finally U-Boot proper (BL33).
#
# The FIT therefore carries three payloads plus the U-Boot control FDT:
# firmware = atf BL31 bl31.bin @ 0x1c200000
# loadables = uboot U-Boot proper u-boot.bin @ 0xaf000000
# = optee OP-TEE OS tee-raw.bin @ 0x1c300000
# fdt = fdt-1 U-Boot dtb (so the SPL records the loadables into
# /fit-images, which is how spl_invoke_atf() discovers the
# OP-TEE (os="tee") and U-Boot (os="u-boot") entry points).
#
# ORDER MATTERS: "uboot" must precede "optee" in loadables. In
# spl_load_simple_fit() the firmware (atf) is not os_takes_devicetree, so
# spl_image->fdt_addr is unset until the U-Boot loadable is processed; a
# loadable is only recorded into /fit-images once fdt_addr is set. If OP-TEE
# came first it would not be recorded and BL31 would receive no BL32 entry.
#
# u-boot.bin (nodtb + appended control dtb) is used for BL33 rather than
# u-boot-nodtb.bin: qcom's board_fdt_blob_setup() prefers U-Boot's internal
# (appended) DTB and only falls back to a prev-stage fdt pointer — which BL31
# does not supply (it hands off with x0 = MPIDR, not an fdt) — so an embedded
# DTB guarantees U-Boot always has a valid device tree.
#
# Output: lemans/output/uefi.elf — the FIT flashed to the uefi_a/uefi_b
# partition (filename referenced by rawprogram4.xml). Despite the .elf name it
# is a FIT (.itb); the name is kept to match the existing flash descriptors.
################################################################################
MKIMAGE ?= $(U_BOOT_OUTPUT)/tools/mkimage
UEFI_OUTPUT = $(CURDIR)/lemans/output/uefi.elf
UEFI_ITS = $(CURDIR)/lemans/output/uefi.its
UBOOT_PROPER_BIN = $(U_BOOT_PROPER_OUTPUT)/u-boot.bin
UBOOT_PROPER_DTB = $(U_BOOT_PROPER_OUTPUT)/u-boot.dtb
.PHONY: uefi uefi-clean
uefi:
mkdir -p $(CURDIR)/lemans/output
@for f in "$(BL31_BIN_FLAT)" "$(OPTEE_RAW_BIN)" "$(UBOOT_PROPER_BIN)" \
"$(UBOOT_PROPER_DTB)"; do \
if [ ! -f "$$f" ]; then \
echo "ERROR: missing FIT input $$f"; \
echo " run 'make tfa optee-os u-boot-proper' first"; \
exit 1; \
fi; \
done
@echo "Generating uefi FIT source ($(UEFI_ITS))..."
@printf '%s\n' \
'/dts-v1/;' \
'' \
'/ {' \
' description = "Lemans uefi boot FIT (BL31 + OP-TEE + U-Boot proper)";' \
' #address-cells = <1>;' \
'' \
' images {' \
' atf {' \
' description = "ARM Trusted Firmware BL31";' \
' data = /incbin/("$(BL31_BIN_FLAT)");' \
' type = "firmware";' \
' arch = "arm64";' \
' os = "arm-trusted-firmware";' \
' compression = "none";' \
' load = <0x1c200000>;' \
' entry = <0x1c200000>;' \
' hash-1 { algo = "sha256"; };' \
' };' \
' optee {' \
' description = "OP-TEE OS (BL32)";' \
' data = /incbin/("$(OPTEE_RAW_BIN)");' \
' type = "tee";' \
' arch = "arm64";' \
' os = "tee";' \
' compression = "none";' \
' load = <0x1c300000>;' \
' entry = <0x1c300000>;' \
' hash-1 { algo = "sha256"; };' \
' };' \
' uboot {' \
' description = "U-Boot proper (BL33)";' \
' data = /incbin/("$(UBOOT_PROPER_BIN)");' \
' type = "firmware";' \
' arch = "arm64";' \
' os = "u-boot";' \
' compression = "none";' \
' load = <0xaf000000>;' \
' entry = <0xaf000000>;' \
' hash-1 { algo = "sha256"; };' \
' };' \
' fdt-1 {' \
' description = "U-Boot control FDT";' \
' data = /incbin/("$(UBOOT_PROPER_DTB)");' \
' type = "flat_dt";' \
' arch = "arm64";' \
' compression = "none";' \
' hash-1 { algo = "sha256"; };' \
' };' \
' };' \
'' \
' configurations {' \
' default = "conf-1";' \
' conf-1 {' \
' description = "Lemans BL31 + OP-TEE + U-Boot";' \
' firmware = "atf";' \
' loadables = "uboot", "optee";' \
' fdt = "fdt-1";' \
' };' \
' };' \
'};' \
> $(UEFI_ITS)
$(MKIMAGE) -f $(UEFI_ITS) $(UEFI_OUTPUT)
@echo "uefi FIT written to $(UEFI_OUTPUT)"
@$(MKIMAGE) -l $(UEFI_OUTPUT)
uefi-clean:
rm -f $(UEFI_OUTPUT) $(UEFI_ITS)
################################################################################
# Boot image (tz.mbn + uefi.elf)
################################################################################
.PHONY: bootimage bootimage-clean
bootimage:
rm -f $(CURDIR)/lemans/output/tz.mbn \
$(CURDIR)/lemans/output/uefi.elf
$(MAKE) optee-os
$(MAKE) tfa
$(MAKE) u-boot
$(MAKE) u-boot-proper
$(MAKE) spl
$(MAKE) uefi
bootimage-clean: spl-clean uefi-clean tfa-clean optee-os-clean u-boot-clean u-boot-proper-clean
################################################################################
# Linux kernel
#
# linux-defconfig applies $(LINUX_DEFCONFIG), enables TEE/OP-TEE and EFI_ZBOOT,
# and disables drivers that cause probe failures on Lemans EVK.
# Auto-invoked by linux if .config is absent.
#
# Generates:
# linux/arch/arm64/boot/Image
# linux/arch/arm64/boot/vmlinuz.efi (EFI_ZBOOT self-decompressing kernel)
################################################################################
LINUX_EXPORTS = ARCH=arm64 CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)"
LINUX_DEFCONFIG ?= defconfig
.PHONY: linux-defconfig linux linux-clean
linux-defconfig:
$(LINUX_EXPORTS) $(MAKE) -C $(LINUX_PATH) mrproper
$(LINUX_EXPORTS) $(MAKE) -C $(LINUX_PATH) $(LINUX_DEFCONFIG)
$(LINUX_EXPORTS) $(LINUX_PATH)/scripts/config --file $(LINUX_PATH)/.config \
-e TEE \
-e OPTEE \
-d QCOMTEE \
-e DEVTMPFS \
-e EFI_BOOT \
-e EFI_ZBOOT \
-e QCOM_FASTRPC \
-e REMOTEPROC \
-e QCOM_PAS \
-e QCOM_PAS_TEE \
-e RPMSG \
-e RPMSG_QCOM_GLINK \
-e RPMSG_QCOM_GLINK_SMEM \
-e QCOM_SMEM \
-e QCOM_SMP2P \
-e QCOM_SMSM \
-e QCOM_AOSS_QMP \
-e QCOM_RPMHPD \
-e QCOM_COMMAND_DB \
-e QCOM_SCM \
-e QRTR \
-e QRTR_SMD \
-e CMA \
-e DMA_CMA \
-e DMABUF_HEAPS \
-e DMABUF_HEAPS_SYSTEM \
-e DMABUF_HEAPS_CMA \
-d MODULES \
-e ARM64_64K_PAGES \
-d ARM64_4K_PAGES \
-d QCOM_SCM
$(LINUX_EXPORTS) $(MAKE) -C $(LINUX_PATH) olddefconfig
linux: linux-overlays
@# Generate .config from the single source of truth (linux-defconfig) so the
@# build can never drift from it (this is why QCOMTEE / QCOM_PAS_TEE / MODULES
@# silently regressed before). linux-defconfig disables MODULES, which forces
@# hidden 'default m' drivers like QCOM_PAS_TEE built-in (needed for the PAS
@# remoteprocs to probe — they can't wait on a late-loaded module).
@if [ ! -f $(LINUX_PATH)/.config ]; then \
$(MAKE) linux-defconfig; \
fi
$(LINUX_EXPORTS) $(MAKE) -C $(LINUX_PATH) -j$(shell nproc) Image vmlinuz.efi
$(LINUX_EXPORTS) $(MAKE) -C $(LINUX_PATH) -j1 dtbs
linux-clean:
$(LINUX_EXPORTS) $(MAKE) -C $(LINUX_PATH) clean
################################################################################
# UKI — Unified Kernel Image (efi.bin)
#
# Bundles the kernel, DTB, initramfs, and command line into a single EFI
# binary using ukify, then builds a fresh FAT32 image containing:
# EFI/BOOT/bootaa64.efi UEFI fallback boot entry (from lemans/input/)
# EFI/Linux/uki.efi Unified Kernel Image
#
# Host dependencies:
# apt install systemd-ukify mtools dosfstools
#
# Generates:
# linux/uki.efi
# lemans/output/efi.bin FAT32 image (EFI_BIN_SIZE)
################################################################################
LINUX_IMAGE = $(LINUX_PATH)/arch/arm64/boot/vmlinuz.efi
LINUX_DTB = $(LINUX_PATH)/arch/arm64/boot/dts/qcom/lemans-evk-el2.dtb
BR_INITRAMFS = $(ROOT)/out-br/images/rootfs.cpio.gz
EFI_BIN_SIZE = 512M
LINUX_CMDLINE ?= \
console=ttyMSM0,115200 \
qcom_scm.download_mode=1 \
arm-smmu.disable_bypass=0 \
clk_ignore_unused \
pd_ignore_unused
# WORKAROUND: arm-smmu.disable_bypass=0 keeps the SMMU in bypass for stream IDs
# that have no context mapping instead of faulting them. Some peripherals on the
# SA8775P/QCS9075 Lemans EVK are not yet fully described with SMMU stream
# mappings in the device tree, so with the default (bypass disabled) their DMA
# transactions are aborted and the devices fail to initialize. Remove once the
# device tree describes all SMMU masters.
.PHONY: efi efi-clean
efi: linux buildroot linux-firmware
rm -f $(LINUX_PATH)/uki.efi $(CURDIR)/lemans/output/efi.bin
ukify build \
--linux=$(LINUX_IMAGE) \
--initrd=$(BR_INITRAMFS) \
--cmdline='$(LINUX_CMDLINE)' \
--efi-arch=aa64 \
--stub=$(CURDIR)/lemans/ukify/linuxaa64.efi.stub \
--os-release=@/etc/os-release \
--devicetree=$(LINUX_DTB) \
--output=$(LINUX_PATH)/uki.efi
truncate -s $(EFI_BIN_SIZE) $(CURDIR)/lemans/output/efi.bin
mkfs.fat -F 32 -S 4096 $(CURDIR)/lemans/output/efi.bin
mmd -i $(CURDIR)/lemans/output/efi.bin ::/EFI
mmd -i $(CURDIR)/lemans/output/efi.bin ::/EFI/BOOT
mmd -i $(CURDIR)/lemans/output/efi.bin ::/EFI/Linux
mcopy -i $(CURDIR)/lemans/output/efi.bin $(BOOTAA64_EFI) ::/EFI/BOOT/bootaa64.efi
mcopy -i $(CURDIR)/lemans/output/efi.bin $(LINUX_PATH)/uki.efi ::/EFI/Linux/uki.efi
efi-clean:
rm -f $(LINUX_PATH)/uki.efi $(CURDIR)/lemans/output/efi.bin
################################################################################
# efi-kernel-only — Build an efi.bin that boots the full Yocto rootfs
#
# Builds a UKI from the locally-built kernel (no initramfs) whose command line
# mounts the on-disk Yocto rootfs partition (root=PARTLABEL=rootfs) and injects
# it into a copy of the Yocto efi.bin (replacing its stock UKI). Flash the
# result with 'make flash-kernel' (efi.bin only — rootfs.img untouched).
#
# Unlike 'efi' (which boots the Buildroot initramfs from a freshly-built
# efi.bin), this reuses the Yocto efi.bin and boots the on-disk Yocto rootfs, so
# the matching Yocto rootfs.img must already be flashed (e.g. 'make flash-yocto').
#
# Based on boot.qclinux.rootfs.sh.
################################################################################
YOCTOFS_CMDLINE ?= root=PARTLABEL=rootfs rw rootwait $(LINUX_CMDLINE)
.PHONY: efi-kernel-only
efi-kernel-only: linux
@if [ ! -f "$(YOCTO_FLASH)/efi.bin" ]; then \
echo "ERROR: Yocto efi.bin not found at $(YOCTO_FLASH)/efi.bin"; \
echo " Run 'make yocto' first to build the release image."; \
exit 1; \
fi
rm -f $(LINUX_PATH)/uki.efi $(CURDIR)/lemans/output/efi.bin
ukify build \
--linux=$(LINUX_IMAGE) \
--cmdline='$(YOCTOFS_CMDLINE)' \
--efi-arch=aa64 \
--stub=$(CURDIR)/lemans/ukify/linuxaa64.efi.stub \
--os-release=@/etc/os-release \
--devicetree=$(LINUX_DTB) \
--output=$(LINUX_PATH)/uki.efi
cp $(YOCTO_FLASH)/efi.bin $(CURDIR)/lemans/output/efi.bin
mdeltree -i $(CURDIR)/lemans/output/efi.bin ::/EFI/Linux
mmd -i $(CURDIR)/lemans/output/efi.bin ::/EFI/Linux
mcopy -i $(CURDIR)/lemans/output/efi.bin $(LINUX_PATH)/uki.efi ::/EFI/Linux/uki.efi
################################################################################
# Firmware blob location (fetched by fetch-blobs; consumed by the flash targets)
#
# Defined here — ahead of the flash targets that list $(BLOBS_STAMP) as a
# prerequisite — because make expands prerequisites at parse time: a variable
# used in a prerequisite must already be set when the rule is read, or it
# silently expands to empty. The download URLs/SHAs live in the fetch-blobs
# section further down.
################################################################################
BLOBS_VERSION = 00132
BLOBS_DIR = $(CURDIR)/lemans/blobs
# Keyed to BLOBS_VERSION: bumping the version invalidates the stamp, so
# fetch-blobs (and anything depending on it, e.g. flash-loader) re-fetches the
# new drop instead of no-op'ing on a stale stamp.
BLOBS_STAMP = $(BLOBS_DIR)/.fetch-complete-$(BLOBS_VERSION)
# SAIL (safety-island) NOR flash set — a self-contained sub-tree of the boot-
# binaries drop (own firehose, rawprogram0/patch0, and payload ELFs). Consumed
# by flash-sail; flashed in place, no staging into lemans/output/.
SAIL_NOR_DIR = $(BLOBS_DIR)/bootbinaries/QCS9100_bootbinaries/sail_nor
# Per-physical-partition GPT/table wipe descriptors consumed by flash-sail-wipe.
# One per NOR physical partition (PHY3 has no descriptor); each zeroes the MBR +
# primary/backup GPT sectors of its partition. (rawprogram0_WIPE_PARTITIONS.xml
# is intentionally not used: it references a mis-cased "zeros_33sectorS.bin" that
# does not exist, so it is broken as shipped.)
SAIL_WIPE_XMLS = wipe_rawprogram_PHY0.xml wipe_rawprogram_PHY1.xml \
wipe_rawprogram_PHY2.xml wipe_rawprogram_PHY4.xml \
wipe_rawprogram_PHY5.xml wipe_rawprogram_PHY6.xml \
wipe_rawprogram_PHY7.xml
################################################################################
# Reusable recipe macros (flash / EDL packaging)
################################################################################
# stage-blobs-strict: $(call stage-blobs-strict,<file-list>)
# Copy each named file straight from lemans/blobs/ into lemans/output/,
# overwriting. Hard error (not skip) if any is missing — the flash set that the
# loader/kernel targets program must be complete.
define stage-blobs-strict
@for f in $(1); do \
if [ ! -f "$(BLOBS_DIR)/$$f" ]; then \
echo "ERROR: $$f missing from $(BLOBS_DIR)"; \
echo " Run 'make fetch-blobs' (or 'make fetch-blobs-clean fetch-blobs' to force a refresh)"; \
exit 1; \
fi; \
cp -f "$(BLOBS_DIR)/$$f" "$(CURDIR)/lemans/output/$$f"; \
done
endef
# stage-flash-files: $(call stage-flash-files,<file-list>,<dest-dir>)
# Copy each named file into <dest-dir>, resolving from the first source that
# has it: lemans/input/ (hand-placed overrides) → YOCTO_FLASH → lemans/blobs/.
# Missing files warn and are skipped (some entries are optional per package).
define stage-flash-files
@for f in $(1); do \
if [ -f "$(CURDIR)/lemans/input/$$f" ]; then \
cp "$(CURDIR)/lemans/input/$$f" "$(2)/$$f"; \
elif [ -f "$(YOCTO_FLASH)/$$f" ]; then \
cp "$(YOCTO_FLASH)/$$f" "$(2)/$$f"; \
elif [ -f "$(BLOBS_DIR)/$$f" ]; then \
cp "$(BLOBS_DIR)/$$f" "$(2)/$$f"; \
else \
echo "WARNING: $$f not found — skipping (run 'make fetch-blobs' if needed)"; \
fi; \
done
endef
# patch-qupfw: $(call patch-qupfw,<rawprogram4-src>,<rawprogram4-dst>)
# Populate the empty qupfw_a/qupfw_b partition entries with qupv3fw.elf so
# U-Boot can load the QUP GENI SE firmware (see flash-loader for the rationale).
define patch-qupfw
sed '/label="qupfw_[ab]"/ s/filename=""/filename="qupv3fw.elf"/' \
"$(1)" > "$(2)"
endef
# strip-rootfs: $(call strip-rootfs,<rawprogram0-src>,<rawprogram0-dst>)
# Drop the rootfs.img entry so only efi.bin (LUN 0 kernel partition) is written.
define strip-rootfs
grep -v 'filename="rootfs.img"' "$(1)" > "$(2)"
endef
################################################################################
# Flash file sets
#
# Every flash/EDL file list is built from the same pieces, so they are composed
# here from shared building blocks instead of being spelled out four times:
#
# FIREHOSE the DDR firehose programmer (always first)
# BOOT_FW_FILES LUN1–4 boot-firmware payload (XBL, CDT, AOP, OP-TEE/U-Boot's
# neighbours …) — identical wherever the boot chain is flashed
# lun-tables $(call lun-tables,<n>) → gpt_main<n>.bin gpt_backup<n>.bin
# lun-raw $(call lun-raw,<n>) → rawprogram<n>.xml
# lun-patch $(call lun-patch,<n>) → patch<n>.xml
#
# The per-target lists below differ only in which LUNs they cover and whether
# they include the patch XMLs / zero-fill files — that difference is now the
# only thing each definition has to state.
################################################################################
FIREHOSE = prog_firehose_ddr.elf
# LUN1–4 boot-firmware payload, flashed by the loader and both EDL packages.
BOOT_FW_FILES = \
xbl.elf xbl_config.elf cdt.bin \
aop.mbn cpucp.elf devcfg_iot.mbn hypvm.mbn imagefv.elf \
multi_image.mbn multi_image_qti.mbn \
shrm.elf tools.fv uefi_sec.mbn XblRamdump.elf
# Zero-fill payloads. The loader needs only the 33-sector fill; the EDL packages
# ship all three (PCATApp/QFIL reference them from the unmodified rawprogram XMLs).
ZEROS_FILES = zeros_33sectors.bin zeros_1sector.bin zeros_5sectors.bin
lun-tables = gpt_main$(1).bin gpt_backup$(1).bin
lun-raw = rawprogram$(1).xml
lun-patch = patch$(1).xml
# flash-loader: LUN1–5 boot chain from blobs/ (no patch XMLs; one zero-fill).
LOADER_BLOB_FILES = \
$(FIREHOSE) \
$(foreach n,1 2 3 4 5,$(call lun-raw,$(n))) \
$(BOOT_FW_FILES) zeros_33sectors.bin \
$(foreach n,1 2 3 4 5,$(call lun-tables,$(n)))
# flash-kernel: LUN0 only (kernel partition tables + rawprogram + patch).
KERNEL_BLOB_FILES = \
$(FIREHOSE) $(call lun-raw,0) $(call lun-tables,0) $(call lun-patch,0)
################################################################################
# Flash helpers
#
# Lemans (SA8775P / QCS9075) uses UFS with 6 LUNs (0–5):
# LUN 0 (rawprogram0): efi.bin, rootfs.img
# LUN 1 (rawprogram1): xbl.elf, xbl_config.elf
# LUN 2 (rawprogram2): xbl.elf, xbl_config.elf (redundant copy)
# LUN 3 (rawprogram3): cdt.bin
# LUN 4 (rawprogram4): all main FW (tz.mbn, uefi.elf, aop, shrm, hyp, …)
# LUN 5 (rawprogram5): GPT only (no payload files)
#
# flash-loader Programs LUNs 1–5 (boot chain: XBL, SPL, U-Boot proper, supporting FW).
# tz.mbn and uefi.elf come from lemans/output/ (built artifacts).
# All other files are staged straight from the fetched blob set
# (lemans/blobs/) into lemans/output/, overwriting — so the most
# recently fetched blobs are always what gets flashed.
#
# flash-kernel Programs LUN 0 (efi.bin only; rootfs.img is stripped out).
################################################################################
.PHONY: flash-loader flash-kernel flash-sail flash-sail-wipe
# LOADER_BLOB_FILES (defined above) is staged straight from the fetched blob set
# (lemans/blobs/, produced by fetch-blobs). NOT included: tz.mbn + uefi.elf
# (staged from lemans/output/ — the SWIV-annotated, qtestsign-signed build) and
# qupv3fw.elf (from linux-firmware). The blob rawprogram/GPT set is
# self-consistent (ptool-generated, dtb.bin stripped), so no dtb.bin is needed.
#
# flash-loader depends on the fetch stamp so the blob set always exists and,
# because the stamp is keyed to BLOBS_VERSION, is refreshed whenever the version
# is bumped. Every file is staged from lemans/blobs/ into lemans/output/
# (overwriting) so the most recently fetched blobs are unequivocally what gets
# flashed — no stale lemans/input/ or Yocto copy can shadow them. Only tz.mbn +
# uefi.elf come from the local build; they already live in lemans/output/.
# The linux-firmware prerequisite stages qupv3fw.elf (QUP GENI SE firmware for
# the qupfw_a/qupfw_b partitions) into $(FW_CLONE_DIR) — it is not part of the
# boot-binaries blob drop, so without it the qupfw slots cannot be programmed.
flash-loader: $(BLOBS_STAMP) linux-firmware
$(call stage-blobs-strict,$(LOADER_BLOB_FILES))
@# Program the QUP GENI SE firmware into the qupfw_a/qupfw_b partitions.
@# U-Boot loads QUP firmware from the qupfw partition (GPT type-GUID