This code is a simple Calculator example generated from an ANSYS Model Based Engineering model. The tool auto-generated this code, which then had the build file modified to allow building this with RTEMS.
See source Teams Document. This example is how to build a simple Calculator Example (source provided) and run it in RTEMS 5 within QEMU. This uses the Realview-PBX-A9 BSP which is an ARM architecture that RTEMS specifically notes is suitable for QEMU. This assumes an Ubuntu installation. This attempts to provide instructions for all necessary dependencies, though it is not guaranteed considering how many things have been installed prior to this example.
This uses the RTEMS Quick Start guide as a basis:
- First install QEMU, this can be done from the terminal with:
sudo apt-get install qemu-system
- Then install the following dependencies (these may not all be necessary, but they are ones I installed over time from tutorials such as this and the first several are likely already installed with your Ubuntu)
sudo apt-get install build-essential
sudo apt-get install git
sudo apt-get install python-dev
sudo apt-get install pax
sudo apt-get build-dep binutils gcc g++ gdb unzip git python2.7-dev pax
- To use “build-dep” in Ubuntu for the first time you need to add source repositories to the install list.
- Open “Software & Updates” and check “Source code”
- Then Close and in the terminal run
sudo apt update
- And then try the build-dep command above again
- This example uses the released builds of RTEMs rather than the Git repo, see 2.3.1 in RTEMS documentation. Theses acquire the released builds of the RTEMS Source Builder tool and the RTEMS Kernel Source
mkdir -p $HOME/quick-start/src
cd $HOME/quick-start/src
curl https://ftp.rtems.org/pub/rtems/releases/5/5.1/sources/rtems-source-builder-5.1.tar.xz | tar xJf -
cd $HOME/quick-start/src
mv rtems-source-builder-5.1 rsb
cd $HOME/quick-start/src
curl https://ftp.rtems.org/pub/rtems/releases/5/5.1/sources/rtems-5.1.tar.xz | tar xJf -
- Next is to build/install the toolchain following section 2.4.
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --prefix=$HOME/quick-start/rtems/5 5/rtems-arm
- This may take awhile to run (10min-3hr depending on your machine and if you’ve run source builder before)
- Check your install and version with
$HOME/quick-start/rtems/5/bin/arm-rtems5-gcc –version
- Next is to Build and Install a BSP (Realview-PBX-A9), per section 2.5.1
../source-builder/sb-set-builder --prefix=$HOME/quick-start/rtems/5 \ --target=arm-rtems5 --with-rtems-bsp=realview_pbx_a9_qemu --with-rtems-tests=yes 5/rtems-kernel
-
In the Git Repo main directory ($GIT_REPO), execute the following:
./waf configure --rtems=$HOME/quick-start/rtems/5 --rtems-bsp=arm/realview_pbx_a9_qemu
-
Then compile with:
./waf
-
The compile application has now been placed in
$GIT_REPO/build/arm-rtems5-realview_pbx_a9_qemu/rtems
-
To run the application using QEMU:
export QEMU_AUDIO_DRV="none"
qemu-system-arm -net none -no-reboot -nographic -M realview-pbx-a9 -m 256M -kernel $GIT_REPO/build/arm-rtems5-realview_pbx_a9_qemu/rtems/calc.exe
- This branch is setup to use the Robot Test Framework for testing which first needs installed
(Assuming Python 3 is already installed)
pip3 install robotframework
pip3 install docutils
- Due to how pipeline runs are setup for this, Robot is looking for
calc.exe
in the top level folder. Either copybuild/arm-rtems6-realview_pbx_a9_qemu/rtems/calc.exe
to the top level Calculator folder or intestScripts/CaluclatorLibrary.py
change this lineqemu_cmd = shlex.split("qemu-system-arm -net none -no-reboot -nographic -monitor none -serial stdio -M realview-pbx-a9 -m 256M -kernel calc.exe")
to have the full path to thecalc.exe
file. - In the main Calculator folder execute
robot testScripts/keyword_driven.robot
This will run 7 basic test cases (4P/3F) and report the results to the command line. Test details can be viewed by openinglog.html
- To execute all Robot tests in the folder run
robot testScripts/.
- For Data Driven tests, first run
pip3 install --upgrade robotframework-datadriver
robot testScripts/data_driver.robot
This will execute a test that reads in a CSV of expressions to testdata_driver.csv
Expressions can be entered on a new line with the first entry being the input expression then the expected output. - To generate XUnit XML output in results.xml, run
robot --xunit results testScripts/.
- More tests and development is in work on this testing framework
TODO: Explain how other users and developers can contribute to make your code better.
To generate Robot Custom Library documentation:
python3 -m robot.libdoc testScripts/CalculatorLibrary.py Calc_Lib.html
To generate HTML documentation on Test Cases:
python3 -m robot.testdoc testScripts/*.robot test_Doc.html
If you want to learn more about creating good readme files then refer the following guidelines. You can also seek inspiration from the below readme files: