Getting Started
This section describes how to install the SPARK Software Development Kit (SDK) virtual environment on a user’s personal computer. Virtual environments are isolated environments that use specific versions of software packages without affecting the rest of the system. They work by creating a separate directory where all the necessary files for the environment are installed. The specific virtual environment is activated by modifying the system’s PATH variable to point to that directory so that commands are executed using the packages installed there rather than the system’s default packages.
The SPARK SDK development environment dependencies are all contained within this virtual environment and can be easily bootstrapped by running a single script.
After following the steps outlined below to install and set up the virtual environment, the user will be ready to start building their own applications. Let’s get started!
Preferred Integrated Development Environment (IDE)
SPARK’s SDK is designed to work with Visual Studio Code (VS Code). This IDE is used internally and can be considered as tested and supported. Other IDEs or source code editors can be utilized provided that they support CMake and Pixi virtual environments.
The use of CMake files and the Pixi virtual environment allows for a more flexible and scalable development process and enables users to access a variety of tools and platforms to build and develop applications using the SPARK SDK.
Warning
Users of a different source code editor or IDE assume the responsibilities of ensuring that it supports CMake and that the necessary plugins or extensions are installed. They will also need to set up a virtual environment using the provided scripts. Refer to the Pixi documentation to learn how to integrate the environment with your IDE.
If you need to create or activate the virtual environment outside of VS Code, refer to the Getting Started with SPARK: Advanced Setup section.
Prerequisites
A 64-bit PC running Windows or Linux
A pair of either:
An EVK1.4 equipped with a SR10xx module
A QUASAR EVK equipped with a SR10xx or SR11xx radio module.
USB Cable for terminal display and flashing with DFU.
VS Code IDE
STM32 STLink programmer for flashing (Optional).
Warning
Make sure to avoid space characters in the SDK’s project path.
Warning
To avoid potential issues with Windows’ maximum path length restriction, it is recommended to unzip the package as close to the root directory (C:\) as possible. Extracting the files too deeply nested may result in errors., you may also refer to the Windows Long Path Support section to enable long path support in Windows.
VS Code Extensions
To use the SPARK SDK and its virtual environment with VS Code, certain VS Code extensions need to be installed.
Follow these steps to install the recommended VS Code extensions:
Open the VS Code command palette by pressing
Ctrl+Shift+P.Type
Extensions: Show Recommended Extensionsand select it from the list.Install Workspace Recommendations.
Note
This will automatically trigger the virtual environment creation process.
Hardware
The example applications provided with the SPARK SDK are written specifically for the SPARK Evaluation Kit (EVK) boards. This means that to run these applications, the user will need at least two EVKs and one ST-Link debug probe (for debugging).
If access to two EVKs is not possible, the user may still use the example applications as a reference for building their own applications. The code will need to be modified for specific hardware configurations, but the overall structure and functionality of the applications are still useful starting points.
In any case, it is recommended to carefully review the documentation and code provided with the SPARK SDK to ensure a clear understanding of how the example applications work and how to adapt them for specific needs.
Create the Virtual Environment with VS Code
To initiate the virtual environment and download all dependencies, it’s necessary to create it once. The environment will be automatically created upon the installation of the extension.
If the extension is installed correctly and the virtual environment is created successfully, the user should now be able to select an application for compilation and any terminal opened within VS Code will have the environment automatically activated.
Attention
If you have restricted or no internet access, refer to the Offline Environment section for alternative setup instructions.
Note
If you need to create or activate the virtual environment outside of VS Code, refer to the Getting Started with SPARK: Advanced Setup section.
Building Applications
With the SPARK Virtual Environment created, the next step is to build the applications. Follow these steps.
Open the VS Code command palette by pressing
Ctrl+Shift+P.Type
CMake: Select Configure Presetand press Enter.Select the desired preset.
Open the VS Code command palette again and choose
CMake: Delete Cache and Reconfigure..Open the VS Code command pallete a final time and choose
CMake: Clean Rebuild.
The applications will build as binaries and the progress can be viewed in the Output terminal.
Flashing an EVK
Once a binary is built through VS Code, it can be flashed onto an EVK in DFU mode.
Setting up an EVK’s DFU Mode driver
On Windows, the bootstrap will install the STM32 USB DFU driver automatically.
On Linux, permission to access STM32 USB devices in DFU mode from user space must be explicitly granted via udev rules.
Create /etc/udev/rules.d/50-usb-conf.rules, and copy the following in it.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", GROUP="users", MODE="0666"
Reload udev system.
sudo udevadm control --reload-rules
Putting an EVK in DFU Mode
With the Power Switch turned ON, press and hold the Bootloader button.
Press and release the MCU Reset button.
Release the Bootloader button.
Flashing
Connect an EVK to the host computer through USB. Make sure to only connect one EVK in DFU mode at a time.
Open the VS Code command palette by pressing
Ctrl+Shift+P.Type
Tasks: Run Taskand press Enter.Select [DFU/STM32] Flash binary.
Select which binary to flash on the EVK and wait for completion.
Debugging with ST-Link Debug Probes
Set launch parameters to enable flashing and debugging. A template is available to configure launch parameters to specific requirements.
Setup the ST-Link debug probes for the operating system.
Download and install the ST-Link debug probe drivers. They can be downloaded from the official website: https://www.st.com/en/development-tools/stsw-link009.html.
Update the system udev rules to use the ST-Link debug probes by performing the following instructions : https://github.com/pyocd/pyOCD/tree/main/udev.
Connect a ST-Link debug probe to the computer and identify the probe’s serial ID. Using a terminal with the virtual environment activated, type this command to print ST-Link serial IDs.
Note
Using a Terminal with the SPARK Virtual Environment To use a terminal with the SPARK virtual environment activated, open a new terminal within VS Code. Do not use the default terminal window of VS Code as it may not have the environment activated.
Optionally, you can also activate the environment in an external terminal by following the instructions in the Getting Started with SPARK: Advanced Setup section.
pyocd listOpen the .vscode\.launch.cfg file and set key values with the ID from step 2. Repeat steps 2-3 for each debug probe.
Example: ST_LINK_NO1_SN=34FF6F065250343836270143 ST_LINK_NO2_SN=67FF6F065250343836270143
Note
The ST-Link debug probe numbers are shared with their respective debug configuration.
- For example:
ST_LINK_NO1_SN is used for PyOCD STLINK STM32G4 1 and PyOCD STLINK STM32U5A 1.
Make sure the ST-Link debug probe is connected to the board and that the board is switched on.
Open the Run and Debug menu by pressing
Ctrl+Shift+D. At the top of the menu, choose the appropriate debug configuration and press the green Play button.
Viewing the Terminal
Every application features a terminal output that displays important information such as real-time SWC link and application statistics. Live statistics viewed through a terminal emulator allow developers to monitor the behavior and performance of the application during runtime. Once an application is built and flashed on the target device, follow these steps depending on the operating system to view the terminal output.
PuTTY is recommended for Windows users.
Install PuTTY from the official website.
Identify the device’s serial port and open it with PuTTY.
Hint
To help identify the device’s COM port number:
Unplug the device (if already connected).
Open the Device Manager and view the Ports (COM & LPT) device category. Note which devices are already listed.
Plug the device and wait for the Device Manager to refresh the list.
The device and its COM port should be added to the previously viewed list.
Minicom is recommended for Linux users. Here is the procedure for Debian-based distributions:
In a terminal, install Minicom.
$ sudo apt update $ sudo apt install minicom
Identify the device’s serial port and run minicom.
$ sudo dmesg $ sudo minicom -D /dev/<serial_port>
Hint
Superuser privileges are not required to run minicom if appropriate udev rules have been added to grant the necessary permissions to access the devices.
Note
The EVKs use the USB Communication Device Class standard and do not require a particular configuration as opposed to UART for example.
Time to Explore
The user is ready to explore and build new applications or port the example applications onto new hardware. It is recommended to start by reviewing the documentation and code provided with the SPARK SDK as well as by experimenting with the example applications to gain a better understanding of how the platform works.
From there, the user can begin building their own applications using the SPARK SDK or modify the example applications to meet their specific needs.
The possibilities are endless, and we’re excited to see the creations that will emerge from our platform!