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

boards: arm: arduino_opta_m4: adds initial support to Arduino OPTA PLC on the M4 core #64101

Merged
Merged
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
7 changes: 7 additions & 0 deletions boards/arm/arduino_opta_m4/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2023 Felipe Neves
# SPDX-License-Identifier: Apache-2.0

config BOARD_ARDUINO_OPTA_M4
bool "Arduino OPTA Programmable Logic Controller M4 Core"
depends on SOC_STM32H747XX
select CPU_CORTEX_M4
9 changes: 9 additions & 0 deletions boards/arm/arduino_opta_m4/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023 Felipe Neves
# SPDX-License-Identifier: Apache-2.0

if BOARD_ARDUINO_OPTA_M4

config BOARD
default "arduino_opta_m4"

endif # BOARD_ARDUINO_OPTA_M4
74 changes: 74 additions & 0 deletions boards/arm/arduino_opta_m4/arduino_opta_m4.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2023 Felipe Neves
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <st/h7/stm32h747Xi_m4.dtsi>
#include <st/h7/stm32h747xihx-pinctrl.dtsi>
#include <zephyr/dt-bindings/input/input-event-codes.h>

/ {
model = "Arduino OPTA M4 core Programmable Logic Controller";
compatible = "arduino,opta-m4";

chosen {
zephyr,sram = &sram1;
zephyr,flash = &flash1;
zephyr,code-partition = &slot0_partition;
};

leds {
compatible = "gpio-leds";
status_led_1: led_1 {
gpios = <&gpioi 0 GPIO_ACTIVE_LOW>;
};
status_led_2: led_2 {
gpios = <&gpioi 1 GPIO_ACTIVE_LOW>;
};
status_led_3: led_3 {
gpios = <&gpioi 3 GPIO_ACTIVE_LOW>;
};
status_led_4: led_4 {
gpios = <&gpioh 15 GPIO_ACTIVE_LOW>;
};
};

gpio_keys {
compatible = "gpio-keys";

user_button: button {
gpios = <&gpioe 4 GPIO_ACTIVE_HIGH>;
zephyr,code = <INPUT_KEY_WAKEUP>;
};
};

aliases {
sw0 = &user_button;
led0 = &status_led_1;
};
};

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

slot0_partition: partition@80000 {
label = "image-0";
reg = <0x00080000 DT_SIZE_K(512)>;
};
};
};

&rcc {
d1cpre = <1>;
hpre = <2>;
d1ppre = <2>;
d2ppre1 = <2>;
d2ppre2 = <2>;
d3ppre = <2>;
clock-frequency = <DT_FREQ_M(240)>;
};
21 changes: 21 additions & 0 deletions boards/arm/arduino_opta_m4/arduino_opta_m4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
identifier: arduino_opta_m4
name: ARDUINO OPTA (M4)
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 288
flash: 512
supported:
- gpio
testing:
ignore_tags:
- mpu
- nfc
- net
- flash
- input
- mcumgr
vendor: arduino
25 changes: 25 additions & 0 deletions boards/arm/arduino_opta_m4/arduino_opta_m4_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2023 Felipe Neves
# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_STM32H7X=y
CONFIG_SOC_STM32H747XX=y

CONFIG_BOARD_ARDUINO_OPTA_M4=y

# enable GPIO
CONFIG_GPIO=y

# clock configuration
CONFIG_CLOCK_CONTROL=y

# Enable MPU
CONFIG_ARM_MPU=y

# Enable HW stack protection
CONFIG_HW_STACK_PROTECTION=y

# enable pin controller
CONFIG_PINCTRL=y

# Use zephyr,code-partition as flash offset
CONFIG_USE_DT_CODE_PARTITION=y
5 changes: 5 additions & 0 deletions boards/arm/arduino_opta_m4/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

board_runner_args(dfu-util "--pid=2341:0364" "--alt=0" "--dfuse")

include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake)
fabiobaltieri marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 177 additions & 0 deletions boards/arm/arduino_opta_m4/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
.. _arduino_opta_m4_board:

Arduino OPTA M4-Core
#######################

Overview
********

The Arduino™ Opta® is a secure micro Programmable Logic Controller (PLC)
with Industrial Internet of Things (IoT) capabilities.

Developed in partnership with Finder®, this device supports both the Arduino
programming language and standard IEC-61131-3 PLC programming languages,
such as Ladder Diagram (LD), Sequential Function Chart (SFC),
Function Block Diagram (FBD), Structured Text (ST), and Instruction List (IL),
making it an ideal device for automation engineers.

For Zephyr RTOS, only the M4 is supported for now, making the M7 run the PLC
tasks while the M4 core under Zephyr acts as a coprocessor.

