Skip to content

husarion/rosbot_ros2_firmware

Repository files navigation

rosbot_ros2_firmware

Micro-ROS powered firmware for STM32F4 microcontroller in ROSbot 2. Embedded, low-level firmware for STM32 microcontroller inside ROSbot. Developed using Mbed Os.

______  _____  _____  _             _           __
| ___ \|  _  |/  ___|| |           | |         / _|
| |_/ /| | | |\ `--. | |__    ___  | |_       | |_ __      __
|    / | | | | `--. \| '_ \  / _ \ | __|      |  _|\ \ /\ / /
| |\ \ \ \_/ //\__/ /| |_) || (_) || |_       | |   \ V  V /
\_| \_| \___/ \____/ |_.__/  \___/  \__|      |_|    \_/\_/

Firmware version:

rosbot_ros2_firmware

Prerequisites

You need to install following tools:

Required Visual Studio Code extensions

Clone the repository

git clone https://github.com/husarion/rosbot_ros2_firmware

Loading dependencies

Unfortunately, PlatformIO has a bug that impacts libraries configuration. We use git submodules instead.

Git submodules https://git-scm.com/book/en/v2/Git-Tools-Submodules

To import dependencies, in project's root directory run command:

git submodule update --init --recursive

Open workspace in Devcontainer

Click the left bottom green button in VS Code and select the Reopen in Container option.

Speed up build process

https://docs.platformio.org/en/latest/frameworks/mbed.html#ignoring-particular-components

In directory ~/.platformio/packages/framework-mbed/features inside the devcontainer create file called .mbedignore with the following content:

cellular/*
cryptocell/*
deprecated_warnings/*
lorawan/*
lwipstack/*
nanostack/*
netsocket/*
nfc/*
unsupported/*

Build firmware

Use PlatformIO: Build task or type

pio run

Uploading firmware

Uploading firmware using ST-Link

Use PlatformIO: Upload task or type

pio run --target upload

Uploading firmware using core2-flasher

You will find firmware.elf in ./pio/build/core2.

To flash firmware using core2-flasher run:

core2-flasher .pio/build/core2/firmware.hex

Uploading firmware using stm32loader

https://github.com/husarion/stm32loader

This tool allows you to upload firmware using RPi connector.

If you have the bootloader the first two sectors are write protected. Before uploading new firmware you must unlock them (this will erase the bootloader):

$ sudo stm32loader -c <your_sbc> -u -W

To upload new firmware run:

$ sudo stm32loader -c <your_sbc> -e -v -w firmware.bin

where <your_sbc> :

  • tinker for Asus Tinker Board
  • upboard for Upboard
  • rpi for Raspberry Pi

You will find firmware.bin in ./pio/build/core2.

Micro-ROS interface

To start Micro-ROS communication run:

docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:humble serial -D <SBC_port_name>  serial -b 576000

<SBC_port_name>:

  • /dev/ttyS1 for Asus Tinker Board,
  • /dev/ttyAMA0 for Raspberry Pi
  • /dev/ttyS4 for UpBoard

The baudrate should be adjusted for SBC you use. The default value for this firmware is 576000.

ROS2 communication

Look ROS_API.md

Development

The easiest way to change the firmware is to work inside a devcontainer. In VSCode use option Reopen in Container from extention:

Creating a release

Release is created automatically after PR with bump command is merged to the master branch. Available bump commands are: bump::major, bump::minor and bump::patch (simply add them to the description of your PR).

Versioning

The project uses SemVer for versioning. For the versions available, see the tags on this repository.

Changelog

See CHANGELOG.md.

Starting with Mbed OS

Documentation:

Important dev links (mbed + platformio)