nanobyte-dev/nanobyte_os
حول
OS tutorial from Nanobyte YouTube channel.
التعلّم والتعليمالنمو المقاس للنجوم
- خلال 24 ساعة
- +٢
- خلال 7 أيام
- +٢
- خلال 15 يومًا
- +٢
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلnanobyte_os
This repository contains the code from the "Building an OS" series on the "Nanobyte" YouTube channel.
Prerequisites
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.
For Part 11, 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. Check the "Building" section if you are coming from Part 10, there are some new dependencies.
Building
- Install dependencies by running
scripts/install_deps.sh. It detects your distro (Debian/Ubuntu, Fedora, Arch, openSUSE), or macOS, and installs the packages listed inscripts/deps/<distro>.txt. On macOS, it needs Homebrew and the Xcode command line tools (xcode-select --install). To install them yourself instead, use that list with your package manager, for example:
sudo apt install $(sed 's/#.*//' scripts/deps/debian.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 modifyscripts/setup_toolchain.shand 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. If you are using themountmethod, type your sudo password when prompted, this is required for runninglosetup,mount,umount.
Building with docker
If you'd rather not install everything on your machine, ./build-docker.sh runs the build in a container, so you only need docker or podman. Any arguments are passed to scons, for example ./build-docker.sh imageType=floppy.
The first run builds a local nanobyte-build image with the dependencies and the cross compiler, which takes a while. Later runs reuse it. When the files it's built from change (scripts/docker/Dockerfile, scripts/install_deps.sh, scripts/deps/debian.txt, scripts/setup_toolchain.sh), the script builds a new image and lists the old ones, which you can delete.
The container always uses the mountless mount method. To run the OS, use scripts/run.sh on your machine (it needs qemu-system-x86), for example scripts/run.sh disk build/i686_debug/image.img. scons run would rebuild everything with your local toolchain.
Mount methods
The mountMethod variable in build_scripts/config.py sets how files are copied into the disk image:
mountless(default) creates the file system with the files already in it, without mounting anything:mtoolswrites them into FAT,mkfs.ext2 -dfills ext2 from a directory. No sudo, and it works in WSL and containers, and on macOS for FAT. ext2 needsmkfs.ext2from e2fsprogs.guestfsmounts the image withguestmount(libguestfs), without sudo. Use it if your distro has nomtools; install libguestfs yourself (libguestfs-toolson Debian/Ubuntu,guestfs-toolson Fedora and openSUSE,libguestfson Arch). It doesn't work properly on some systems, most notably WSL.mountuseslosetupandmount. The disadvantage is that it requires typing your password every time you rebuild the disk image.
Warning
** 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.
Running
run
scons runto test your OS using qemu.to make a bootable ISO, build a floppy image (
scons imageType=floppy), then runscripts/img_to_iso.sh build/i686_debug/image.img nbos.iso. It needsxorriso. The ISO boots in floppy emulation mode:qemu-system-i386 -cdrom nbos.iso.
Debugging with qemu and GDB
- run
scons debug.
Debugging with bochs
- run
scons bochs.
Troubleshooting: Bochs has proven to be pretty unreliable. Check this article for some troubleshooting tips.
Links
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…