Skip to content

winksaville/baremetal-hi

Repository files navigation

Baremetal Hi Build Status

A trivial baremetal test app that prints "Hi" to the Uart on the qemu Virtual Development board for ARM. For some build systems there are two targets. BmArm builds the arm image to be run on qemu and the Posix target. For BmArm the resulting runnable output is "test.bin" and can be tested by running with qemu-system-arm:

qemu-system-arm -M versatilepb -m 128M -nographic -kernel test.bin

Or with run-BmArm target.

For Posix the resulting runnable output is "test". It can be built using the Posix target and run with the run-Posix target. Not available using all build systems.

I'm exploring various build systems as I'm trying to decide which to use as my preferred build system in the future. At the moment I feel using a meta-build system which generates Ninja code is the best approach, but we'll see how it goes.

Currently the set of build systems I'm interested in are:

There are some prerequisites: I've created some python scripts to build some of the prerequisites. These tools are also used to install them on travis-ci.org for "testing":

  • tools/ninja-install.py
  • tools/binutils-install.py
  • tools/qemu-install.py
  • tools/gcc-install.py
  • Install which ever build system you're interested.

Don't hesitate to provide pull requests or fork this project to do your own exploration.

To use GNU Make:

mkdir build-makefile
cd build-makefile
make -f ../Makefile Posix

To run posix app:

make run-Posix

To build and run the arm version using qemu:

make run-BmArm

You can also split into two above steps "make BmArm && make run-BmArm"

To use kati

Kati is interesting in that it uses GNU Makefiles as its input source and internally generates ninja code.

mkdir build-kati
cd build-kati
kati -f ../Makefile Posix
kati -f ../Makefile run-Posix

To have kati generate build.ninja and use ninja:

kati --ninja -f ../Makefile
ninja run-Posix
ninja run-BmArm

To use CMake, based on this:

mkdir build-cmake-ninja
cd build-cmake-ninja
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=../toolchain-arm-eabi.cmake ..
ninja
ninja run

For unix Makefile you can use the run target which doesn't work for ninja

mkdir build-cmake-make
cd build-cmake-make
cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../toolchain-arm-eabi.cmake ..
make
make run

To use Meson:

The build.meson file supports two platforms, Posix and BmArm. The BmArm causes test.c to assume a Qemu VersatilePB platform.

To build and run Posix platform:

mkdir build-meson-posix
cd build-meson-posix
meson -D Platform=Posix ..
ninja
ninja run

To build and run for BmArm platform:

mkdir build-meson-bmarm
cd build-meson-bmarm
meson -D Platform=BmArm --cross-file ../arm-eabi-cross_file.txt --buildtype plain ..
ninja
ninja run

To use Craftr:

To build and emulate for arm-eabi:

mkdir build-craftr && cd build-craftr
craftr -ebp .. run

You can also use the build.ninja directly (Also tab completion works for ninja):

craftr -ep ..
ninja -t clean
ninja baremetal_hi.run

About

A trivial baremetal app that prints "Hi".

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published