Skip to content

Commit 254cfa5

Browse files
authored
Merge pull request #975 from aidangarske/psoc6-eval
PSoC 6 parity and CY8CEVAL-062S2 support, with two core power cut fixes
2 parents 8c1f19e + 896163d commit 254cfa5

33 files changed

Lines changed: 4621 additions & 700 deletions

‎.github/workflows/test-build-psoc6.yml‎

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Wolfboot Reusable Build Workflow for Cypress PSoC6
1+
name: Wolfboot Reusable Build Workflow for Infineon PSoC 6
22

33
on:
44

@@ -13,6 +13,10 @@ on:
1313
make-args:
1414
required: false
1515
type: string
16+
ramcode-check:
17+
required: false
18+
type: boolean
19+
default: false
1620

1721
jobs:
1822

@@ -27,31 +31,12 @@ jobs:
2731
with:
2832
submodules: true
2933

30-
- uses: actions/checkout@v4
31-
with:
32-
repository: Infineon/psoc6pdl
33-
path: lib/psoc6pdl
34-
35-
- uses: actions/checkout@v4
36-
with:
37-
repository: Infineon/TARGET_CY8CKIT-062S2-43012
38-
path: lib/TARGET_CY8CKIT-062S2-43012
39-
40-
- uses: actions/checkout@v4
41-
with:
42-
repository: Infineon/core-lib
43-
path: lib/core-lib
44-
4534
- name: Trust workspace
4635
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
4736

48-
- name: Patch cy_syslib.c to declare cy_delay32kMs
37+
- name: Fetch Infineon PSoC 6 libraries
4938
run: |
50-
# Add extern declaration for cy_delay32kMs directly in cy_syslib.c
51-
# Find the line with the include and add the extern declaration after it
52-
awk '/#include "cy_syslib.h"/ {print; print ""; print "/* Extern declaration for delay variable */"; print "extern uint32_t cy_delay32kMs;"; next} 1' \
53-
lib/psoc6pdl/drivers/source/cy_syslib.c > /tmp/cy_syslib_patched.c
54-
mv /tmp/cy_syslib_patched.c lib/psoc6pdl/drivers/source/cy_syslib.c
39+
tools/ci/fetch-psoc6-pdl.sh lib
5540
5641
- name: make distclean
5742
run: |
@@ -68,3 +53,9 @@ jobs:
6853
- name: Build wolfboot
6954
run: |
7055
make ${{inputs.make-args}} V=1
56+
57+
- name: Check the self-update code is all in RAM
58+
if: ${{ inputs.ramcode-check }}
59+
run: |
60+
python3 tools/scripts/check-ramcode.py --selftest
61+
python3 tools/scripts/check-ramcode.py wolfboot.elf wolfBoot_self_update 0x08000000 0x08060000

‎.github/workflows/test-configs.yml‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,71 @@ jobs:
2020
arch: arm
2121
config-file: ./config/examples/cypsoc6.config
2222

