Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce zephyr into firmware monorepo #4449

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ __pycache__/
proto.gv*
.DS_Store
crypto/tests/libtrezor-crypto.so.dSYM/
/nordic/.west/
/nordic/bootloader/
/nordic/modules/
/nordic/nrf/
/nordic/nrfxlib/
/nordic/test/
/nordic/tools/
/nordic/zephyr/
/nordic/trezor/build/
/nordic/trezor/trezor-ble/build/
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ignore-paths=
crypto,
legacy,
storage,
nordic,
fail-under=10.0
jobs=0
load-plugins=trezor_pylint_plugin
Expand Down
1 change: 1 addition & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ignore: |
vendor/
/common/defs/ethereum/chains/
/common/defs/ethereum/tokens/
/nordic/

rules:
# fix for truthy warning on github action files
Expand Down
9 changes: 9 additions & 0 deletions nordic/trezor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
#
# This CMake file is picked by the Zephyr build system because it is defined
# as the module CMake entry point (see zephyr/module.yml).


zephyr_include_directories(include)

7 changes: 7 additions & 0 deletions nordic/trezor/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
#
# This Kconfig file is picked by the Zephyr build system because it is defined
# as the module Kconfig entry point (see zephyr/module.yml). You can browse
# module options by going to Zephyr -> Modules in Kconfig.

77 changes: 77 additions & 0 deletions nordic/trezor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Trezor BLE Gateway

Welcome to the **Trezor BLE Gateway** project!
This repository contains the source code and instructions to build and flash the application onto the `t3w1_nrf52833` board.

## Table of Contents

- [Prerequisites](#prerequisites)
- [Getting Started](#getting-started)
- [Install the toolchain](#install-the-toolchain)
- [Launch the nRF Shell](#launch-the-nrf-shell)
- [Initialize the Workspace](#initialize-the-workspace)
- [Update nRF Connect SDK Modules](#update-nrf-connect-sdk-modules)
- [Build the Application](#build-the-application)
- [Flash the Application](#flash-the-application)
- [Contributing](#contributing)
- [License](#license)

## Prerequisites

Before you begin, ensure you have met the following requirements:

- **nrfutil**: Install [nrfutil](https://docs.nordicsemi.com/bundle/nrfutil/page/README.html). This tool is essential for managing the nRF Connect SDK and toolchains.
- **Git**: Ensure you have Git installed for cloning repositories.

## Getting Started

Follow these steps to set up the project on your local machine.

### Install the toolchain

Using nrfutil, install the required toolchain for the nRF Connect SDK:
```sh
nrfutil toolchain-manager install --ncs-version v2.6.2
```

### Launch the nRF Shell

First, launch the nRF shell using the `nrfutil` toolchain manager:

```sh
nrfutil toolchain-manager launch --shell
```

### Initialize the Workspace
Initialize your West workspace for the Trezor BLE Gateway project:
```sh
cd west
west init -l ./trezor
```

### Update nRF Connect SDK Modules

Update the modules:
```sh
west update
```


### Building the Application
west build ./trezor-ble -b t3w1_revA_nrf52832 --sysbuild
```

Debug builds can be built using the debug overlay configuration:
Build the application for the t3w1_revA_nrf52832 board:
```sh
cd trezor
```sh
west build ./trezor-ble -b t3w1_revA_nrf52832 --sysbuild -- -DOVERLAY_CONFIG=debug.conf
```


### Flashing the Application
Flash the compiled application onto the board:
```sh
west flash
```
14 changes: 14 additions & 0 deletions nordic/trezor/boards/arm/t3w1_d1_nrf52833/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# nRF52833 DK NRF52833 board configuration

# Copyright (c) 2019 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if BOARD_T3W1_D1_NRF52833

config BOARD
default "t3w1_d1_nrf52833"

config BT_CTLR
default BT

endif # BOARD_T3W1_NRF52833
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# nRF52833 DK NRF52833 board configuration

# Copyright (c) 2019 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config BOARD_T3W1_D1_NRF52833
select SOC_NRF52833_QIAA
12 changes: 12 additions & 0 deletions nordic/trezor/boards/arm/t3w1_d1_nrf52833/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

board_runner_args(jlink "--device=nRF52833_xxAA" "--speed=4000")
board_runner_args(pyocd "--target=nrf52833" "--frequency=4000000")

set(OPENOCD_NRF5_SUBFAMILY "nrf52")

include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake)
8 changes: 8 additions & 0 deletions nordic/trezor/boards/arm/t3w1_d1_nrf52833/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

board:
name: t3w1_d1_nrf52833
vendor: vendor
socs:
- name: nrf52833
7 changes: 7 additions & 0 deletions nordic/trezor/boards/arm/t3w1_d1_nrf52833/pre_dt_board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0

# Suppress "unique_unit_address_if_enabled" to handle the following overlaps:
# - power@40000000 & clock@40000000 & bprot@40000000
# - acl@4001e000 & flash-controller@4001e000
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2022 Nordic Semiconductor
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
uart0_default: uart0_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 27)>,
<NRF_PSEL(UART_RTS, 0, 8)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 0, 26)>,
<NRF_PSEL(UART_CTS, 0, 6)>;
bias-pull-up;
};
};

uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 27)>,
<NRF_PSEL(UART_RX, 0, 26)>,
<NRF_PSEL(UART_RTS, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 6)>;
low-power-enable;
};
};

spi0_default: spi0_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 5)>,
<NRF_PSEL(SPIM_MOSI, 0, 19)>,
<NRF_PSEL(SPIM_MISO, 1, 3)>;
};
};

