Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user account prereq, number step headings, consolidate CLI docs #668

Merged
merged 20 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 100 additions & 65 deletions docs/Meadow/Getting_Started/Deploying_Meadow.OS/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: Meadow
sidebar_label: Deploy Meadow.OS
title: Meadow.OS Deployment
title: Deploying Meadow.OS
subtitle: Flashing the Meadow with the latest OS via Meadow.CLI
---

Expand All @@ -10,48 +10,51 @@ When you receive your Meadow board, it will need to have the latest Meadow.OS up
<Tabs groupId="os">
<TabItem value="windows" label="Windows" default>

### Install .NET SDK
[//]: # (Whenever editing these OS sections, make sure any common instructions are edited in the other OS/IDE sections as well to keep them in sync with each other.)

Download and install version 8 [.NET SDK](https://dotnet.microsoft.com/en-us/download/dotnet).
### Step 1 - Create a Wilderness Labs Account

### Install or update Meadow CLI
To install Meadow CLI, execute the following command in your console:
In order to download the latest version of Meadow.OS, you will need to [register for a **Wilderness Labs Account**](https://identity.wildernesslabs.co/signin/register).

```console
dotnet tool install WildernessLabs.Meadow.CLI --global
```
### Step 2 - Install .NET SDK

To update Meadow CLI, if already installed, execute the following command in your console:
Download and install version 8 [.NET SDK](https://dotnet.microsoft.com/en-us/download/dotnet).

```console
dotnet tool update WildernessLabs.Meadow.CLI --global
```
### Step 3 - Install Meadow.CLI

The way we flash Meadow boards (among other things) is via our command-line-interface tool called [Meadow.CLI](../../Meadow_Tools/Meadow_CLI/). Make sure you have it installed to continue.

### Install dfu-util
### Step 4 - Install dfu-util
From a console with admin rights, execute following command:

```console
meadow install dfu-util
```

### Put the device into DFU Bootloader mode.
To update the OS, Meadow must be in _DFU bootloader_ mode. To enter this mode, the `BOOT` button needs to be held down while the board boots up. This can be accomplished one of two ways.
### Step 5 - Put the device into DFU Bootloader mode

**If the board is disconnected:** hold the `BOOT` button down and connect the board to your computer via a Micro USB Cable.
To flash your board with the latest OS, Meadow must be in _DFU bootloader_ mode. To enter this mode, the `BOOT` button needs to be held down while the board boots up. This can be accomplished one of two ways.

**If the board is connected:** hold the `BOOT` button down, and then press and release the `RST` (Reset) button. Then release the `BOOT` button.
* **If the board is disconnected:** hold the `BOOT` button down and connect the board to your computer via a Micro USB Cable.

* **If the board is connected:** hold the `BOOT` button down, and then press and release the `RST` (Reset) button. Then release the `BOOT` button.

![Meadow board with boot button labeled at the end of the header on the battery JST side of the board.](./wildernesslabs_meadow_boot_button.jpg)

### Install Meadow USB drivers
### Step 6 - Install Meadow USB drivers

#### Checking Meadow USB drivers

Before flashing a Meadow board, open the Device Manager and check:
- When connecting the board while holding down the BOOT button to power it on in **Bootloader mode** it should show up as a `STM32 BOOTLOADER` device under `Universal Serial Bus Devices` section.
- When connecting it normally it should show up as a `USB Serial Device (COMX)` under the `Ports (COM & LPT)` section

![Meadow drivers shown in Bootloader and regular mode](meadow_driver_state.png)
- When the board is in **Bootloader mode** it should show up as a `STM32 BOOTLOADER` device under `Universal Serial Bus Devices` section.
- When the board is connected normally it should show up as a `USB Serial Device (COMX)` under the `Ports (COM & LPT)` section

![Meadow drivers shown in Bootloader and regular mode](meadow_driver_state.png)

If the board is in this state you can skip the next step and move on to the [Download Meadow OS and network binaries](#download-meadow-os-and-network-binaries).
If the board is in this state you can head over to the next step.

#### Updating Meadow USB drivers

If Meadow shows as **Meadow F7 Micro (COMX)** in regular mode, right-click on it and select **Uninstall Device**, and make sure to select *Attempt to remove the driver for this device* like so:

Expand All @@ -60,25 +63,38 @@ If Meadow shows as **Meadow F7 Micro (COMX)** in regular mode, right-click on it
Now to flash Meadow OS, *dfu-util* is recommended. However, the default Windows USB driver for ST devices is not compatible with *dfu-util*, so it needs to be replaced. For more in-depth information on this, check out [Scott Hanselman's post](https://www.hanselman.com/blog/how-to-fix-dfuutil-stm-winusb-zadig-bootloaders-and-other-firmware-flashing-issues-on-windows). Follow these steps:

1. Download and run [Zadig](https://zadig.akeo.ie/)
1. Connect the Meadow device holding the BOOT button pressed to power it on in **Bootloader mode**.
1. Connect the Meadow device holding the BOOT button pressed to power it on in **Bootloader mode**.
1. In Zadig, click *Options* > *List All Devices*
1. Select **STM32 BOOTLOADER** in the dropdown
1. Click *Replace Driver*

![Zadig showing STM32 Bootloader device selected and WinUSB driver chosen with a Replace Driver button.](./zadig1.png)
![Zadig showing STM32 Bootloader device selected and WinUSB driver chosen with a Replace Driver button.](./zadig1.png)

1. After the installation is complete, driver should be *WinUSB*

![Zadig showing the replaced driver as WinUSB with a Reinstall Driver button.](./zadig2.png)
![Zadig showing the replaced driver as WinUSB with a Reinstall Driver button.](./zadig2.png)

Your board is now ready to flash it with latest Meadow.OS version.

### Step 7 - Log in to your Wilderness Labs account

Use the following command to log into your Wilderness Labs Account:

```console
meadow login
```

This will open a web browser where you'll need to enter your account credentials. If successful, you'll receive a confirmation on the CLI.

### Step 8 - Download Meadow.OS

### Download Meadow OS and network binaries
Execute the following command in your console:
Now we can download the latest Meadow.OS binary files with the command:

```console
meadow firmware download
```

### Flash Meadow.OS and Coprocessor Firmware
### Step 9 - Flash Meadow.OS

Once connected the Meadow device via the USB cable and having put the device into DFU Bootloader mode, execute the following command in your console:

Expand All @@ -93,14 +109,19 @@ Your board is now ready to have a Meadow application deployed to it!
</TabItem>
<TabItem value="macos" label="macOS">

### Install .NET SDK
[//]: # (Whenever editing these OS sections, make sure any common instructions are edited in the other OS/IDE sections as well to keep them in sync with each other.)

### Step 1 - Create a Wilderness Labs Account

In order to download the latest version of Meadow.OS, you will need to [register for a **Wilderness Labs Account**](https://identity.wildernesslabs.co/signin/register).

### Step 2 - Install .NET SDK

Download and install version 8 [.NET SDK](https://dotnet.microsoft.com/en-us/download/dotnet) for your Mac's processor architecture.

Even if you are working on an ARM-based computer, such as Apple M1, M1 Pro, or M2 CPUs, you should still install the x86 version of the .NET SDK.
### Step 3 - Install or update Meadow CLI

### Install or update Meadow CLI
To install Meadow CLI, execute the following command in your terminal:
To install [Meadow CLI](/Meadow/Meadow_Tools/Meadow_CLI/) as a .NET tool, execute the following command in your terminal:

```console
dotnet tool install WildernessLabs.Meadow.CLI --global
Expand All @@ -112,14 +133,7 @@ To update Meadow CLI, if already installed, execute the following command in you
dotnet tool update WildernessLabs.Meadow.CLI --global
```

If you are working on an ARM-based Mac (M1, M1 Pro, M2 CPU), you will also need to explicitly add the x64 version of `libusb` and add an additional location to your `PATH` variable that aren't added by default on those systems.

```console
arch -arm64 brew install libusb
export PATH=/usr/local/share/dotnet/x64/:$PATH
```

### Install dfu-util
### Step 4 - Install dfu-util

To install `dfu-util`, we'll be using **Homebrew**. If you don't have it yet, [install Homebrew](https://brew.sh/) first.

Expand All @@ -129,7 +143,7 @@ Execute the following command in your terminal:
brew install dfu-util
```

### Download Meadow OS and network binaries
### Step 5 - Download Meadow OS and network binaries

Execute the following command in your terminal:

Expand All @@ -145,57 +159,69 @@ If your terminal cannot find the `meadow` command, it means the .NET SDK didn't
export PATH="$PATH:$HOME/.dotnet/tools"
```

### Put the device into DFU Bootloader mode.
### Step 6 - Put the device into DFU Bootloader mode

To update the OS, Meadow must be in _DFU bootloader_ mode. To enter this mode, the `BOOT` button needs to be held down while the board boots up. This can be accomplished one of two ways.

**If the board is disconnected:** hold the `BOOT` button down and connect the board to your computer via a Micro USB Cable.

**If the board is connected:** hold the `BOOT` button down, and then press and release the `RST` (Reset) button. Then release the `BOOT` button.
**If the board is connected:** hold the `BOOT` button down, and then press and release the `RST` (Reset) button. Then release the `BOOT` button.

![Meadow board with boot button labeled at the end of the header on the battery JST side of the board.](./wildernesslabs_meadow_boot_button.jpg)

### Flash Meadow.OS and Coprocessor Firmware
> NOTE: On macOS Sonoma and newer, you may need to allow USB device access for both regular Meadow mode and bootloader mode. If you release the `BOOT` button before allowing the USB access in bootloader mode, your device may not be available for writing the firmware. Repeat the above process after alowing for USB access to get into bootloader mode again.

### Step 7 - Flash Meadow.OS and Coprocessor Firmware

Now you have two options, please try the option 1 first:

#### Option 1 (from bootloader mode)
#### Option 1 (from bootloader mode)

Once connected the Meadow device via the USB cable and having put the device into DFU Bootloader mode, execute the following command in your terminal:

```console
meadow firmware write
```

#### Option 2 (from normal mode)

This following will only work if you have a newer version of Meadow OS installed. It is recommended to try option 1 first.
Reset the device (push the RST button or disconnect and reconnect) and identify the serial port name that the Meadow is connecting on.

Execute the following command in your terminal:
Execute the following Meadow CLI command in your terminal to determine the port your Meadow device is using.

```console
ls /dev/tty.usb*
meadow list ports
```

The port should be something like `/dev/tty.usbmodem01`.
Once you've identified the port name, run the following command in your console replacing [PORT] with the serial port name:
On macOS, you should see a port like `/dev/tty.usbmodem336F336D30361`.
Once you've identified the port name, run the following command in your console, replacing `{port}` with the serial port name to send all future `meadow` commands to that device.

```console
meadow config route [PORT]
meadow config route {port}
```

**NOTE: If the process hangs on _Opening port '[PORT]'..._, hit the RST button on the device.**
**NOTE: If the process hangs on _Opening port '{PORT}'..._, hit the RST button on the device.**

Unplug and replug Meadow to give it a full restart.
Your board is now ready to have a Meadow application deployed to it!
Unplug and replug Meadow to give it a full restart. Your board is now ready to have a Meadow application deployed to it!

</TabItem>
<TabItem value="linux" label="Linux">

[//]: # (Whenever editing these OS sections, make sure any common instructions are edited in the other OS/IDE sections as well to keep them in sync with each other.)

Please note: Linux may require `sudo` to access USB devices.

### Install .NET SDK
### Step 1 - Create a Wilderness Labs Account

In order to download the latest version of Meadow.OS, you will need to [register for a **Wilderness Labs Account**](https://identity.wildernesslabs.co/signin/register).

### Step 2 - Install .NET SDK

Download and install version 8 [.NET SDK](https://dotnet.microsoft.com/en-us/download/dotnet).

### Install or update Meadow CLI
### Step 3 - Install or update Meadow CLI

To install Meadow CLI, execute the following command in your terminal:

```console
Expand All @@ -208,38 +234,44 @@ To update Meadow CLI, if already installed, execute the following command in you
dotnet tool update WildernessLabs.Meadow.CLI --global
```

### Install dfu-util
### Step 4 - Install dfu-util

Execute the following command in your terminal:

```console
sudo apt-get install dfu-util
```

### Install libusb
### Step 5 - Install libusb

Execute the following command in your terminal:

```console
sudo apt-get install libusb-1.0-0-dev
```

### Download Meadow OS and network binaries
### Step 6 - Download Meadow OS and network binaries

Execute the following command in your terminal:

```console
meadow firmware download
```

### Put the device into DFU Bootloader mode.
### Step 7 - Put the device into DFU Bootloader mode

To update the OS, Meadow must be in _DFU bootloader_ mode. To enter this mode, the `BOOT` button needs to be held down while the board boots up. This can be accomplished one of two ways.

**If the board is disconnected:** hold the `BOOT` button down and connect the board to your computer via a Micro USB Cable.

**If the board is connected:** hold the `BOOT` button down, and then press and release the `RST` (Reset) button. Then release the `BOOT` button.
**If the board is connected:** hold the `BOOT` button down, and then press and release the `RST` (Reset) button. Then release the `BOOT` button.

![Meadow board with boot button labeled at the end of the header on the battery JST side of the board.](./wildernesslabs_meadow_boot_button.jpg)

### Enable access to the device
To be able to access the device a udev rule needs to be added.
### Step 8 - Enable access to the device

To be able to access the device a udev rule needs to be added.

* Go to the folder `/etc/udev/rules.d`
* Create the file `50-meadow.rules`
* Add the following to the file:
Expand All @@ -262,21 +294,24 @@ Bus 001 Device 009: ID 0483:df11 STMicroelectronics STM Device in DFU Mode

The format for the IDs is `idVendor:idProduct`. Please note that you need to disconnect and reconnect the Meadow to make the rules take affect.

### Flash Meadow.OS and Coprocessor Firmware
### Step 9 - Flash Meadow.OS and Coprocessor Firmware

Now you have two options, please try the option 1 first:

#### Option 1 (from bootloader mode)
#### Option 1 (from bootloader mode)

Once connected the Meadow device via the USB cable and having put the device into DFU Bootloader mode, execute the following command in your terminal:

```console
meadow firmware write
```

#### Option 2 (from normal mode)

This following will only work if you have a newer version of Meadow OS installed. It is recommended to try option 1 first.
Reset the device (push the RST button or disconnect and reconnect) and identify the serial port name that the Meadow is connecting on.

To get access to the port your user needs to be added to the group `dialout`.
To get access to the port your user needs to be added to the group `dialout`.
This is done with the command:

```console
Expand Down
Binary file modified docs/Meadow/Getting_Started/Deploying_Meadow.OS/zadig1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/Meadow/Getting_Started/Deploying_Meadow.OS/zadig2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading