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: content/hardware/04.pro/boards/portenta-x8/tutorials/uploading-sketches-m4/content.md
+27-20
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: 'Uploading Sketches to the M4 Core on Arduino Portenta X8'
3
3
description: 'This tutorial explains how to upload Arduino sketches to the M4 core.'
4
4
difficulty: intermediate
5
5
tags:
6
-
- firmware
6
+
- Firmware
7
7
- M4
8
8
author: 'Pablo Marquínez'
9
9
hardware:
@@ -15,26 +15,31 @@ software:
15
15
---
16
16
17
17
## Overview
18
-
In this tutorial we will go through the process of uploading sketches to the M4 core on the STM32H747XI MCU. For the user the process is the same as usual but it differs quite a bit in regards to what happens behind the scenes compared to other Arduino boards.
18
+
19
+
In this tutorial, we will go through the process of uploading sketches to the M4 core on the STM32H747XI MCU. For the user, the process is the same as usual but it differs quite a bit in regards to what happens behind the scenes compared to other Arduino boards.
19
20
20
21
## Goals
21
-
- Learn how to use the Arduino IDE to compile and upload a sketch.
22
-
- Learn how to compile the sketch binaries with the Arduino IDE and upload it manually via ADB.
22
+
23
+
- Learn how to use the Arduino IDE to compile and upload a sketch
24
+
- Learn how to compile the sketch binaries with the Arduino IDE and upload them manually via ADB
- USB-C® cable (either USB-A to USB-C® or USB-C® to USB-C®)
27
-
- Arduino IDE 1.8.10+or Arduino-cli
28
-
- Latest "Arduino Mbed OS Portenta Boards" Core > 3.0.1
30
+
-[Arduino IDE 1.8.10+](https://www.arduino.cc/en/software), [Arduino IDE 2.0+](https://www.arduino.cc/en/software), or [Arduino CLI](https://github.com/arduino/arduino-cli)
31
+
- Latest "Arduino Mbed OS Portenta Boards" Core
29
32
30
33
## Instructions
31
34
32
35
### Standard Arduino IDE Upload
33
-
Open the Arduino IDE, make sure you have selected the Portenta X8 in the boards selector.
36
+
37
+
It is a straightforward process to upload to M4 Core using Arduino IDE. You will have to select the Portenta X8 in the board selector inside the Arduino IDE.
Create a custom sketch or open one of the example sketches e.g. the blink sketch:
41
+
Create a custom sketch or open one of the example sketches. For example, we will use the blink sketch:
42
+
38
43
```arduino
39
44
void setup(){
40
45
pinMode(LED_BUILTIN ,OUTPUT);
@@ -48,33 +53,35 @@ void loop(){
48
53
}
49
54
```
50
55
51
-
- Select the port of your device in the port selector menu.
52
-
- Press the Compile and Upload button.
56
+
1. Select the port of your device in the port selector menu
57
+
2. Press the Compile and Upload button
53
58
54
-
Behind the curtains, the sketch gets compiled into a binary. That binary file is then uploaded to the Linux side of the Portenta X8 via an `adb` SSH connection. The flashing itself is done on the board itself by a service running on Linux. When the sketch has bee uploaded successfully, check if the onboard LED is blinking at an interval of one second.
59
+
The sketch gets compiled into a binary. That binary file is then uploaded to the Linux side of the Portenta X8 via an `adb` SSH connection. The flashing is done on the board itself by active service on Linux. When the sketch has been uploaded successfully, check if the onboard LED is blinking at an interval of one second.
55
60
56
61
### Upload Manually Using ADB
57
62
58
-
To upload a firmware manually, you first need to compile the sketch. In the Arduino IDE select "Export compiled binary" from the Sketch menu. It will compile the sketch and save the binary file in the sketch folder. Alternatively you can use the [Arduino CLI](https://arduino.github.io/arduino-cli/) to create an elf file.
63
+
An alternative to using the standard Arduino IDE upload procedure is by uploading the sketch manually using ADB. First, we need to compile the sketch. In the Arduino IDE, select "Export compiled binary" from the Sketch menu. It will compile the sketch and save the binary file in the sketch folder. Alternatively, you can use the [Arduino CLI](https://arduino.github.io/arduino-cli/) to create an `elf` file.
64
+
65
+
To upload the firmware, you can use the ADB tool that has been installed as part of the Portenta X8 core. It can be found at `Arduino15\packages\arduino\tools\adb\32.0.0`.
59
66
60
-
To upload the firmware you can use the ADB tool that has been installed as part of the Portenta X8 core. It can be found at `Arduino15\packages\arduino\tools\adb\32.0.0`.
67
+
From that directory, you can use the `adb` tool. To upload your compiled sketch, you will need to use the following command:
61
68
62
-
From that directory you can use the `adb` tool. To upload your compiled sketch you just need to type:

68
74
69
-
## How It Works?
70
-
The Portenta X8 has a service that waits for a sketch to be uploaded to a folder. If it detects changes the device will flash the M4 with the uploaded firmware.
75
+
## How Does It Work?
71
76
72
-
This work thanks to the following services:
73
-
***monitor-m4-elf-file.service**: this service monitors the directory `/tmp/arduino/m4-user-sketch.elf` and each time it detects a new file it will proceed to flash the M4 using `openOCD` with the sketch that has been pushed.
77
+
The Portenta X8 has a service that waits for a sketch to be uploaded to a folder. If it detects changes, the device will flash the M4 with the uploaded firmware. This works thanks to the following service:
78
+
79
+
***monitor-m4-elf-file.service**: this service monitors the directory `/tmp/arduino/m4-user-sketch.elf` and each time it detects a new file, it will proceed to flash the M4 using `openOCD` with the sketch that has been pushed.
74
80
75
81
## Conclusion
76
-
In this tutorial you have learned how to upload a sketch to the M4 core. Now for example you are able to connect an I<sup>2</sup>C sensor and interact with it.
82
+
83
+
In this tutorial, you have learned how to upload a sketch to the M4 core, by using the standard Arduino IDE procedure and manually with ADB. Now for example you can connect an I<sup>2</sup>C sensor and interact with it.
77
84
78
85
## Troubleshooting
79
86
80
-
- If you cannot use the `ADB` tool and the folder `Arduino15\packages\arduino\tools\adb\32.0.0` is empty Remove the Mbed Portenta Core and install it again.
87
+
- If you cannot use the `ADB` tool and the folder `Arduino15\packages\arduino\tools\adb\32.0.0` is empty, remove the Mbed Portenta Core and install it again.
0 commit comments