|
| 1 | +--- |
| 2 | +title: 'Upload sketches to Portenta X8' |
| 3 | +description: 'This tutorial will show how to upload Arduino sketches on the M4 processor' |
| 4 | +difficulty: medium |
| 5 | +beta: true |
| 6 | +tags: |
| 7 | + - Bootloader |
| 8 | + - Firmware |
| 9 | + - Core |
| 10 | +author: 'Pablo Marquínez' |
| 11 | +hardware: |
| 12 | + - hardware/04.pro/boards/portenta-x8 |
| 13 | +software: |
| 14 | + - ide-v1 |
| 15 | + - ide-v2 |
| 16 | + - cli |
| 17 | +--- |
| 18 | + |
| 19 | +## Overview |
| 20 | +This tutorial will explain how to upload a standard Arduino sketch to your portenta X8's M4. |
| 21 | + |
| 22 | +## Goals |
| 23 | +- Use the Arduino IDE to compile and upload. |
| 24 | +- Compile the sketch binaries with the Arduino IDE and upload it through ADB. |
| 25 | + |
| 26 | +### Required Hardware and Software |
| 27 | +- Portenta X8 |
| 28 | +- USB C cable (either USB A to USB C or USB C to USB C) |
| 29 | +- Arduino IDE 1.8.10+ or Arduino-cli |
| 30 | +- arduino-mbed portenta Core up to date (greater than 3.0.1) |
| 31 | + |
| 32 | +## Instructions |
| 33 | + |
| 34 | +### Standard Arduino IDE upload |
| 35 | +Open the Arduino IDE, make sure you have selected the Portenta X8 on the boards selector. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +Create your sketch, for example the blink sketch: |
| 40 | +```arduino |
| 41 | +void setup(){ |
| 42 | + pinMode(LED_BUILTIN ,OUTPUT); |
| 43 | +} |
| 44 | +
|
| 45 | +void loop(){ |
| 46 | + digitalWrite(LED_BUILTIN , HIGH); |
| 47 | + delay(1000); |
| 48 | + digitalWrite(LED_BUILTIN , LOW); |
| 49 | + delay(1000); |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +Once your sketch it's completed, select the port of your device. |
| 54 | + |
| 55 | +Press the Compile and Upload button. |
| 56 | + |
| 57 | +To finalize, when you see that the sketch has bee uploaded successfully, check that every second you are getting the LED changing from OFF to ON. |
| 58 | + |
| 59 | +### Upload using ADB |
| 60 | + |
| 61 | +To use ADB, it gets installed at `Arduino15\packages\arduino\tools\adb\32.0.0`. |
| 62 | + |
| 63 | +From that directory you can use the `adb` tool. To upload your compiled sketch you just need to type: |
| 64 | +``` |
| 65 | +adb push <sketchBinaryPath> /tmp/arduino/m4-user-sketch.elf |
| 66 | +``` |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +## Conclusion |
| 71 | +You now have access to the M4 processor, so for example you are able to connect an I<sup>2</sup>C sensor and interact with it and the Arduino X8 Linux side. |
| 72 | + |
| 73 | +## Troubleshooting |
| 74 | + |
| 75 | +### ADB folder empty |
| 76 | + |
| 77 | +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