[LINUX] Build TOPPERS / ASP3 and try it


It was announced on December 25, 2019 in the topics of the TOPPERS project that a simple package for the ** TOPPERS / ASP3 ** kernel for Nucleo F401RE was released. Previously, " Build and run TOPPERS / ASP (https://qiita.com/Yukiya_Ishioka/items/ 9ecbe080939600c323c6) ”, I wrote an article to build ** RTOS ** called ** TOPPERS / ASP ** and run it on the microcomputer board, but this time I wrote ** TOPPERS / ASP3 ** which is the TOPPERS 3rd generation kernel. As with the last time, we have summarized the method for building from source in the Linux environment so that it will work on the ** NUCLEO-F401RE ** microcomputer board. Most of the Linux environment can use the previous environment, so only the changes from that are described.

What is TOPPERS / ASP3?

** TOPPERS / ASP3 ** is a TOPPERS project (TOPPERS: ** T ** oyohashi ** OP ** en ** P ** platform for ** E ** mbedded ** R ** eal-time ** S ** ystems) is one of the ITRON-specification RTOS managed and published. This is an extension / improvement of the TOPPERS / ASP kernel, and is the TOPPERS 3rd generation kernel. The main changes from ** TOPPERS / ASP ** are as follows.

・ Added functions Tickless high resolution time management External time synchronization function Task end request function ・ Deleted functions Task exception handling function Mailbox function

In my opinion, "tickless high-resolution time management" is a major feature, which reduces unnecessary kernel operation and enables fine time control. It seems that we can expect the implementation of power saving functions and the improvement of real-time performance when using a high-speed microcomputer. For details on ** TOPPERS **, ** TOPPERS Project **, and ** TOPPERS / ASP3 **, refer to the following pages.

・ TOPPERS page  https://www.toppers.jp/ ・ TOPPERS project page  https://www.toppers.jp/project.html ・ TOPPERS / ASP3 kernel page  https://www.toppers.jp/asp3-kernel.html

Preparation for running TOPPERS / ASP3

1. 1. Let's prepare a microcomputer board

This time as well, ** TOPPERS / ASP3 ** will be operated using a microcomputer board called ** NUCLEO-F401RE ** released by ** STMicroelectronics ** (hereinafter, ** STMicro **). https://www.st.com/ja/evaluation-tools/nucleo-f401re.html

** NUCLEO-F401RE ** is a board using ARM's Cortex-M4 core microcomputer. If you answer the questionnaire at the STMicro booth at an exhibition for embedded devices, you can get it for free, or you can purchase it at a store that handles electronic components as shown on the page below. http://akizukidenshi.com/catalog/g/gM-07723/

2. Get the source file

You can get the source file of ** TOPPERS / ASP3 ** from the following page. https://www.toppers.jp/asp3-e-download.html#nucleo

TOPPERS / ASP kernels are usually provided in two parts, ** target-independent part ** and ** target-dependent part **, but this time ** non-target part for ** NUCLEO-F401RE ** A ** simple package ** that combines the dependent part ** and the ** target dependent part ** is provided in the following ZIP file.  https://www.toppers.jp/download.cgi/asp3_nucleo_f401re_gcc-20191220.zip

Also, ** TOPPERS / ASP3 ** builds require ** Configurator ** and ** TECS Generator **, which are also included in the ** Simple Package ** above.

3. 3. Let's prepare the build environment (1)

We will build ** TOPPERS / ASP3 ** in a Linux environment, but this time we will use the environment used in the previous build of ** TOPPERS / ASP **. If you do not have a ** TOPPERS / ASP ** build environment, please refer to the following page.

Build TOPPERS / ASP and try it https://qiita.com/Yukiya_Ishioka/items/9ecbe080939600c323c6

4. Let's prepare the build environment (2)

I thought it would be easy to build ** TOPPERS / ASP3 ** using the ** TOPPERS / ASP ** build environment, but to run the ** configurator ** and ** TECS generator ** ** I found that I needed Ruby **. By the way, I remembered that I had given up trying to build ** TOPPERS / ASP3 ** because I knew I needed Ruby. The ** ubuntu ** I used doesn't include ** Ruby **, but this time I'll try to install it. Even if you try, you can find it immediately by searching for "ubuntu", "Ruby", "Install" ... The procedure performed is described below.

  1. Installation of required packages  sudo apt-get install rbenv ruby-build

  2. Make rbenv available in bash  echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

  3. Check the installable Ruby version  rbenv install --list

  1. Install Ruby by specifying the version  rbenv install 2.1.0

