Giter Club home page Giter Club logo

baremetal-os's Introduction

BareMetal OS is an exokernel-based operating system crafted entirely in x86-64 assembly and is designed to provide unparalleled levels of flexibility and efficiency. By exposing hardware resources directly to applications, it empowers developers to finely tune and optimize their software for specific tasks. With the exokernel's minimalist design, it minimizes the overhead imposed by traditional operating systems, enabling applications to achieve peak performance. Its x86-64 assembly implementation speaks to its commitment to squeezing every ounce of performance from the hardware, making it a compelling choice for those who demand the utmost control and efficiency from their computing environments.

Note

BareMetal OS is under active development. Some physical hardware configurations may not work correctly.

Table of Contents

Prerequisites

The script in this repo depends on a Debian-based Linux system like Ubuntu or Elementary. macOS is also supported to build and test the OS, as well as the Assembly applications, if you are using Homebrew.

  • NASM - Assembly compiler to build the loader and kernel, as well as the apps written in Assembly.
  • QEMU - Computer emulator if you plan on running the OS for quick testing.
  • GCC - C compiler for building C/C++ applications.
  • Git - Version control software for pulling the source code from GitHub.
  • mtools - Utilities to access DOS (FAT32) disk images in Unix.

In Linux this can be completed with the following command:

sudo apt install nasm qemu-system-x86 gcc git mtools

In macOS via Homebrew this can be completed with the following command:

brew install nasm qemu gcc git mtools

Components

BareMetal OS consists of several different projects:

Supported Hardware

  • CPU
    • Multi-core on 64-bit x86 systems (Intel/AMD)
  • Bus
    • PCIe
    • PCI
  • Network
    • e1000 / e1000e
  • Storage
    • NVMe
    • AHCI (SATA)
    • IDE
    • Virtio-Blk

Initial configuration

git clone https://github.com/ReturnInfinity/BareMetal-OS.git
cd BareMetal-OS
./baremetal.sh setup

baremetal.sh setup automatically runs the build and install functions. Once the setup is complete you can execute baremetal.sh run to verify that everything installed correctly.

Building

./baremetal.sh build

Installing

Installing the system

./baremetal.sh install

This command installs the boot sector, loader (Pure64), kernel, and simple command line interface (Monitor) to the disk image. If you want to attach your own binary to the end of the kernel you can use ./baremetal.sh install mybinary.bin

Installing the demos

./baremetal.sh demos

This command installs the demo programs to the disk image.

Running on a virtual system

QEMU

./baremetal.sh run

QEMU via UEFI

./baremetal.sh run-uefi

QEMU - Second Instance

./baremetal.sh run-2

Running a cloned second instance is useful for testing network connectivity between QEMU systems.

VMware

./baremetal.sh vmdk

VirtualBox

./baremetal.sh vdi

The VDI script rewrites the disk ID of the VDI file to avoid the disk warning in VirtualBox.

Bochs

bochs -f bochs.cfg

Notes:

  • The bochs.cfg file may need to be adjusted for your usage. It was created for a Linux-based system.
  • display_libary is set to use x for X Windows with the GUI Debugger by default. On macOS or Windows you will need to use sdl2 with no additional options.
  • The file paths for romimage and vgaromimage will need to be updated if the Bochs BIOS files are in a different location.

Running on a physical system

Important

Booting from a USB drive should work but BareMetal does not have a USB storage driver so you will not be able to load any programs after the command line interface comes up.

Caution

Doublecheck that you are writing the disk image to the correct disk

dd if=baremetal_os.img of=/dev/sdc

Once the disk image is written you can install the disk in the system and boot from it.

// EOF

baremetal-os's People

Contributors

coditva avatar gil0mendes avatar giulioz avatar ianseyler avatar not-nik avatar scherrey avatar tay10r avatar vilhelmgray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

baremetal-os's Issues

Support for imgui/opengl

A wonderful improvement for BareMetal-OS would be to be able to launch ImGui apps.
This would require OpenGL v2 or v3 to be present.

Some info about ImGui:

Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).

Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine

I believe that no-dependencies, lightweightness and cool looks would be its great advantages.

Error in build.sh

Hi,

When I run:

$ ./setup.sh
Pulling code from GitHub...
Creating disk image...
Building src/Pure64...
Building src/BareMetal...
Building src/BareMetal-Monitor...
Building src/BMFS...
Building OS image...
Done!

$ ./build.sh
Building src/Pure64...
Building src/BareMetal...
Building src/BareMetal-Monitor...
Building src/BMFS...
mkdir: cannot create directory β€˜bin’: File exists

[... add a new b_output() call to BareMetal-OS/src/BareMetal-Demo/src/helloc.c before the 'Hello, world!' b_output() call for testing purposes ...]

