Repository navigation
Expand file tree
/
Copy patharch.mk
More file actions
3522 lines (3267 loc) · 137 KB
/
Copy patharch.mk
File metadata and controls
3522 lines (3267 loc) · 137 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
## CPU Architecture selection via $ARCH
# check for math library
ifeq ($(SPMATH),1)
# SP Math
MATH_OBJS:=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_int.o
else
ifeq ($(SPMATHALL),1)
# SP Math all
CFLAGS+=-DWOLFSSL_SP_MATH_ALL
MATH_OBJS:=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_int.o
else
# Fastmath
CFLAGS+=-DUSE_FAST_MATH
MATH_OBJS:=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/integer.o $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/tfm.o
endif
endif
# Default flash offset
ARCH_FLASH_OFFSET?=0x0
# Default SPI driver name
SPI_TARGET=$(TARGET)
I2C_TARGET=$(TARGET)
# Default UART driver name
UART_TARGET=$(TARGET)
# Include some modules by default
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sha256.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/hash.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/memory.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/wc_port.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/wolfmath.o
ifeq ($(ARCH),x86_64)
CFLAGS+=-DARCH_x86_64 -DFAST_MEMCPY
ifeq ($(FORCE_32BIT),1)
NO_ASM=1
CFLAGS+=-DFORCE_32BIT
endif
ifeq ($(SPMATH),1)
ifeq ($(NO_ASM),1)
ifeq ($(FORCE_32BIT),1)
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o
CFLAGS+=-DWOLFSSL_SP_DIV_WORD_HALF
else
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c64.o
endif
else
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_x86_64.o
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_x86_64_asm.o
WOLFCRYPT_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/cpuid.o
endif
endif
ifeq ($(TARGET),x86_64_efi)
OBJS+=src/boot_x86_64.o
ifeq ($(DEBUG),1)
CFLAGS+=-DWOLFBOOT_DEBUG_EFI=1
endif
endif
endif
## ARM Cortex-A
ifeq ($(ARCH),AARCH64)
ifeq ($(TARGET),aarch64_efi)
# UEFI app: Linux GNU toolchain (freestanding EFI ABI), not aarch64-none-elf-
CROSS_COMPILE?=aarch64-linux-gnu-
else
CROSS_COMPILE?=aarch64-none-elf-
endif
CFLAGS+=-DARCH_AARCH64 -DFAST_MEMCPY
ifeq ($(TARGET),aarch64_efi)
# UEFI app: gnu-efi CRT0 is the entry; do_boot is in boot_aarch64_efi.o.
# Skip the bare-metal reset (boot_aarch64_start.S) and EL2/GIC glue.
OBJS+=src/boot_aarch64_efi.o
else
OBJS+=src/boot_aarch64.o src/boot_aarch64_start.o src/boot_aarch64_cache.o
endif
ifeq ($(TARGET),zynq)
ARCH_FLAGS=-march=armv8-a+crypto
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A53
CFLAGS+=-DNO_QNX
# Support detection and skip of U-Boot legacy header */
CFLAGS+=-DWOLFBOOT_UBOOT_LEGACY
CFLAGS+=-DWOLFBOOT_DUALBOOT
# FPGA bitstream-from-FIT is supported via the PMU firmware
# (PM_FPGA_LOAD). Enable with FPGA_BITSTREAM=1 (opt-in).
ifeq ($(HW_SHA3),1)
# Use HAL for hash (see zynqmp.c)
HASH_HAL=1
CFLAGS+=-DWOLFBOOT_ZYNQMP_CSU
endif
ifeq ($(ZYNQMP_FSBL),1)
# wolfBoot fully replaces the Xilinx FSBL: the BootROM authenticates and
# loads wolfBoot into OCM at EL3, and wolfBoot runs psu_init() to bring up
# the PLLs/DDR/MIO/clocks before loading the downstream images. wolfBoot
# therefore links and runs entirely from OCM (DDR is not up at entry).
#
# The board-specific psu_init_gpl.c / psu_init_gpl.h (generated from the
# XSA, Xilinx copyright) are supplied at build time from
# ZYNQMP_PSU_INIT_DIR and are NOT part of the wolfBoot tree. The
# hal/zynqmp/ shim headers (xil_io.h, sleep.h) let that unmodified file
# compile. Set EL3_SECURE=1 in the target .config.
ZYNQMP_PSU_INIT_DIR?=hal/board/zynqmp
CFLAGS+=-DWOLFBOOT_ZYNQMP_FSBL
CFLAGS+=-Ihal/zynqmp -I$(ZYNQMP_PSU_INIT_DIR)
$(call LSCRIPT_IN_DEFAULT,hal/zynqmp_ocm.ld)
OBJS+=hal/zynqmp_psu_shim.o
OBJS+=hal/zynqmp_atf.o
OBJS+=$(ZYNQMP_PSU_INIT_DIR)/psu_init_gpl.o
# Load the PMU configuration object (EEMI permission table) into PMU
# firmware so the APU can control the SoC nodes. Like psu_init_gpl.c the
# pm_cfg_obj.c is design-specific and supplied from ZYNQMP_PSU_INIT_DIR.
ifeq ($(ZYNQMP_PM_CFG),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_PM_CFG
OBJS+=$(ZYNQMP_PSU_INIT_DIR)/pm_cfg_obj.o
endif
# Run the PS-GTR serdes init (USB3/SATA/PCIe/DP PHY lanes). Required if the
# kernel drives a PS-GTR peripheral (e.g. USB3 dwc3, whose probe hangs on
# an unclocked PHY). Skipped by default since QSPI/SD/RGMII boot needs no
# serdes; the shim runs the full calibrated sequence when enabled.
ifeq ($(ZYNQMP_PSU_INIT_SERDES),1)
CFLAGS+=-DZYNQMP_PSU_INIT_SERDES
endif
# FSBL security features (eFuse read, PUF, AES-CSU). At EL3 these access
# the CSU/eFuse controllers directly (pmu_mmio is direct MMIO in FSBL
# mode). Read-only eFuse dump today; PUF/AES land incrementally.
ifeq ($(ZYNQMP_SEC),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_FSBL_SEC
endif
# PUF register+regenerate self-test at boot (bring-up only; registers the
# PUF every boot). Opt-in, needs ZYNQMP_SEC=1.
ifeq ($(ZYNQMP_PUF_SELFTEST),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_PUF_SELFTEST
endif
# AES-CSU known-answer self-test at boot (KUP key; eFuse-safe). Opt-in.
ifeq ($(ZYNQMP_AES_SELFTEST),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_AES_SELFTEST
endif
# BBRAM AES key programming. Battery-backed and erasable, so unlike the
# eFuse AES key it can be replaced; it also has no temperature or supply
# voltage precondition. The key cannot be read back, so programming and
# CRC verification are a single operation. Opt-in.
ifeq ($(ZYNQMP_BBRAM),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_BBRAM
endif
# BBRAM program+verify check at boot (bring-up only; re-programs a fixed
# test key every boot and leaves it resident so battery retention can be
# seen across a power cycle). Reversible, eFuse-safe. Needs ZYNQMP_BBRAM=1.
ifeq ($(ZYNQMP_BBRAM_SELFTEST),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_BBRAM_SELFTEST
# The self-test calls into the BBRAM code, so it cannot be enabled on
# its own without an undefined reference.
CFLAGS+=-DWOLFBOOT_ZYNQMP_BBRAM
endif
# eFuse programming support. Report-only by default: the SysMon
# temperature/supply gate and the controller timing are built, the
# brick-class SEC_CTRL fuses are rejected unconditionally, and the
# program strobe is compiled out unless ZYNQMP_EFUSE_BURN is also set.
# OTP is one-shot -- enabling the burn is deliberate and irreversible.
ifeq ($(ZYNQMP_EFUSE_WRITE),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_EFUSE_WRITE
ifeq ($(ZYNQMP_EFUSE_BURN),1)
CFLAGS+=-DZYNQMP_EFUSE_BURN
endif
# Report the SysMon readings and whether the gate passes, at boot.
# Read-only; never programs a fuse.
ifeq ($(ZYNQMP_EFUSE_SELFTEST),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_EFUSE_SELFTEST
endif
endif
endif
endif
ifeq ($(TARGET),versal)
# AMD Versal ACAP (VMK180) - Dual Cortex-A72
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72
CFLAGS+=-DWOLFBOOT_DUALBOOT
# Support detection and skip of U-Boot legacy header
CFLAGS+=-DWOLFBOOT_UBOOT_LEGACY
# NOTE: FPGA_BITSTREAM is stubbed on Versal (PL config is a PDI loaded
# by the PLM via XilLoader Load-PDI IPI - not yet implemented). Leave
# FPGA_BITSTREAM off until that path lands.
# PLM owns RVBAR on Versal in JTAG boot; skip RVBAR writes
CFLAGS+=-DSKIP_RVBAR=1
# Disable SDMA for multi-block transfers - use PIO instead.
# The Versal Arasan SDHCI controller does not restart SDMA after
# boundary crossings via SRS22/SRS23 writes (Cadence-specific behavior).
CFLAGS_EXTRA+=-DSDHCI_SDMA_DISABLED
endif
ifeq ($(TARGET),agilex5)
# Altera Agilex 5: Cortex-A55, entered as non-secure BL33 at EL2 by
# the GSRD TF-A BL31 image. SPL owns DDR, clocks, pinmux and resets.
ARCH_FLAGS=-mcpu=cortex-a55+crypto -march=armv8.2-a+crypto \
-mtune=cortex-a55
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A55
CFLAGS+=-DWOLFBOOT_DUALBOOT -DWOLFBOOT_UBOOT_LEGACY
# BL31 owns GICv3 and secondary-core/PSCI setup. Do not touch RVBAR.
CFLAGS+=-DSKIP_RVBAR=1 -DSKIP_GIC_INIT=1
ifeq ($(DEBUG_UART),1)
OBJS+=hal/uart/ns16550.o
endif
# Full SDHCI host reset: SPL leaves the Cadence host in UHS-I 1.8V/SDR104,
# which mutes CMD8 against the 3.3V re-powered card (hardware-verified).
endif
ifeq ($(TARGET),nxp_ls1028a)
# DUART console on the generic driver (plain MMIO on AArch64).
ifeq ($(DEBUG_UART),1)
OBJS+=hal/uart/ns16550.o
endif
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72
# ZynqMP RVBAR (0xFD5C0040) does not exist on LS1028A -- the store faults
# pre-UART. Its reset vector comes from the boot ROM (DCFG BOOTLOCPTR).
CFLAGS+=-DSKIP_RVBAR=1
# MMU on (boot_aarch64_start.S LS1028A table): DDR Normal cacheable -- required
# for coherency with the ENETC coherent DMA (SICAR=0x27276767); CCSR/BAR Device.
CFLAGS +=-ffunction-sections -fdata-sections
LDFLAGS+=-Wl,--gc-sections
ifeq ($(DEBUG_UART),0)
CFLAGS+=-fno-builtin-printf
endif
# SD card disk boot uses the Freescale eSDHC driver, not the Cadence
# SDHCI one (the shared AARCH64 block below wires update_disk.o).
# hal/nxp_esdhc.c is SD card only, so DISK_EMMC has no driver here:
# reject it rather than silently link the wrong controller driver.
ifeq ($(DISK_EMMC),1)
$(error DISK_EMMC is not supported on nxp_ls1028a (hal/nxp_esdhc.c is SD card only))
endif
ifeq ($(DISK_SDCARD),1)
override DISK_DRIVER=esdhc
OBJS+=hal/nxp_esdhc.o
endif
SPI_TARGET=nxp
endif
ifeq ($(TARGET),tegra234)
# NVIDIA Jetson Orin (Tegra234, Cortex-A78AE): bare-metal wolfBoot as the
# BL33 firmware stage. The UEFI-application alternative is the aarch64_efi
# target. See hal/tegra234.c.
# -mstrict-align: wolfBoot runs with the MMU off, where every access is
# Device-nGnRnE and an unaligned access takes an alignment fault. Without
# it the compiler is free to emit unaligned accesses for struct copies.
ARCH_FLAGS=-mcpu=cortex-a78+crypto -march=armv8.2-a+crypto -mstrict-align
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A78
# wolfBoot links and runs at the BL33 (cpubl) load address; must agree with
# ORIGIN in hal/tegra234.ld or the RAM-boot overlap guard misjudges where
# wolfBoot lives.
WOLFBOOT_ORIGIN=0x272000000
# Bring-up: dump the state the prior stage handed wolfBoot (entry EL,
# SCTLR/MMU/cache bits, handoff x0/DTB pointer). Read-only; opt out for a
# quiet build.
ifeq ($(TEGRA234_HANDOFF_DUMP),1)
CFLAGS+=-DTEGRA234_HANDOFF_DUMP
endif
# SDMMC1 bring-up probe. Separate from the dump above because it MUTATES
# SoC state the booted OS inherits: it enables the SDMMC1 clock, deasserts
# its reset, and drives the SD power-rail GPIO. Off unless asked for.
ifeq ($(TEGRA234_SDMMC_PROBE),1)
CFLAGS+=-DTEGRA234_SDMMC_PROBE
endif
# MMU/WOLFBOOT_FDT/DUALBOOT + fdt.o come from the shared AARCH64 block.
# tegra234 stays MMU-off at runtime (1:1 physical); those flags only pull
# in the FDT/DTS codepath. EL2_HYPERVISOR+BOOT_EL1 add the EL2->EL1 drop
# with the DTB in x0 (config/examples/tegra234-linux.config).
ifeq ($(EL2_HYPERVISOR),1)
CFLAGS+=-DEL2_HYPERVISOR=1
endif
# BOOT_EL1 itself is emitted by options.mk; nothing to add here.
endif
ifeq ($(TARGET),imx8qm)
# Bare-metal wolfBoot as BL33, replacing U-Boot in the NXP boot container.
# SCFW trains DDR before any A-core runs. A53 is the lowest common
# denominator across the cluster pair; -mstrict-align because the MMU is off.
ARCH_FLAGS=-mcpu=cortex-a53+crypto -march=armv8-a+crypto -mstrict-align
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A53
# BL33 entry address. Must agree with ORIGIN in hal/imx8qm.ld.
WOLFBOOT_ORIGIN=0x80020000
# The RVBAR write in the full startup path is a ZynqMP register.
CFLAGS+=-DSKIP_RVBAR=1
# On by default: the SCU owns the console's power, clock and pads, so this
# is not optional at real BL33 entry.
IMX8QM_SCU ?= 1
ifeq ($(IMX8QM_SCU),1)
CFLAGS+=-DIMX8QM_SCU=1
endif
# Cacheable DRAM for load-and-verify, torn down before handoff.
ifeq ($(IMX8QM_MMU),1)
# The teardown needs the stack-free assembly routine in
# src/boot_aarch64_start.S, which this selects.
CFLAGS+=-DIMX8QM_MMU -DWOLFBOOT_AARCH64_MMU_TEARDOWN
# With the MMU on, DRAM is Normal cacheable and the wolfcrypt ARMv8
# assembly is safe: its NEON multi-register loads are only a problem
# while memory is Device-typed, which is why the shared AArch64 block
# defaults NO_ARM_ASM=1. Worth having, because SHA-384 dominates this
# target's boot: 4011 ms to 557 ms over a 32 MB image, hardware
# measured, with the signature still verifying. Set NO_ARM_ASM=1 to
# opt back out. This is first, so it wins the later ?= default.
NO_ARM_ASM ?= 0
endif
# Opt-in: pin the SD node to 3.3V high-speed and cap its clock. Off by
# default, since the board runs DDR50 at 50 MHz. Set it to keep Linux out
# of UHS, which is what makes a warm reboot work: once the card is at
# 1.8V, a reboot does no VDD cycle and wolfBoot's 3.3V CMD8 times out.
ifeq ($(IMX8QM_SD_NO_UHS),1)
CFLAGS+=-DIMX8QM_SD_NO_UHS
endif
# uSDHC board facts. Here rather than in the config because a command-line
# CFLAGS_EXTRA= would replace the config's, whereas CFLAGS is additive.
ifneq ($(filter 1,$(DISK_SDCARD) $(DISK_EMMC)),)
# Card detect is lsio_gpio5[22], so PRES_STATE bit 16 never sets.
# SDMA is on: the read is the dominant boot cost and PIO caps it near
# 1.6 MB/s regardless of bus clock. IMX8QM_SDHCI_PIO=1 falls back.
CFLAGS+=-DSDHCI_FORCE_CARD_DETECT
ifeq ($(IMX8QM_SDHCI_PIO),1)
CFLAGS+=-DSDHCI_SDMA_DISABLED
endif
# Read the payload in 64 KB chunks rather than the 512-byte default.
# A 32 MB image is 63083 separate commands at 512 bytes, and every one
# of them is below SDHCI_DMA_THRESHOLD (4 KB), so the transfer never
# reaches the SDMA path and pays full per-command overhead instead.
DISK_BLOCK_SIZE ?= 65536
CFLAGS+=-DDISK_BLOCK_SIZE=$(DISK_BLOCK_SIZE)
# Clock ceiling per medium: the SD is a removable slot whose sustained
# reads fail CRC above 25 MHz here; the soldered 8-bit eMMC has no such
# limit and takes the 3.3V high-speed rate. DISK_EMMC wins if both are
# set, matching the base-address selection in hal/imx8qm.c.
ifeq ($(DISK_EMMC),1)
IMX8QM_USDHC_MAX_CLK_KHZ ?= 52000
else ifeq ($(IMX8QM_SD_NO_UHS),1)
IMX8QM_USDHC_MAX_CLK_KHZ ?= 25000
else
IMX8QM_USDHC_MAX_CLK_KHZ ?= 50000
endif
CFLAGS+=-DIMX8QM_USDHC_MAX_CLK_KHZ=$(IMX8QM_USDHC_MAX_CLK_KHZ)
endif
# MMU/WOLFBOOT_FDT/DUALBOOT come from the shared AARCH64 block and only pull
# in the FDT codepath; imx8qm still runs MMU-off, 1:1.
ifeq ($(EL2_HYPERVISOR),1)
CFLAGS+=-DEL2_HYPERVISOR=1
endif
endif
ifeq ($(TARGET),imx95_a55)
# NXP i.MX95 Cortex-A55 cluster, running as BL33 in AHAB container 2.
# -mstrict-align because this stage runs with the MMU off, so every access
# is Device-nGnRnE and unaligned ones fault.
ARCH_FLAGS=-mcpu=cortex-a55+crypto -march=armv8.2-a+crypto -mstrict-align
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A55
LDFLAGS+=$(ARCH_FLAGS)
# BL31 loads and enters this image here; must match ORIGIN in
# hal/imx95_a55.ld and IMX95_BL33_BASE in hal/imx95_a55.h.
WOLFBOOT_ORIGIN=0x90200000
# Console, SCMI client and uSDHC driver all live in hal/imx95_a55.c, so none
# needs its own object; the switches below pick which paths compile in.
# Bring-up aid: print the entry EL, SCTLR and handoff x0 that BL31 passed.
ifeq ($(IMX95_HANDOFF_DUMP),1)
CFLAGS+=-DIMX95_HANDOFF_DUMP
endif
# i.MX95 is GICv3 and BL31 already configured it. EL2_HYPERVISOR is not a
# generic options.mk variable, so it is emitted here as tegra234 does.
ifeq ($(EL2_HYPERVISOR),1)
CFLAGS+=-DEL2_HYPERVISOR=1
endif
# i.MX uSDHC is not SDHCI-compatible: skip src/sdhci.c, use our driver.
ifneq ($(filter 1,$(DISK_SDCARD) $(DISK_EMMC)),)
DISK_DRIVER=usdhc
# SCMI cold-init of uSDHC2 (clock+pinmux) when no prior stage did it.
ifeq ($(IMX95_SCMI_COLD_INIT),1)
CFLAGS+=-DIMX95_SCMI_COLD_INIT
endif
endif
# SCMI M7 power-on + TCM ECC scrub (U-Boot's power_on_m7 equivalent) for a
# Cortex-M7 that Linux launches later. Independent of the disk driver.
ifeq ($(IMX95_INIT_M7),1)
CFLAGS+=-DIMX95_INIT_M7
endif
# One-shot diagnostic: read the AHAB container out of the eMMC boot
# partitions and report it, from inside an image that boots from SD.
ifeq ($(IMX95_EMMC_PROBE),1)
CFLAGS+=-DIMX95_EMMC_PROBE
OBJS+=hal/imx95_ahab.o
endif
# Mirror the console into a DDR ring that survives the handoff to Linux.
ifeq ($(IMX95_LOG_RING),1)
CFLAGS+=-DIMX95_LOG_RING
endif
# Stage 1 and BL33 must agree on where the ring lives, and both read this
# from arch.mk, which stage1/Makefile includes.
ifneq ($(IMX95_LOG_RING_BASE),)
CFLAGS+=-DIMX95_LOG_RING_BASE=$(IMX95_LOG_RING_BASE)
endif
# Verbose per-step trace of the SCMI cold-init and SD bring-up.
ifeq ($(IMX95_SCMI_DEBUG),1)
CFLAGS+=-DIMX95_SCMI_DEBUG
endif
endif
ifeq ($(TARGET),cm4)
# Raspberry Pi Compute Module 4 - Broadcom BCM2711, Cortex-A72
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
# -mstrict-align: the plain RAM-boot config runs with the MMU off (simple
# startup), where all memory is Device-nGnRnE and unaligned access faults.
# The FIPS / disk configs bring up an identity MMU first (CM4_USE_MMU in
# hal/cm4.c). cm4 defaults to NO_ARM_ASM=1, which keeps it off the wolfcrypt
# ARM port asm (NEON structure loads); it does NOT disable the SP ECC
# AArch64 asm, which is gated on __aarch64__ in include/user_settings.h. So
# -mstrict-align keeps every config safe either way.
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72 -mstrict-align
# RAUC A/B slot selection via a raw U-Boot env partition (wolfBoot replaces
# U-Boot's boot script). Adds the env state-machine module + define.
ifeq ($(CM4_RAUC_AB),1)
OBJS+=src/ubootenv.o
CFLAGS+=-DCM4_RAUC_AB
endif
endif
# Default ARM ASM setting for unrecognized AARCH64 targets. cm4 defaults to
# NO_ARM_ASM=1, which keeps it off the wolfcrypt ARM port asm (WOLFSSL_ARMASM /
# wolfcrypt/src/port/arm/*, the NEON multi-register loads that would fault
# MMU-off in the plain config). NO_ARM_ASM does NOT disable the SP ECC AArch64
# asm (sp_arm64.c / WOLFSSL_SP_ARM64_ASM); that is enabled independently on
# __aarch64__ in include/user_settings.h, so a non-FIPS cm4 build still links
# sp_arm64 asm.
ifeq ($(filter zynq versal agilex5 nxp_ls1028a imx95_a55,$(TARGET)),)
NO_ARM_ASM?=1
endif
ifeq ($(SPMATH),1)
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_arm64.o
endif
ifneq ($(NO_ARM_ASM),1)
ARCH_FLAGS=-mstrict-align
CFLAGS+=$(ARCH_FLAGS) -DWOLFSSL_ARMASM -DWOLFSSL_ARMASM_INLINE -DWC_HASH_DATA_ALIGNMENT=8 -DWOLFSSL_AARCH64_PRIVILEGE_MODE
WOLFCRYPT_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/cpuid.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-sha512-asm_c.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-sha3-asm_c.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-aes-asm_c.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-sha256-asm_c.o
endif
endif
## ARM Cortex-M
ifeq ($(ARCH),ARM)
CROSS_COMPILE?=arm-none-eabi-
CFLAGS+=-DARCH_ARM
CFLAGS+=-mthumb -mlittle-endian
LDFLAGS+=-mthumb -mlittle-endian
ifeq ($(USE_GCC),1)
ifeq ($(findstring clang,$(notdir $(CC))),)
CFLAGS+=-mthumb-interwork
LDFLAGS+=-mthumb-interwork
endif
endif
## Target specific configuration
ifeq ($(TARGET),samr21)
CORTEX_M0=1
endif
ifeq ($(TARGET),imx_rt)
CORTEX_M7=1
endif
ifeq ($(TARGET),imx95_m7)
CORTEX_M7=1
endif
ifeq ($(TARGET),stm32l0)
CORTEX_M0=1
SPI_TARGET=stm32
endif
ifeq ($(TARGET),stm32c0)
CORTEX_M0=1
ARCH_FLASH_OFFSET=0x08000000
endif
ifeq ($(TARGET),stm32g0)
CORTEX_M0=1
ARCH_FLASH_OFFSET=0x08000000
endif
ifeq ($(TARGET),stm32g4)
ARCH_FLASH_OFFSET=0x08000000
endif
ifeq ($(TARGET),stm32f1)
CORTEX_M3=1
NO_ARM_ASM=1
ARCH_FLASH_OFFSET=0x08000000
endif
ifeq ($(TARGET),stm32f4)
ARCH_FLASH_OFFSET=0x08000000
SPI_TARGET=stm32
# Partition trailers in sectors 1-2, see hal/stm32f4.c
ifeq ($(CUSTOM_PARTITION_TRAILER),1)
$(call LSCRIPT_IN_DEFAULT,hal/stm32f4-trailer.ld)
endif
endif
ifeq ($(TARGET),max32666)
ARCH_FLASH_OFFSET=0x10000000
ifeq ($(MAX32666_FTHR2),1)
CFLAGS+=-DMAX32666_FTHR2
endif
# MAX3266X TPU hardware SHA256 acceleration (requires MSDK_DIR)
ifeq ($(MAX3266X_TPU),1)
NO_ARM_ASM=1
CFLAGS+=-DMAX3266X_SHA -DFAST_MEMCPY
CFLAGS+=-ffunction-sections -fdata-sections
CFLAGS+=-DTARGET=MAX32665 -DTARGET_REV=0x4131
ifeq ($(MAX3266X_OLD),1)
# Older Maxim SDK tree (flat MAX32665PeriphDriver layout)
CFLAGS+=-DWOLFSSL_MAX3266X_OLD
MAX3266X_CFLAGS:= \
-I$(MSDK_DIR)/Libraries/MAX32665PeriphDriver/Include/ \
-I$(MSDK_DIR)/Libraries/CMSIS/Device/Maxim/MAX32665/Include/ \
-I$(MSDK_DIR)/Libraries/CMSIS/Include/
CFLAGS+=$(MAX3266X_CFLAGS)
OBJS+=$(MSDK_DIR)/Libraries/MAX32665PeriphDriver/Source/mxc_sys.o \
$(MSDK_DIR)/Libraries/MAX32665PeriphDriver/Source/mxc_delay.o
else
CFLAGS+=-DWOLFSSL_MAX3266X
MAX3266X_CFLAGS:= \
-I$(MSDK_DIR)/Libraries/PeriphDrivers/Include/MAX32665/ \
-I$(MSDK_DIR)/Libraries/CMSIS/Device/Maxim/MAX32665/Include/ \
-I$(MSDK_DIR)/Libraries/PeriphDrivers/Source/TPU/ \
-I$(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/ \
-I$(MSDK_DIR)/Libraries/CMSIS/Include/
CFLAGS+=$(MAX3266X_CFLAGS)
OBJS+=$(MSDK_DIR)/Libraries/PeriphDrivers/Source/TPU/tpu_me14.o \
$(MSDK_DIR)/Libraries/PeriphDrivers/Source/TPU/tpu_reva.o \
$(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/sys_me14.o \
$(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/mxc_delay.o
endif
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/maxim/max3266x.o
endif
endif
ifeq ($(TARGET),pic32cz)
ARCH_FLASH_OFFSET=0x08000000
CORTEX_M7=1
OBJS+=hal/pic32c.o
ifeq ($(WOLFHSM_CLIENT),1)
# Normally already resolved to an absolute path (and exported) by the
# top-level Makefile; this default only covers a standalone test-app make.
WOLFHSM_MICROCHIP_PIC32CZ ?= ..
CFLAGS+=-I$(WOLFHSM_MICROCHIP_PIC32CZ) \
-DWOLFHSM_CFG_NO_SYS_TIME \
-DWOLFHSM_CFG_TRANSPORT_MEM \
-DWOLFHSM_CFG_CLIENT_ID=WOLFBOOT_WOLFHSM_CLIENT_ID \
-DPIC32CZ_CFG_SHARED_MEM_PHYS_BASE=0x20100000U \
-DPIC32CZ_CFG_SHARED_MEM_REQ_SIZE=4096 \
-DPIC32CZ_CFG_SHARED_MEM_RESP_SIZE=4096 \
'-DPIC32CZ_CFG_SHARED_MEM_TOTAL_SIZE=(PIC32CZ_CFG_SHARED_MEM_REQ_SIZE+PIC32CZ_CFG_SHARED_MEM_RESP_SIZE)'
OBJS+=$(WOLFHSM_MICROCHIP_PIC32CZ)/port/mailbox.o \
$(WOLFHSM_MICROCHIP_PIC32CZ)/port/client/czhsm_client.o \
$(WOLFHSM_MICROCHIP_PIC32CZ)/port/client/fwmetadata.o \
$(WOLFBOOT_LIB_WOLFHSM)/src/wh_transport_mem.o
# HSM server firmware. Optional: set HSM_FW_BIN to have wolfBoot load/boot
# the HSM core from it at boot; leave it unset when the firmware is already
# resident and wolfBoot must not touch it.
ifneq ($(HSM_FW_BIN),)
ifeq ($(wildcard $(HSM_FW_BIN)),)
$(error HSM_FW_BIN=$(HSM_FW_BIN) not found: build the wolfHSM server \
firmware before wolfBoot)
endif
HSM_FW_ADDR?=0x0c1c0000
HSM_FW_SIZE:=$(shell stat -c %s $(HSM_FW_BIN))
CFLAGS+=-DHSM_FW_ADDR=$(HSM_FW_ADDR) -DHSM_FW_SIZE=$(HSM_FW_SIZE)
endif
# Signing pubkey header. Optional: set HSM_PUBKEY_HEADER to have the HAL
# push the key into the HSM at boot; leave it unset when pre-provisioned.
ifneq ($(HSM_PUBKEY_HEADER),)
CFLAGS+=-DHSM_PUBKEY_HEADER='"$(HSM_PUBKEY_HEADER)"'
endif
endif
endif
ifeq ($(TARGET),pic32ck)
ARCH_FLASH_OFFSET=0x08000000
CORTEX_M33=1
OBJS+=hal/pic32c.o
endif
ifeq ($(TARGET),stm32l4)
SPI_TARGET=stm32
ARCH_FLASH_OFFSET=0x08000000
OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.o
OBJS+=$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.o
CFLAGS+=-DSTM32L4A6xx -DUSE_HAL_DRIVER -Isrc -Ihal \
-I$(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Inc/ \
-I$(STM32CUBE)/Drivers/BSP/STM32L4xx_Nucleo_144/ \
-I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ \
-I$(STM32CUBE)/Drivers/CMSIS/Include/
endif
ifeq ($(TARGET),stm32f7)
CORTEX_M7=1
ARCH_FLASH_OFFSET=0x08000000
SPI_TARGET=stm32
endif
ifeq ($(TARGET),stm32h7)
CORTEX_M7=1
ARCH_FLASH_OFFSET=0x08000000
SPI_TARGET=stm32
endif
# STM32H7S/H7R: wolfBoot runs from the 64 KB internal flash and keeps
# all three partitions on an external Octo-SPI NOR reached over XSPI2.
# The HAL implements ext_flash_* directly, so OCTOSPI_FLASH is left off:
# setting it would alias ext_flash_* onto src/qspi_flash.c, whose
# transfer helper disables the controller on every command.
ifeq ($(TARGET),stm32h7s)
CORTEX_M7=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x08000000
WOLFBOOT_ORIGIN=0x08000000
EXT_FLASH=1
PART_UPDATE_EXT=1
PART_SWAP_EXT=1
# hal_init() takes PLL1 to 600 MHz and drives the XSPI2 kernel clock
# from PLL2. Set STM32H7S_HSI_ONLY=1 to stay on the 64 MHz HSI reset
# clock instead, which is a smaller thing to debug during bring-up.
STM32H7S_HSI_ONLY?=0
CFLAGS+=-DSTM32H7S_HSI_ONLY=$(STM32H7S_HSI_ONLY)
endif
# Defaults for linker script placeholders (overridden when WOLFHAL=1)
WOLFHAL_FLASH_EXCLUDE_TEXT?=*(.text*)
WOLFHAL_FLASH_EXCLUDE_RODATA?=*(.rodata*)
WOLFHAL_FLASH_RAM_SECTIONS?=
ifeq ($(TARGET),stm32wb)
ARCH_FLASH_OFFSET=0x08000000
SPI_TARGET=stm32
ifneq ($(PKA),0)
PKA_EXTRA_OBJS+= $(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pka.o $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/st/stm32.o
PKA_EXTRA_CFLAGS+=-DWOLFSSL_STM32WB -DWOLFSSL_STM32_PKA -DWOLFSSL_STM32_CUBEMX -DNO_STM32_HASH -DSTM32WB55xx
PKA_EXTRA_CFLAGS+=-Isrc -Ihal \
-I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc \
-I$(STM32CUBE)/Drivers/BSP/P-NUCLEO-WB55.Nucleo/ \
-I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32WBxx/Include \
-I$(STM32CUBE)/Drivers/STM32WBxx_HAL_Driver/Inc \
-I$(STM32CUBE)/Drivers/CMSIS/Include
endif
endif
ifeq ($(TARGET),stm32wba)
CORTEX_M33=1
ARCH_FLASH_OFFSET=0x08000000
SPI_TARGET=stm32
endif
ifeq ($(TARGET),stm32l5)
CORTEX_M33=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x08000000
ifeq ($(TZEN),1)
WOLFBOOT_ORIGIN=0x0C000000
else
WOLFBOOT_ORIGIN=0x08000000
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET)-ns.ld)
endif
endif
ifeq ($(TARGET),stm32u5)
CORTEX_M33=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x08000000
ifeq ($(TZEN),1)
WOLFBOOT_ORIGIN=0x0C000000
else
WOLFBOOT_ORIGIN=0x08000000
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET)-ns.ld)
endif
SPI_TARGET=stm32
endif
ifeq ($(TARGET),stm32u3)
CORTEX_M33=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x08000000
WOLFBOOT_ORIGIN=0x08000000
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET).ld)
SPI_TARGET=stm32
endif
ifeq ($(TARGET),stm32c5)
CORTEX_M33=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x08000000
WOLFBOOT_ORIGIN=0x08000000
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET).ld)
SPI_TARGET=stm32
endif
ifeq ($(TARGET),psoc_c3)
CORTEX_M33=1
CFLAGS+=-Ihal
# Code executes from the Secure CBUS alias; the BootROM flash API is
# reached through the Secure SBUS alias, which the HAL derives from it.
ARCH_FLASH_OFFSET=0x12000000
WOLFBOOT_ORIGIN=0x12000000
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET).ld)
SPI_TARGET=psoc_c3
# Board wiring. Defaults match the PSOC Control C3 evaluation kit; override
# for another variant.
PSOC_C3_UART_SCB?=3
PSOC_C3_UART_PORT?=6
PSOC_C3_UART_PCLK_GR?=4
PSOC_C3_UART_PCLK_IDX?=6
PSOC_C3_PCLK_HZ?=48000000
PSOC_C3_SPI_SCB?=2
PSOC_C3_SPI_PORT?=7
PSOC_C3_SPI_HSIOM_SEL?=17
CFLAGS+=-DPSOC_C3_UART_SCB=$(PSOC_C3_UART_SCB)
CFLAGS+=-DPSOC_C3_UART_PORT=$(PSOC_C3_UART_PORT)
CFLAGS+=-DPSOC_C3_UART_PCLK_GR=$(PSOC_C3_UART_PCLK_GR)
CFLAGS+=-DPSOC_C3_UART_PCLK_IDX=$(PSOC_C3_UART_PCLK_IDX)
CFLAGS+=-DPSOC_C3_PCLK_HZ=$(PSOC_C3_PCLK_HZ)
CFLAGS+=-DPSOC_C3_SPI_SCB=$(PSOC_C3_SPI_SCB)
CFLAGS+=-DPSOC_C3_SPI_PORT=$(PSOC_C3_SPI_PORT)
CFLAGS+=-DPSOC_C3_SPI_HSIOM_SEL=$(PSOC_C3_SPI_HSIOM_SEL)
# I2C: SCB0 on P9.0 (SCL) and P9.2 (SDA), HSIOM selector 15.
PSOC_C3_I2C_SCB?=0
PSOC_C3_I2C_PORT?=9
PSOC_C3_I2C_SCL_PIN?=0
PSOC_C3_I2C_SDA_PIN?=2
PSOC_C3_I2C_HSIOM_SEL?=15
PSOC_C3_I2C_HZ?=100000
PSOC_C3_TPM_SEL_PORT?=7
PSOC_C3_TPM_SEL_PIN?=7
CFLAGS+=-DPSOC_C3_TPM_SEL_PORT=$(PSOC_C3_TPM_SEL_PORT)
CFLAGS+=-DPSOC_C3_TPM_SEL_PIN=$(PSOC_C3_TPM_SEL_PIN)
CFLAGS+=-DPSOC_C3_I2C_SCB=$(PSOC_C3_I2C_SCB)
CFLAGS+=-DPSOC_C3_I2C_PORT=$(PSOC_C3_I2C_PORT)
CFLAGS+=-DPSOC_C3_I2C_SCL_PIN=$(PSOC_C3_I2C_SCL_PIN)
CFLAGS+=-DPSOC_C3_I2C_SDA_PIN=$(PSOC_C3_I2C_SDA_PIN)
CFLAGS+=-DPSOC_C3_I2C_HSIOM_SEL=$(PSOC_C3_I2C_HSIOM_SEL)
CFLAGS+=-DPSOC_C3_I2C_HZ=$(PSOC_C3_I2C_HZ)
endif
ifeq ($(TARGET),psoc_e8)
CORTEX_M33=1
CFLAGS+=-Ihal
# Extended boot runs the first CM33 image in place, after a 0x400 boot
# header: from QSPI by default, or from RRAM with PSOC_E8_BOOT_RRAM=1
# (needs the boot policy reprovisioned). ARCH_FLASH_OFFSET is the slot,
# which also holds the header's 0x28-byte SHA-256 trailer after wolfBoot.
PSOC_E8_BOOT_RRAM?=0
ifeq ($(PSOC_E8_BOOT_RRAM),1)
PSOC_E8_RRAM_SLOT_SIZE?=0x20000
ARCH_FLASH_OFFSET=0x12011000
WOLFBOOT_ORIGIN=0x12011400
BOOTLOADER_PARTITION_SIZE=$$(( $(PSOC_E8_RRAM_SLOT_SIZE) - 0x400 - 0x40))
else
ARCH_FLASH_OFFSET=0x18100000
WOLFBOOT_ORIGIN=0x18100400
# The boot partition is in the Non-secure alias with TZEN=1.
BOOTLOADER_PARTITION_SIZE=$$(( ($(WOLFBOOT_PARTITION_BOOT_ADDRESS) | 0x10000000) - $(WOLFBOOT_ORIGIN) - 0x40))
endif
ifeq ($(TZEN),1)
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET)-tz.ld)
OBJS+=hal/psoc_e8_tz.o
# wolfHSM NVM in the RRAM user area, Secure.
WOLFBOOT_KEYVAULT_ADDRESS?=0x32040000
WOLFBOOT_KEYVAULT_SIZE?=0x10000
else
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET).ld)
endif
# Board wiring, defaulted for KIT_PSE84_AI.
PSOC_E8_UART_SCB?=2
PSOC_E8_UART_PORT?=6
PSOC_E8_UART_RX_PIN?=5
PSOC_E8_UART_TX_PIN?=7
PSOC_E8_UART_HSIOM_SEL?=20
PSOC_E8_UART_PCLK_GR?=1
PSOC_E8_UART_PCLK_IDX?=1
PSOC_E8_PCLK_HZ?=100000000
PSOC_E8_QSPI_SECTOR_SIZE?=0x40000
PSOC_E8_QSPI_SIZE?=0x4000000
PSOC_E8_CPU_HZ?=200000000
CFLAGS+=-DPSOC_E8_UART_SCB=$(PSOC_E8_UART_SCB)
CFLAGS+=-DPSOC_E8_UART_PORT=$(PSOC_E8_UART_PORT)
CFLAGS+=-DPSOC_E8_UART_RX_PIN=$(PSOC_E8_UART_RX_PIN)
CFLAGS+=-DPSOC_E8_UART_TX_PIN=$(PSOC_E8_UART_TX_PIN)
CFLAGS+=-DPSOC_E8_UART_HSIOM_SEL=$(PSOC_E8_UART_HSIOM_SEL)
CFLAGS+=-DPSOC_E8_UART_PCLK_GR=$(PSOC_E8_UART_PCLK_GR)
CFLAGS+=-DPSOC_E8_UART_PCLK_IDX=$(PSOC_E8_UART_PCLK_IDX)
CFLAGS+=-DPSOC_E8_PCLK_HZ=$(PSOC_E8_PCLK_HZ)
CFLAGS+=-DPSOC_E8_QSPI_SECTOR_SIZE=$(PSOC_E8_QSPI_SECTOR_SIZE)
# QSPI through src/qspi_flash.c, single-line with 4-byte opcodes. The
# driver runs from RAM because wolfBoot executes from the same device; it
# is used directly, not as EXT_FLASH, so the partitions stay in place.
OBJS+=src/qspi_flash.o
CFLAGS+=-DQSPI_FLASH -DQSPI_FLASH_RAM_CODE -DQSPI_ADDR_SZ=4
CFLAGS+=-DQSPI_NO_4BYTE_MODE
CFLAGS+=-DQSPI_DATA_MODE=QSPI_DATA_MODE_SPI
CFLAGS+=-DPAGE_PROG_CMD=0x12 -DSEC_ERASE_CMD=0xDC
CFLAGS+=-DFLASH_DEVICE_SIZE=$(PSOC_E8_QSPI_SIZE)
CFLAGS+=-DSPI_FLASH_SECTOR_SIZE=$(PSOC_E8_QSPI_SECTOR_SIZE)
CFLAGS+=-DQSPI_FLASH_READY_TRIES=4000000
CFLAGS+=-DPSOC_E8_CPU_HZ=$(PSOC_E8_CPU_HZ)
endif
ifeq ($(TARGET),m2354)
CORTEX_M23=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x00000000
WOLFBOOT_ORIGIN=0x00000000
ifneq ($(TZEN),1)
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET)-ns.ld)
endif
endif
ifeq ($(TARGET),stm32h5)
CORTEX_M33=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x08000000
ifeq ($(TZEN),1)
WOLFBOOT_ORIGIN=0x0C000000
else
WOLFBOOT_ORIGIN=0x08000000
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET)-ns.ld)
endif
SPI_TARGET=stm32
ifneq ($(DEBUG),0)
CFLAGS+=-DPKCS11_SMALL
endif
endif
ifeq ($(TARGET),stm32n6)
CORTEX_M55=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x70000000
# Boot ROM copies FSBL from NOR to AXISRAM2 at 0x34180400.
# The signing -la flag in the flash script must match.
WOLFBOOT_ORIGIN=0x34180400
EXT_FLASH=1
PART_UPDATE_EXT=1
PART_SWAP_EXT=1
endif
ifeq ($(TARGET),rp2350)
CORTEX_M33=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x10000000
WOLFBOOT_ORIGIN=0x10000000
ifeq ($(TZEN),1)
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET).ld)
else
$(call LSCRIPT_IN_DEFAULT,hal/$(TARGET)-ns.ld)
endif
SPI_TARGET=raspberrypi_pico
CFLAGS+=-DPICO_SDK_PATH=$(PICO_SDK_PATH)
CFLAGS+=-I$(PICO_SDK_PATH)/src/common/pico_stdlib_headers/include
endif
ifeq ($(TARGET),rtl8735b)
# RealTek RTL8735B SoC (Cortex-M33), e.g. the AmebaPro2 EVB. wolfBoot is
# staged into SRAM by the RealTek bootloader and copies the verified app
# from external SPI NOR into DDR before jumping (src/update_ram.c RAMBOOT).
CORTEX_M33=1
CFLAGS+=-Ihal
# ASDK 10.3.0 toolchain (system arm-none-eabi-gcc clashes on newlib/lwip).
CROSS_COMPILE:=$(ASDK_PATH)/arm-none-eabi-
# Match the RealTek SDK FPU/ABI (-mfpu=fpv5-sp-d16 -mfloat-abi=softfp) so
# linking the SDK libraries is consistent; wolfBoot enables the FPU at
# hal_init before any SDK code runs.
CFLAGS+=-mfpu=fpv5-sp-d16 -mfloat-abi=softfp
LDFLAGS+=-mfpu=fpv5-sp-d16 -mfloat-abi=softfp
UPDATE_OBJS:=src/update_ram.o
CFLAGS+=-DWOLFBOOT_DUALBOOT
CFLAGS+=-ffunction-sections -fdata-sections
LDFLAGS+=-Wl,--gc-sections
# Flash/UART/cache backend: "sdk" (default, RealTek SDK drivers) or "bare"
# (smaller, no SDK dependency -- not yet implemented). See hal/rtl8735b.c.
HAL_BACKEND?=sdk
ifeq ($(HAL_BACKEND),sdk)
CFLAGS+=-DHAL_BACKEND_SDK
# The SDK backend folds the RealTek SDK driver chain into hal/rtl8735b.o.
# Its objects.h pulls the SDK's "hal.h" (defines flash_t,
# hal_audio_adapter_t, ...); wolfBoot also ships "hal.h". hal/rtl8735b.c
# does not include wolfBoot's hal.h, and the SDK dirs are passed with
# -iquote (searched before the global -I for quoted includes) so the SDK
# objects.h "hal.h" resolves to the SDK one for THIS object only. sdk-shim
# supplies a stub cmsis_os.h so the chain does not pull CMSIS-OS/FreeRTOS
# (wolfBoot never calls it). The CONFIG_* defines mirror the bare-metal
# bootloader build; -mcmse satisfies the SDK cache header (SCB_NS). The
# rest of wolfBoot stays plain M33.
HAL_SDK_IQUOTE=-iquote $(WOLFBOOT_ROOT)/hal/rtl8735b/sdk-shim \
-iquote $(AMEBA_SDK)/component/mbed/hal_ext \
-iquote $(AMEBA_SDK)/component/mbed/hal \
-iquote $(AMEBA_SDK)/component/mbed/api \
-iquote $(AMEBA_SDK)/component/mbed/targets/hal/rtl8735b \
-iquote $(AMEBA_SDK)/component/soc/8735b/fwlib/rtl8735b/include \
-iquote $(AMEBA_SDK)/component/soc/8735b/fwlib/rtl8735b/lib/include \
-iquote $(AMEBA_SDK)/component/soc/8735b/cmsis/rtl8735b/include \
-iquote $(AMEBA_SDK)/component/soc/8735b/cmsis/rtl8735b/lib/include \
-iquote $(AMEBA_SDK)/component/soc/8735b/cmsis/cmsis-core/include \
-iquote $(AMEBA_SDK)/component/soc/8735b/app/rtl_printf/include \
-iquote $(AMEBA_SDK)/component/soc/8735b/app/stdio_port \
-iquote $(AMEBA_SDK)/component/soc/8735b/misc/utilities/include \
-iquote $(AMEBA_SDK)/component/os/os_dep/include
# The same dirs as plain -I too, so angle-bracket includes (e.g. some
# CMSIS-Core headers) resolve; -iquote only covers quoted includes.
HAL_SDK_INC=$(patsubst -iquote,-I,$(HAL_SDK_IQUOTE))
HAL_SDK_DEFS=-DCONFIG_PLATFORM_8735B -DCONFIG_RTL8735B_PLATFORM=1 \
-DCONFIG_BUILD_RAM=1
hal/rtl8735b.o: CFLAGS += $(HAL_SDK_IQUOTE) $(HAL_SDK_INC) $(HAL_SDK_DEFS) -mcmse
# Final link also needs the SDK fwlib + ROM symbol table; point at the
# prebuilt SDK lib/objects and ROM symbol linker file during bring-up:
# make TARGET=rtl8735b LIBS+=... LDFLAGS_EXTRA="-T<rom_symbol.ld>"
else
CFLAGS+=-DHAL_BACKEND_BARE
endif
endif
ifeq ($(TARGET),sama5d3)
CORTEX_A5=1
UPDATE_OBJS:=src/update_ram.o
CFLAGS+=-DWOLFBOOT_DUALBOOT -DEXT_FLASH -DNAND_FLASH -fno-builtin -ffreestanding
CFLAGS+=-DWOLFBOOT_USE_STDLIBC
endif
ifeq ($(TARGET),zynq7000)
# AMD/Xilinx Zynq-7000 (Cortex-A9, ARMv7-A) - ZC702 Evaluation Kit.
# Loaded by Xilinx FSBL into DDR; see hal/zynq7000.{c,h,ld}.
CORTEX_A9=1
UPDATE_OBJS:=src/update_ram.o
CFLAGS+=-DWOLFBOOT_DUALBOOT -fno-builtin -ffreestanding
# Do NOT define WOLFBOOT_USE_STDLIBC: newlib's memcpy uses unaligned
# LDRs which fault on ARMv7-A whenever the active mapping treats memory
# as Strongly-Ordered (typically MMU off, but also some boot-stage
# configurations). wolfBoot's startup keeps FSBL's MMU + flat 1:1
# mapping enabled to avoid that, but we still link against the
# aligned-safe memcpy in src/string.c so unaligned loads can never
# surprise us regardless of MMU state.
# Enable the legacy 64-byte uImage header strip unconditionally to
# match sibling Xilinx targets (zynqmp, versal). update_ram.c
# validates magic + ih_hcrc (header CRC32) + ih_size before
# stripping, so a non-uImage payload whose first 4 bytes happen to
# match UBOOT_IMG_HDR_MAGIC cannot be silently treated as a uImage
# -- the additional CRC32 + size checks drop the joint false-
# positive probability from ~2^-32 to ~2^-64, matching what U-Boot's
# own mkimage/bootm does.
CFLAGS+=-DWOLFBOOT_UBOOT_LEGACY
# FPGA bitstream-from-FIT is supported via the DevC/PCAP DMA engine
# (full bitstream). Enable with FPGA_BITSTREAM=1 (opt-in).
endif
ifeq ($(TARGET),va416x0)
CFLAGS+=-I$(WOLFBOOT_ROOT)/hal/vorago/ \
-I$(VORAGO_SDK_DIR)/common/drivers/hdr/ \
-I$(VORAGO_SDK_DIR)/common/mcu/hdr/ \
-I$(VORAGO_SDK_DIR)/common/utils/hdr/
SDK_OBJS=$(VORAGO_SDK_DIR)/common/drivers/src/va416xx_hal.o \
$(VORAGO_SDK_DIR)/common/drivers/src/va416xx_hal_spi.o \
$(VORAGO_SDK_DIR)/common/drivers/src/va416xx_hal_clkgen.o \
$(VORAGO_SDK_DIR)/common/drivers/src/va416xx_hal_ioconfig.o \
$(VORAGO_SDK_DIR)/common/drivers/src/va416xx_hal_irqrouter.o \
$(VORAGO_SDK_DIR)/common/drivers/src/va416xx_hal_uart.o \
$(VORAGO_SDK_DIR)/common/drivers/src/va416xx_hal_timer.o \
$(VORAGO_SDK_DIR)/common/mcu/src/system_va416xx.o
ifeq ($(USE_HAL_SPI_FRAM),1)
SDK_OBJS+=$(VORAGO_SDK_DIR)/common/utils/src/spi_fram.o
CFLAGS+=-DUSE_HAL_SPI_FRAM
endif
OBJS+=$(SDK_OBJS)
endif
## Cortex CPU
ifeq ($(CORTEX_R5),1)
CFLAGS+=-mcpu=cortex-r5 -DCORTEX_R5
LDFLAGS+=-mcpu=cortex-r5
ifeq ($(NO_ASM),1)
ifeq ($(SPMATH),1)
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o
endif