The version of Ruby to be installed was "2.0.0" in ** doc / user.txt ** in the source of ** TOPPERS / ASP3 **, but it is not in the installable version. So I specified "2.1.0". However, when I checked the version after installation, another version was installed. As a result, the build of ** TOPPERS / ASP3 ** is completed, so you can proceed without worrying about it.

$ ruby --version
ruby 2.3.1p112 (2016-04-26) [i386-linux-gnu]

TOPPERS / ASP build preparation

1. 1. Deploying TOPPERS / ASP kernel sources

Extract the TOPPERS / ASP3 kernel source file ** asp3_nucleo_f401re_gcc-20191220.zip ** to any directory.

unzip asp3_nucleo_f401re_gcc-20191220.zip

When expanded, the ** asp3_3.5 ** directory will be created, and the directory structure under it will be as follows.

└ asp3_3.5
    ├── arch
    ├── cfg
    ├── doc
    ├── extension
    ├── include
    ├── kernel
    ├── library
    ├── sample
    ├── syssvc
    ├── target
    │   ├── dummy_gcc
    │   └── nucleo_f401re_gcc
    ├── tecs_kernel
    ├── tecsgen
    ├── test
    └── utils

2. Creating a directory for building applications

Go back to the directory one level above the ** asp3_3.5 ** directory and create the application directory and the application build directory. Here, it is ** appli **, but you can give it any directory name.

cd ..
mdir -p appli/obj
├─ asp3_3.5
│   ├─arch
│   :
└─ appli ← Application directory
└─ obj ← Application build directory

3. 3. Copy of sample application

Copy the sample application source code included in ** TOPPERS / ASP3 ** to the ** appli ** directory. If you just want to check the operation, you do not need to copy it, but you can see the operation while modifying it, and it will be the base of the user program, so copy it.

cd appli
/bin/cp -a ../asp3_3.5/sample .

4. TOPPERS / ASP3 kernel configuration

Then go to the ** appli / obj ** directory and configure the kernel. The meanings of the options of the configure command are as follows. -T: Target selection This time it is for ** NUCLEO-F401RE **, so set ** nucleo_f401re_gcc **

cd appli/obj
../../asp3_3.5/configure.rb -T nucleo_f401re_gcc

5. Modify Makefile

If the kernel is successfully configured, an appli / obj / Makefile will be generated. Check the definition on line 51 of the generated Makefile.

TARGET = nucleo_f401re_gcc

Add ** $ (OBJNAME) .bin ** on line 435 so that the build-generated code file contains the binary file.

    430 #
    431 #Error check processing
    432 #
    433 .PHONY: check
    434 check: check.timestamp ;
    435 check.timestamp: cfg2_out.db $(OBJNAME).syms $(OBJNAME).srec $(OBJNAME).bin
    436         $(CFG) --pass 3 $(CFG_KERNEL) -O $(INCLUDES) -T $(TARGET_CHECK_TRB) \
    437                                 --rom-symbol $(OBJNAME).syms --rom-image $(OBJNAME).srec
    438         @echo "configuration check passed"

To change the path specification of the sample application program, modify and add the contents of the APPLDIRS definition on line 181 as shown by the star below.

    177 #
    178 #Definition of application program
    179 #
★  180 APPLNAME = sample1
★  181 #APPLDIRS = $(SRCDIR)/sample
    182 APPLDIRS = ../sample

TOPPERS / ASP build execution

Run the make command in the ** appli / obj ** directory. If the build is successful, the files necessary for executing TOPPERS / ASP3 such as asp.bin will be generated.

$ ll asp*
-rwxrwxr-x 1 ubuntu ubuntu 510968 January 13 17:59 asp*
-rwxrwxr-x 1 ubuntu ubuntu 26944 January 13 17:59 asp.bin*
-rwxrwxr-x 1 ubuntu ubuntu 80892 January 13 17:59 asp.srec*
-rw-rw-r--1 ubuntu ubuntu 10441 January 13 17:59 asp.syms

Run on a microcomputer board

1. 1. Write to the microcomputer

Connect the NUCLEO-F401RE board to your PC via USB. When connected, it will be recognized as mass storage by the PC, and you can copy files with Explorer. Next, copy the asp.bin file generated by the build on Ubuntu to the NUCLEO-F401RE board via Explorer. When the copy is completed, writing to the board is completed.

2. Execute

After installing the STMicro driver, the USB on the NUCLEO-F401RE board will also be recognized as a virtual COM port. When you start up serial terminal software such as TeraTerm and connect the COM port of the NUCLEO-F401RE board at ** 115200bps **, the log information output by the TOPPERS / ASP kernel is displayed on the serial terminal software, and on the NUCLEO-F401RE board. You can confirm that the TOPPERS / ASP3 kernel and the sample program are working.

