User Guide - Lyra 24 Software

Introduction

The Lyra 24 module is supported by Canvas Platform Firmware as part of the Canvas Software Suite. This firmware provides developers a path to quickly design and build applications using the Python language and leverage Python-based APIs for access to the underlying hardware and radio feature set. This guide focuses on developing software for the Lyra 24 DVK, though the principles described apply to any PCB on which the Lyra 24 module is placed as long as the appropriate SWD and serial port access is provided by the PCB to use with Canvas Tools for programming.

Getting Started

The Lyra 24 DVK is equipped with a USB port used to both provide access to SWD programming capabilities and access to a single USB-to-UART interface to the Lyra 24 module. This is the primary interface you will use when developing software for the Lyra 24 module.

This USB port connects to an on-board Segger j-link interface to provide the programming interface to the module.

When you plug a micro-USB cable from the DEBUG USB port into your workstation, the DVK hardware will be auto-detected and drivers are installed for the serial port. This serial port will provide access to the Python REPL prompt (>>>). You can attach to this serial port with 115200 baud, 8N1 to verify your DVK is running Canvas Firmware.

If you do not see this output, you can press the RESET button (labeled RST on the DVK silk screen) to reset the firmware and something similar to the output above will appear in a serial terminal.

If you do not see any output similar to above, you may need to load Canvas Firmware onto your DVK board. To do so, follow the steps in the next section to update your Canvas Firmware.

Also be aware that you may also need to set up the USB serial protocol using Simplicity Studio. Details are below.

Updating Canvas Firmware

Downloading the Latest Firmware Image

The latest version of Canvas Firmware for the Lyra 24 module can be found here:

Releases: Lyra 24 Canvas Python

Download the required release of the .hex file for the module you are using. The module will either be p10, p20, prf or s10.

Programming the Firmware onto the DVK

Programming firmware onto the Lyra 24 DVK depends on the Silabs Simplicity Studio tool suite. It is recommended that you download and install the latest version from here:

Simplicity Studio

This is available for multiple platforms, examples will be from the windows platform.

Opening the flash programmer

To program the DVK with the Canvas firmware .hex file you will need to use the Flash Programmer tool contained in the Simplicity Studio. Open Simplicity Studio and locate the Tool button in the top bar menu. Click this and you will see a list of tools you can use.

Locate the Flash Programmer tool, select it and click OK to open it.

You may be prompted to select the device you wish to flash. If so select the desired device and click OK to continue.

Once selected the Flash Programmer will be displayed. Browse to the location of the .hex file you wish to flash. Select it and then click Program. A progress bar will briefly be shown and once complete the Flash Programmer can be closed.

If for any reason the device requires erasing or is accidentally erased. A new bootloader can be found here:

Lyra 24 Bootloader and AT firmware.

Follow the above procedure to flash the appropriate bootloader first and then the firmware image. This step is typically not necessary.

Configuring the Virtual COM Port

The virtual COM port used to communicate with the Python REPL does not come configured with RTS/CTS enabled. To enable this please follow the instructions here:

Enabling RTS/CTS

Default settings of the com port are 115200, 8, 1.

Using the Canvas Xbit Extension for VS Code

With Python 3.11.6 installed, you also have the option of using our Xbit VS Code extension to load .hex files right from within the VS Code editor environment.

Install the Xbit tools for VS Code extension by navigating to the Extensions tab within VS Code and searching for “Xbit tools for VS Code”.

Interacting with the Lyra 24 DVK via Python REPL

The Canvas Firmware provides a Python execution environment right on the Lyra 24 module. This environment can be interacted with through the Python REPL serial port. The Xbit VS Code extension will automatically detect this serial port and provide easy access to the REPL terminal.

To access the Python REPL, ensure your DVK’s USB DEBUG port is attached to your workstation and open the Xbit VS Code extension. Navigate to the USB DEVICES panel and locate the serial port associated with your DVK board. Click the board name (e.g. 'COM9' or similar) to connect to the board and expand a listing of its filesystem. In the lower right, you’ll find a tab labeled TERMINAL. If you press the ENTER key in the TERMINAL panel, you’ll see the REPL prompt for the device (>>>). From here, you can type Python commands interactively with the DVK board.

One common set of commands provides an easy way to find the Canvas Firmware version running on your device. Type the following lines, pressing ENTER after each one into the REPL terminal to display the system version information. The Canvas Firmware version is the string value for the property named release.

>>> import os
>>> os.uname()

If the commands were issued properly, you should see a Python tuple displayed similar to the following:

(sysname='Lyra', nodename='Lyra', release='1.21.0', 
version='v1.21.0 on 2023-12-14', machine='LYRA_24_P10_999.6.0.1')

Creating a Python File

The Python interpreter built into the Canvas Firmware running on the Lyra 24 DVK is designed to look for two specially named Python files in its filesystem at system boot. These files are named boot.py and main.py. If a file named boot.py exists in the filesystem, the Python code in that file will be executed automatically on boot, allowing you to easily configure the hardware for your preferred startup conditions. After executing the boot.py script, the interpreter looks for a main.py and if it exists, executes it. This allows you to automatically launch a Python script application after system boot.

To create a Python file on the device, right-click the device name in the USB DEVICES panel in the Xbit VS Code extension and select Create File. This will bring up a field where you can specify the name of the file (e.g., ‘main.py’).

The new file will now appear in the file listing under the device in the USB DEVICES panel. To edit the file, click on the file in the panel and a new editor tab will display. You can now type in this editor and save using FILE → SAVE or the hotkey for saving a file on your platform to save the updated file back to the device. To edit a file already on the device, just click the name of the file and an editor tab will open where you can modify and save the file like you usually would any text file within VS Code.

It is best practice to disable autosaving of files within VSCode when dealing with files directly on the device.

Next Steps

Now that you have your DVK connected to your workstation and have the Xbit VS Code extension up and running and interacting with the board, you are ready to try out some sample Python applications or develop your own. Note that sample applications may not be named main.py, in which case in order for the script to run on startup, simply rename the script to main.py before loading to the board or use the Right-click context menu within Xbit VS Code extension to rename the file to main.py in order for the device to automatically run the script after a reset.

Python Sample Applications

We’ve provided a set of simple Python applications for you to get started with some simple examples and test out the hardware. These samples are hosted in a public GitHub repository and will evolve over time to include more examples of exciting things you can do with Python on the Canvas Firmware with your DVK board. Please check this GitHub repository for a list of sample applications:https://github.com/LairdCP/canvas_python_samples

NOTE: Not all sample applications work properly with all Canvas Firmware supported hardware. Please take note of the requirements described in each sample application to ensure it is compatible with your hardware. The Canvas API Compatibility Table is a useful resource for determining which Python APIs are available on each Canvas-enabled hardware product.

Python API Documentation

Once you’ve taken a look at some sample applications and start to become familiar with how Python can be used to develop applications on the device, you can check out our detailed Python API documentation for more details on what hardware is accessible from Python and how to use it.

Canvas Python API Documentation on GitHub

Canvas API Compatibility Table - Lyra 24

The following table lists the specific Python APIs available on the Lyra 24 module.

Python API Compatibility

machine.
Pin
machine.
I2C
machine.
SPI
canvas_ble.
GattServer
canvas_ble.
GattClient
canvas_ble.
Connection
canvas_ble.
Advertiser
canvas_ble.
Scanner
canvas.
Timer
canvas_ble
(Common)
canvas_uwb
Floating
Point
canvas.
LEDStrip
canvas.
zcbor

Lyra 24

(tick)(tick)(tick)(tick) (tick) (tick)(tick)(tick)(tick)(tick)(tick)(tick) (error) (tick)

Canvas Firmware Feature Support

OTA FW Update
MicroPython Engine
Filesystem
RTOS Shell
Xbit VS Code
AT Command Set
Host Driver
DAPLink
Xbit Desktop
Xbit Mobile

Lyra 24

(tick)(star)(tick)(tick)(error) (tick)(tick)(tick)(error) Segger J-Link USB(tick)(tick)

(star) OTA FW update is a function of the Silabs Bootloader and while it currently works it is not optimal. Laird and Silabs are working on this issue.

Lyra 24 DVK Features

Single color LED

The Lyra 24 DVK has a single color LED on PA08. You can use the machine.Pin interface to control it’s state.

>>> import machine
>>> p = machine.Pin("LED", machine.Pin.OUT, machine.Pin.PULL_NONE)
>>> p.on()
>>> p.off()

User Button

The Lyra 24 DVK has a single USER Buttonthat can be used by your Python script applications to interact with the program flow as your application requires via the GPIO interface. Use the machine.Pin API to detect the state of the button or setup an event on a rising/falling edge.

The Lyra 24 DVK user button is named “PC07” when accessing it from Python. Here is an example showing how to initialize the user button and read its value:

>>> import machine
>>> user = machine.Pin("PC07", machine.Pin.IN, machine.Pin.PULL_UP)
>>> user.value()
1

MikroBUS Socket

The Lyra 24 DVK provides a single mikroBUS socket making it easy to experiment with mikroE Click boards for easily adding sensors and other external accessories through GPIO, I2C or SPI interface. Use the machine.I2C, machine.SPI and machine.Pin APIs as appropriate to interact with the Click board you install.

QWIIC Header

The Lyra 24 provides a single QWIIC header/port allowing you to plug in a QWIIC accessory board to interact from Python using the I2C interface. Use the machine.I2C API to interact with QWIIC attached devices.

More Resources

To continue learning more about how to use your Lyra 24 DVK see the Lyra 24 product page for links to application notes and articles.