From 2fe4d3c825151263fb69190bb03203b973d1c905 Mon Sep 17 00:00:00 2001 From: Dominik Jaumann Date: Mon, 5 Oct 2026 10:07:41 +0200 Subject: [PATCH 1/2] control: add PSoC Control variant --- boards.txt | 49 +++++++++++++++ loader/main.c | 6 ++ .../kit_psc3m5_evk_psc3m5fds2afq1.conf | 52 +++++++++++++++ .../kit_psc3m5_evk_psc3m5fds2afq1.overlay | 57 +++++++++++++++++ .../kit_psc3m5_evk_psc3m5fds2afq1/openocd.cfg | 12 ++++ .../kit_psc3m5_evk_psc3m5fds2afq1/variant.h | 63 +++++++++++++++++++ 6 files changed, 239 insertions(+) create mode 100644 variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.conf create mode 100644 variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.overlay create mode 100644 variants/kit_psc3m5_evk_psc3m5fds2afq1/openocd.cfg create mode 100644 variants/kit_psc3m5_evk_psc3m5fds2afq1/variant.h diff --git a/boards.txt b/boards.txt index 2d758849f..4d0e3a3eb 100644 --- a/boards.txt +++ b/boards.txt @@ -742,3 +742,52 @@ ventunoq.bootloader.tool=remoteocd ventunoq.bootloader.tool.default=remoteocd ventunoq.bootloader.file=zephyr-{build.variant}.elf ventunoq.bootloader.target=stm32h5f5xx + +############################################################################################################## + +kit_psc3m5_evk.name=Infineon KIT_PSC3M5 EVK +kit_psc3m5_evk.build.core=arduino +kit_psc3m5_evk.build.crossprefix=arm-zephyr-eabi- +kit_psc3m5_evk.build.compiler_path={runtime.tools.arm-zephyr-eabi-1.0.1.path}/bin/ + +kit_psc3m5_evk.build.zephyr_target=kit_psc3m5_evk +kit_psc3m5_evk.build.zephyr_args= +kit_psc3m5_evk.build.zephyr_hals=hal_infineon +kit_psc3m5_evk.build.zephyr_toolchain=arm-zephyr-eabi +kit_psc3m5_evk.build.variant=kit_psc3m5_evk_psc3m5fds2afq1 +kit_psc3m5_evk.build.artifact=zephyr_main + +kit_psc3m5_evk.build.extra_flags= +kit_psc3m5_evk.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit +kit_psc3m5_evk.build.board=KIT_PSC3M5_EVK + +kit_psc3m5_evk.menu.debug.false=Standard +kit_psc3m5_evk.menu.debug.true=Debug +kit_psc3m5_evk.menu.debug.true.build.zsk_args.debug=-debug + +kit_psc3m5_evk.menu.link_mode.dynamic=Dynamic +kit_psc3m5_evk.menu.link_mode.static=Static +kit_psc3m5_evk.menu.link_mode.static.build.link_mode=static +kit_psc3m5_evk.menu.link_mode.static.upload.extension=bin-zsk.bin +kit_psc3m5_evk.menu.link_mode.default=static + +kit_psc3m5_evk.openocd_cfg=flash_sketch.cfg + +kit_psc3m5_evk.upload.tool=openocd +kit_psc3m5_evk.upload.tool.default=openocd +kit_psc3m5_evk.upload.protocol= +kit_psc3m5_evk.upload.config=-f target/infineon/psc3.cfg +kit_psc3m5_evk.upload.programmer=-f interface/cmsis-dap.cfg +kit_psc3m5_evk.tools.openocd.upload.pattern.windows=cmd /C cd /D "{build.path}" && "{path}/{cmd}" {upload.verbose} -s "{path}/scripts/" -s "{path}/share/openocd/scripts/" -s "{runtime.platform.path}/variants/{build.variant}/" -f interface/cmsis-dap.cfg -f target/infineon/psc3.cfg -c "set filename0 [list \runtime.platform.path}/firmwares/zephyr-{build.variant}.hex]; set filename1 [list \build.path}/{build.project_name}.{upload.extension}]; set offset {upload.address}" -f "{runtime.platform.path}/variants/{build.variant}/openocd.cfg" "{upload.verbose}" +kit_psc3m5_evk.tools.openocd.program.pattern.windows=cmd /C cd /D "{build.path}" && "{path}/{cmd}" {program.verbose} -s "{path}/scripts/" -s "{path}/share/openocd/scripts/" -s "{runtime.platform.path}/variants/{build.variant}/" -f interface/cmsis-dap.cfg -f target/infineon/psc3.cfg -c "set filename0 [list \runtime.platform.path}/firmwares/zephyr-{build.variant}.hex]; set filename1 [list \build.path}/{build.project_name}.{upload.extension}]; set offset {upload.address}" -f "{runtime.platform.path}/variants/{build.variant}/openocd.cfg" "{program.verbose}" +kit_psc3m5_evk.upload.use_1200bps_touch=false +kit_psc3m5_evk.upload.wait_for_upload_port=false +kit_psc3m5_evk.upload.native_usb=false +kit_psc3m5_evk.tools.openocd.upload.pattern.windows=cmd /C cd /D "{build.path}" && "{path}/{cmd}" {upload.verbose} -s "{path}/scripts/" -s "{path}/share/openocd/scripts/" -s "{runtime.platform.path}/variants/{build.variant}/" -f interface/cmsis-dap.cfg -f target/infineon/psc3.cfg -c "set filename0 [file normalize {{runtime.platform.path}/firmwares/zephyr-{build.variant}.hex}]; set filename1 [file normalize {{build.path}/{build.project_name}.{upload.extension}}]; set offset {upload.address}" -f "{runtime.platform.path}/variants/{build.variant}/openocd.cfg" "{upload.verbose}" +kit_psc3m5_evk.tools.openocd.program.pattern.windows=cmd /C cd /D "{build.path}" && "{path}/{cmd}" {program.verbose} -s "{path}/scripts/" -s "{path}/share/openocd/scripts/" -s "{runtime.platform.path}/variants/{build.variant}/" -f interface/cmsis-dap.cfg -f target/infineon/psc3.cfg -c "set filename0 [file normalize {{runtime.platform.path}/firmwares/zephyr-{build.variant}.hex}]; set filename1 [file normalize {{build.path}/{build.project_name}.{upload.extension}}]; set offset {upload.address}" -f "{runtime.platform.path}/variants/{build.variant}/openocd.cfg" "{program.verbose}" + +kit_psc3m5_evk.bootloader.tool=openocd +kit_psc3m5_evk.bootloader.tool.default=openocd +kit_psc3m5_evk.bootloader.file=../firmwares/zephyr-{build.variant}.hex +kit_psc3m5_evk.tools.openocd.bootloader.pattern.windows=cmd /C cd /D "{runtime.platform.path}/firmwares" && "{path}/{cmd}" {bootloader.verbose} -s "{path}/scripts/" -s "{path}/share/openocd/scripts/" -s "{runtime.platform.path}/variants/{build.variant}/" -f interface/cmsis-dap.cfg -f target/infineon/psc3.cfg -c "set filename0 [list zephyr-{build.variant}.hex]" -f "{runtime.platform.path}/variants/{build.variant}/openocd.cfg" "{bootloader.verbose}" +kit_psc3m5_evk.bootloader.target=psc3.cm33 diff --git a/loader/main.c b/loader/main.c index c8fa42fa2..db114d91e 100644 --- a/loader/main.c +++ b/loader/main.c @@ -127,6 +127,7 @@ struct backup_store { extern volatile __stm32_backup_sram_section struct backup_store backup; static int loader(const struct shell *sh) { +#if defined(CONFIG_FLASH_MAP) const struct flash_area *fa; int rc; @@ -136,6 +137,7 @@ static int loader(const struct shell *sh) { printk("Failed to open flash area, rc %d\n", rc); return rc; } +#endif #if defined(CONFIG_OTA) try_ota_update(fa); @@ -144,11 +146,15 @@ static int loader(const struct shell *sh) { uintptr_t base_addr = DT_PARTITION_ADDR(DT_NODELABEL(user_sketch)); char header[SKETCH_HEADER_LEN]; +#if defined(CONFIG_FLASH_MAP) rc = flash_area_read(fa, 0, header, sizeof(header)); if (rc) { printk("Failed to read header, rc %d\n", rc); return rc; } +#else + memcpy(header, (const void *)base_addr, sizeof(header)); +#endif bool sketch_valid = true; struct sketch_header_v1 *sketch_hdr = (struct sketch_header_v1 *)(header + 7); diff --git a/variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.conf b/variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.conf new file mode 100644 index 000000000..2ef39ea1c --- /dev/null +++ b/variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.conf @@ -0,0 +1,52 @@ +# +# Copyright (c) Arduino s.r.l. and/or its affiliated companies +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Keep the board defaults and only add the minimum Arduino-required features. +CONFIG_ARM_MPU=y +# CONFIG_HW_STACK_PROTECTION=y +CONFIG_TRUSTED_EXECUTION_SECURE=y +CONFIG_ARM_TRUSTZONE_M=y + +# This board only exposes 64KB of secure RAM. The loader's default +# heap/stack sizes (32KB each) alone consume all of it, overflowing +# RAM. Shrink them to fit. +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=16384 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1024 + +# Default LLEXT heap (32KB) plus the above still leaves almost no headroom +# for the kernel/drivers on this 64KB chip, corrupting RAM at boot. Shrink +# it too; small sketches don't need a large extension heap. +CONFIG_LLEXT_HEAP_SIZE=16 + +CONFIG_LLEXT_STORAGE_WRITABLE=n + +CONFIG_GPIO=y +CONFIG_CLOCK_CONTROL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_CAN=y + +# The board's QSPI/flash controller is not provided by the current Zephyr tree +# in a way that exposes the flash_map APIs required by the Arduino loader. +# Disable this so the loader build does not reference missing symbols. +CONFIG_FLASH=n +CONFIG_FLASH_MAP=n + +CONFIG_SHARED_INTERRUPTS=y + +CONFIG_BOOT_BANNER=n + +CONFIG_ARM_MPU=n +CONFIG_HW_STACK_PROTECTION=n + +CONFIG_FLASH=n +CONFIG_FLASH_MAP=n + +CONFIG_BUILD_OUTPUT_BIN=n + +CONFIG_BOOTLOADER_MCUBOOT=n \ No newline at end of file diff --git a/variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.overlay b/variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.overlay new file mode 100644 index 000000000..b78375ad6 --- /dev/null +++ b/variants/kit_psc3m5_evk_psc3m5fds2afq1/kit_psc3m5_evk_psc3m5fds2afq1.overlay @@ -0,0 +1,57 @@ +/* + * Copyright (c) Arduino s.r.l. and/or its affiliated companies + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * Minimal Arduino overlay for the Infineon KIT_PSC3M5_EVK. + * + * This board defines real GPIOs and the UART node in the upstream Zephyr DTS: + * - user LED aliases: user_led0 -> GPIO port 8 pin 5, user_led1 -> GPIO port 8 pin 4 + * - user buttons: SW_1 -> GPIO port 5 pin 0, SW_2 -> GPIO port 2 pin 0 + * - serial console: uart3 -> scb3 on pins P6_3/P6_2 + * + * The upstream board DTS does not define an Arduino Uno R3 header or a PWM/ADC + * alias table, so this file maps the board-defined GPIOs directly instead of + * inventing a non-existent Arduino header pin map. + */ + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + user_sketch: partition@10010000 { + label = "user_sketch"; + reg = <0x10010000 DT_SIZE_K(56)>; + }; + }; +}; + +/ { + zephyr,user { + /* Execute the sketch through the address used by the Arduino uploader. */ + sketch-runtime-address = <0x22010000>; + + digital-pin-gpios = <&gpio_prt5 0 0>, /* D0 / SW_1 */ + <&gpio_prt2 0 0>, /* D1 / SW_2 */ + <&gpio_prt8 5 0>, /* D2 / LED_0 */ + <&gpio_prt8 4 0>; /* D3 / LED_1 */ + + builtin-led-gpios = <&gpio_prt8 5 GPIO_ACTIVE_LOW>, + <&gpio_prt8 4 GPIO_ACTIVE_LOW>; + + serials = <&uart3>; + cans = <&can1>; + }; +}; + +&uart3 { + status = "okay"; +}; + +&rtc0 { + status = "okay"; +}; \ No newline at end of file diff --git a/variants/kit_psc3m5_evk_psc3m5fds2afq1/openocd.cfg b/variants/kit_psc3m5_evk_psc3m5fds2afq1/openocd.cfg new file mode 100644 index 000000000..47192aa81 --- /dev/null +++ b/variants/kit_psc3m5_evk_psc3m5fds2afq1/openocd.cfg @@ -0,0 +1,12 @@ +targets psc3.cm33 + +telnet_port disabled +init +reset init +halt +flash write_image erase "${filename0}" +if {[info exists filename1] && [string length $filename1] > 0} { + flash write_image erase "${filename1}" ${offset} bin +} +reset run +shutdown diff --git a/variants/kit_psc3m5_evk_psc3m5fds2afq1/variant.h b/variants/kit_psc3m5_evk_psc3m5fds2afq1/variant.h new file mode 100644 index 000000000..4a20e29dc --- /dev/null +++ b/variants/kit_psc3m5_evk_psc3m5fds2afq1/variant.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) Arduino s.r.l. and/or its affiliated companies + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifndef __PINS_ARDUINO__ +#define __PINS_ARDUINO__ + +#include + +/* + * Minimal Arduino-style pin map for the Infineon KIT_PSC3M5_EVK. + * + * This board exposes its real GPIOs in the Zephyr DTS and we mapped the + * Arduino-style aliases to the actual board-defined GPIOs in the overlay. + * The mapping here is intentionally conservative and matches the board's + * runtime GPIO layout without inventing a non-existent Uno R3 header. + */ + +#define PINS_COUNT (4u) +#define NUM_DIGITAL_PINS (4u) +#define NUM_ANALOG_INPUTS (0u) +#define NUM_ANALOG_OUTPUTS (0u) + +#define PIN_LED (2u) +#define LED_BUILTIN PIN_LED + +/* Arduino-style digital pins used by the board overlay */ +#define PIN_D0 (0u) +#define PIN_D1 (1u) +#define PIN_D2 (2u) +#define PIN_D3 (3u) + +/* + * If the board gains ADC-capable GPIOs in the future, these can be mapped here + * and exposed as A0..A7 in the same way as the rest of the ArduinoCore-zephyr + * variants. For now the board DTS only exposes the user GPIOs/LEDs and UART. + */ +#define PIN_A0 (0u) +#define PIN_A1 (1u) +#define PIN_A2 (2u) +#define PIN_A3 (3u) +#define PIN_A4 (4u) +#define PIN_A5 (5u) +#define PIN_A6 (6u) +#define PIN_A7 (7u) + +#define PIN_SERIAL_RX (0u) +#define PIN_SERIAL_TX (1u) + +#define SERIAL_HOWMANY (1u) +#define SERIAL1_TX (1u) +#define SERIAL1_RX (0u) + +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_MONITOR Serial + +#define WIRE_HOWMANY (0u) + +#endif /* __PINS_ARDUINO__ */ \ No newline at end of file From 463e01c998129dbb8e54382f4ae2204fc0989b2a Mon Sep 17 00:00:00 2001 From: Dominik Jaumann Date: Mon, 12 Oct 2026 13:02:47 +0200 Subject: [PATCH 2/2] boards: kit_psc3m5_evk: Changed workflow execution and used build artifacts --- boards.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boards.txt b/boards.txt index 4d0e3a3eb..7715a4029 100644 --- a/boards.txt +++ b/boards.txt @@ -755,7 +755,8 @@ kit_psc3m5_evk.build.zephyr_args= kit_psc3m5_evk.build.zephyr_hals=hal_infineon kit_psc3m5_evk.build.zephyr_toolchain=arm-zephyr-eabi kit_psc3m5_evk.build.variant=kit_psc3m5_evk_psc3m5fds2afq1 -kit_psc3m5_evk.build.artifact=zephyr_main +kit_psc3m5_evk.build.release_group=psc3 +kit_psc3m5_evk.build.feature_board=true kit_psc3m5_evk.build.extra_flags= kit_psc3m5_evk.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit