The Thing
As of an issue-closing commit today, Alpha RTOS has a build process I'm happy to use to develop it with.
Using a CMake project script with an associated toolchain script, I am now able to run compilation of the Alpha kernel in the following environments:
- Xilinx SDK on Windows
- Ubuntu (in the Windows Subsystem for Linux flavor)
I'm sad that Visual Studio 2017 is not on that list, but for some reason CMake refuses to discover the Microsoft compiler.
The Background
In my first ever post, I summarized Alpha Automata's origins, its status at the time, and where I want to develop it into.
Since this project involves VHDL modules, a lot of my development will occur on a Xilinx Zynq SoC. My current priority is to get the Alpha RTOS kernel running, for several reasons:
- I want to deepen my knowledge of real-time operating systems.
- I want to design and implement a somewhat complex, highly modular system that I can be proud of. None of the other Alpha Automata components are nearly as complex as an RTOS.
- A C++Now 2018 talk gave me, for the first time, a good example of how to use CMake toolchain files. This inspired me to lay the groundwork for using CI/CD in Alpha Automata.
- Having a working RTOS makes writing and running test code snippets for every other part of Alpha Automata easier.
The last two bullet points in that list led me to create CMake scripts for Alpha RTOS now, instead of just using projects manually set up in Xilinx SDK and leaving CMake for later.
The CMaking Of
The C++Now 2018 talk showed CMake examples for compiling bare-metal executable images outside of any IDEs. For Alpha RTOS, I want to compile a bare-metal static library in Xilinx SDK. Compiling a static library using Xilinx SDK allows me to skip the tedium of studying the Zynq memory map to create a linker script and trying to figure out how to compile Xilinx libraries that initialize Zynq-specific registers. Using Xilinx SDK forces me to learn how to generate Eclipse projects using CMake.
I welcomed the chance to learn how to generate Eclipse projects using CMake. When I was in Wisconsin Robotics, we created a packet library built using CMake to target Linux and Windows. I wanted the embedded target build system (we used Code Composer Studio at the time) to also use CMake, but we never found the time to make that happen.
The first version of the CMake scripts for Alpha RTOS closely mirror the examples from the C++Now 2018 talk. This was my first attempt at writing a cross-compiling CMake script, and I only wanted to get it to work at all. The first version of these scripts could run compilations targeting the host system, and cross-compile on Linux. However, I couldn't generate an eclipse project using the Eclipse CDT generators provided by CMake. Even if I gave CMake the proper paths to the ARM-target compilers, the CMake Eclipse CDT generators kept making this complaint:
CMake Error: CMake was unable to find a build program corresponding to "Unix
Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a
different build tool.
After some reading and experimentation, I figured out that I needed to point CMake to a proper make
executable. After some more digging around, I found out that Xilinx distributes a bunch of GNU tools, including make
and gcc
, with Xilinx SDK. Armed with this new knowledge, I made improvements to the Alpha RTOS CMake scripts. They toolchain script now makes use of the tools distributed by Xilinx when given a Xilinx SDK version and the Xilinx SDK installation directory.
This generated Eclipse project files that I could import into Xilinx SDK, but for some weird reason, the project wouldn't compile. The compiler kept complaining about not being able to find any of the #include
files. I scoured the Internet for answers, but found none. Finally, I took the compile command from the SDK console and tried playing around with it in PowerShell. It took me less than ten minutes to figure out what hours of Google searching couldn't tell me: the GCC version distributed by Xilinx doesn't process -I
include paths that have ..
in them.
Running gcc
with this flag works:
-IC:/SVC/AlphaAutomata/AlphaRTOS/api
Running gcc
with this flag fails:
-IC:/SVC/AlphaAutomata/AlphaRTOS/build/../api
My CMake script set parent directories using set
and the ..
special directory:
set(PARENT_DIR ${CURRENT_DIR}/..)
Using get_filename_component
fixed my problem:
get_filename_component(PARENT_DIR ${CURRENT_DIR} DIRECTORY)
With this fix in the [latest version], I can now run compilation using a Xilinx SDK project generated using CMake.
The State of Alpha
Since last month, not much has changed. I've defined the Alpha RTOS API and internal architecture some more, but the kernel is nowhere near a usable state. Now that the CMake scripts are working, I hope to make faster progress.
Onwards and Upwards
I will continue working on Alpha RTOS to get the kernel running and solidify the API.
I made a promise to post on Dev every Wednesday, but the last time I posted was a month ago. I can't stick to a weekly schedule because of work and other life pressures, but I will try really hard to post every two weeks.
Top comments (0)