$ ./install-demos.sh
Error: File already exists.
Error: File already exists.
Error: File already exists.
Error: File already exists.
Error: File already exists.

$ ./run.sh

load
Enter file number: 4
exec
Hello, world!

This is what I see - the b_output() call which should have come before the 'Hello, world!' print isn't there. I can't tell if helloc.c is being rebuilt or not, but it also(?) looks like install-demos.sh isn't overwriting the old demo files on the BMFS image or rebuilding the whole disk image from scratch, depending on what is necessary.

run.sh does not boot properly

I'm not very familiar with bare metal but it is displaying some weird characters on top right and nothing else.

Am I doing something wrong?

I'm using;

./build.sh ./install.sh ./run.sh

after setup.

setup.sh fails on Linux

Pulling code from GitHub...
Creating disk image...
monitor.asm:154: error: symbol `b_disk_read' not defined
monitor.asm:211: error: symbol `b_disk_read' not defined
monitor.asm:225: error: symbol `b_disk_read' not defined
Building src/Pure64...
Building src/BareMetal...
Building src/BareMetal-Monitor...
monitor.asm:154: error: symbol `b_disk_read' not defined
monitor.asm:211: error: symbol `b_disk_read' not defined
monitor.asm:225: error: symbol `b_disk_read' not defined
./setup.sh: 33: ./bmfs: not found
Building OS image...
cat: pure64.sys: No such file or directory
cat: kernel.sys: No such file or directory
cat: monitor.bin: No such file or directory
Done!

on Ubuntu 22.04.01 LTS, Linux 5.15.0-53-generic (x86_64)

Travis CI

I think this project should have a Travis CI account. We could use it to deploy disk images every time a release is published on GitHub.

The tutorial is here.

@IanSeyler if you active the repository in Travis CI then I can set the rest of it up.

And while I don't think that the project is currently ready for a release, the service is also useful for testing the project in a sandbox environment. Travis CI will build the project every time a set of commits is pushed to GitHub. It will send an alert via email if this build fails.

Cannot run newlib test app

After building the test app with newlib, I'm copying it into output/apps and run;

cd output
bin/bmfs baremetal-os.img create test.app 2
bin/bmfs baremetal-os.img write test.app "apps/test.app"
cd ..
./run.sh

Then I enter test.app and qemu system hangs. I'm not sure what is going on.

newlib.sh refers to missing legacy repo

newlib.sh refers to src/BareMetal-OS directory, which does not exist after setup.sh is run.

Examination made determined this is now actually the BareMetal-OS-legacy repo, which also is not installed by setup.sh.

It appears manually doing the git clone of the legacy repo, into the src dir, and renaming to BareMetal-OS is required, as other scripts still refer to it under the name which is now for the scripts repo.

Should this script be removed and be replaced by git cloning BareMetal-newlib instead?

"No filesystem detected" after setting up and running

I'm getting "No filesystem detected" after running commands like dir, load, etc.

Here's the complete command history:

$ git clone https://github.com/ReturnInfinity/BareMetal-OS.git
$ cd BareMetal-OS/
$ ./baremetal.sh setup
Pulling code from GitHub...
Downloading UEFI firmware...
Creating disk images...
Preparing dependancies...
Building src/Pure64...
Building src/BareMetal...
Building src/BareMetal-Monitor...
Building src/BMFS...
Building src/BareMetal-Demo...
Building OS image...
Done!
$ ./baremetal.sh run
Starting QEMU...

Right after, the QEMU window shows up with the OS loaded. I can type things into the prompt and so on.
Here's the result after executing dir:
Screenshot_20240513_001402

Any steps I might be missing in the setup?

How to load BareMetal-OS onto a device.

