From 8f3deea171b08ed29c27c571d90ac1b1492af17b Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Mon, 21 Aug 2023 12:32:18 +0200 Subject: [PATCH 1/7] wip: nrf9131ek board files --- boards/arm/nrf9131ek_nrf9131/Kconfig.board | 14 ++ .../arm/nrf9131ek_nrf9131/Kconfig.defconfig | 62 +++++ boards/arm/nrf9131ek_nrf9131/board.cmake | 14 ++ .../nrf9131ek_nrf9131/nrf9131ek_nrf9131.dts | 19 ++ .../nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml | 21 ++ .../nrf9131ek_nrf9131_common-pinctrl.dtsi | 100 ++++++++ .../nrf9131ek_nrf9131_common.dtsi | 231 ++++++++++++++++++ .../nrf9131ek_nrf9131_defconfig | 26 ++ .../nrf9131ek_nrf9131_ns.dts | 22 ++ .../nrf9131ek_nrf9131_ns.yaml | 19 ++ .../nrf9131ek_nrf9131_ns_defconfig | 29 +++ .../nrf9131ek_nrf9131_partition_conf.dtsi | 60 +++++ .../arm/nrf9131ek_nrf9131/pre_dt_board.cmake | 7 + 13 files changed, 624 insertions(+) create mode 100644 boards/arm/nrf9131ek_nrf9131/Kconfig.board create mode 100644 boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig create mode 100644 boards/arm/nrf9131ek_nrf9131/board.cmake create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.dts create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common-pinctrl.dtsi create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_defconfig create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.dts create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig create mode 100644 boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi create mode 100644 boards/arm/nrf9131ek_nrf9131/pre_dt_board.cmake diff --git a/boards/arm/nrf9131ek_nrf9131/Kconfig.board b/boards/arm/nrf9131ek_nrf9131/Kconfig.board new file mode 100644 index 00000000000..e61588f4a47 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/Kconfig.board @@ -0,0 +1,14 @@ +# nRF9161 DK NRF9161 board configuration + +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if SOC_NRF9161_SICA + +config BOARD_NRF9131EK_NRF9131 + bool "nRF9161 DK NRF9161" + +config BOARD_NRF9131EK_NRF9131_NS + bool "nRF9161 DK NRF9161 non-secure" + +endif # SOC_NRF9161_SICA diff --git a/boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig b/boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig new file mode 100644 index 00000000000..fa4c9547cf2 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig @@ -0,0 +1,62 @@ +# nRF9161 DK NRF9161 board configuration + +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS + +config BOARD + default "nrf9131ek_nrf9131" + +# By default, if we build for a Non-Secure version of the board, +# enable building with TF-M as the Secure Execution Environment. +config BUILD_WITH_TFM + default y if BOARD_NRF9131EK_NRF9131_NS + +if BUILD_WITH_TFM + +# By default, if we build with TF-M, instruct build system to +# flash the combined TF-M (Secure) & Zephyr (Non Secure) image +config TFM_FLASH_MERGED_BINARY + bool + default y + +endif # BUILD_WITH_TFM + +# For the secure version of the board the firmware is linked at the beginning +# of the flash, or into the code-partition defined in DT if it is intended to +# be loaded by MCUboot. If the secure firmware is to be combined with a non- +# secure image (TRUSTED_EXECUTION_SECURE=y), the secure FW image shall always +# be restricted to the size of its code partition. +# For the non-secure version of the board, the firmware +# must be linked into the code-partition (non-secure) defined in DT, regardless. +# Apply this configuration below by setting the Kconfig symbols used by +# the linker according to the information extracted from DT partitions. + +# Workaround for not being able to have commas in macro arguments +DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition + +config FLASH_LOAD_SIZE + default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) + depends on BOARD_NRF9131EK_NRF9131 && TRUSTED_EXECUTION_SECURE + +if BOARD_NRF9131EK_NRF9131_NS + +config FLASH_LOAD_OFFSET + default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) + +config FLASH_LOAD_SIZE + default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) + +endif # BOARD_NRF9131EK_NRF9131_NS + +config BT_HCI_VS + default y if BT + +config BT_WAIT_NOP + default BT && $(dt_nodelabel_enabled,nrf5340_reset) + +config I2C + default $(dt_compat_on_bus,$(DT_COMPAT_NXP_PCAL6408A),i2c) + +endif # BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS diff --git a/boards/arm/nrf9131ek_nrf9131/board.cmake b/boards/arm/nrf9131ek_nrf9131/board.cmake new file mode 100644 index 00000000000..4f2ab4870d5 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/board.cmake @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_BOARD_NRF9131EK_NRF9131_NS) + set(TFM_PUBLIC_KEY_FORMAT "full") +endif() + +if(CONFIG_TFM_FLASH_MERGED_BINARY) + set_property(TARGET runners_yaml_props_target PROPERTY hex_file tfm_merged.hex) +endif() + +# TODO: change to nRF9161_xxAA when such device is available in JLink +board_runner_args(jlink "--device=nRF9160_xxAA" "--speed=4000") +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.dts b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.dts new file mode 100644 index 00000000000..33f384782d4 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.dts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "nrf9131ek_nrf9131_common.dtsi" + +/ { + chosen { + zephyr,sram = &sram0_s; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + zephyr,sram-secure-partition = &sram0_s; + zephyr,sram-non-secure-partition = &sram0_ns; + }; +}; diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml new file mode 100644 index 00000000000..04d14cfca62 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml @@ -0,0 +1,21 @@ +identifier: nrf9131ek_nrf9131 +name: nRF9161-DK-NRF9161 +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 88 +flash: 1024 +supported: + - arduino_gpio + - arduino_i2c + - arduino_serial + - arduino_spi + - gpio + - i2c + - pwm + - spi + - watchdog + - counter diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common-pinctrl.dtsi b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common-pinctrl.dtsi new file mode 100644 index 00000000000..419e7c8d70c --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common-pinctrl.dtsi @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + uart0_default: uart0_default { + group1 { + psels = , + ; + }; + group2 { + psels = , + ; + bias-pull-up; + }; + }; + + uart0_sleep: uart0_sleep { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; + + uart1_default: uart1_default { + group1 { + psels = , + ; + }; + group2 { + psels = , + ; + bias-pull-up; + }; + }; + + uart1_sleep: uart1_sleep { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; + + i2c2_default: i2c2_default { + group1 { + psels = , + ; + }; + }; + + i2c2_sleep: i2c2_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + pwm0_default: pwm0_default { + group1 { + psels = , + , + ; + }; + }; + + pwm0_sleep: pwm0_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + spi3_default: spi3_default { + group1 { + psels = , + , + ; + nordic,drive-mode = ; + }; + }; + + spi3_sleep: spi3_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi new file mode 100644 index 00000000000..2ceb68cff0e --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "nrf9131ek_nrf9131_common-pinctrl.dtsi" + +/ { + model = "Nordic nRF9131 EK NRF9131"; + compatible = "nordic,nrf9131-ek-nrf9131"; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,uart-mcumgr = &uart0; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + label = "Green LED 1"; + }; + led1: led_1 { + gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; + label = "Green LED 2"; + }; + led2: led_2 { + gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>; + label = "Green LED 3"; + }; + }; + + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm0 0 PWM_MSEC(8) PWM_POLARITY_NORMAL>; + }; + pwm_led1: pwm_led_1 { + pwms = <&pwm0 1 PWM_MSEC(8) PWM_POLARITY_NORMAL>; + }; + pwm_led2: pwm_led_2 { + pwms = <&pwm0 2 PWM_MSEC(8) PWM_POLARITY_NORMAL>; + }; + }; + + buttons { + compatible = "gpio-keys"; + button0: button_0 { + gpios = <&gpio0 28 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button 1"; + }; + }; + + /* These aliases are provided for compatibility with samples */ + aliases { + led0 = &led0; + led1 = &led1; + led2 = &led2; + pwm-led0 = &pwm_led0; + pwm-led1 = &pwm_led1; + pwm-led2 = &pwm_led2; + sw0 = &button0; + bootloader-led0 = &led0; + mcuboot-button0 = &button0; + mcuboot-led0 = &led0; + watchdog0 = &wdt0; + spi-flash0 = &gd25wb256; + }; +}; + +&adc { + status = "okay"; +}; + +&gpiote { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_default>; + pinctrl-1 = <&uart0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +arduino_serial: &uart1 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart1_default>; + pinctrl-1 = <&uart1_sleep>; + pinctrl-names = "default", "sleep"; +}; + +arduino_i2c: &i2c2 { + compatible = "nordic,nrf-twim"; + status = "okay"; + pinctrl-0 = <&i2c2_default>; + pinctrl-1 = <&i2c2_sleep>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; + + pmic_main: npm1300@6b { + compatible = "nordic,npm1300"; + label = "nPM1300"; + reg = <0x6b>; + pmic_charger: charger { + compatible = "nordic,npm1300-charger"; + term-microvolt = <4150000>; + term-warm-microvolt = <4000000>; + current-microamp = <150000>; + dischg-limit-microamp = <1000000>; + vbus-limit-microamp = <500000>; + thermistor-ohms = <10000>; + thermistor-beta = <3380>; + charging-enable; + }; + regulators { + compatible = "nordic,npm1300-regulator"; + BUCK1 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + }; + BUCK2 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + }; + }; + }; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_default>; + pinctrl-1 = <&pwm0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +arduino_spi: &spi3 { + compatible = "nordic,nrf-spim"; + status = "okay"; + cs-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&spi3_default>; + pinctrl-1 = <&spi3_sleep>; + pinctrl-names = "default", "sleep"; + + gd25wb256: gd25wb256e3ir@1 { + compatible = "jedec,spi-nor"; + status = "disabled"; + reg = <1>; + spi-max-frequency = <60000000>; + /* todo: update these from LB256 to WB256 */ + jedec-id = [c8 67 19]; + sfdp-bfp = [ + e5 20 ea ff ff ff ff 0f 44 eb 08 6b 00 3b 00 bb + fe ff ff ff ff ff 00 ff ff ff 44 eb 0c 20 0f 52 + 10 d8 00 ff d5 31 b1 fe 82 e4 14 4c ec 60 06 33 + 7a 75 7a 75 04 bd d5 5c 29 06 74 00 08 50 00 01 + ]; + size = <268435456>; + has-dpd; + t-enter-dpd = <3000>; + t-exit-dpd = <30000>; + }; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0x10000>; + }; + slot0_partition: partition@10000 { + label = "image-0"; + }; + slot0_ns_partition: partition@50000 { + label = "image-0-nonsecure"; + }; + slot1_partition: partition@80000 { + label = "image-1"; + }; + slot1_ns_partition: partition@c0000 { + label = "image-1-nonsecure"; + }; + scratch_partition: partition@f0000 { + label = "image-scratch"; + reg = <0x000f0000 0xa000>; + }; + storage_partition: partition@fa000 { + label = "storage"; + reg = <0x000fa000 0x00006000>; + }; + }; +}; + + + +/ { + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + sram0_s: image_s@20000000 { + /* Secure image memory */ + }; + + sram0_modem: image_modem@20016000 { + /* Modem (shared) memory */ + }; + + sram0_ns: image_ns@20020000 { + /* Non-Secure image memory */ + }; + }; +}; + +/* Include partition configuration file */ +#include "nrf9131ek_nrf9131_partition_conf.dtsi" diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_defconfig b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_defconfig new file mode 100644 index 00000000000..dd272810697 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_defconfig @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_NRF91X=y +CONFIG_SOC_NRF9161_SICA=y +CONFIG_BOARD_NRF9131EK_NRF9131=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable TrustZone-M +CONFIG_ARM_TRUSTZONE_M=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable uart driver +CONFIG_SERIAL=y + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +CONFIG_PINCTRL=y diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.dts b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.dts new file mode 100644 index 00000000000..549d6ad3380 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.dts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "nrf9131ek_nrf9131_common.dtsi" + +/ { + chosen { + zephyr,flash = &flash0; + zephyr,sram = &sram0_ns; + zephyr,code-partition = &slot0_ns_partition; + }; +}; + +/* Disable UART1, because it is used by default in TF-M */ +&uart1 { + status = "disabled"; +}; diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml new file mode 100644 index 00000000000..d9089594360 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml @@ -0,0 +1,19 @@ +identifier: nrf9131ek_nrf9131_ns +name: nRF9161-DK-NRF9161-Non-Secure +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 128 +flash: 192 +supported: + - arduino_gpio + - arduino_i2c + - arduino_serial + - arduino_spi + - i2c + - pwm + - watchdog + - netif:modem diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig new file mode 100644 index 00000000000..833479710c9 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_NRF91X=y +CONFIG_SOC_NRF9161_SICA=y +CONFIG_BOARD_NRF9131EK_NRF9131_NS=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable TrustZone-M +CONFIG_ARM_TRUSTZONE_M=y + +# This Board implies building Non-Secure firmware +CONFIG_TRUSTED_EXECUTION_NONSECURE=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable uart driver +CONFIG_SERIAL=y + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +CONFIG_PINCTRL=y diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi new file mode 100644 index 00000000000..80b4c5f6b3a --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * Default Flash planning for nRF9161dk_nrf9161. + * + * Zephyr build for nRF9161 with ARM TrustZone-M support, + * implies building Secure and Non-Secure Zephyr images. + * + * Secure image will be placed, by default, in flash0 + * (or in slot0, if MCUboot is present). + * Secure image will use sram0 for system memory. + * + * Non-Secure image will be placed in slot0_ns, and use + * sram0_ns for system memory. + * + * Note that the Secure image only requires knowledge of + * the beginning of the Non-Secure image (not its size). + */ + +&slot0_partition { + reg = <0x00010000 0x40000>; +}; + +&slot0_ns_partition { + reg = <0x00050000 0x30000>; +}; + +&slot1_partition { + reg = <0x00080000 0x40000>; +}; + +&slot1_ns_partition { + reg = <0x000c0000 0x30000>; +}; + +/* Default SRAM planning when building for nRF9161 with + * ARM TrustZone-M support + * - Lowest 88 kB SRAM allocated to Secure image (sram0_s). + * - 40 kB SRAM reserved for and used by the modem library + * (sram0_modem). This memory is Non-Secure. + * - Upper 128 kB allocated to Non-Secure image (sram0_ns). + * When building with TF-M, both sram0_modem and sram0_ns + * are allocated to the Non-Secure image. + */ + +&sram0_s { + reg = <0x20000000 DT_SIZE_K(88)>; +}; + +&sram0_modem { + reg = <0x20016000 DT_SIZE_K(40)>; +}; + +&sram0_ns { + reg = <0x20020000 DT_SIZE_K(128)>; +}; diff --git a/boards/arm/nrf9131ek_nrf9131/pre_dt_board.cmake b/boards/arm/nrf9131ek_nrf9131/pre_dt_board.cmake new file mode 100644 index 00000000000..c8267afd1b4 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/pre_dt_board.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2021 Linaro Limited +# SPDX-License-Identifier: Apache-2.0 + +# Suppress "unique_unit_address_if_enabled" to handle the following overlaps: +# - flash-controller@39000 & kmu@39000 +# - power@5000 & clock@5000 +list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled") From 324a3fc0a5d682b6ae3edcb91795255ee8daff2d Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Mon, 21 Aug 2023 13:44:56 +0200 Subject: [PATCH 2/7] enable regulator by default --- boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig index 833479710c9..7b059059578 100644 --- a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig @@ -27,3 +27,5 @@ CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y CONFIG_PINCTRL=y + +CONFIG_REGULATOR=y From 7798a2e970a4d911a2d092f04bacdeab08662387 Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Mon, 21 Aug 2023 13:52:38 +0200 Subject: [PATCH 3/7] enable charging --- boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig index 7b059059578..088be68ffe0 100644 --- a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns_defconfig @@ -29,3 +29,7 @@ CONFIG_UART_CONSOLE=y CONFIG_PINCTRL=y CONFIG_REGULATOR=y + +CONFIG_SENSOR=y + +CONFIG_NPM1300_CHARGER=y From 0b77adbf0234304a9eee97e9b59c4e40c20b40f4 Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Mon, 21 Aug 2023 14:34:53 +0200 Subject: [PATCH 4/7] wip: spi flash --- .../nrf9131ek_nrf9131_common.dtsi | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi index 2ceb68cff0e..a12ae9cf0be 100644 --- a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi @@ -151,23 +151,11 @@ arduino_spi: &spi3 { pinctrl-1 = <&spi3_sleep>; pinctrl-names = "default", "sleep"; - gd25wb256: gd25wb256e3ir@1 { + gd25wb256: gd25wb256e3ir@0 { compatible = "jedec,spi-nor"; - status = "disabled"; - reg = <1>; - spi-max-frequency = <60000000>; - /* todo: update these from LB256 to WB256 */ - jedec-id = [c8 67 19]; - sfdp-bfp = [ - e5 20 ea ff ff ff ff 0f 44 eb 08 6b 00 3b 00 bb - fe ff ff ff ff ff 00 ff ff ff 44 eb 0c 20 0f 52 - 10 d8 00 ff d5 31 b1 fe 82 e4 14 4c ec 60 06 33 - 7a 75 7a 75 04 bd d5 5c 29 06 74 00 08 50 00 01 - ]; - size = <268435456>; - has-dpd; - t-enter-dpd = <3000>; - t-exit-dpd = <30000>; + status = "okay"; + reg = <0>; + spi-max-frequency = <1000000>; }; }; From 93423712023978fdd1725b6c0266aea20fc8a2cf Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Mon, 21 Aug 2023 15:56:08 +0200 Subject: [PATCH 5/7] workaround for npm1300 --- boards/arm/nrf9131ek_nrf9131/CMakeLists.txt | 7 +++ boards/arm/nrf9131ek_nrf9131/Kconfig | 18 +++++++ boards/arm/nrf9131ek_nrf9131/npm1300.c | 53 +++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 boards/arm/nrf9131ek_nrf9131/CMakeLists.txt create mode 100644 boards/arm/nrf9131ek_nrf9131/Kconfig create mode 100644 boards/arm/nrf9131ek_nrf9131/npm1300.c diff --git a/boards/arm/nrf9131ek_nrf9131/CMakeLists.txt b/boards/arm/nrf9131ek_nrf9131/CMakeLists.txt new file mode 100644 index 00000000000..81c27d56c9a --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA. +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +if (CONFIG_BOARD_NRF9131EK_NRF9131 OR CONFIG_BOARD_NRF9131EK_NRF9131_NS) +zephyr_library() +zephyr_library_sources(npm1300.c) +endif() diff --git a/boards/arm/nrf9131ek_nrf9131/Kconfig b/boards/arm/nrf9131ek_nrf9131/Kconfig new file mode 100644 index 00000000000..35b0102106a --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/Kconfig @@ -0,0 +1,18 @@ +# Thingy:91 nRF9161 board configuration +# +# Copyright (c) 2019 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +if BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS + +config BOARD_INIT_PRIORITY + int "Initialization priority for board configuration" + default 80 + +endif # BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS + +module=BOARD +module-dep=LOG +module-str=Log level for board +source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" diff --git a/boards/arm/nrf9131ek_nrf9131/npm1300.c b/boards/arm/nrf9131ek_nrf9131/npm1300.c new file mode 100644 index 00000000000..48dbe393d63 --- /dev/null +++ b/boards/arm/nrf9131ek_nrf9131/npm1300.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include +#include +#include +#include + +LOG_MODULE_REGISTER(board_secure, CONFIG_BOARD_LOG_LEVEL); + +#define CHECKERR if (err) {LOG_ERR("I2C error: %d", err); return err;} + +static const struct i2c_dt_spec pmic = I2C_DT_SPEC_GET(DT_NODELABEL(pmic_main)); + +static int pmic_write_reg(uint16_t address, uint8_t value) +{ + uint8_t buf[] = { + address >> 8, + address & 0xFF, + value, + }; + + return i2c_write_dt(&pmic, buf, ARRAY_SIZE(buf)); +} + +static int thingy91x_board_init(void) +{ + int err = 0; + + if (!device_is_ready(pmic.bus)) { + LOG_ERR("cannot reach PMIC!"); + return -ENODEV; + } + + // disable charger for config + err = pmic_write_reg(0x0305, 0x03); CHECKERR; + + // set VBUS current limit 500mA + err = pmic_write_reg(0x0201, 0x00); CHECKERR; + err = pmic_write_reg(0x0202, 0x00); CHECKERR; + err = pmic_write_reg(0x0200, 0x01); CHECKERR; + + // enable charger + err = pmic_write_reg(0x0304, 0x03); CHECKERR; + + return err; +} + +SYS_INIT(thingy91x_board_init, POST_KERNEL, CONFIG_BOARD_INIT_PRIORITY); From 43892864bdf910baca7006e3dcffb12f17ce3552 Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Mon, 21 Aug 2023 17:16:04 +0200 Subject: [PATCH 6/7] get flash info using jesd216 sample --- .../nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi index a12ae9cf0be..83beac75245 100644 --- a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common.dtsi @@ -153,9 +153,17 @@ arduino_spi: &spi3 { gd25wb256: gd25wb256e3ir@0 { compatible = "jedec,spi-nor"; - status = "okay"; + status = "disabled"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <8000000>; + size = <268435456>; + sfdp-bfp = [ + e5 20 f3 ff ff ff ff 0f 44 eb 08 6b 08 3b 42 bb + ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52 + 10 d8 00 ff 44 7a c9 fe 83 67 26 62 ec 82 18 44 + 7a 75 7a 75 04 c4 d5 5c 00 06 74 00 08 50 00 01 + ]; + jedec-id = [c8 65 19]; }; }; From 25168050a4ea37201999cb32c137205a7fa70712 Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Tue, 22 Aug 2023 10:47:17 +0200 Subject: [PATCH 7/7] some renamings --- boards/arm/nrf9131ek_nrf9131/Kconfig | 4 ++-- boards/arm/nrf9131ek_nrf9131/Kconfig.board | 6 +++--- boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig | 2 +- boards/arm/nrf9131ek_nrf9131/board.cmake | 2 +- boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml | 2 +- boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml | 2 +- .../nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/boards/arm/nrf9131ek_nrf9131/Kconfig b/boards/arm/nrf9131ek_nrf9131/Kconfig index 35b0102106a..d2135d7dbbd 100644 --- a/boards/arm/nrf9131ek_nrf9131/Kconfig +++ b/boards/arm/nrf9131ek_nrf9131/Kconfig @@ -1,6 +1,6 @@ -# Thingy:91 nRF9161 board configuration +# nRF9131-EK board configuration # -# Copyright (c) 2019 Nordic Semiconductor ASA +# Copyright (c) 2023 Nordic Semiconductor ASA # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause diff --git a/boards/arm/nrf9131ek_nrf9131/Kconfig.board b/boards/arm/nrf9131ek_nrf9131/Kconfig.board index e61588f4a47..3800c98d1a9 100644 --- a/boards/arm/nrf9131ek_nrf9131/Kconfig.board +++ b/boards/arm/nrf9131ek_nrf9131/Kconfig.board @@ -1,4 +1,4 @@ -# nRF9161 DK NRF9161 board configuration +# nRF9131-EK board configuration # Copyright (c) 2023 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -6,9 +6,9 @@ if SOC_NRF9161_SICA config BOARD_NRF9131EK_NRF9131 - bool "nRF9161 DK NRF9161" + bool "nRF9131 EK NRF9131" config BOARD_NRF9131EK_NRF9131_NS - bool "nRF9161 DK NRF9161 non-secure" + bool "nRF9131 EK NRF9131 non-secure" endif # SOC_NRF9161_SICA diff --git a/boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig b/boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig index fa4c9547cf2..650c1190c37 100644 --- a/boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig +++ b/boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig @@ -1,4 +1,4 @@ -# nRF9161 DK NRF9161 board configuration +# nRF9131 EK NRF9131 board configuration # Copyright (c) 2023 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 diff --git a/boards/arm/nrf9131ek_nrf9131/board.cmake b/boards/arm/nrf9131ek_nrf9131/board.cmake index 4f2ab4870d5..8293a428b40 100644 --- a/boards/arm/nrf9131ek_nrf9131/board.cmake +++ b/boards/arm/nrf9131ek_nrf9131/board.cmake @@ -8,7 +8,7 @@ if(CONFIG_TFM_FLASH_MERGED_BINARY) set_property(TARGET runners_yaml_props_target PROPERTY hex_file tfm_merged.hex) endif() -# TODO: change to nRF9161_xxAA when such device is available in JLink +# TODO: change to nRF9131_xxAA when such device is available in JLink board_runner_args(jlink "--device=nRF9160_xxAA" "--speed=4000") include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml index 04d14cfca62..113277e9431 100644 --- a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml @@ -1,5 +1,5 @@ identifier: nrf9131ek_nrf9131 -name: nRF9161-DK-NRF9161 +name: nRF9131-DK-NRF9131 type: mcu arch: arm toolchain: diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml index d9089594360..adc5696a4d9 100644 --- a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_ns.yaml @@ -1,5 +1,5 @@ identifier: nrf9131ek_nrf9131_ns -name: nRF9161-DK-NRF9161-Non-Secure +name: nRF9131-EK-NRF9131-Non-Secure type: mcu arch: arm toolchain: diff --git a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi index 80b4c5f6b3a..c8d1d0e042f 100644 --- a/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi +++ b/boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_partition_conf.dtsi @@ -5,9 +5,9 @@ */ /* - * Default Flash planning for nRF9161dk_nrf9161. + * Default Flash planning for nRF9131ek_nrf9131. * - * Zephyr build for nRF9161 with ARM TrustZone-M support, + * Zephyr build for nRF9131 with ARM TrustZone-M support, * implies building Secure and Non-Secure Zephyr images. * * Secure image will be placed, by default, in flash0 @@ -37,7 +37,7 @@ reg = <0x000c0000 0x30000>; }; -/* Default SRAM planning when building for nRF9161 with +/* Default SRAM planning when building for nRF9131 with * ARM TrustZone-M support * - Lowest 88 kB SRAM allocated to Secure image (sram0_s). * - 40 kB SRAM reserved for and used by the modem library