<commit_before># Bare Metal Hi

A trivial bare metal test app that prints "Hi" to the Uart on the qemu Virtual
Development board for ARM. 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
```
I'm also 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](https://martine.github.io/ninja/) code
is the best approach, but we'll see how it goes.

Currently the set of build systems I'm interested in are:
* [GNU Make](https://www.gnu.org/software/make/) (done)
* [CMake](https://cmake.org) (partially done)
* [Meson](https://mesonbuild.com) (Not workng)
* [Craftr](https://github.com/craftr-build/craftr) (TODO)

There are some prerequisites:
* An arm-eabi cross compiler. (For now see [here](https://github.com/winksaville/sortie-dopsys-myos)
and change 'i586-elf' to 'arm-eabi'). TODO: Create a project to make it easier to create
cross-compilers and also add a gdb.
* Install [Ninja](https://martine.github.io/ninja/)
* Install which ever build system you're interested.

Also, don't hesitate to provide pull requests or fork this project to
do your own exploration.
___
## To build using [GNU Make](https://www.gnu.org/software/make/):
Currently his has a hard coded path [issue #1]](https://github.com/winksaville/baremetal-hi/issues/1) so they'll need to be adjusted manually.
```
make
```
To run using QEMU:
```
make run
```
To exit from QEMU type (ctrl-a) then the letter 'x'
___
## To build using [CMake](https://cmake.org/), which is patterned after [this](http://www.valvers.com/open-software/raspberry-pi/step03-bare-metal-programming-in-c-pt3/):
```
mkdir build-make
cd build-make
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=../toolchain-arm-eabi.cmake ..
ninja
qemu-system-arm -M versatilepb -m 128M --nographic --kernel test.bin
```
Again, to exit from QEMU type (ctrl-a) then the letter 'x'
___
## To use [Meson](https://mesonbuild.com):
Two platforms Posix and Qemu_ARM_VersatilePB

For Posix:
```
mkdir build-meson-posix
cd build-meson-posix
meson -D Platform=Posix ..
ninja
./testit
```
For Qemu_ARM_VersatitlePB
```
mkdir build-meson-versatitlepb
cd build-meson-versatitlepb
meson -D Platform=Qemu_ARM_VersatilePB --cross-file ../arm-eabi-cross_file.txt --buildtype plain ..<commit_msg>Update README.md with meson instructions.<commit_after># Bare Metal Hi

A trivial bare metal test app that prints "Hi" to the Uart on the qemu Virtual
Development board for ARM. 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
```
I'm also 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](https://martine.github.io/ninja/) code
is the best approach, but we'll see how it goes.

Currently the set of build systems I'm interested in are:
* [GNU Make](https://www.gnu.org/software/make/) (done)
* [CMake](https://cmake.org) (partially done)
* [Meson](https://mesonbuild.com) (Not workng)
* [Craftr](https://github.com/craftr-build/craftr) (TODO)

There are some prerequisites:
* An arm-eabi cross compiler. (For now see [here](https://github.com/winksaville/sortie-dopsys-myos)
and change 'i586-elf' to 'arm-eabi'). TODO: Create a project to make it easier to create
cross-compilers and also add a gdb.
* Install [Ninja](https://martine.github.io/ninja/)
* Install which ever build system you're interested.

Also, don't hesitate to provide pull requests or fork this project to
do your own exploration.
___
## To build using [GNU Make](https://www.gnu.org/software/make/):
Currently his has a hard coded path [issue #1]](https://github.com/winksaville/baremetal-hi/issues/1) so they'll need to be adjusted manually.
```
make
```
To run using QEMU:
```
make run
```
To exit from QEMU type (ctrl-a) then the letter 'x'
___
## To build using [CMake](https://cmake.org/), which is patterned after [this](http://www.valvers.com/open-software/raspberry-pi/step03-bare-metal-programming-in-c-pt3/):
```
mkdir build-make
cd build-make
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=../toolchain-arm-eabi.cmake ..
ninja
qemu-system-arm -M versatilepb -m 128M --nographic --kernel test.bin
```
Again, to exit from QEMU type (ctrl-a) then the letter 'x'
___
## To use [Meson](https://mesonbuild.com):
Two platforms Posix and Qemu_ARM_VersatilePB
(Note: The following two changes need to be
applied to meson before this code works:
```
https://github.com/mesonbuild/meson/pull/283
https://github.com/mesonbuild/meson/pull/282
```


To build and run Posix platform:
```
mkdir build-meson-posix
cd build-meson-posix
meson -D Platform=Posix ..
ninja
./testit
```
To build and run for Qemu_ARM_VersatitlePB platform:
```
mkdir build-meson-versatitlepb
cd build-meson-versatitlepb
meson -D Platform=Qemu_ARM_VersatilePB --cross-file ../arm-eabi-cross_file.txt --buildtype plain ..
{'fraction_non_alphanumeric': 0.1269656377402446, 'fraction_numerical': 0.006600660066006601, 'mean_word_length': 4.333333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 24, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5278438', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1691, 'n_words': 584}