Getting started

Requirement

The OpenWize stack is basically developed to target STMicroelectronic MCU, based on ARM-M cpu core. For convenience reasons, we use the STM32CubeIDE as an IDE. It come with all necessary to compile, load and debug firmware on that ST MCU. This IDE can be download from STMicroelectronics web-site (STM32CubeIDE).

The build system is based on cmake and make tools which rely on the cross-toolchain provided by the STM32CubeIDE. We provide a little bash script “set_env.sh” in “tools/script” to help you to setup some environment variables.

Restriction

The whole development and tests have been done under Linux operating system, Windows is not supported.

Minimum version

The following table gives the minimum recommended versions to be able to build the OpenWize stack.

Host

Linux Ubuntu 18.04

There are no special requirement. It should works on any Linux distribution.

Git

2.24

There are no special requirement.

Cmake

3.13.2

The CMakeLists.txt and xxx.cmake files are based on cmake version greater equal than 3.12

Make

4.1

There are no special requirement.

Cross-toolchain

7.3.1 (arm-non-eabi-gcc) and 2.30.0 (binutils)

There are no special requirement.

Newlib

3.0.0

This is the versions packaged with the cross-toolchain.

Note that Git, Cmake and Make are usually already installed on basic Linux distribution, so there is nothing more to do.

First steps

Cloning this repository

git clone --recurse-submodules https://github.com/WizeEveryWhere/OpenWize.git

or alternatively

git clone https://github.com/WizeEveryWhere/OpenWize.git
cd OpenWize
git submodule init --recursive
git submodule update --recursive

This will also clone the following required submodules :

Submodule

Version

Destination (from third-party/)

sha

FreeRTOS

V10.4.4

rtos/FreeRTOS/FreeRTOS-Kernel

8de8a9da1aa9b036812a72fdcd7cbdefc2789365

cmsis core

v5.4.0_cm4

firmware/STM32/cmsis_core

cb6d9400754e6c9050487dfa573949b61152ac99

cmsis device L4

v1.5.1

firmware/STM32/cmsis_device_l4

f42a6c319cc887c8a13f171d347294f2eabfab3b

stm32l4xx_hal_driver

v1.10.0

firmware/STM32/stm32l4xx_hal_driver

2737a6e3fdefa41570a29321afb6cd9c1de69b1c

CMock

v2.5.2

testing/Unity/CMock

150573c742ce15061a0b675aa0f8e29c85008062

Tinycrypt

master branch

libraries/Tinycrypt/tinycrypt

5969b0e0f572a15ed95dc272e57104faeb5eb6b0

Install the STM32Cube IDE

Go to the STMicroelectronic web page (STM32CubeIDE), on STM32CubeIDE Generic Linux Installer line, select the version 1.8.0 and download it. Unzip the zip file somewhere in temporary directory, then execute the resulting file (”st-stm32cubeide_1.8.0_11526_20211125_0815_amd64.sh”) and follow the instruction.

Note that preferred installation path as “/opt/Application/st/stm32cubeide_1.8.0”.

After few minutes, the STM32CubeIDE installation is completed.

Setup environment variables

Environment variables :

  • CROSS_TOOL_PATH : give the main path of the cross-toolchain, which is used and mandatory by the cmake build system.

  • ST_PROG_PATH : give the main path of the STM32Cube programmer tool. This tool is use to upload the binary firmware on the target board from command line, so not required with the IDE.

  • JLINK_PROG_PATH : give the main path of the Segger programmer tool. This tool is use to upload the binary firmware on the target board from command line, so not required with the IDE.

The easy way to set these variable is to run the provided script in OpenWize/tools/scripts. This script will create all necessary to set these environment variable on new console or terminal.

In a console run the script :

cd OpenWize/tools/scripts
./set_env.sh -i

and follow the instructions.

It’s also possible to “un-install” :

cd OpenWize/tools/scripts
./set_env.sh -u

