Welcome to Chopin's homepage!
distortos 0.3.0 released
Written by Freddie Chopin   
Friday, 25 November 2016 21:16

Yesterday I finally completed third version of distortos - a RTOS I've been working on for over 2 years, aimed primarily at C++ enthusiasts. In the most recent version, which supports exactly 302 microcontrollers, there are quite a few new features, most of them probably related to the built-in HAL. The most important changes introduced in this version, in chronological order, are:

  • support for periodic software timers,
  • easy to use serial port driver, operating on hardware exclusively via abstract interface class, with implementations of this interface class for all supported chip families (STM32F0, STM32F1, STM32F4), currently only interrupt-driven,
  • RS-485 bus driver, based on the serial port driver mentioned above,
  • SPI master mode bus driver, also using the hardware only through abstract interface class, obviously with implementations for all supported microcontrollers, also interrupt-driven only,
  • abstract base class for external peripherals connected to SPI bus with first implementation of this interface in the form of driver for popular SPI EEPROMs (Atmel AT25xxx, ON Semiconductor CAT25xxx, ST M95xxx, Microchip 25xxxxx or similar),
  • fixes required by GCC 6, so the most recent bleeding-edge-toolchain (GCC 6.2.0) can be used with no issues,
  • replacement of distortosConfiguration.h generator which used AWK with the one using only shell and sed, so AWK is no longer required by this project.

By the way - I've completely forgot to write about version 0.2.0, which was published long time ago. So while we're at it, I'll briefly mention that the biggest additions in the previous version were support for ARMv6-M architecture (ARM Cortex-M0, ...), STM32F0 and STM32F1 chip families.

Source code packages, most recent API reference and changelog can be obviously found on project's website.

Last Updated on Friday, 25 November 2016 22:06
How does multitasking work?
Written by Freddie Chopin   
Saturday, 12 November 2016 18:29

I would like to invite anyone interested in this subject to read my first article of a real-time operating systems introduction series  - Multitasking explained. This article is about the absolute basics, but you have to start with something, right? (;

EDIT (03.12.2016): After a longer break I've published another article about Task states and transitions between them. This time a bit harder subject, but I really tried to keep the explanation as clear as possible, even for people reading about RTOSes for the first time. I'm not sure whether these efforts were successful or not, but let's hope they were. The frequency of publishing of new articles should now increase a little bit, at least that's my plan.

Last Updated on Saturday, 03 December 2016 20:56
bleeding-edge-toolchain (r)evolution?
Written by Freddie Chopin   
Wednesday, 12 October 2016 12:07

As I grew tired of solving problems caused by bizarre workflow of ARM employees and also realized that solving incompatibilities between various Linux distributions is probably impossible, I decided to make a next step. So I present you a preview of a new all-in-one shell script for toolchain compilation, which is supposed to slightly change current form of bleeding-edge-toolchain.

For now I've tested this script on Linux only (on my PC, on a different machine and in Travis-CI system - Ubuntu 12.04.5 LTS "precise"), but soon I'm going to test it on Windows. It's quite possible that even now this script would work in MSYS2 on Windows, but this was not tried yet. The idea is to stop distributing toolchains for Linux in "binary" form - this script will allow anyone to build the toolchain that will work for sure on given distribution. I know that such compilation doesn't last 30 seconds, but it also doesn't last half a day - in here everything (including download of all sources) took 22 minutes. On very slow Travis-CI virtual system it took 80 minutes. I think such amount of time can be sacrificed once every few months, especially that you can do anything else during the compilation [; If someone wants to make this time much shorter, then just find a line with "--with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r" in the script and remove what you don't use (WARNING - there are two identical lines in the script, they both must stay identical!). Windows versions will most likely be still distributed in "binary" form, as this platform has no such issues with library compatibility.

Anyway - the script generally does everything that is required - it downloads the sources of the toolchain and required libraries in proper versions, extracts them and then configures & compiles each in proper order. This idea is obviously not new and there are many scripts like this one, but all that I know of are either not developed anymore or just not entirely the way they should be. The script should not require anything fancy to work, the standard set present in any Linux distribution should be enough - the only exception are the tools needed to generate documentation ("makeinfo", which usually is a part of a package like "texinfo"). I encourage anyone to try it out, if something doesn't work as expected let me know - either here in the comments or file an issue at GitHub. I'll also be very happy to hear that it is working correctly (;

Current versions of toolchain components are - obviously - most recent (; More recent than in the toolchain from ARM <:

  • gcc-6.2.0 + multilib patch
  • newlib-
  • binutils-2.27
  • gdb-7.12
  • expat-2.2.0
  • gmp-6.1.1
  • isl-0.16
  • libelf-0.8.13
  • mpc-1.0.3
  • mpfr-3.1.5
  • zlib-1.2.8
Last Updated on Friday, 14 October 2016 10:33
First version of distortos published!
Written by Freddie Chopin   
Thursday, 10 March 2016 16:39

Less than two weeks ago, after 584 days since I started working on distortos system, I finally published first version - 0.1.0. List of functionalities included in this release can be found in the change log and packages with source code can be found on http://distortos.org/ in Downloads section. In the same place you can also download packages with project template and example applications that were published on the same day. This second package currently has just the "classic" LED blinker which uses static or dynamic threads. I've even recorded a short video featuring this application (;

As a small incentive - a little bit of "magic" code, which asynchronously calculates result of sine function for four different numbers in four separate threads. It is a complete and working code of application - you don't need to add anything else!

#include "distortos/board/leds.hpp"
#include "distortos/chip/ChipOutputPin.hpp"
#include "distortos/StaticThread.hpp"

void sinWrapper(const double operand, double& result)
  result = sin(operand);

int main()
  const double operands[4] {0.9867816015, 0.4641984149, 0.4665572273, 0.8926178650};
  double results[4] {};
  auto sinThread0 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[0], std::ref(results[0]));
  auto sinThread1 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[1], std::ref(results[1]));
  auto sinThread2 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[2], std::ref(results[2]));
  auto sinThread3 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[3], std::ref(results[3]));

  // do something while the threads are calculating results...

  // make sure the threads are done

  // results are ready!
Last Updated on Thursday, 10 March 2016 17:55
distortos - official website and support for all STM32F4 chips
Written by Freddie Chopin   
Saturday, 26 December 2015 13:57

A few weeks ago distortos project - advanced real-time operating system - got its own website, which is available at http://distortos.org/. For now it contains only a few short news articles, a few useful links and source code documentation generated with doxygen tool, but the amount of useful content will constantly increase.

On the other hand, complete support for all 115 chips from the STM32F4 family was added to the Kconfig configuration system and to the source code of the project. Two more example configurations for popular boards with STM32F4 chips were also added, so there are now three tested, ready to run configurations:

All these configurations run the test application at the max possible system clock frequency. Whole configuration of the clock system frequency and some details from the power system is done with the Kconfig configuration tool, presented on the screenshots below.

Kconfig, STM32F4
Kconfig, STM32F4
Kconfig, STM32F4
Kconfig, STM32F4
Kconfig, STM32F4
Kconfig, STM32F4

The correctness of the selected configuration is verified partly in the Kconfig tool and partly in the source code, using only compile-time methods (static_assert(…) or preprocessor).

Last Updated on Saturday, 26 December 2015 23:47

Page 1 of 10