|
| 1 | +--- |
| 2 | +title: "Arduino Zero" |
| 3 | +weight: 3 |
| 4 | +--- |
| 5 | + |
| 6 | +The [Arduino Zero](https://store.arduino.cc/arduino-zero) is a very small ARM development board based on the Atmel [SAMD21](https://www.microchip.com/wwwproducts/en/ATSAMD21G18) family of processors. |
| 7 | + |
| 8 | +## Interfaces |
| 9 | + |
| 10 | +| Interface | Hardware Supported | TinyGo Support | |
| 11 | +| --------- | ------------- | ----- | |
| 12 | +| GPIO | YES | YES | |
| 13 | +| UART | YES | YES | |
| 14 | +| SPI | YES | YES | |
| 15 | +| I2C | YES | YES | |
| 16 | +| ADC | YES | YES | |
| 17 | +| PWM | YES | YES | |
| 18 | + |
| 19 | +## Machine Package Docs |
| 20 | + |
| 21 | +[Documentation for the machine package for the Arduino Zero](../machine/arduino-zero) |
| 22 | + |
| 23 | +## Installing BOSSA |
| 24 | + |
| 25 | +In order to flash your TinyGo programs onto the Arduino Zero board, you will need to install the "bossac" command line utility which is part of the [BOSSA command line utilities](https://github.com/shumatech/BOSSA). |
| 26 | + |
| 27 | +### macOS |
| 28 | + |
| 29 | +You can use Homebrew to install the BOSSA command line interface by using the following command: |
| 30 | + |
| 31 | +```shell |
| 32 | +brew cask install bossa |
| 33 | +``` |
| 34 | + |
| 35 | +Or if you prefer, you can also download the installer from https://github.com/shumatech/BOSSA/releases/download/1.9.1/bossa-1.9.1.dmg |
| 36 | + |
| 37 | +Once you have downloaded it, double click on the .dmg file to perform the installation. |
| 38 | + |
| 39 | +### Linux |
| 40 | + |
| 41 | +On Linux, install from source: |
| 42 | + |
| 43 | +```shell |
| 44 | +sudo apt install libreadline-dev libwxgtk3.0-* |
| 45 | +git clone https://github.com/shumatech/BOSSA.git |
| 46 | +cd BOSSA |
| 47 | +make |
| 48 | +sudo cp bin/bossac /usr/local/bin |
| 49 | +``` |
| 50 | + |
| 51 | +### Windows |
| 52 | + |
| 53 | +You can download BOSSA from https://github.com/shumatech/BOSSA/releases/download/1.9.1/bossa-x64-1.9.1.msi |
| 54 | + |
| 55 | +*VERY IMPORTANT*: During the installation, you much choose to install into `c:\Program Files`. The installer might have the wrong path, so edit it to match `c:\Program Files`. |
| 56 | + |
| 57 | +After the installation, you must add BOSSA to your PATH: |
| 58 | + |
| 59 | +```shell |
| 60 | +set PATH=%PATH%;"c:\Program Files\BOSSA"; |
| 61 | +``` |
| 62 | + |
| 63 | +Test that you have installed "BOSSA" correctly by running this command: |
| 64 | + |
| 65 | +```shell |
| 66 | +bossac --help |
| 67 | +``` |
| 68 | + |
| 69 | +## Flashing |
| 70 | + |
| 71 | +Once you have installed the needed BOSSA command line utility, as in the previous section, you are ready to build and flash code to your Arduino Zero board. |
| 72 | + |
| 73 | +### CLI Flashing on Linux |
| 74 | + |
| 75 | +- Plug your Arduino Zero board into your computer's USB port. |
| 76 | +- Build and flash your TinyGo code using the `tinygo flash` command. This command flashes the Arduino Zero with the blinky1 example: |
| 77 | + |
| 78 | + ``` |
| 79 | + tinygo flash -target=arduino-zero examples/blinky1 |
| 80 | + ``` |
| 81 | +
|
| 82 | +- The Arduino Zero board should restart and then begin running your program. |
| 83 | +
|
| 84 | +### CLI Flashing on macOS |
| 85 | +
|
| 86 | +- Plug your Arduino Zero board into your computer's USB port. |
| 87 | +- Build and flash your TinyGo code using the `tinygo flash` command. This command flashes the Arduino Zero with the blinky1 example: |
| 88 | +
|
| 89 | + ``` |
| 90 | + tinygo flash -target=arduino-zero examples/blinky1 |
| 91 | + ``` |
| 92 | +
|
| 93 | +- The Arduino Zero board should restart and then begin running your program. |
| 94 | +
|
| 95 | +### CLI Flashing on Windows |
| 96 | +
|
| 97 | +- Plug your Arduino Zero board into your computer's USB port. |
| 98 | +- Build and flash your TinyGo code using the `tinygo flash` command. This command flashes the Arduino Zero with the blinky1 example: |
| 99 | +
|
| 100 | + ``` |
| 101 | + tinygo flash -target=arduino-zero examples/blinky1 |
| 102 | + ``` |
| 103 | +
|
| 104 | +- The Arduino Zero board should restart and then begin running your program. |
| 105 | +
|
| 106 | +### Troubleshooting |
| 107 | +
|
| 108 | +If you have troubles getting your Arduino Zero board to receive code, try this: |
| 109 | +
|
| 110 | +- Press the "RESET" button on the board two times to get the Arduino Zero board ready to receive code. |
| 111 | +- Now try running the `tinygo flash` command as above: |
| 112 | +
|
| 113 | + ```shell |
| 114 | + tinygo flash -target=arduino-zero [PATH TO YOUR PROGRAM] |
| 115 | + ``` |
| 116 | +
|
| 117 | +Once you have updated your Arduino Zero board the first time, after that you should be able to flash it entirely from the command line. |
| 118 | +
|
| 119 | +## Notes |
| 120 | +
|
| 121 | +You can use the USB port to the Arduino Zero as a serial port. `UART0` refers to this connection. |
0 commit comments