Run this script only the first time. Next, in each new open console, these environement variables will be automatically set.

Demo application

  • This application is provide as a simple demonstrator of OpenWize stack targeting an ST Nucleo-L476RG board.

  • The Nucleo-L476RG board doesn’t integrate any RF device, so to overcome this, the demo application use the PhyFake device, which input/output frames over an UART peripheral.

  • This demo is very simple so, there is no console or local interface to communicate with it. Instead, application periodically send DATA and INSTALL (aka. PING) message and use the provided Logger module to print out messages (info, warning, debug, error).

  • The Logger is connected to the MCU USART2 peripheral

    • Configuration : 115200 bps, 8 bits data, no parity, 1 stop bit.

    • This USART is mapped onto CN1 (USB-mini).

  • The PhyFake is connected to the MCU LPUART1 peripheral :

    • Configuration : 115200 bps, 8 bits data, no parity, 1 stop bit.

    • This USART is mapped onto :

      • RX : PC0 (CN7-38)

      • TX : PC1 (CN7-36).

  • Some default parameters have been set to :

    ID

    Name

    Value

    0x28

    CIPH_CURRENT_KEY

    0

    0x18

    EXCH_RX_DELAY

    1

    0x19

    EXCH_RX_LENGTH

    1

    0x1A

    EXCH_RESPONSE_DELAY

    1

    0x30

    PING_RX_DELAY

    1

    0x31

    PING_RX_LENGTH

    1

Build the application

cd Openwize
mkdir -p _build
cd _build
cmake -DBUILD_CFG=Nucleo-L476/Nucleo-L476 -DCMAKE_BUILD_TYPE=Debug ../.
make DemoApp -j
make install

The firmware files are installed in OpenWize/_install directory

_install/
   └── bin
       ├── DemoApp.elf  : The "elf" file (i.e. with debug symbols)
       ├── DemoApp.bin  : Pure binary file
       ├── DemoApp.lst  : Disassembly listing
       └── DemoApp.map  : Symbols and files mapping

Load and run the firmware

To be able to load and run the demo application, you will need an ST Nucleo-L476 board and USB-to-UART converter.

  1. Connect your Nucleo-L476RG board to your computer

  2. Connect the USB-to-UART to your computer

  3. Check ST-Link probe id

    cd OpenWize
    STM32_Programmer_CLI -l
    

    You should get something like that :

          -------------------------------------------------------------------
                            STM32CubeProgrammer v2.9.0-RC01
          -------------------------------------------------------------------
    
    =====  DFU Interface   =====
    
    No STM32 device in DFU mode connected
    
    ===== STLink Interface =====
    
    -------- Connected ST-LINK Probes List --------
    
    ST-Link Probe 0 :
       ST-LINK SN  : 066CFF383333554157243011
       ST-LINK FW  : V2J34M25
    -----------------------------------------------
    
    =====  UART Interface  =====
    
    Total number of serial ports available: 4
    
    Port: ttyUSB0
    Location: /dev/ttyUSB0
    Description: FT232R USB UART
    Manufacturer: FTDI
    
    Port: ttyACM0
    Location: /dev/ttyACM0
    Description: STM32 STLink
    Manufacturer: STMicroelectronics
    
    Port: ttyS0
    Location: /dev/ttyS0
    Description: N/A
    Manufacturer: N/A
    

In this example, the probe id id 0 :

ST-Link Probe 0 :
ST-LINK SN  : 066CFF383333554157243011
...

Then, upload the firmware onto the board

STM32_Programmer_CLI -c port=SWD mode=UR reset=HWrst index=0 -d _install/bin//DemoApp.bin 0x08000000

You should be able to the Logger messages on ttyACM0 and Wize frames on ttyUSB0.

Debug the demo application

In the directory “OpenWize/demo/project”, we provides Eclipse project files. Open the STMCube32 IDE and Import as Existing Projects into Workspace.