Hello there. I am wondering if one could explain briefly some inexpensive devices that could be used to install BareMetal-OS from scratch. I understand you can use QEMU or VirtualBox to emulate a blank slate (though I am not sure how that works, I have only used VirtualBox for Linux virtualization on a Mac), and install BareMetal-OS on that from scratch (need to learn more how this works because I still don't see how the boot process works if there is no operating system in place).

But in addition to the emulators, I am wondering if there are actual hardware devices that you can use that don't have any operating systems installed that you can try this out on. I have seen that you can use a RaspberryPI, one of the few bare-metal devices I've come across. Actually, I can't think of anything other than the RaspberryPI as a bare-metal device. But that is ARM, whereas BareMetal-kernel only currently has implemented x86-64. Wondering how you actually can test that out on a real device, I haven't seen any bare-metal x86-64 devices. A quick more recent search brings up this which points to minnowboard (currently unavailable on Amazon), but have to look more around for other x86 stuff. It seems that you have to buy a Dell laptop with Windows preinstalled, and somehow uninstall Windows. Or maybe there is a ChromeBook way. If that's the case, would love to know how that works to get initialized with an x86-64 bare-metal machine.

Anyway, thank you for your help. Looking forward to trying this out on a real device.

app.sh needs update

app.sh also refers to non-existent ./src/BareMetal-OS/programs directory, which is only found in the BareMetal-OS-legacy repo.

ld errors

Trying to link xxd.c, ld spits out this error:
xxd.c:(.text+0x2fb): undefined reference to '__stack_chk_fail'
quick google said that it's a stack protector, -fno-stack-protector solves it
Is it okay to use this linker flag?

Using Git Submodules

It may be useful to use Git Submodules instead of downloading the repositories via a script. This way, we can ditch setup.sh and setupt.bat entirely. Instead, you just use git submodule update --init --recursive. You can continue to make new commits in the submodules, and push them using git push origin HEAD:master.

How do I boot it on to a machine from a bootable usb?

I am quite a noob into bare metal, I want to explore baremetal os, first thing I want to do is to be able to boot it into a machine from a bootable usb, I feel like I am lost completely, any help is appreciated.

After using setup install run. bat scripts from site no boot with qemu

Hi i just downloaded Baremetal-Os install scripts run the scripts on Windows (.bat) files.
Setup.bat
install.bat
run.bat
Everything compiled ok and Bmfs image generated ok.
I type Run.bat -> qemu starts but is having boot problems with the hdd - is looping somehow.

If i change in install.bat lines to
copy /b ".\bin\bmfs_mbr.sys" + ".\bin\pure64.sys" ".\bin\software.sys"
call ".\bin\BMFS\src\bmfs.exe" "bin\bmfs.image" initialize 128M "bin\software.sys"

recompile and then run again to boot with qemux64 and i get the message BMFS v1.0 - error
something is wrong with image or boot binary check ... Can you please help me on this ..i can't boot Baremetal using Qemu on win 64

Cheers,
Alex

setup.sh cp command fails on macOS

It appears to be back again. I did a fresh git clone today, ran setup.sh, and:

Entering /Users/paul/dev/BareMetal-OS/src/BMFS/utils
 CC      /Users/paul/dev/BareMetal-OS/src/BMFS/utils/bmfs.o
 LD      /Users/paul/dev/BareMetal-OS/src/BMFS/utils/bmfs
Updating /Users/paul/dev/BareMetal-OS/output/bin/bmfs
cp: illegal option -- -
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory

'cp --update' appears in several places, and on Mac the 'cp' command does not support the '--update' option. Some people have suggested using 'rsync' to get similar behavior (as it does allow the '--update' option).

App files

Hi,
Where the app examples are, how hello.asm, and how running It in BM?
Best regards

How to build ethtoolc

I would like to build ethtoolc.c and some of the other apps but they won't build from app.sh or the makefile in Examples or even using the instructions in the top of the source file. I just need some pointers/general direction on where to start. I naively tried the following based on the comments in the source file:

gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -o ethtoolc.o ethtoolc.c -I ../../output/include -I ../
gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -o libBareMetal.o libBareMetal.c
ld -T example.ld -o ethtoolc.app ethtoolc.o libBareMetal.o  -L ../../output/lib -L ../../output/x86_64-pc-baremetal/lib/ -lc -lbmfs -L ../Alloy/lib -lalloy

but where do I get definitions for b_output, et. al.?

ethtoolc.o: In function `main':
ethtoolc.c:(.text+0x17): undefined reference to `b_output'
ethtoolc.c:(.text+0x17): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `b_output'
ethtoolc.c:(.text+0x2b): undefined reference to `b_system_config'
ethtoolc.c:(.text+0x2b): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `b_system_config'
ethtoolc.o: In function `ethtool_send':
ethtoolc.c:(.text+0xc7): undefined reference to `b_ethernet_tx'
ethtoolc.c:(.text+0xc7): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `b_ethernet_tx'
ethtoolc.o: In function `ethtool_receive':
ethtoolc.c:(.text+0x101): undefined reference to `b_ethernet_rx'
ethtoolc.c:(.text+0x101): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `b_ethernet_rx

Add Automake to Requisites

I just wanted to let you guys know that you should add "automake" to the list of requisites to build this kernel or else some machines won't be able to use "aclocal"

Aside from that... this kernel was SUPER easy to build and run! Works flawlessly on OS X.

What libs are avalible

I am going to try to port a few applications over to BareMetal for a project I am dreaming up. It would be nice to have a full list of libraries provided "out of the box" as well as ones that can be added without porting.

App Scripts Improvements

Currently, the app compile scripts are:

  • app.sh - assembles an assembly app
  • `appc.sh - compiles a C app

There should just be one app.sh, and it should:

  • determine whether to assemble or compile the app based on the file extension
  • list the available apps (as hello.app, cat.app ... etc), if no app was passed to the script

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.