You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: variants/STM32MP157_DK/README.md
+79-7Lines changed: 79 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,8 @@ In this example, the user **must** upload `<Arduino build output path>/run_ardui
43
43
After uploading the user can use `sh run_arduino_<sketch name>.sh start` in the console of host Linux via either SSH or Serial Console, to run the Arduino firmware.
44
44
45
45
#### Note
46
-
*`sh run_arduino_<sketch name>.sh start` is a one-shot command, the Arduino firmware only runs for the current boot. If you want to make it run after reboot, you need to use `sh run_arduino_<sketch name>.sh install` command.
46
+
47
+
*`sh run_arduino_<sketch name>.sh start` is a one-shot command, the Arduino firmware only runs for the current boot. If you want to make it run after reboot, you need to use `sh run_arduino_<sketch name>.sh install` command.
47
48
48
49
`run_arduino_<sketch name>.sh` help page summary:
49
50
@@ -90,17 +91,17 @@ See the source code [run_arduino_gen.sh] for the full help page and the more det
90
91
91
92
## Virtual Serial
92
93
93
-
With Virtual Serial, you can easily implement inter-core communication between the Linux host and Arduino coprocessor. Virtual Serial uses OpenAMP rpmsg framework. This is available as `VirtIOSerial` object and you can use it as a standard Arduino Serial object.
94
+
With Virtual Serial, you can easily implement inter-core communication between the Linux host and Arduino coprocessor. Virtual Serial uses OpenAMP rpmsg framework. This is available as `SerialVirtIO` object and you can use it as a standard Arduino Serial object.
94
95
95
-
Enable `VirtIOSerial` in Arduino IDE->Tools->Virtual serial support. You can optionally alias generic `Serial` object with `VirtIOSerial` as well.
96
+
Enable `SerialVirtIO` in Arduino IDE->Tools->Virtual serial support. You can optionally alias generic `Serial` object with `SerialVirtIO` as well.
96
97
97
98
When enabled, `/dev/ttyRPMSG0` is available to the Linux host. You can use it as a normal serial tty. `sh run_arduino_<sketch name>.sh` provides `monitor`, `minicom`, `send-msg`, `send-file` as a convenience. See above command descriptions.
98
99
99
100
See [OpenAMP] and [Linux RPMsg] to learn more.
100
101
101
102
### Configuration
102
103
103
-
To increase the performance of VirtIOSerial you can resize the related buffer configurations. There are three definitions you can use:
104
+
To increase the performance of SerialVirtIO you can resize the related buffer configurations. There are three definitions you can use:
Note the use of `Serial.availableForWrite()`. SerialVirtIO has [a hard restriction of the write size], so it is important to `Serial.write()` less than the value of `Serial.availableForWrite()`.
147
+
148
+
After loading Arduino, You can use SerialVirtIO in two ways in this example:
149
+
150
+
* Run `sh run_arduino_<sketch name>.sh minicom` and type anything in the minicom console. The console will print out what you type immediately.
151
+
152
+
* Open two Linux consoles (using SSH)
153
+
1. In the first console, run `sh run_arduino_<sketch name>.sh monitor`
154
+
2. In the second console, run `sh run_arduino_<sketch name>.sh send-msg <your message>` or `sh run_arduino_<sketch name>.sh send-file <your file>`, the first console will print the content of the message.
155
+
113
156
## Debugging
114
157
115
158
For printf-style debugging, `core_debug()` is highly recommended instead of using Arduino Serial. In STM32MP1, `core_debug()` utilizes OpenAMP trace buffer and it has a minimal real-time impact (other than the overhead of printf) because it is not bound to the speed of a hardware IO peripheral while printing it.
@@ -124,16 +167,44 @@ build_opt.h (in the same directory of your Sketch)
124
167
-DVIRTIO_LOG_BUFFER_SIZE=4086
125
168
```
126
169
127
-
Don't forget to change any of Arduino IDE option to reflect this as in the warning section in [build_opt.h description in wiki]. This is important because if `-DCORE_DEBUG` is not configured correctly `core_debug()` silently becomes an empty function without triggering any build error.
170
+
Don't forget to change any of Arduino IDE option to reflect this as in the warning section in [build_opt.h description in wiki]. This is important because if `-DCORE_DEBUG` is not configured correctly `core_debug()` silently becomes an empty function without triggering any build error. Don't forget to add `#include "core_debug.h"` in your code in order to use `core_debug()`.
128
171
129
-
Also, need to add `#include "core_debug.h"` in your code in order to use `core_debug()`.
172
+
Also, you must enable the Virtual Serial (described in the above section) and include `SerialVirtIO.begin();` in your Arduino sketch, because this logging feature is tightly coupled to OpenAMP virtio.
130
173
131
174
You can use `sh run_arduino_<sketch name>.sh log` command or `cat /sys/kernel/debug/remoteproc/remoteproc0/trace0` command to print out the debug log in the Linux host.
132
175
133
176
Note that when overflow occurs the trace buffer is re-written from the beginning, removing existing logs. Consider increasing `VIRTIO_LOG_BUFFER_SIZE` in this case, as mentioned above.
134
177
135
178
See [virtio_log.h] for more information.
136
179
180
+
### Debugging Example
181
+
182
+
Here is a basic blink example with `core_debug()`:
183
+
```cpp
184
+
#include"core_debug.h"
185
+
186
+
unsignedlong time = 0;
187
+
unsignedlong count = 1;
188
+
189
+
voidsetup() {
190
+
// You must enable SerialVirtIO to use core_debug(), even if you don't use SerialVirtIO.
Don't forget to add [build_opt.h] described above.
205
+
206
+
After loading Arduino, you can simply `sh run_arduino_<sketch name>.sh log` to print the current `core_debug()` logs.
207
+
137
208
## Pin mapping
138
209
139
210
The boards have two pin headers: Raspberry Pi HAT headers and Arduino shield headers. This project currently supports Arduino Shield headers only, leaving RPi HAT headers for the Linux applications.
@@ -214,7 +285,7 @@ And then the Device Tree should enable TIM1 for the coprocessor, although this d
214
285
215
286
* Ethernet and USB are not supported. Use them in the Linux host.
216
287
* I2C pins on Raspberry Pi HAT header (GPIO2 and GPIO3) are not available in Linux host. This is because the Discovery board shares I2C pins on Arduino header and those on the HAT header.
217
-
*[Early firmware loading from U-Boot stage] is not supported. Only firmware loading on Linux boot stage by systemd supported. The binary itself may be loaded by U-Boot without any problems, but there is no out-of-box tool to configure U-Boot to load the firmware using Arduino IDE yet.
288
+
*[Early firmware loading from U-Boot stage] is not supported. Only firmware loading on Linux boot stage by systemd (aka. `sh run_arduino_<sketch name>.sh install`) supported. The binary itself may be loaded by U-Boot without any problems, but there is no out-of-box tool to configure U-Boot to load the firmware using Arduino IDE yet.
218
289
* EEPROM library: Those devices do not have non-volatile memory. The emulation is done using RETRAM. Therefore data will be preserved *only* when VBAT is supplied (e.g. A coin battery is connected to CN3 on STM32MP157A_DK1) and the coprocessor is waken up from sleep. This implies that cold boot the board may cause data loss, even if VBAT is supplied. See [discussions on RETRAM] for more detail.
219
290
220
291
@@ -232,6 +303,7 @@ And then the Device Tree should enable TIM1 for the coprocessor, although this d
0 commit comments