Skip to content

Commit

Permalink
Merge pull request tock#4300 from OxidosAutomotive/psoc6
Browse files Browse the repository at this point in the history
boards: add initial code for CY8CPROTO-062-4343W
  • Loading branch information
alexandruradovici authored Feb 5, 2025
2 parents 9d55284 + 168d7d9 commit 36c8123
Show file tree
Hide file tree
Showing 21 changed files with 6,046 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"boards/arty_e21",
"boards/opentitan/earlgrey-cw310",
"boards/esp32-c3-devkitM-1",
"boards/cy8cproto_62_4343_w",
"boards/clue_nrf52840",
"boards/veer_el2_sim",
"boards/hail",
Expand Down Expand Up @@ -80,6 +81,7 @@ members = [
"chips/nrf52840",
"chips/nrf5x",
"chips/qemu_rv32_virt_chip",
"chips/psoc62xa",
"chips/rp2040",
"chips/sam4l",
"chips/segger",
Expand Down
1 change: 1 addition & 0 deletions boards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ but the approximate definitions:
| [Teensy 4.0](teensy40/README.md) | ARM Cortex-M7 | i.MX RT 1062 | custom | custom | No |
| [Digilent Arty A-7 100T](arty_e21/README.md) | RISC-V RV32IMAC | SiFive E21 | openocd | tockloader | No |
| [MSP432 Evaluation kit MSP432P401R](msp_exp432p401r/README.md) | ARM Cortex-M4 | MSP432P401R | openocd | custom | No |
| [CY8CPROTO-062-4343W](cy8cproto_62_4343_w/README.md) | ARM Cortex-M0+ | PSoC62 | openocd | custom | No |


### Other
Expand Down
14 changes: 14 additions & 0 deletions boards/cy8cproto_62_4343_w/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright OxidOS Automotive SRL 2025.

include = [
"../../cargo/tock_flags.toml",
"../../cargo/unstable_flags.toml",
]

[build]
target = "thumbv6m-none-eabi"

[unstable]
config-include = true
26 changes: 26 additions & 0 deletions boards/cy8cproto_62_4343_w/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright OxidOS Automotive 2025 SRL.

[package]
name = "cy8cproto_62_4243_w"
version.workspace = true
authors.workspace = true
edition.workspace = true
build = "../build.rs"

[dependencies]
cortexm0p = { path = "../../arch/cortex-m0p" }
kernel = { path = "../../kernel" }
psoc62xa = { path = "../../chips/psoc62xa" }
components = { path = "../components" }

capsules-core = { path = "../../capsules/core" }
capsules-extra = { path = "../../capsules/extra" }
capsules-system = { path = "../../capsules/system" }

[build-dependencies]
tock_build_scripts = { path = "../build_scripts" }

[lints]
workspace = true
27 changes: 27 additions & 0 deletions boards/cy8cproto_62_4343_w/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright OxidOS Automotive 2025 SRL.

include ../Makefile.common

OPENOCD_OPTIONS= -s ${OPENOCD_ROOT}/scripts -f openocd.cfg
# Define the path to the TBF file to flash an application
APP=
KERNEL=$(TOCK_ROOT_DIRECTORY)/target/$(TARGET)/release/$(PLATFORM).elf
KERNEL_WITH_APP=$(TOCK_ROOT_DIRECTORY)/target/$(TARGET)/release/$(PLATFORM)-app.elf

install: flash
.PHONY: install

flash: release
${OPENOCD_ROOT}/bin/openocd $(OPENOCD_OPTIONS) -c "program $(KERNEL); verify_image $(KERNEL); reset; shutdown"
.PHONY: flash

.PHONY: program
program: release
ifeq ($(APP),)
$(error Please define the APP variable with the TBF file to flash an application)
endif
arm-none-eabi-objcopy --set-section-flags .apps=LOAD,ALLOC $(KERNEL) $(KERNEL_WITH_APP)
arm-none-eabi-objcopy --update-section .apps=$(APP) $(KERNEL_WITH_APP)
${OPENOCD_ROOT}/bin/openocd $(OPENOCD_OPTIONS) -c "program $(KERNEL_WITH_APP); verify_image $(KERNEL_WITH_APP); reset; shutdown"
32 changes: 32 additions & 0 deletions boards/cy8cproto_62_4343_w/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Cypress CY8CPROTO-062-4343W
===========================

<img src="https://www.infineon.com/export/sites/default/_images/product/evaluation-boards/cypress-boards/CY8CPROTO-062-4343W_0.jpg_1361197165.jpg" width="40%">

The [Cypress CY8CPROTO-062-4343W](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062-4343w/) is a prototyping board based on the PSoC 62xA SoC.

## Getting started

1. Download the [Infineon Customized OpenOCD](https://github.com/Infineon/openocd/releases/latest)
2. Set OPENOCD_ROOT to the directory from extracted archive.
3. Connect the computer to the `KitProg3` USB connector.
4. Add the udev rule for `KitProg3`:
```bash
$ sudo bash -c "echo 'ATTRS{idVendor}==\"04b4\", ATTRS{idProduct}==\"f155\", MODE=\"0666\"' > /etc/udev/rules.d/99-kitprog3.rules"
```

## Flashing the kernel

The kernel can be programmed by going inside the board's directory and running:
```bash
$ make flash
```

## Flashing an app

Apps are built out-of-tree. Once an app is built, you must add the path to the generated TBF in the Makefile (APP variable), then run:
```bash
$ make program
```

This will generate a new ELF file that can be deployed on the CY8CPROTO-062-4343W via gdb and OpenOCD.
14 changes: 14 additions & 0 deletions boards/cy8cproto_62_4343_w/layout.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Licensed under the Apache License, Version 2.0 or the MIT License. */
/* SPDX-License-Identifier: Apache-2.0 OR MIT */
/* Copyright Oxidos Automotive 2025 SRL. */

MEMORY
{
rom (rx) : ORIGIN = 0x10000000, LENGTH = 1M
prog (rx) : ORIGIN = 0x10100000, LENGTH = 1M
ram (rwx) : ORIGIN = 0x08000000, LENGTH = 1M
}

ENTRY(initialize_ram_jump_to_main)

INCLUDE tock_kernel_layout.ld
8 changes: 8 additions & 0 deletions boards/cy8cproto_62_4343_w/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright OxidOS Automotive 2025 SRL.
#
# OpenOCD configuration for the CY8CPROTO-062 development board

source [find interface/kitprog3.cfg]
source [find target/psoc6_2m.cfg]
64 changes: 64 additions & 0 deletions boards/cy8cproto_62_4343_w/src/io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright OxidOS Automotive 2025 SRL.

use core::panic::PanicInfo;
use kernel::utilities::cells::OptionalCell;

use psoc62xa::gpio::GpioPin;
use psoc62xa::scb::Scb;

use kernel::debug::{self, IoWrite};
use kernel::hil::led::LedHigh;

use crate::CHIP;
use crate::PROCESSES;
use crate::PROCESS_PRINTER;

/// Writer is used by kernel::debug to panic message to the serial port.
pub struct Writer {
scb: OptionalCell<&'static Scb<'static>>,
}

impl Writer {
pub fn set_scb(&self, scb: &'static Scb) {
self.scb.set(scb);
}
}

impl core::fmt::Write for Writer {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
self.scb.map(|scb| scb.transmit_uart_sync(s.as_bytes()));
Ok(())
}
}

impl IoWrite for Writer {
fn write(&mut self, buf: &[u8]) -> usize {
self.scb.map(|scb| scb.transmit_uart_sync(buf));
buf.len()
}
}

pub static mut WRITER: Writer = Writer {
scb: OptionalCell::empty(),
};

/// Panic handler for the CY8CPROTO-062-4343 board.
#[panic_handler]
pub unsafe fn panic_fmt(panic_info: &PanicInfo) -> ! {
use core::ptr::{addr_of, addr_of_mut};
let writer = &mut *addr_of_mut!(WRITER);
let led_kernel_pin = &GpioPin::new(psoc62xa::gpio::PsocPin::P13_7);
let led = &mut LedHigh::new(led_kernel_pin);

debug::panic(
&mut [led],
writer,
panic_info,
&cortexm0p::support::nop,
&*addr_of!(PROCESSES),
&*addr_of!(CHIP),
&*addr_of!(PROCESS_PRINTER),
);
}
Loading

0 comments on commit 36c8123

Please sign in to comment.