Additionally, the device features:
uLipe marked this conversation as resolved.
Show resolved Hide resolved

- Ethernet compliant with IEEE802.3-2002
- 16MB QSPI Flash
- 4 x green color status LEDs
- 1 x user push-button
- 1 x reset push-button accessible via pinhole
- 8 x analog inputs
- 4 x isolated relay outputs

.. image:: img/arduino_opta.jpeg
:align: center
:alt: ARDUINO-OPTA

More information about the board can be found at the `ARDUINO-OPTA website`_.
More information about STM32H747XIH6 can be found here:

- `STM32H747XI on www.st.com`_
- `STM32H747xx reference manual`_
- `STM32H747xx datasheet`_

Supported Features
==================

The current Zephyr arduino_opta_m4 board configuration supports the following hardware features:

+-----------+------------+-------------------------------------+
| Interface | Controller | Driver/Component |
+===========+============+=====================================+
| NVIC | on-chip | nested vector interrupt controller |
+-----------+------------+-------------------------------------+
| PINMUX | on-chip | pinmux |
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| FLASH | on-chip | flash memory |
+-----------+------------+-------------------------------------+
| RNG | on-chip | True Random number generator |
+-----------+------------+-------------------------------------+
| IPM | on-chip | virtual mailbox based on HSEM |
+-----------+------------+-------------------------------------+

Other hardware features are not yet supported on Zephyr porting.

The default configuration per core can be found in the defconfig files:
``boards/arm/arduino_opta_m4/arduino_opta_m4_defconfig``

Pin Mapping
===========

ARDUINO OPTA M4 has access to the 9 GPIO controllers. These controllers are responsible for pin muxing,
input/output, pull-up, etc.

For mode details please refer to `ARDUINO-OPTA website`_.

Default Zephyr Peripheral Mapping
---------------------------------

- Status LED1 : PI0
- Status LED2 : PI1
- Status LED3 : PI3
- Status LED4 : PH15
- User button : PE4

System Clock
============

The STM32H747I System Clock can be driven by an internal or external oscillator,
as well as by the main PLL clock. By default, the CPU2 (Cortex-M4) System clock
is driven at 240MHz. PLL clock is fed by a 25MHz high speed external clock.

Resources sharing
=================

The dual core nature of STM32H747 SoC requires sharing HW resources between the
two cores. This is done in 3 ways:

- **Compilation**: Clock configuration is only accessible to M7 core. M4 core only
has access to bus clock activation and deactivation.
- **Static pre-compilation assignment**: Peripherals such as a UART are assigned in
devicetree before compilation. The user must ensure peripherals are not assigned
to both cores at the same time.
- **Run time protection**: Interrupt-controller and GPIO configurations could be
accessed by both cores at run time. Accesses are protected by a hardware semaphore
to avoid potential concurrent access issues.

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

Applications for the ``arduino_opta_m4`` use the regular Zephyr build commands.
See :ref:`build_an_application` for more information about application builds.

Flashing
========

Flashing operation will depend on the target to be flashed and the SoC
option bytes configuration. The OPTA has a DFU capable bootloader which
can be accessed by connecting the device to the USB, and then pressing
the RESET button shortly twice, the RESET-LED on the board will fade
indicating the board is in bootloader mode.

By default:

- CPU2 (Cortex-M4) boot address is set to 0x08180000 (OB: BOOT_CM4_ADD0)

Zephyr flash configuration has been set to meet these default settings.

Flashing an application to ARDUINO OPTA M4
------------------------------------------

First, connect the device to your host computer using
the USB port to prepare it for flashing. Then build and flash your application.

Here is an example for the :zephyr:code-sample:`blinky` application on M4 core.

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

Starting the application on the ARDUINO OPTA M4
-----------------------------------------------

Make sure the option bytes are set to prevent the M4 from auto-starting, and
that the M7 side starts the M4 at the correct Flash address.

This can be done by selecting in the Arduino IDE's "Tools" / "Flash Split"
menu the "1.5MB M7 + 0.5MB M4" option, and loading a sketch that contains
at least the following code:

.. code-block:: cpp

#include <RPC.h>

void setup() {
RPC.begin();
}

void loop() { }

Debugging
=========

Debugging is not yet supported by this board, since the debug port does
not have an easy access.

.. _ARDUINO-OPTA website:
https://docs.arduino.cc/hardware/opta

.. _STM32H747XI on www.st.com:
https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-high-performance-mcus/stm32h7-series/stm32h747-757/stm32h747xi.html

.. _STM32H747xx reference manual:
https://www.st.com/resource/en/reference_manual/dm00176879.pdf

.. _STM32H747xx datasheet:
https://www.st.com/resource/en/datasheet/stm32h747xi.pdf
Loading