23+
cypsoc6_eval_test:
24+
uses: ./.github/workflows/test-build-psoc6.yml
25+
with:
26+
arch: arm
27+
config-file: ./config/examples/cypsoc6.config
28+
make-args: PSOC6_BOARD=CY8CEVAL_062S2
29+
30+
cypsoc6_nouart_test:
31+
uses: ./.github/workflows/test-build-psoc6.yml
32+
with:
33+
arch: arm
34+
config-file: ./config/examples/cypsoc6.config
35+
make-args: DEBUG_UART=0
36+
37+
cypsoc6_crypto_test:
38+
uses: ./.github/workflows/test-build-psoc6.yml
39+
with:
40+
arch: arm
41+
config-file: ./config/examples/cypsoc6.config
42+
make-args: PSOC6_CRYPTO=1
43+
44+
cypsoc6_cm4_test:
45+
uses: ./.github/workflows/test-build-psoc6.yml
46+
with:
47+
arch: arm
48+
config-file: ./config/examples/cypsoc6.config
49+
make-args: PSOC6_CM4_APP=1 IMAGE_HEADER_SIZE=1024
50+
51+
cypsoc6_ramcode_test:
52+
uses: ./.github/workflows/test-build-psoc6.yml
53+
with:
54+
arch: arm
55+
config-file: ./config/examples/cypsoc6.config
56+
make-args: RAM_CODE=1
57+
ramcode-check: true
58+
59+
cypsoc6_dualbank_test:
60+
uses: ./.github/workflows/test-build-psoc6.yml
61+
with:
62+
arch: arm
63+
config-file: ./config/examples/cypsoc6.config
64+
make-args: DUALBANK_SWAP=1 WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x12020000 WOLFBOOT_PARTITION_SWAP_ADDRESS=0xFFFFFFFF
65+
66+
cypsoc6_qspi_test:
67+
uses: ./.github/workflows/test-build-psoc6.yml
68+
with:
69+
arch: arm
70+
config-file: ./config/examples/cypsoc6-qspi.config
71+
make-args: PSOC6_BOARD=CY8CEVAL_062S2
72+
73+
cypsoc6_qspi_ramcode_test:
74+
uses: ./.github/workflows/test-build-psoc6.yml
75+
with:
76+
arch: arm
77+
config-file: ./config/examples/cypsoc6-qspi.config
78+
make-args: PSOC6_BOARD=CY8CEVAL_062S2 RAM_CODE=1
79+
ramcode-check: true
80+
81+
cypsoc6_qspi_cm4_test:
82+
uses: ./.github/workflows/test-build-psoc6.yml
83+
with:
84+
arch: arm
85+
config-file: ./config/examples/cypsoc6-qspi.config
86+
make-args: PSOC6_BOARD=CY8CEVAL_062S2 PSOC6_CM4_APP=1 IMAGE_HEADER_SIZE=1024
87+
2388
hifive1_test:
2489
uses: ./.github/workflows/test-build-riscv.yml
2590
with:

‎.github/workflows/test-units.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ jobs:
2929
run: |
3030
tools/ci/fetch-mcuxsdk-headers.sh "$GITHUB_WORKSPACE/mcuxsdk"
3131
32+
- name: Fetch Infineon PSoC 6 PDL headers
33+
run: |
34+
tools/ci/fetch-psoc6-pdl.sh "$GITHUB_WORKSPACE/psoc6libs"
35+
3236
- name: Build unit tests
3337
run: |
34-
make -C tools/unit-tests MCUXSDK="$GITHUB_WORKSPACE/mcuxsdk"
38+
make -C tools/unit-tests MCUXSDK="$GITHUB_WORKSPACE/mcuxsdk" \
39+
PSOC6_LIBS="$GITHUB_WORKSPACE/psoc6libs"
3540
3641
- name: Run unit tests
3742
run: |
38-
make -C tools/unit-tests run MCUXSDK="$GITHUB_WORKSPACE/mcuxsdk"
43+
make -C tools/unit-tests run MCUXSDK="$GITHUB_WORKSPACE/mcuxsdk" \
44+
PSOC6_LIBS="$GITHUB_WORKSPACE/psoc6libs"

‎.gitignore‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ tools/unit-tests/unit-delta
146146
tools/unit-tests/unit-psoc-c3-divider
147147
tools/unit-tests/unit-psoc-e8-tz
148148
tools/unit-tests/unit-psoc-e8-flash
149+
tools/unit-tests/unit-psoc6-flash
150+
tools/unit-tests/unit-psoc6-qspi
151+
tools/unit-tests/unit-psoc6-boot
149152
tools/unit-tests/unit-disk
150153
tools/unit-tests/unit-fs-probe
151154
tools/unit-tests/unit-fat32
@@ -181,6 +184,10 @@ tools/unit-tests/unit-string
181184
tools/unit-tests/unit-update-flash
182185
tools/unit-tests/unit-update-flash-enc
183186
tools/unit-tests/unit-update-flash-db
187+
tools/unit-tests/unit-update-flash-flagshome
188+
tools/unit-tests/unit-update-flash-invert
189+
tools/unit-tests/unit-update-flash-int-invert
190+
tools/unit-tests/unit-update-flash-smallsector
184191
tools/unit-tests/unit-update-flash-enc-full
185192
tools/unit-tests/unit-update-flash-enc-intswap
186193
tools/unit-tests/unit-update-ram
@@ -428,6 +435,12 @@ lib/r_config
428435
lib/r_flash_rx
429436
lib/r_tsip_rx
430437

438+
# Infineon PSoC 6 libraries
439+
lib/mtb-pdl-cat1
440+
lib/mtb-template-cat1
441+
lib/cmsis
442+
lib/core-lib
443+
431444
Debug/
432445
Release/
433446
language.settings.xml

