Skip to content

Commit

Permalink
boards: norik: Add support for Norik Octopus IO-Board
Browse files Browse the repository at this point in the history
Add support for Norik Systems Octopus IO-Board based on
Norik Systems Octopus SoM.

Supported features:
 - LTE-M/NB-IoT
 - GPS
 - LED
 - 3-axis accelerometer
 - Battery charger
 - Solar charger
 - SPI NOR flash
 - Nano SIM connector

Signed-off-by: Florijan Plohl <[email protected]>
  • Loading branch information
FPlohl committed Oct 14, 2024
1 parent 954ce4c commit b190fa0
Show file tree
Hide file tree
Showing 20 changed files with 589 additions and 0 deletions.
5 changes: 5 additions & 0 deletions boards/norik/octopus_io_board/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 Norik Systems
# SPDX-License-Identifier: Apache-2.0

zephyr_library()
zephyr_library_sources(board.c)
15 changes: 15 additions & 0 deletions boards/norik/octopus_io_board/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2024 Norik Systems
# SPDX-License-Identifier: Apache-2.0

config BOARD_OCTOPUS_IO_BOARD
select PINCTRL

config OCTOPUS_IO_BOARD_CONTROL_INIT_PRIORITY
int "Init priority"
default 99
help
Init priority for board control.

module = OCTOPUS_IO_BOARD_CONTROL
module-str = Board Control
source "subsys/logging/Kconfig.template.log_config"
33 changes: 33 additions & 0 deletions boards/norik/octopus_io_board/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2024 Norik Systems
# SPDX-License-Identifier: Apache-2.0

if BOARD_OCTOPUS_IO_BOARD

# 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_OCTOPUS_IO_BOARD && TRUSTED_EXECUTION_SECURE

if BOARD_OCTOPUS_IO_BOARD_NRF9160_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_OCTOPUS_IO_BOARD_NRF9160_NS

endif # BOARD_OCTOPUS_IO_BOARD
5 changes: 5 additions & 0 deletions boards/norik/octopus_io_board/Kconfig.octopus_io_board
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 Norik Systems
# SPDX-License-Identifier: Apache-2.0

config BOARD_OCTOPUS_IO_BOARD
select SOC_NRF9160_SICA
63 changes: 63 additions & 0 deletions boards/norik/octopus_io_board/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2024 Norik Systems
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/init.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
#include <zephyr/drivers/charger.h>
#include <zephyr/drivers/i2c.h>

LOG_MODULE_REGISTER(board_control, CONFIG_OCTOPUS_IO_BOARD_CONTROL_LOG_LEVEL);

#define CHARGER_NODE DT_NODELABEL(bq25180)
#define SIM_SELECT_NODE DT_PATH(sim_select)

struct charger_config {
struct i2c_dt_spec i2c;
uint32_t initial_current_microamp;
};

static int octopus_io_board_init(void)
{
int ret;

const struct gpio_dt_spec simctrl = GPIO_DT_SPEC_GET(DT_PATH(sim_select), sim_gpios);

if (!gpio_is_ready_dt(&simctrl)) {
LOG_ERR("SIM select GPIO not available");
return -ENODEV;
}

if (DT_ENUM_IDX(SIM_SELECT_NODE, sim) == 0) {
(void)gpio_pin_configure_dt(&simctrl, GPIO_OUTPUT_LOW);
LOG_INF("On-board SIM selected");
} else {
(void)gpio_pin_configure_dt(&simctrl, GPIO_OUTPUT_HIGH);
LOG_INF("External SIM selected");
}

const struct device *charger = DEVICE_DT_GET(CHARGER_NODE);

if (!device_is_ready(charger)) {
LOG_ERR("Charger not ready");
return -ENODEV;
}

const struct charger_config *cfg = charger->config;

ret = i2c_reg_update_byte_dt(&cfg->i2c, 0x5, 0xff, 0b00100100);

if (ret < 0) {
LOG_ERR("Failed to set charger CHARGECTRL0 register");
return ret;
}
LOG_INF("Set CHARGECTRL0 register");

return 0;
}

SYS_INIT(octopus_io_board_init, POST_KERNEL, CONFIG_OCTOPUS_IO_BOARD_CONTROL_INIT_PRIORITY);
6 changes: 6 additions & 0 deletions boards/norik/octopus_io_board/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024 Norik Systems
# SPDX-License-Identifier: Apache-2.0

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)
7 changes: 7 additions & 0 deletions boards/norik/octopus_io_board/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
board:
name: octopus_io_board
vendor: norik
socs:
- name: nrf9160
variants:
- name: 'ns'
Binary file not shown.
147 changes: 147 additions & 0 deletions boards/norik/octopus_io_board/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
.. _octopus_io_board:

Norik Octopus IO-Board
######################

Overview
********

Octopus IO-Board is an expansion to the Octopus SoM, which is built around the nRF9160 SiP
offering NB-IoT and LTE-M connectivity, GPS and accelerometer. Octopus IO-Board expands
the capabilities of the Octopus SoM by providing additional peripherals and interfaces for
development and prototyping of low-power IoT applications.

nRF9160 SiP contains ARM Cortex-M33 application processor and the
following devices:

* :abbr:`ADC (Analog to Digital Converter)`
* CLOCK
* FLASH
* :abbr:`GPIO (General Purpose Input Output)`
* :abbr:`I2C (Inter-Integrated Circuit)`
* :abbr:`MPU (Memory Protection Unit)`
* :abbr:`NVIC (Nested Vectored Interrupt Controller)`
* :abbr:`PWM (Pulse Width Modulation)`
* :abbr:`RTC (nRF RTC System Clock)`
* Segger RTT (RTT Console)
* :abbr:`SPI (Serial Peripheral Interface)`
* :abbr:`UARTE (Universal asynchronous receiver-transmitter with EasyDMA)`
* :abbr:`WDT (Watchdog Timer)`
* :abbr:`IDAU (Implementation Defined Attribution Unit)`

.. figure:: img/Norik_Octopus_IO-board.webp
:align: center
:alt: Norik Octopus IO-Board front view

Norik Octopus IO-Board

Octopus IO Board offers the following features:

* Battery charger
* USB-C for power
* Solar charger
* Alkaline battery input
* LDO regulator to power Octopus SoM and peripherals
* Battery monitoring using ADC
* 64 Mbit SPI NOR flash
* Dedicated ADC, GPIO, I2C, SPI and UARTE pins for expansion
* Exposed headers for current measurements
* Nano SIM connector
* Tag-Connect TC2030-IDC 6-pin connector for SWD programming and debugging
* 2x3 pinheader for SWD programming and debugging

Hardware
********

Connections and IOs
===================

The Octopus IO Board features multiple dedicated pin headers for peripherals:

* 3x I2C0 bus
* 2x SPI0 bus
* 3x I2C1/SPI1 bus (selectable)
* 1x UARTE0 bus
* 1x Analog input (5 input pins)
* 1x GPIO (7 I/O pins)

The I2C1/SPI1 bus is selectable by the user by cutting/soldering SB8 and SB9 solder bridges and configuring the bus in the device tree.

The GPIO pin header provides 7 I/O pins, which can be used as digital input/output. Some of them also serve as chip selects for SPI peripherals.

Power supply
============

The Octopus IO Board can be powered from the following sources:

* USB-C connector
* Solar cell
* Alkaline battery
* Li-Po battery

When powered from USB-C or solar cell, the board can charge the Li-Po battery. The battery voltage can be monitored using ADC which can
provide information about the battery State of charge (SOC).

When powered from alkaline battery, the user needs to set switch SW1 to ALK position. This ensures that the Li-Ion battery is not charged from the alkaline battery.

The board has a built-in LDO regulator that is used to power the Octopus SoM and peripherals. The EN2 pin can be used to enable/disable output 2 of the LDO regulator.
This can be used to power off peripherals to save power when they are not needed.

The board also has multiple built-in test points for measuring current consumption of the board, which enables the user to measure and optimize the power consumption of the board.

Programming and Debugging
*************************

Norik Octopus IO board can be programmed and debugged using the Tag-Connect TC2030-IDC 6-pin connector or 6-pin SWD pinheader.

Building an application
=======================

In most case you'll need to use ``octopus_io_board/nrf9160/ns`` target for building examples.
Some examples don't require non secure mode and can be built with ``octopus_io_board/nrf9160`` target.

Flashing
========
Refer to the instruction in the :ref:`nordic_segger` page to install and
configure all the necessary software.

Here is an example for the Hello World application.

First, run your favorite terminal program to listen for output.

.. code-block:: console
$ minicom /dev/<tty_device> 115200
Replace <tty_device> with the port where the Octopus IO-Board can be found. For example, under Linux, /dev/ttyACM0.

Then build and flash the application in the usual way.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: octopus_io_board/nrf9160
:goals: build flash

To build and flash the application in non-secure mode, use the following command:

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: octopus_io_board/nrf9160/ns
:goals: build flash

Debugging
=========
Refer to the instruction in the :ref:`nordic_segger` page for information on
debugging.

Testing the on-board LED
========================
Use the :zephyr:code-sample:`blinky` to test the on-board LED. Build and flash the example to make sure Zephyr is running correctly on your board.

.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: octopus_io_board/nrf9160
:goals: build flash

References
**********
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) 2024 Norik Systems
# SPDX-License-Identifier: Apache-2.0

description: |
This binding is used for controlling battery charger and
LDO regulator on the Octopus IO Board.
compatible: "norik,power-controller"

include: base.yaml

properties:
debounce-interval-ms:
type: int
default: 30
description: |
Debouncing interval time in milliseconds.
If not specified defaults to 30.
polling-mode:
type: boolean
description: |
Do not use interrupts for the key GPIOs, poll the pin periodically at the
specified debounce-interval-ms instead.
child-binding:
description: Child Node for the power controller
properties:
gpios:
type: phandle-array
required: true

label:
type: string
description: Descriptive name of the gpio

zephyr,code:
type: int
description: Key code to emit.
26 changes: 26 additions & 0 deletions boards/norik/octopus_io_board/dts/bindings/norik,sim_select.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2024 Norik Systems
# SPDX-License-Identifier: Apache-2.0

description: |
The Octopus SoM provides the user 2 options for connecting
a SIM card to the nRF9160. Option one is to use on-board eSIM or
external nano SIM. Which SIM is used can be selected using the 'sim'
property of the 'sim_select' dt node.
compatible: "norik,sim_select"

include: base.yaml

properties:
sim-gpios:
type: phandle-array
required: true
description: Pin used to select which SIM is used

sim:
type: string
required: true
enum:
- "on-board"
- "external"
description: SIM choice (on-board eSIM or external nano SIM)
36 changes: 36 additions & 0 deletions boards/norik/octopus_io_board/octopus_io_board_common-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 Norik Systems
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
i2c0_default: i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
<NRF_PSEL(TWIM_SCL, 0, 3)>;
};
};

i2c0_sleep: i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
<NRF_PSEL(TWIM_SCL, 0, 3)>;
low-power-enable;
};
};

i2c1_default: i2c1_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 2)>,
<NRF_PSEL(TWIM_SCL, 0, 1)>;
};
};

i2c1_sleep: i2c1_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 2)>,
<NRF_PSEL(TWIM_SCL, 0, 1)>;
low-power-enable;
};
};
};
Loading

0 comments on commit b190fa0

Please sign in to comment.