Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

The Twilio CLI Microvisor Plugin


(warning)

Warning

Microvisor Public Beta

Microvisor is in a pre-release phase and the information contained in this document is subject to change. Some features referenced below may not be fully available until Microvisor's General Availability (GA) release.


Current version: 0.3.13

current-version-0313 page anchor

This utility adds Microvisor-oriented functionality to the Twilio CLI tool.


Prerequisites

prerequisites page anchor

The Microvisor plugin requires Twilio CLI. You can find full instructions for your platform in the Twilio CLI Quickstart guide.

Run the following command:


_10
twilio plugins:install @twilio/plugin-microvisor

(warning)

Warning

Installing the plugin may result in a number of warnings being output by the installer. We are working to address this.

After installation, you can keep the plugin up to date by running:


_10
twilio plugins:update

(warning)

Warning

We expect to make a number of improvements to the plugin as Microvisor continues through its pre-release phases and moves toward General Availability. We strongly recommend that you keep your installed plugin updated by running the command shown above regularly.

(warning)

Warning

Plugin 0.3.10 or above is required for Microvisor 0.5.1 or above.


The plugin operates with commands and sub-commands, separated by colons, and entered this way:


_10
twilio microvisor:<COMMAND>:<SUB_COMMAND>

The plugin provides the following commands:


The apps command provides the following sub-commands:

  • bundle — Build an application bundle that can be uploaded. It has two required arguments:


    _10
    twilio microvisor:apps:bundle /path/to/bin path/to/bundle/zip

    The latter is the path at which the bundle will be created: the path you will subsequently pass into the create call as shown below.
    If you are using remote debugging, include the debugging public key with the --debug-auth-pubkey switch as follows:


    _10
    twilio microvisor:apps:bundle /path/to/bin /path/to/bundle/zip \
    _10
    --debug-auth-pubkey=/path/to/public/key/pem

    You can generate a suitable private-public key pair with the debug:generate_keypair sub-command.

  • create — Upload an application bundle. It takes as its argument a path to the application bundle to upload:


    _10
    twilio microvisor:apps:create /path/to/bundle/zip


    If you specify a path that doesn't reach a bundle file, or the uploaded file is not a bundle, an error will be thrown.
    Optionally, you may also provide a unique friendly name to help you locate and reference the bundle in future:


    _10
    twilio microvisor:apps:create /path/to/app/bundle <OPTIONAL_UNIQUE_NAME>

    Optionally, add --bundle-out and provide a path to which a signed version of the bundle will be written:


    _10
    twilio microvisor:apps:create /path/to/app/bundle --bundle-out /path/to/write/signed/bundle


The debug command takes a device SID and a path to a remote debugging private key as its arguments. For more information on why this key is required and how it is generated, please see Microvisor Remote Debugging.


_10
twilio microvisor:debug $MV_DEVICE_SID /path/to/private/key/pem

Your call may also include the --listen-port flag, which is used to select the port through which debugging data will flow.


_10
twilio microvisor:debug $MV_DEVICE_SID /path/to/private/key/pem \
_10
--listen-port=<PORT_NUMBER>

The default port is 8001. If you specify an alternative port number, you will need to update your .gdbinit file or run the command


_10
target remote localhost:<PORT_NUMBER>

within gdb.

It also has the following sub-commands:

  • generate_keypair — Generate private and public remote debugging encryption keys. It takes two arguments: paths to where the generated private and public keys should be stored:


    _10
    twilio microvisor:debug:generate_keypair \
    _10
    --debug-auth-privkey=/path/to/private/key/pem \
    _10
    --debug-auth-pubkey=/path/to/public/key/pem

    If you don't provide either or both key paths, your current working directory will be used.


This command provides a streamlined application build and deploy flow based on the standard Microvisor CMake-based workflow. It has no sub-commands, but takes the path to a CMake project directory (i.e., the directory containing the root CMakeLists.txt file) as a required argument.

