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
83Resources sharing
84=================
85
86The dual core nature of STM32H747 SoC requires sharing HW resources between the
87two cores. This is done in 3 ways:
88
89- **Compilation**: Clock configuration is only accessible to M7 core. M4 core only
90  has access to bus clock activation and deactivation.
91- **Static pre-compilation assignment**: Peripherals such as a UART are assigned in
92  devicetree before compilation. The user must ensure peripherals are not assigned
93  to both cores at the same time.
94- **Run time protection**: Interrupt-controller and GPIO configurations could be
95  accessed by both cores at run time. Accesses are protected by a hardware semaphore
96  to avoid potential concurrent access issues.
97
98Programming and Debugging
99*************************
100
101Applications for the ``arduino_opta`` use the regular Zephyr build commands.
102See :ref:`build_an_application` for more information about application builds.
103
104Flashing
105========
106
107Flashing operation will depend on the target to be flashed and the SoC
108option bytes configuration. The OPTA has a DFU capable bootloader which
109can be accessed by connecting the device to the USB, and then pressing
110the RESET button shortly twice, the RESET-LED on the board will fade
111indicating the board is in bootloader mode.
112
113By default:
114
115  - CPU1 (Cortex-M7) boot address is set to 0x08040000
116  - CPU2 (Cortex-M4) boot address is set to 0x08180000
117
118Zephyr flash configuration has been set to be compatible with the
119"Flash split: 1.5MB M7 + 0.5MB M4" option in the Arduino IDE. The flash is
120partitioned as follows:
121
122  - 0x08000000-0x0803FFFF (256k) Arduino MCUboot-derived bootloader
123  - 0x08040000-0x080FFFFF (768k) M7 application
124  - 0x08180000-0x081FFFFF (512k) M4 application
125
126
127Flashing an application to ARDUINO OPTA M7
128------------------------------------------
129
130First, connect the device to your host computer using
131the USB port to prepare it for flashing. Then build and flash your application.
132
133Here is an example for the :zephyr:code-sample:`blinky` application on M7 core.
134
135.. zephyr-app-commands::
136   :zephyr-app: samples/basic/blinky
137   :board: arduino_opta/stm32h747xx/m7
138   :goals: build flash
139
140Flashing an application to ARDUINO OPTA M4
141------------------------------------------
142
143First, connect the device to your host computer using
144the USB port to prepare it for flashing. Then build and flash your application.
145
146Here is an example for the :zephyr:code-sample:`blinky` application on M4 core.
147
148.. zephyr-app-commands::
149   :zephyr-app: samples/basic/blinky
150   :board: arduino_opta/stm32h747xx/m4
151   :goals: build flash
152
153Starting the application on the ARDUINO OPTA M4
154-----------------------------------------------
155
156If you also flashed an application to M7 the M4 processor is started at boot.
157If not you will need to start the processor from an Arduino sketch.
158
159Make sure the option bytes are set to prevent the M4 from auto-starting, and
160that the M7 side starts the M4 at the correct Flash address.
161
162This can be done by selecting in the Arduino IDE's "Tools" / "Flash Split"
163menu the "1.5MB M7 + 0.5MB M4" option, and loading a sketch that contains
164at least the following code:
165
166 .. code-block:: cpp
167
168    #include <RPC.h>
169
170    void setup() {
171        RPC.begin();
172    }
173
174    void loop() { }
175
176Debugging
177=========
178
179The debug port does not have an easy access but it is possible to open the
180case and solder a standard 10-pin SWD connector to the board. After that
181both flashing and debugging are available via ST-LINK (M7 core only).
182
183.. _ARDUINO-OPTA website:
184   https://docs.arduino.cc/hardware/opta
185
186.. _STM32H747XI on www.st.com:
187   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
188
189.. _STM32H747xx reference manual:
190   https://www.st.com/resource/en/reference_manual/dm00176879.pdf
191
192.. _STM32H747xx datasheet:
193   https://www.st.com/resource/en/datasheet/stm32h747xi.pdf
194