spi0_sleep: spi0_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 5)>,
<NRF_PSEL(SPIM_MOSI, 0, 19)>,
<NRF_PSEL(SPIM_MISO, 1, 3)>;
low-power-enable;
};
};


};
145 changes: 145 additions & 0 deletions nordic/trezor/boards/arm/t3w1_d1_nrf52833/t3w1_d1_nrf52833.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <nordic/nrf52833_qiaa.dtsi>
#include "t3w1_d1_nrf52833-pinctrl.dtsi"
#include <zephyr/dt-bindings/input/input-event-codes.h>

/ {
model = "T3W1 D1 NRF52833";
compatible = "nordic,t3w1_d1_nrf52833";

chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,uart-mcumgr = &uart0;
zephyr,bt-mon-uart = &uart0;
zephyr,bt-c2h-uart = &uart0;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
zephyr,ieee802154 = &ieee802154;
};

leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
label = "Green LED 0";
};
out0: out_0 {
gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
label = "FW Running";
};
led1: led_1 {
gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
label = "Green LED 1";
};
};

buttons {
compatible = "gpio-keys";
button0: button_0 {
gpios = <&gpio1 8 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
label = "Push button switch 0";
zephyr,code = <INPUT_KEY_0>;
};
trezor_ready: trezor_ready {
gpios = <&gpio0 30 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
label = "Trezor ready";
zephyr,code = <INPUT_KEY_1>;
};
};

/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0;
led1 = &led1;
sw0 = &button0;
bootloader-led0 = &led0;
mcuboot-button0 = &button0;
mcuboot-led0 = &led0;
watchdog0 = &wdt0;
};
};

&adc {
status = "okay";
};

&uicr {
gpio-as-nreset;
};

&gpiote {
status = "okay";
};

&gpio0 {
status = "okay";
};

&gpio1 {
status = "okay";
};

&uart0 {
compatible = "nordic,nrf-uarte";
status = "okay";
current-speed = <1000000>;
pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};

&spi0 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi0_default>;
pinctrl-1 = <&spi0_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
reg_my_spi_master: spi-dev-a@0 {
reg = <0>;
};
};

&ieee802154 {
status = "okay";
};

&flash0 {

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0xC000>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000C000 0x37000>;
};
slot1_partition: partition@43000 {
label = "image-1";
reg = <0x00043000 0x37000>;
};
storage_partition: partition@7a000 {
label = "storage";
reg = <0x0007A000 0x00006000>;
};
};
};

zephyr_udc0: &usbd {
compatible = "nordic,nrf-usbd";
status = "okay";
};
16 changes: 16 additions & 0 deletions nordic/trezor/boards/arm/t3w1_d1_nrf52833/t3w1_d1_nrf52833.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
identifier: t3w1_d1_nrf52833
name: tw31-d1-NRF52833
type: mcu
arch: arm
ram: 128
flash: 512
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- usb_device
- ble
- gpio
- watchdog
- counter
Loading
Loading