The --devicesid switch is mandatory in cases where a deploy will take place, i.e., the call is made without the -b flag. It takes as a value the SID of the device you wish to deploy code to.

The deploy command also provides the following optional flags and switches:

  • -b , --build — Build without deploying.
  • -c , --clean — Clean the build folder first.
  • -d , --deploy — Deploy the most recent build without rebuilding.
  • --genkeys — Generate remote debugging key.
  • --privatekey=``<value> — Path to your private key. Default: none.
  • --publickey=``<value> — Path to your public key. Default: none.
  • --log — Start logging after a deploy and/or build.
  • --logonly — Start logging immediately without building or deploying.

The --privatekey and --publickey options can take paths to pre-existing keys or, if the --genkeys switch is included, will be used as paths to which the generated keys will be written. By default, plugin-generated keys are placed in the build directory.

Build and deploy the app in the working directory:


_10
twilio microvisor:deploy . --devicesid $MV_DEVICE_SID

Build and deploy the app in the working directory, adding remote debugging keys, and initiating logging immediately:


_10
twilio microvisor:deploy . --devicesid $MV_DEVICE_SID --genkeys --log

Build and deploy the app in the working directory, using pre-existingh remote debugging keys:


_10
twilio microvisor:deploy . --devicesid $MV_DEVICE_SID \
_10
--publickey ~/rdkeys/pukey.pem \
_10
--privatekey ~/rdkeys/pvkey.pem

Build and deploy the app in the working directory, generating keys and specifying paths for those keys:


_10
twilio microvisor:deploy . --devicesid $MV_DEVICE_SID \
_10
--genkeys --publickey ~/rdkeys --privatekey ~/rdkeys \

Just build the current code:


_10
twilio microvisor:deploy . --build

Auto-incrementing build numbers

auto-incrementing-build-numbers page anchor

From version 0.3.11, the plugin will automatically increment build numbers when they are defined in the application-level CMakeLists.txt file as follows:


_10
set(BUILD_NUMBER "0")

The current build number is available to code by importing the header file app_version.h as the constant BUILD_NUM. This is demonstrated in the sample applications.


The factory command provides tools required by the Microvisor factory process by which devices on the assembly line are prepared for end-use.

  • image — Generate an application SPI flash image for factory installation. It has one required argument:


    _10
    twilio microvisor:factory:image /path/to/write/image

    The value is the path at which the image will be created. In addition, you will need to provide values for these flags:

    • --application — The path to your application bundle .
    • --application-test — The path to your application test bundle.
    • --microvisor — The path to a Microvisor kernel bundle, provided by us.
    • --microvisor-test — The path to a Microvisor kernel test bundle, provided by us.

    An additional, optional flag --purpose defaults to the value factory. This flag should not be used. It is intended to support alternative installation pathways which will be documented in due course.


To use the following sub-commands, connect a USB Micro A cable between your computer and the Nucleo Development Board's CONTROL port, then press the board's RESET button. The board's SYSTEM LED will turn solid blue and your application will halt.

The info command provides the following sub-commands, all of which require you to pass the Unix path to the device file, e.g., /dev/tty.usbmodem14244401 or /dev/ttyACM0.

If you are using Windows, replace /path/to/device in the following sub-commands with the COM port, e.g., COM7. See the wificonfig:ports sub-command, below, for more information.

  • sid — Display the connected device's SID.


    _10
    twilio microvisor:info:sid /dev/cu.usbmodem14101
    _10
    Device SID: UVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

  • version — Display the version of Microvisor installed on the connected device.


    _10
    twilio microvisor:info:version /dev/cu.usbmodem14101
    _10
    Microvisor version: 0.5.1
    _10
    Build date: Tue Mar 7 12:39:36 2023

(warning)

Warning

On Linux, you will need to perform these commands as root or as a member of the group dialout. To add a user to that group, open a terminal and run:


_10
sudo usermod -a -G dialout <username>

If you are in a GUI, you will need to log out and then back in again for this to take effect.


The logs command provides the following sub-commands:

(warning)

Warning

Only a single log stream can be open to a particular device. If you open a second terminal window and use a new instance of the Twilio CLI to view logs from the same device, the first connection will be closed automatically. You can, however, open multiple streams from multiple devices.

The log output includes the reports issued by Microvisor when an application has crashed. Currently reports are presented in JSON form, and this is the case whether you are outputting to plain text or JSON. For the former, the report JSON is prettified; for the latter, whitespace is removed. For example:

Text


_46
Connection established
_46
Crash Report:
_46
{
_46
"basic_registers": {
_46
"lr": 134219695,
_46
"pc": 134218520,
_46
"r0": 536870912,
_46
"r1": 0,
_46
"r12": 134219640,
_46
"r2": 0,
_46
"r3": 0,
_46
"xpsr": 1761608192
_46
},
_46
"crash_reason": "CPU_FAULT",
_46
"extended_registers": {
_46
"r10": 134219640,
_46
"r11": 134219640,
_46
"r4": 134219640,
_46
"r5": 134219640,
_46
"r6": 134219640,
_46
"r7": 537395196,
_46
"r8": 134219640,
_46
"r9": 134219640,
_46
"sp": 537395160
_46
},
_46
"fast_interrupt_data": null,
_46
"fault_registers": {
_46
"bfar": 0,
_46
"cfsr": 0,
_46
"fault": 7,
_46
"hfsr": 0,
_46
"mmfar": 0,
_46
"sfar": 0,
_46
"sfsr": 72,
_46
"shcsr": 0
_46
},
_46
"gtzc_registers": null,
_46
"special_registers": {
_46
"control": 0,
_46
"msp": 537395160,
_46
"msplim": 0,
_46
"psp": 0,
_46
"psplim": 0
_46
}
_46
}
_46
Connection dropped

JSON


_10
{"category":"connection","connection_id":"c12cfe06-2f7b-11ed-af0e-0a9fcaaa3415","device_timestamp_usecs":null,"message":"Connection established","timestamp":"2022-09-08T13:40:08.731082Z"}
_10
{"category":"app_crash","connection_id":"c12cfe06-2f7b-11ed-af0e-0a9fcaaa3415","device_timestamp_usecs":null,"message":"{\"basic_registers\":{\"lr\":134219695,\"pc\":134218520,\"r0\":536870912,\"r1\":0,\"r12\":134219640,\"r2\":0,\"r3\":0,\"xpsr\":1761608192},\"crash_reason\":\"CPU_FAULT\",\"extended_registers\":{\"r10\":134219640,\"r11\":134219640,\"r4\":134219640,\"r5\":134219640,\"r6\":134219640,\"r7\":537395196,\"r8\":134219640,\"r9\":134219640,\"sp\":537395160},\"fast_interrupt_data\":null,\"fault_registers\":{\"bfar\":0,\"cfsr\":0,\"fault\":7,\"hfsr\":0,\"mmfar\":0,\"sfar\":0,\"sfsr\":72,\"shcsr\":0},\"gtzc_registers\":null,\"special_registers\":{\"control\":0,\"msp\":537395160,\"msplim\":0,\"psp\":0,\"psplim\":0}}","timestamp":"2022-09-08T13:40:09.028666Z"}


The wificonfig command provides tools to allow you to get, set, and clear WiFi credentials stored on a Microvisor device.

To use these commands, connect a USB Micro A cable between your computer and, for example, the Nucleo Development Board's CONTROL port, then press the board's RESET button. The board's SYSTEM LED will turn solid blue and your application will halt.

The wificonfig command has the following sub-commands, all of which require you to pass the Unix path to the device file, e.g., /dev/tty.usbmodem14244401 or /dev/ttyACM0.

If you are using Windows, replace /path/to/device in the following sub-commands with the COM port, e.g., COM7. See the ports sub-command, below, for more information.

(warning)

Warning