‎arch.mk‎

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,25 +2480,71 @@ endif
24802480

24812481
ifeq ($(TARGET),psoc6)
24822482
CORTEX_M0=1
2483-
OBJS+=\
2483+
PSOC6_BOARD?=CY8CKIT_062S2_43012
2484+
# The boot ROM's flash NMI handler reprograms the CM0+ MPU for itself and
2485+
# cannot run under wolfBoot's map, which marks the ROM execute-never.
2486+
ifneq ($(NO_MPU),1)
2487+
$(error TARGET=psoc6 requires NO_MPU=1)
2488+
endif
2489+
# Main and work flash erase to 0x00
2490+
ifneq ($(FLAGS_INVERT),1)
2491+
$(error TARGET=psoc6 requires FLAGS_INVERT=1)
2492+
endif
2493+
# Rewriting a programmed row erases it first, so trailer updates need the
2494+
# two-sector trailer to survive a power cut
2495+
ifneq ($(NVM_FLASH_WRITEONCE),1)
2496+
$(error TARGET=psoc6 requires NVM_FLASH_WRITEONCE=1)
2497+
endif
2498+
CYPRESS_PDL_DEV:=$(CYPRESS_PDL)/devices/COMPONENT_CAT1A
2499+
CYPRESS_PDL_TEMPLATE:=$(CYPRESS_TEMPLATE_LIB)/files/templates/cat1a/COMPONENT_MTB
2500+
PSOC6_LIB_FILES:=$(CYPRESS_PDL_DEV)/include/cy_device_headers.h \
2501+
$(CYPRESS_PDL_TEMPLATE)/COMPONENT_CM0P/system_psoc6_cm0plus.c \
2502+
$(CYPRESS_CMSIS)/Core/Include/core_cm0plus.h \
2503+
$(CYPRESS_CORE_LIB)/include/cy_result.h
2504+
ifneq ($(filter-out $(wildcard $(PSOC6_LIB_FILES)),$(PSOC6_LIB_FILES)),)
2505+
ifeq ($(filter clean keysclean distclean keytools,$(MAKECMDGOALS)),)
2506+
$(error PSoC 6 libraries not found: run tools/ci/fetch-psoc6-pdl.sh lib, \
2507+
or set CYPRESS_PDL, CYPRESS_TEMPLATE_LIB, CYPRESS_CMSIS and \
2508+
CYPRESS_CORE_LIB. Missing: \
2509+
$(filter-out $(wildcard $(PSOC6_LIB_FILES)),$(PSOC6_LIB_FILES)))
2510+
endif
2511+
endif
2512+
PSOC6_PDL_OBJS:=\
24842513
$(CYPRESS_PDL)/drivers/source/cy_flash.o \
24852514
$(CYPRESS_PDL)/drivers/source/cy_ipc_pipe.o \
24862515
$(CYPRESS_PDL)/drivers/source/cy_ipc_sema.o \
24872516
$(CYPRESS_PDL)/drivers/source/cy_ipc_drv.o \
2488-
$(CYPRESS_PDL)/drivers/source/cy_device.o \
24892517
$(CYPRESS_PDL)/drivers/source/cy_sysclk.o \
24902518
$(CYPRESS_PDL)/drivers/source/cy_sysint.o \
24912519
$(CYPRESS_PDL)/drivers/source/cy_syslib.o \
2492-
$(CYPRESS_PDL)/drivers/source/cy_ble_clk.o \
2493-
$(CYPRESS_PDL)/drivers/source/cy_wdt.o \
2494-
$(CYPRESS_PDL)/drivers/source/TOOLCHAIN_GCC_ARM/cy_syslib_gcc.o \
2495-
$(CYPRESS_PDL)/devices/templates/COMPONENT_MTB/COMPONENT_CM0P/system_psoc6_cm0plus.o
2520+
$(CYPRESS_PDL)/drivers/source/cy_gpio.o \
2521+
$(CYPRESS_PDL)/drivers/source/TOOLCHAIN_GCC_ARM/cy_syslib_ext.o \
2522+
$(CYPRESS_PDL_DEV)/source/cy_device.o
2523+
OBJS+=$(PSOC6_PDL_OBJS) \
2524+
$(CYPRESS_PDL_TEMPLATE)/COMPONENT_CM0P/system_psoc6_cm0plus.o
2525+
PSOC6_UART_OBJS:=\
2526+
$(CYPRESS_PDL)/drivers/source/cy_scb_common.o \
2527+
$(CYPRESS_PDL)/drivers/source/cy_scb_uart.o
2528+
PSOC6_SMIF_OBJS:=\
2529+
$(CYPRESS_PDL)/drivers/source/cy_smif.o \
2530+
$(CYPRESS_PDL)/drivers/source/cy_smif_memslot.o \
2531+
$(CYPRESS_PDL)/drivers/source/cy_smif_sfdp.o
2532+
ifeq ($(DEBUG_UART),1)
2533+
OBJS+=$(PSOC6_UART_OBJS)
2534+
endif
2535+
ifeq ($(BOOT_BENCHMARK),1)
2536+
OBJS+=$(CYPRESS_PDL)/drivers/source/cy_tcpwm_counter.o
2537+
endif
2538+
ifeq ($(EXT_FLASH),1)
2539+
OBJS+=$(PSOC6_SMIF_OBJS)
2540+
endif
24962541
PSOC6_CRYPTO_OBJS=\
24972542
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/cypress/psoc6_crypto.o \
24982543
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_vu.o \
24992544
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_ecc_domain_params.o \
25002545
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_ecc_nist_p.o \
25012546
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_ecc_ecdsa.o \
2547+
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_ecc_key_gen.o \
25022548
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_sha_v2.o \
25032549
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_sha_v1.o \
25042550
$(CYPRESS_PDL)/drivers/source/cy_crypto_core_mem_v2.o \
@@ -2508,15 +2554,20 @@ ifeq ($(TARGET),psoc6)
25082554
$(CYPRESS_PDL)/drivers/source/cy_crypto.o
25092555

