Sistema operativo didattico con una shell interattiva in stile Linux (ls, cd, mkdir, touch, cat,
rm, mv, cp, tree, un editor di testo, neofetch e altro), file salvati davvero sul disco (FAT32) e
tastiera italiana. Basato su nanobyte_os
(branch videos/part11), con varie personalizzazioni.
- RELAZIONE.md: come si usa, i comandi fatti e quelli da fare, ogni file spiegato, test, bug corretti
- theory/: la teoria, capitolo per capitolo
Avvio rapido (con il cross-compiler in ../.toolchains):
scons run # compila, crea build/i686_debug/image.img e avvia in QEMU
scons savefiles # prima di ricompilare: salva in image/root/ i file creati dentro DACOSLe istruzioni originali di nanobyte qui sotto parlano di
guestfse del modulo Pythonsh: in questa versione il default èmountMethod = 'mtools'(niente sudo) eshnon serve più.
This repository contains the code from the "Building an OS" series on the "Nanobyte" YouTube channel.
This branch contains the code as written in Part 11 - Memory detection, with some minor bug fixes:
- fixed bochs configuration
- fixed
missing ../.toolchains directoryerror when building toolchain - fixed error related to PREFIX when building toolchain
- added support for "mount" method (in addition to libguestfs)
The project requires a Unix-like environment. If you are using Windows, there are various ways of setting one up (WSL, a Linux virtual machine, Cygwin, MSYS2). I recommend using WSL, which is the easiest to setup.
You need the following tools:
sconsnasmmtools- dependencies to build a GCC cross compiler (see the section below)
qemu-system-x86for testingbochs-x bochsbios vgabiosfor debugging- your preferred text editor
A major change in Part 11 was the move from make to scons. Most of the build scripts are now written in Python.
- Install dependencies:
# Ubuntu, Debian:
sudo apt install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo wget \
nasm mtools python3 python3-pip python3-parted scons dosfstools libguestfs-tools qemu-system-x86
# Fedora:
sudo dnf install gcc gcc-c++ make bison flex gmp-devel libmpc-devel mpfr-devel texinfo wget \
nasm mtools python3 python3-pip python3-pyparted python3-scons dosfstools guestfs-tools qemu-system-x86
# Arch & Arch-based:
paru -S gcc make bison flex libgmp-static libmpc mpfr texinfo nasm mtools qemu-system-x86 python3 sconsNOTE: to install all the required packages on Arch, you need an AUR helper.
-
Install python packages:
python3 -m pip install -r requirements.txt -
Check the
build_scripts/config.pyconfiguration file. Thetoolchainvariable specifies where the toolchain will be downloaded and installed. The default path is../.toolchains, which is in the parent directory to where you cloned the repo.
Coming from Part 10, you might want to reuse the old toolchain you have already built. Simply change the path toolchain variable to point to the correct directory.
Another important variable is mountMethod. See the section below for details.
-
Run
scons toolchain, this should download and build the required tools (binutils and GCC). If you encounter errors during this step, you might have to modifybuild_scripts/config.mkand try a different version of binutils and gcc. Using the same version as the one bundled with your distribution is your best bet. -
Run
scons. Type your sudo password when prompted, this is required for runninglosetup,mount,umount.
There are 2 supported mount methods that can be configured in build_scripts/config.py with the mountMethod variable:
-
guestfsuses theguestmountcommand, and it doesn't require sudo access. This is the preferred method, however in some distributions (most notably WSL) it isn't working properly. -
mountis provided as a backup whenguestfsfails. The disadvantage is that it requires typing your password every time you rebuild the disk image.
** DO NOT use sudo to run the build**. This will mess up file permissions for all the files in the build directory, and has the potential of damaging your system. The build script will request elevated privileges only when performing the mount operations.
- run
scons runto test your OS using qemu.
- run
scons debug.
- run
scons bochs.
Troubleshooting: Bochs has proven to be pretty unreliable. Check this article for some troubleshooting tips.