1.. zephyr:board:: arduino_opta
2
3Overview
4********
5
6The Arduino™ Opta® is a secure micro Programmable Logic Controller (PLC)
7with Industrial Internet of Things (IoT) capabilities.
8
9Developed in partnership with Finder®, this device supports both the Arduino
10programming language and standard IEC-61131-3 PLC programming languages,
11such as Ladder Diagram (LD), Sequential Function Chart (SFC),
12Function Block Diagram (FBD), Structured Text (ST), and Instruction List (IL),
13making it an ideal device for automation engineers.
14
15For Zephyr RTOS, both cores are supported. It is also possible to run only on
16the M4 making the M7 run the PLC tasks while the M4 core under Zephyr acts as
17a coprocessor.
18
19Additionally, the device features:
20
21- Ethernet compliant with IEEE802.3-2002
22- 16MB QSPI Flash
23- 4 x green color status LEDs
24- 1 x green or red led over the reset push-button
25- 1 x blue led over the user push-button (Opta Advanced only)
26- 1 x user push-button
27- 1 x reset push-button accessible via pinhole
28- 8 x analog inputs
29- 4 x isolated relay outputs
30
31More information about the board can be found at the `ARDUINO-OPTA website`_.
32More information about STM32H747XIH6 can be found here:
33
34- `STM32H747XI on www.st.com`_
35- `STM32H747xx reference manual`_
36- `STM32H747xx datasheet`_
37
38Supported Features
39==================
40
41.. zephyr:board-supported-hw::
42
43Pin Mapping
44===========
45
46Both the M7 and M4 cores have access to the 9 GPIO controllers. These
47controllers are responsible for pin muxing, input/output, pull-up, etc.
48
49For more details please refer to `ARDUINO-OPTA website`_.
50
51Default Zephyr Peripheral Mapping
52---------------------------------
53
54- Status LED1: PI0
55- Status LED2: PI1
56- Status LED3: PI3
57- Status LED4: PH15
58- Green "reset" LED: PH12
59- Red "reset" LED: PH11
60- Blue LED: PE5
61- User button: PE4
62- Input 1 : PA0
63- Input 2 : PC2
64- Input 3 : PF12
65- Input 4 : PB0
66- Input 5 : PF10
67- Input 6 : PF8
68- Input 7 : PF6
69- Input 8 : PF4
70- Relay 1: PI6
71- Relay 2: PI5
72- Relay 3: PI7
73- Relay 4: PI4
74
75System Clock
76============
77
78The STM32H747I System Clock can be driven by an internal or external oscillator,
79as well as by the main PLL clock. By default, the CPU2 (Cortex-M4) System clock
80is driven at 240MHz. PLL clock is fed by a 25MHz high speed external clock. The
81M7 clock is driven at 400MHz.
82
83External flash
84==============
85
86External flash (16MB on QSPI) access can be enabled by the ``CONFIG_FLASH``
87option. The ``partitions`` entry provided in the default device tree is meant
88as an example and is valid only if the Opta is fresh from the factory and the
89flash has not been repartitioned. As a second example, the partitioning scheme
90created by the new ``QSPIFormat.ino`` sketch from Arduino is available as a
91DTSI in ``arduino_opta-external-flash-partitioning.dtsi``.
92
93Resources sharing
94=================
95
96The dual core nature of STM32H747 SoC requires sharing HW resources between the
97two cores. This is done in 3 ways:
98
99- **Compilation**: Clock configuration is only accessible to M7 core. M4 core only
100  has access to bus clock activation and deactivation.
101- **Static pre-compilation assignment**: Peripherals such as a UART are assigned in
102  devicetree before compilation. The user must ensure peripherals are not assigned
103  to both cores at the same time.
104- **Run time protection**: Interrupt-controller and GPIO configurations could be
105  accessed by both cores at run time. Accesses are protected by a hardware semaphore
106  to avoid potential concurrent access issues.
107
108Programming and Debugging
109*************************
110
111.. zephyr:board-supported-runners::
112
113Applications for the ``arduino_opta`` use the regular Zephyr build commands.
114See :ref:`build_an_application` for more information about application builds.
115
116Flashing
117========
118
119Flashing operation will depend on the target to be flashed and the SoC
120option bytes configuration. The OPTA has a DFU capable bootloader which
121can be accessed by connecting the device to the USB, and then pressing
122the RESET button shortly twice, the RESET-LED on the board will fade
123indicating the board is in bootloader mode.
124
125By default:
126
127  - CPU1 (Cortex-M7) boot address is set to 0x08040000
128  - CPU2 (Cortex-M4) boot address is set to 0x08180000
129
130Zephyr flash configuration has been set to be compatible with the
131"Flash split: 1.5MB M7 + 0.5MB M4" option in the Arduino IDE. The flash is
132partitioned as follows:
133
134  - 0x08000000-0x0803FFFF (256k) Arduino MCUboot-derived bootloader
135  - 0x08040000-0x080FFFFF (768k) M7 application
136  - 0x08180000-0x081FFFFF (512k) M4 application
137
138
139Flashing an application to ARDUINO OPTA M7
140------------------------------------------
141
142First, connect the device to your host computer using
143the USB port to prepare it for flashing. Then build and flash your application.
144
145Here is an example for the :zephyr:code-sample:`blinky` application on M7 core.
146
147.. zephyr-app-commands::
148   :zephyr-app: samples/basic/blinky
149   :board: arduino_opta/stm32h747xx/m7
150   :goals: build flash
151
152Flashing an application to ARDUINO OPTA M4
153------------------------------------------
154
155First, connect the device to your host computer using
156the USB port to prepare it for flashing. Then build and flash your application.
157
158Here is an example for the :zephyr:code-sample:`blinky` application on M4 core.
159
160.. zephyr-app-commands::
161   :zephyr-app: samples/basic/blinky
162   :board: arduino_opta/stm32h747xx/m4
163   :goals: build flash
164
165Starting the application on the ARDUINO OPTA M4
166-----------------------------------------------
167
168If you also flashed an application to M7 the M4 processor is started at boot.
169If not you will need to start the processor from an Arduino sketch.
170
171Make sure the option bytes are set to prevent the M4 from auto-starting, and
172that the M7 side starts the M4 at the correct Flash address.
173
174This can be done by selecting in the Arduino IDE's "Tools" / "Flash Split"
175menu the "1.5MB M7 + 0.5MB M4" option, and loading a sketch that contains
176at least the following code:
177
178 .. code-block:: cpp
179
180    #include <RPC.h>
181
182    void setup() {
183        RPC.begin();
184    }
185
186    void loop() { }
187
188Debugging
189=========
190
191The debug port does not have an easy access but it is possible to open the
192case and solder a standard 10-pin SWD connector to the board. After that
193both flashing and debugging are available via ST-LINK (M7 core only).
194
195.. _ARDUINO-OPTA website:
196   https://docs.arduino.cc/hardware/opta
197
198.. _STM32H747XI on www.st.com:
199   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
200
201.. _STM32H747xx reference manual:
202   https://www.st.com/resource/en/reference_manual/dm00176879.pdf
203
204.. _STM32H747xx datasheet:
205   https://www.st.com/resource/en/datasheet/stm32h747xi.pdf
206