TOPPERS/ASP3 Kernel Release 3.5.0 for NUCLEO(STM32F401RE:ARM Cortex-M4) (Jan 13 2020, 18:20:43)
Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
                            Toyohashi Univ. of Technology, JAPAN
Copyright (C) 2004-2019 by Embedded and Real-Time Systems Laboratory
            Graduate School of Information Science, Nagoya Univ., JAPAN

System logging task is started.
Sample program starts (exinf = 0).
task1 is running (001).   |
task1 is running (002).   |
task1 is running (003).   |

When executed by the above operation, appli / sample / sample1.c is built and executed as a user program. The comment in sample1.c states as follows. When you enter characters, you can check the operation that matches the character code in the log output. You can also run your own program by referring to this source code. Try it with Iloilo.

 *  '1' :Switch the target task to TASK1 (initial setting).
 *  '2' :Switch the target task to TASK2.
 *  '3' :Switch the target task to TASK3.
 *  'a' :Act the target task_It is started by tsk.
 *  'A' :Can launch request for target task_Cancel by act.
 *  'e' :Ext to the target task_Call tsk and terminate it.
 *  't' :Target task ter_Forced termination by tsk.
 *  '>' :HIGH the priority of the target task_Set to PRIORITY.
 *  '=' :MID the priority of the target task_Set to PRIORITY.
 *  '<' :LOW priority of target task_Set to PRIORITY.
 *  'G' :Get the priority of the target task_Read with pri.
 *  's' :Slp to the target task_Call tsk and wait for it to wake up.
 *  'S' :Tslp for the target task_tsk(10 seconds)Is called and waits for waking up.
 *  'w' :Wup the target task_Get up by tsk.
 *  'W' :Can wake up request for target task_Cancel with wup.
 *  'l' :Rell the target task_Forcibly cancel the wait by wai.
 *  'u' :Sus the target task_Forced to wait by tsk.
 *  'm' :Forced wait status of target task is rsm_Release with tsk.
 *  'd' :Dly to the target task_tsk(10 seconds)Is called and waits for the passage of time.
 *  'x' :Ras for target task_Request the end by ter.
 *  'y' :Dis to the target task_Call ter and prohibit task termination.
 *  'Y' :Target task ena_Call ter and allow the task to end.
 *Rotate the dequeue.
 *  'c' :Start the operation of the periodic handler.
 *  'C' :Stop the operation of the periodic handler.
 *  'b' :Start the operation so that the alarm handler is activated after 5 seconds.
 *  'B' :Stop the alarm handler.
 *  'z' :Generates a CPU exception for the target task (it can be returned depending on the target).
 *  'Z' :Generates a CPU exception for the target task in the CPU locked state (cannot return).
 *  'V' :With a short loop in between, fch_Read the high resolution timer twice with hrt.
 *  'v' :Display the issued system call (default).
 *  'q' :Do not display the issued system call.


The behavior of the sample application sample1.c is the same for ** TOPPERS / ASP3 ** as for ** TOPPERS / ASP **, so you can't tell the difference except for the message at startup. However, if you look at the contents of sample1.c and sample1.cfg, you can see that it is an ASP3 kernel because the time is specified in microseconds.


    188       case 'S':
    189           syslog(LOG_INFO, "#%d#tslp_tsk(10000000)", tskno);
    190           SVC_PERROR(tslp_tsk(10000000));
    191           break;
    192       case 'd':
    193           syslog(LOG_INFO, "#%d#dly_tsk(10000000)", tskno);
    194           SVC_PERROR(dly_tsk(10000000));
    195           break;


     14 CRE_CYC(CYCHDR1, { TA_NULL, { TNFY_HANDLER, 0, cyclic_handler }, 2000000, 0 });

Based on sample1.c, you can try switching tasks, replacing periodic handlers, alarm handlers, etc. with your own program. Also, the TOPPERS / ASP kernel can be run on the same board, so it is possible to compare the differences on the actual machine. If you build or build the environment so far, why not try various things?

Recommended Posts

Build TOPPERS / ASP3 and try it
Build and run TOPPERS / ASP (2020-03-10 version)
Try using tensorflow ① Build python environment and introduce tensorflow
Let's make a Makefile and build it (super beginner)
Install selenium on Mac and try it with python
Try to make it using GUI and PyQt in Python
Try Caffe and Pylearn2 together
Try using pytest-Overview and Samples-
Build and try an OpenCV & Python environment in minutes using Docker