25102556
CFLAGS+=\
2511-
-I$(CYPRESS_PDL)/devices/include \
25122557
-I$(CYPRESS_PDL)/drivers/include \
2513-
-I$(CYPRESS_PDL)/cmsis/include \
2514-
-I$(CYPRESS_TARGET_LIB) \
2558+
-I$(CYPRESS_PDL_DEV)/include \
2559+
-I$(CYPRESS_PDL_DEV)/include/ip \
2560+
-I$(CYPRESS_PDL_TEMPLATE) \
2561+
-I$(CYPRESS_CMSIS)/Core/Include \
25152562
-I$(CYPRESS_CORE_LIB)/include \
2516-
-I$(CYPRESS_PDL)/devices/include/ip \
2517-
-I$(CYPRESS_PDL)/devices/templates/COMPONENT_MTB \
2518-
-DCY8C624ABZI_D44
2563+
-DCY8C624ABZI_S2D44 \
2564+
-DPSOC6_BOARD_$(PSOC6_BOARD)
25192565
ARCH_FLASH_OFFSET=0x10000000
2566+
# Copies then program whole erased rows instead of rewriting half rows
2567+
CFLAGS+=-DFLASHBUFFER_SIZE=512
2568+
ifeq ($(PSOC6_CM4_APP),1)
2569+
CFLAGS+=-DPSOC6_CM4_APP -DWOLFBOOT_BOOT_REMOTE_CORE
2570+
endif
25202571
ifneq ($(PSOC6_CRYPTO),0)
25212572
CFLAGS+=-DWOLFSSL_PSOC6_CRYPTO
25222573
OBJS+=$(PSOC6_CRYPTO_OBJS)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
ARCH?=ARM
2+
TARGET?=psoc6
3+
PSOC6_BOARD?=CY8CKIT_062S2_43012
4+
SIGN?=ECC256
5+
HASH?=SHA256
6+
CYPRESS_PDL?=$(WOLFBOOT_ROOT)/lib/mtb-pdl-cat1
7+
CYPRESS_CMSIS?=$(WOLFBOOT_ROOT)/lib/cmsis
8+
CYPRESS_TEMPLATE_LIB?=$(WOLFBOOT_ROOT)/lib/mtb-template-cat1
9+
CYPRESS_CORE_LIB?=$(WOLFBOOT_ROOT)/lib/core-lib
10+
DEBUG?=0
11+
DEBUG_UART?=1
12+
VTOR?=1
13+
NO_MPU?=1
14+
FLAGS_INVERT?=1
15+
CORTEX_M0?=1
16+
NO_ASM?=0
17+
EXT_FLASH?=1
18+
NO_SWAP_EXT?=1
19+
FLAGS_HOME?=1
20+
SPI_FLASH?=0
21+
NO_XIP?=0
22+
UART_FLASH?=0
23+
ALLOW_DOWNGRADE?=0
24+
NVM_FLASH_WRITEONCE?=1
25+
WOLFBOOT_VERSION?=0
26+
V?=0
27+
SPMATH?=1
28+
RAM_CODE?=0
29+
DUALBANK_SWAP?=0
30+
PKA?=0
31+
WOLFTPM?=0
32+
PSOC6_CRYPTO?=0
33+
# Sectors match the 256 KB QSPI erase sector. wolfBoot 0x10000000 (256 KB),
34+
# BOOT 0x10040000 (1.5 MB) and SWAP 0x101C0000 (256 KB) in internal flash,
35+
# UPDATE 0x18000000 (1.5 MB) in QSPI. QSPI erases to 0xFF, so FLAGS_HOME
36+
# keeps every flag in the BOOT trailer.
37+
WOLFBOOT_PARTITION_SIZE?=0x180000
38+
WOLFBOOT_SECTOR_SIZE?=0x40000
39+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10040000
40+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x18000000
41+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x101C0000

‎config/examples/cypsoc6.config‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
ARCH?=ARM
22
TARGET?=psoc6
3-
SIGN?=ED25519
3+
PSOC6_BOARD?=CY8CKIT_062S2_43012
4+
SIGN?=ECC256
45
HASH?=SHA256
5-
CYPRESS_PDL?=$(WOLFBOOT_ROOT)/lib/psoc6pdl
6-
CYPRESS_TARGET_LIB?=$(WOLFBOOT_ROOT)/lib/TARGET_CY8CKIT-062S2-43012
6+
CYPRESS_PDL?=$(WOLFBOOT_ROOT)/lib/mtb-pdl-cat1
7+
CYPRESS_CMSIS?=$(WOLFBOOT_ROOT)/lib/cmsis
8+
CYPRESS_TEMPLATE_LIB?=$(WOLFBOOT_ROOT)/lib/mtb-template-cat1
79
CYPRESS_CORE_LIB?=$(WOLFBOOT_ROOT)/lib/core-lib
8-
DEBUG?=1
10+
DEBUG?=0
11+
DEBUG_UART?=1
912
VTOR?=1
13+
NO_MPU?=1
14+
FLAGS_INVERT?=1
1015
CORTEX_M0?=1
1116
NO_ASM?=0
1217
EXT_FLASH?=0
1318
SPI_FLASH?=0
1419
NO_XIP?=0
1520
UART_FLASH?=0
1621
ALLOW_DOWNGRADE?=0
17-
NVM_FLASH_WRITEONCE?=0
22+
NVM_FLASH_WRITEONCE?=1
1823
WOLFBOOT_VERSION?=0
1924
V?=0
2025
SPMATH?=1
@@ -23,16 +28,10 @@ DUALBANK_SWAP?=0
2328
PKA?=0
2429
WOLFTPM?=0
2530
PSOC6_CRYPTO?=0
26-
WOLFBOOT_PARTITION_SIZE?=0x80000
27-
WOLFBOOT_SECTOR_SIZE?=512
28-
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10080000
31+
# wolfBoot 0x10000000 (128 KB), BOOT 0x10020000 and UPDATE 0x10100000
32+
# (896 KB each), SWAP 0x101E0000 (one 4 KB subsector)
33+
WOLFBOOT_PARTITION_SIZE?=0xE0000
34+
WOLFBOOT_SECTOR_SIZE?=0x1000
35+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10020000
2936
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x10100000
30-
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x10010000
31-
32-
# cypsoc6 places the swap sector (0x10010000) inside the bootloader
33-
# write-protect region [0x10000000, 0x10080000). This is a deliberate
34-
# peculiarity of this target: hal_flash_protect() is the weak no-op
35-
# (psoc6 does not override it), so the overlap is harmless at runtime.
36-
# Allow the overlap so the partition-geometry #error guards in
37-
# include/target.h.in do not fire for this config.
38-
WOLFBOOT_ALLOW_PART_OVERLAP = 1
37+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x101E0000

0 commit comments

Comments
 (0)