FAQ

How can I tell what peripheral instances are supported in Canvas firmware?

Most wireless MCU’s used on Ezurio modules will have support for multiple peripheral instances that can be shared with other peripherals. For example, Nordic based modules may have up to five serial instances that may be shared between TWI, UART or SPI. The Canvas FW will typically have a mix that will support at a minimum one instance of each. There is always a UART reserved for REPL port but an additional UART is typically enabled for customer specific use.

For Nordic based modules there is an additional python method added to the machine module called machine.list_devices(). Use this API to determine peripheral instance availability and label.

Below is an example using machine.list_devices() at the REPL prompt of the BL54L15 DVK.

>>> import machine

>>> machine.list_devices()

['clock@10e000', 'gpio@10a000', 'gpio@d8200', 'gpio@50400', 'entropy_bt_hci', 'psa-rng', 'uart@104000', 'uart@c7000', 'uart@c6000', 'watchdog@109000', 'bt_hci_sdc', 'adc@d5000', 'rram-controller@5004b000', 'i2c@c8000', 'spi@4a000']

>>>

 Additional hardware information may also be listed in the README.md file associated with the board in the canvas_python_firmware Git repository.
 

https://github.com/Ezurio/canvas_python_firmware/tree/main

Key Specs are also provided including default REPL port, file system size, python heap size and available Canvas firmware variants with special features.

Can python scripts be loaded onto my device via SWD if no UART is available?

Python scripts can only be loaded onto a Canvas enabled device via serial interface such as UART or USB. Canvas FW is programmed over SWD programming interface only.

Ensure your custom hardware design has provisions for both SWD for Canvas FW programming and serial for loading python scripts.

Review the README.md of the canvas_python_firmware repository (https://github.com/Ezurio/canvas_python_firmware) for the hardware platform to locate the "Default REPL port"

Is there a way to determine the battery level on MG100 using Canvas?

Yes, battery level can be read on P0.02_AIN0 via the ADC machine class in Python.

https://lairdcp.github.io/canvas_python_docs/machine.html#machine.ADC

 There is also a python sample provided that measures and returns the battery voltage level.

 https://github.com/LairdCP/canvas_python_samples/blob/main/apps/mg100/adc/main.py

How can I determine what Python modules in my devices Canvas Firmware can be imported?

Canvas firmware has enabled a feature of MicroPython that allows you to use the following command to list all available modules (that can be imported with the 'import' statement):

help("modules")

The following is one example of the list of available modules. Note not all products will have the same modules as it is dependent on the device and size of memory.

__main__

canvas

hashlib

os

_onewire

canvas_ble

io

struct

array

collections

machine

sys

binascii

erno

math

time

builtins

gc

micropython

(Plus any modules on the filesystem)

At the time of writing this FAQ the most recent Canvas FW available for a particular module may not yet have support for the help("modules") command.

Is there a way to run scripts with Xbit VS Code Extension without naming them main.py

Yes, python scripts can be run manually by right clicking on <File>.py and select Run Python (no reset).




With this option python scripts can be named differently than main.py during development. This is useful when a developer doesn't want main.py to run automatically after reset.

Is there a script to load multiple python scripts for Canvas Firmware Applications?

Some python scripts written for use with Canvas Firmware require several other python files as dependencies. Rather than load one python script at a time there is a file_uploader.py script developed for just this purpose. Refer to the Canvas_Software_Suite_Tools at the following Ezurio Git repository.

 Canvas_Software_Suite_Tools

Type python file_uploader.py -h. This will provide available command options one of which allows the user to select the REPL port the device is plugged into. A single file can be loaded with this tool or several files contained in a directory can be loaded.

 python file_uploader.py -h

 usage: File Uploader [-h] [-d] -u UPLOAD [-r REPL]

 Tool to upload files onto a MicroPython board.

 options:

  -h, --help            show this help message and exit

  -d, --debug           Enable verbose debug messages

  -u UPLOAD, --upload UPLOAD

                        upload a file or all files in directory

  -r REPL, --repl REPL  The REPL com port to use for file upload

Is there a way to update Canvas FW or load python applications onto my device using Xbit Mobile App?

For any Canvas enabled device both python applications and Canvas firmware updates can be made using the Xbit mobile app. With the device programmed with just the Canvas FW and no applications running (i.e., no main.py or boot.py), the Canvas FW runs a built-in script to just advertise as a generic "Canvas Device".

Xbit mobile app provides the Canvas Hub applet that will allow you to select the advertising Canvas enabled device, connect to it and complete both firmware updates and python application updates.

Lyra 24 allows application updates via BLE transfers but does not allow FW updates.

The NX040 supports two UART Ports. Which UART is needed to communicate with the Python REPL?

UART1 is used by the Python REPL and is set via Canvas FW running on the module.

I'm having trouble transferring scripts to my Canvas enabled device, what should I do?

To reliably transfer files, your python app cannot be in a loop or printing any messages. Follow the steps provided below to ensure reliable file transfers.

  1. Open the UART and issue Ctrl+C.
  2. You should now have a REPL prompt.
  3. Open the UART with Xbit VS Code.
  4. Rename main.py to something else and reboot.
  5. Now you can transfer files.
  6. Important Note: To have a reliable file transfer experience, reduce the print messages in your python app, the file transfer is over this UART so cross talk must be eliminated.

How can I make calls to the OS using Micro-Python enabled Canvas firmware?

The commands detailed in the document linked below can be executed in the REPL to make calls to the Zephyr OS:

https://docs.micropython.org/en/latest/library/os.html

Not all commands are implemented, particularly in older firmware versions of Canvas.  The best way to know if a command is available is by executing it.