Skip to content

Commit

Permalink
Adding samples instructions H745 and Windows (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
wduraes authored Jul 8, 2021
1 parent 3518cad commit a4b2695
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 3 deletions.
111 changes: 110 additions & 1 deletion demos/projects/PC/windows/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,110 @@
# TODO
# Use Windows to simulate a device using Azure IoT Middleware for FreeRTOS

## Get the middleware

Clone the following repo to download all sample device code, setup scripts, and offline versions of the documentation.

**If you previously cloned this repo in another sample, you don't need to do it again.**

```bash
git clone https://github.com/Azure-Samples/iot-middleware-freertos-samples.git
```

To initialize the repo, run the following command:

```bash
cd iot-middleware-freertos-samples
git submodule update --init --recursive --depth 1
```


## Install Prerequisites

* [CMake](https://cmake.org/download/) (Version 3.13 or higher)

* An installed version of [WinPcap](https://www.winpcap.org/default.htm) (NPCap may also work). If you have Wireshark installed then this step might not be necessary. This is needed to create an Ethernet interface to be used by the simulator.

* To run this sample you can use a device previously created in your IoT Hub or have the Azure IoT Middleware for FreeRTOS provision your device automatically using DPS.

IoT Hub | DPS
---------|----------
Have an [Azure IoT Hub](https://docs.microsoft.com/azure/iot-hub/iot-hub-create-through-portal) created | Have an instance of [IoT Hub Device Provisioning Service](https://docs.microsoft.com/en-us/azure/iot-dps/quick-setup-auto-provision#create-a-new-iot-hub-device-provisioning-service)
Have a [logical device](https://docs.microsoft.com/azure/iot-hub/iot-hub-create-through-portal#register-a-new-device-in-the-iot-hub) created in your Azure IoT Hub using your preferred authentication method* | Have an [individual enrollment](https://docs.microsoft.com/en-us/azure/iot-dps/how-to-manage-enrollments#create-a-device-enrollment) created in your instance of DPS using your preferred authentication method*

*While this sample supports SAS keys and Certificates, this guide will refer only to SAS keys.

## Prepare the simulation

To connect the simulated device to Azure, you'll modify a configuration file for Azure IoT settings, rebuild the image, and run it.

Update the file `demos/projects/PC/windows/config/demo_config.h` with your configuration values.

If you're using a device previously created in your **IoT Hub** with SAS authentication, comment out line #53 (`#define democonfigENABLE_DPS_SAMPLE`) and set the following parameters:

Parameter | Value
---------|----------
`democonfigDEVICE_ID` | _{Your Device ID value}_
`democonfigHOSTNAME` | _{Your Host name value}_
`democonfigDEVICE_SYMMETRIC_KEY` | _{Your Primary Key value}_

If you're using **DPS** with an individual enrollment with SAS authentication, set the following parameters:

Parameter | Value
---------|----------
`democonfigID_SCOPE` | _{Your ID scope value}_
`democonfigREGISTRATION_ID` | _{Your Device Registration ID value}_
`democonfigDEVICE_SYMMETRIC_KEY` | _{Your Primary Key value}_


## Build the image

To build the device image, run the following commands from the root of the cloned Repo:

```bash
cmake -DVENDOR=PC -DCMAKE_GENERATOR_PLATFORM=Win32 -DBOARD=windows -Bbuild_windows .

cmake --build build_windows
```

In the output of the second command you'll find the path to the `iot-middleware-sample.exe`. Navigate to its folder and execute it. You should get an output similar to the below:

```bash
The following network interfaces are available:

Interface 1 - rpcap://\Device\NPF_{F2D50519-58E5-4655-9257-357F1D4977AD}
(Network adapter 'Microsoft' on local host)

Interface 2 - rpcap://\Device\NPF_{14EF9902-36A1-4BEA-8F13-51CFC8C556B0}
(Network adapter 'Microsoft' on local host)

Interface 3 - rpcap://\Device\NPF_{14B13215-DB7A-4E0F-8227-6106FB7C4161}
(Network adapter 'Intel(R) Ethernet Connection I217-LM' on local host)

Interface 4 - rpcap://\Device\NPF_{703B43D3-8B10-4831-957E-79D4A18C5E7D}
(Network adapter 'Microsoft' on local host)


The interface that will be opened is set by "configNETWORK_INTERFACE_TO_USE", which
should be defined in FreeRTOSConfig.h

ERROR: configNETWORK_INTERFACE_TO_USE is set to 0, which is an invalid value.
Please set configNETWORK_INTERFACE_TO_USE to one of the interface numbers listed above,
then re-compile and re-start the application. Only Ethernet (as opposed to WiFi)
interfaces are supported.

HALTING
```

This error message is normal since we still need to setup the Interface Adapter. It shows the list of interfaces on your PC. Identify and make a note of the active interface (in this case Interface 3, which is the one with Ethernet connection).

Edit the `demos/projects/PC/windows/config/FreeRTOSConfig.h` file and replace the `( 0L )` on line 116 by the number of your active interface. In the sample case above the number will be 3 or `( 3L )`. Save and close this file.

## Confirm simulated device connection details

Rebuild the sample with the new Network Adaptor information:

```bash
cmake --build build_windows
```

In the output of this command you'll find the path to the `iot-middleware-sample.exe`. Navigate to its folder and execute it.
4 changes: 3 additions & 1 deletion demos/projects/ST/b-l475e-iot01a/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//STM475

# Connect a STMicroelectronics B-L475E-IOT01A Discovery kit using Azure IoT Middleware for FreeRTOS

## What you need
Expand Down Expand Up @@ -62,7 +64,7 @@ Parameter | Value
`WIFI_SSID` | _{Your Wi-Fi SSID}_
`WIFI_PASSWORD` | _{Your Wi-Fi Password}_

If you're using a device previously created in your **IoT Hub** with SAS authentication, disable DPS by commeting out line #53 (`#define democonfigENABLE_DPS_SAMPLE`) and set the following parameters:
If you're using a device previously created in your **IoT Hub** with SAS authentication, disable DPS by commenting out line #53 (`#define democonfigENABLE_DPS_SAMPLE`) and set the following parameters:

Parameter | Value
---------|----------
Expand Down
108 changes: 107 additions & 1 deletion demos/projects/ST/stm32h745i-disco/cm7/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,107 @@
# TODO
# Connect a STMicroelectronics STM32H745I-DISCO Discovery kit using Azure IoT Middleware for FreeRTOS

## What you need

* ST Microelectronics DevKit: [STM32H745I](https://www.st.com/en/evaluation-tools/stm32h745i-disco.html)

* Ethernet Cable

* Micro USB male cable

## Prerequisites

* [CMake](https://cmake.org/download/) (Version 3.13 or higher)

* [Ninja build system](https://github.com/ninja-build/ninja/releases) (Version 1.10 or higher)

- [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) (Version 9 or higher)
* Serial terminal tool like [Termite](https://www.compuphase.com/software_termite.htm), Putty, Tera Term, etc.

To run this sample you can use a device previously created on your Azure IoT Hub or you may have the Azure IoT Middleware for FreeRTOS provision your device automatically using Azure Device Provisioning Services (DPS).

IoT Hub | DPS
---------|----------
Have an [Azure IoT Hub](https://docs.microsoft.com/azure/iot-hub/iot-hub-create-through-portal) created | Have an instance of [IoT Hub Device Provisioning Service](https://docs.microsoft.com/en-us/azure/iot-dps/quick-setup-auto-provision#create-a-new-iot-hub-device-provisioning-service)
Have a [logical device](https://docs.microsoft.com/azure/iot-hub/iot-hub-create-through-portal#register-a-new-device-in-the-iot-hub) created in your Azure IoT Hub using your preferred authentication method* | Have an [individual enrollment](https://docs.microsoft.com/en-us/azure/iot-dps/how-to-manage-enrollments#create-a-device-enrollment) created in your instance of DPS using your preferred authentication method*

*While this sample supports SAS keys and Certificates, this guide will refer only to SAS keys.

### Install prerequisites on Windows

Ensure that cmake, ninja and the ARM toolset binaries are available in the `PATH` environment variable.

You may also need to enable long path support for both Windows and git:
* Windows: <https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later>
* Git: As **administrator** run `git config --system core.longpaths true`

## Get the middleware

Clone the following repo to download all sample device code, setup scripts, and offline versions of the documentation.

*If you previously cloned this repo in another sample, you don't need to do it again.*

```bash
git clone https://github.com/Azure-Samples/iot-middleware-freertos-samples.git
```

To initialize the repo, run the following command:

```bash
git submodule update --init --recursive --depth 1
```

## Prepare the device
To connect the STM DevKit to Azure, you'll modify a configuration file for Wi-Fi and Azure IoT settings, rebuild the image, and flash the image to the device.

Update the file `iot-middleware-freertos-samples/demos/projects/ST/stm32h745i-disco/cm7/config/demo_config.h` with your configuration values.

If you're using a device previously created in your **IoT Hub** with SAS authentication, disable DPS by commenting out line #53 (`#define democonfigENABLE_DPS_SAMPLE`) and set the following parameters:

Parameter | Value
---------|----------
`democonfigDEVICE_ID` | _{Your Device ID value}_
`democonfigHOSTNAME` | _{Your Azure IoT Hub Host name value}_
`democonfigDEVICE_SYMMETRIC_KEY` | _{Your Primary Key value}_

If you're using **DPS** with an individual enrollment with SAS authentication, set the following parameters:

Parameter | Value
---------|----------
`democonfigID_SCOPE` | _{Your DPS ID scope value}_
`democonfigREGISTRATION_ID` | _{Your Device Registration ID value}_
`democonfigDEVICE_SYMMETRIC_KEY` | _{Your Primary Key value}_

## Build the image

To build the device image, navigate to the `iot-middleware-freertos-samples` directory and run the following commands:

```bash
cmake -G Ninja -DVENDOR=ST -DBOARD=stm32h745i-disco -Bstm32h745i-disco .
cmake --build stm32h745i-disco
```

After the build completes, confirm that a folder named `stm32h745i-disco/` was created and it contains a file named `demo/projects/ST/stm32h745i-disco/iot-middleware-sample.bin`.

## Flash the image

1. Connect the Micro USB cable to the USB STLINK port on the STM DevKit, and then connect it to your computer.

2. In File Explorer, find the binary file that you created in the previous section and copy it.

3. In File Explorer, find the STM Devkit that's connected to your computer. The device appears as a drive on your system with the drive label `DIS_H745XI`.

4. Paste the binary file into the root folder of the STM Devkit. Flashing starts automatically and completes in a few seconds.

5. Connect an Ethernet cable to your STM DevKit and your network equipment.

## Confirm device connection details

You can use one of the terminal applications to monitor communication and confirm that your device is set up correctly. Go to Device Manager in Windows to determine which COM port your device was assigned.

The following settings can be used to monitor serial data:

- Baud Rate: `115200`
- Data Bits: `8`
- Stop Bits: `1`
- Parity: none
- Flow Control: none

0 comments on commit a4b2695

Please sign in to comment.