Cygnet Quickstart
Cygnet is a low-cost Feather-compatible STM32L433-based microcontroller board designed to accelerate the development and deployment of battery-powered solutions.
In this tutorial you'll learn how to flash firmware to your Cygnet using Arduino IDE.
There are many ways to write firmware for Cygnet. This tutorial uses Arduino IDE for its ease of use, but after completing the quickstart tutorials you may wish try out of one the following alternative approaches:
Install Prerequisites
Before working with firmware in Arduino IDE, you must first install the following prerequisites.
-
Download and install Arduino IDE.
-
Download and install STM32CubeCLT, which is a toolset that allows third-party environments to work with STM32-based host MCUs.
note
Alternatively, you may install both STM32CubeIDE and STM32CubeProgrammer. These are much larger software packages that may not be necessary for your local development environment. Be sure to also follow these installation notes when installing STM32CubeProgrammer.
Linux-only setup required for accessing the device in DFU mode and virtual COM port.
-
Create a
/etc/udev/rules.d/
rule for the device in DFU mode.(echo '# DFU (Internal bootloader for STM32 MCUs)'; echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0664", GROUP="plugdev"') | sudo tee /etc/udev/rules.d/49-stdfu-permissions.rules > /dev/null
-
Create a
/etc/udev/rules.d/
rule for the device's virtual COM port.(echo '# Virtual COM Port for STM32 MCUs'; echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"') | sudo tee /etc/udev/rules.d/49-stvcp-permissions.rules > /dev/null
-
Add active user to
plugdev
group in/etc/group
.sudo usermod -aG plugdev $USER
Using the Arduino CLI
As an alternative to using Arduino IDE to configure and build your project, you can use the Arduino CLI.
-
In order to specify Cygnet as the board, you need to first install the STM32duino core. You'll need a minimum of version
2.9.0
of the STM32duino core installed.arduino-cli core install STMicroelectronics:stm32
-
You can then specify the Cygnet by using the board part number. For example:
arduino-cli compile --fqbn STMicroelectronics:stm32:Blues blinky.ino
Configuring Arduino IDE
With Arduino IDE installed, you next need to configure your environment to build and flash code to your Cygnet.
Installing STM32duino in the Arduino IDE
-
Within Arduino IDE open your Settings/Preferences.
-
Locate the Additional boards manager URLs (see screenshot below), and add the following URL:
https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
-
Click OK to save your changes, and then restart Arduino IDE.
-
Next, click the Boards Manager icon (second icon down in the left panel), search for STM32 MCU based boards, and install version
2.9.0
or greater. -
Restart Arduino IDE.
Using STM32duino in the Arduino IDE
-
Under Tools > Board, select STM32 MCU based boards, and then Blues boards.
-
Next, under Tools > Board part number, select Cygnet.
-
Lastly, under Tools > USB support (if available), select CDC (generic 'Serial' supersede U(S)ART).
Flashing Firmware
Now that you have Arduino IDE configured to work with Cygnet, you're ready to flash firmware.
To do so, we recommend using programmer like the STLINK-V3MINI, however, you may also program Cygnet via a USB cable connected to your computer.
Programming Cygnet with the STLINK-V3MINI (Recommended)
-
In Arduino IDE, under Tools > Upload method, select STM32CubeProgrammer (SWD)."
-
Plug the STLINK-V3MINI into your computer over USB.
-
Plug the Cygnet into a power source (e.g. a LiPo battery or your computer via USB).
NOTE: If you want to see Serial output from the Cygnet, you need to either use a USB cable as the power source or customize your sketch to use the STLINK-V3MINI for Serial output.
-
Plug the Cortex-Debug connector from the STLINK-V3MINI into the Cygnet.
-
Skip to the Blink the Onboard LED instructions below.
Programming Cygnet without the STLINK-V3MINI
-
In Arduino IDE, under Tools > Upload method, select STM32CubeProgrammer (DFU)."
-
Connect the Cygnet's USB C port to your computer with a USB cable.
-
Press and hold the
BOOT
button on the Cygnet, press and releaseRESET
, then releaseBOOT
to cause the Cygnet to jump into its bootloader. This sequence must be done every time you want to upload firmware to the Cygnet. -
Proceed to the Blink the Onboard LED instructions below.
Blink the Onboard LED
-
In the Arduino IDE, use File > New Sketch to create a new sketch.
-
Overwrite the provided boilerplate code with the following to cause the onboard LED to blink repeatedly:
// the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
-
Use the Upload button to upload this sketch to your Cygnet.
If the Cygnet's LED blinks on and off every second—you're good to go! Follow the next section if you have an STLINK programmer and want to learn about step debugging, or move on to the next steps.
Step Debugging with Arduino IDE
Cygnet supports step debugging with Arduino Native Debugging on Arduino IDE when used with an attached STLINK programmer/debugger.
-
Set one or more breakpoints on your sketch.
-
In the Sketch menu, select Optimize for Debugging.
-
Upload the sketch to Cygnet.
-
Click the Start Debugging button.
-
When a breakpoint is hit, use the Arduino IDE to step through relevant code blocks and inspect variables, view the call stack, and watch expressions.
Next Steps
Congratulations! You've configured your Cygnet and flashed new firmware to it using Arduino IDE.
If you're following the Blues Quickstart, next we recommend building your first IoT app:
Use the Notecard to Send DataSet Up Your Microcontroller- Build Your First IoT App With Blues
- Send Data to Your Cloud
At any time, if you find yourself stuck, please reach out on the community forum.