On Linux, you will need to perform these commands as root or as a member of the group dialout. To add a user to that group, open a terminal and run:


_10
sudo usermod -a -G dialout <username>

If you are in a GUI, you will need to log out and then back in again for this to take effect.

  • get — Get and display the current WiFi credentials.


    _10
    twilio microvisor:wificonfig:get /path/to/device

  • set — Set the device's WiFi credentials, passed as follows:


    _10
    twilio microvisor:wificonfig:set <SSID> <PASSWORD> /path/to/device

  • clear — Clear any WiFi credentials stored on the device.


    _10
    twilio microvisor:wificonfig:clear /path/to/device

There is an additional sub-command which does not require a device path or any other argument. Indeed it is intended to help you locate your connected Microvisor device by listing the serial devices currently connected to your computer:

  • ports — List currently available device paths: Linux


    _10
    $ twilio microvisor:wificonfig:ports
    _10
    Available ports on your computer:
    _10
    1. /dev/ttyACM0

    macOS


    _10
    $ twilio microvisor:wificonfig:ports
    _10
    Available ports on your computer:
    _10
    1. /dev/tty.usbmodem14244401

    Windows


    _10
    C:\Users\user>twilio microvisor:wificonfig:ports
    _10
    Available ports on your computer:
    _10
    1. COM1
    _10
    2. COM4

(information)

Info

To determine which Windows COM port to use, open Device Manager after you have connected your Microvisor device and check which port listed under Ports (COM and LPT) is labelled USB Serial Port (COMx) . This is the COM port you should pass into the get, set, and clear sub-commands.


(warning)

Warning

The list of properties included in the log messages output as JSON is still being defined and is therefore subject to change. You should not build against the following description, which is intended for information purposes only.

You can optionally set the log:stream command to output log messages in their source form, which is JSON. The default output mode emits the value of one of the JSON's properties, message. The other properties can be accessed by adding -o=json to the command.

Property NameValue(s)Notes
categoryconnectionDevice-cloud connection status
app_loggingApplication logging messages
ota_updateMicrovisor update messages
messageTextThe exact message depends on the value of category. App logging values are the text issued by the application using mvServerLog(). Connection messages indicate connection status updates
timestampA Unix timestampThe date and time at which the message was emitted by Twilio

0.3.13 July 01, 2023

0313-july-01-2023 page anchor
  • Further support for Factory Provisioning image creation.

0.3.12 June 26, 2023

0312-june-26-2023 page anchor
  • Initial support for Factory Provisioning image creation.
  • Update WiFiConfig commands to use binary messaging.

0.3.11 May 15, 2023

0311-may-15-2023 page anchor
  • Add auto-incrementing build count to the deploy command.
  • Compiler and linker output shown during deploy build rather than afterwards.
  • Add dependency pre-flight checks to the deploy command.
  • Pass the debug flag setting on to sub-commands.
  • Better Windows support; exit on an unsupported platform.
  • User permissions checking and warning on Linux for the wificonfig command.
  • The create command issues signed bundles.

0.3.10 March 20, 2023

0310-march-20-2023 page anchor
  • Provide application deploy functionality based on the standard Microvisor demo code workflow.
  • Provide device SID and Microvisor version information.
  • Updated bundle encryption code to support Microvisor 0.5.1.

0.3.9 February 1, 2023

039-february-1-2023 page anchor
  • Bug fixes and internal changes.

0.3.8 January 10, 2023

038-january-10-2023 page anchor
  • JSON output reflects Twilio CLI standard format.
  • Add WiFi credential get, set, and clear functionality.
  • Application logging fixes.
  • Dependency updates.
(information)

Info

Microvisor Help and Support

We welcome all inquiries you may have about Microvisor and its implementation, and any support questions that arise once you've begun developing with Microvisor. Please submit your queries via a KORE Wireless ticket: log in to the Kore console(link takes you to an external page) and click the Contact Support button in the left-hand navbar.


Rate this page: