The first step is to install prerequisites for RT-Thread. You may have noticed that there is a RTOS running. It is RT-Thread, a burgeoning RTOS in China.
The command line interface is really convenient when debugging on STM32, so that I can train ANN interactively. Another reason I choose RT-Thread is the large quantity of MCUs it supports. Now it supports nearly 100 MCUs, which means I can run my program on all of these MCU without extra work. This is a real good news for benchmark purpose.
As you can see, I can choose different types of MCUs and trim the Kernel as needed with KConfig. If you have used buildroot to compile Linux Kernel and build root file system before, you'll find the GUI really handy. My program has been released as an online package on the platform of RT-Thread.
You can download all the tools required here https://www.rt-thread.org/page/download.html
If you are using Windows, please download RT-Thread Env tools first (built-in with all the tools you need) : https://pan.baidu.com/s/1cg28rk
If you are using Linux, such as Ubuntu, make sure you have Scons and cross-compile tools installed.
Finally for both Windows and Linux, clone the source code of RT-Thread, and we're ready to go.
git clone https://github.com/RT-Thread/rt-thread
2Install package libann
The following instructions is based on STM32F103RCT6, but should work for all MCUs RT-Thread supports.
If you are using Windows, simply dive into the directory rt-thread\bsp\stm32\stm32f103-atk-nano and right click ConEmu here, then type menuconfig, you should see configuration menu on the first step.
If you are using Linux,
$ cd rt-thread\bsp\stm32\stm32f103-atk-nano rt-thread\bsp\stm32\stm32f103-atk-nano$ scons --menuconfig
Now here's the configuration menu, you can use Arrow to navigate and Space to select/deselect
Remember use Space to select, let's navigate to,:
RT-Thread online Packages --> miscellaneous packages ---> [*] libann: a light-weight ANN library, capable of training, saving and loading models. ---> [*] Iris load model from flash and predict example [ ] Iris train model and predict example [ ] Iris load model and predict example
You may try the last two examples if you have a SD card on your board, but as for now, I'll choose the first one only that loads dataset from FLASH. Now, it's time to compile.
If you are using Windows:
# Make sure you are in the directory rt-thread\bsp\stm32\stm32f103-atk-nano $ pkgs --update $ scons # If you prefer use Keil MDK5 to compile # pkgs --update # scons --target=mdk5 -s # scons
If you are using Linux:
# Make sure you are in the directory rt-thread\bsp\stm32\stm32f103-atk-nano # You may need to modify rtconfig.py if Python failed to find your cross-compiler $ source ~/.env/env.sh $ pkgs --update $ scons
Upload compiled firmware onto your board, open UART1 at baudrate 115200, you should see the command line interface.
Simply type in:
msh /> iris_train_and_predict_flash
You should see STM32 training: