An OS based on UEFI
A 64-bit all-inclusive operating system, from bootloader to userspace.
LensorOS is migrating away from GitHub, in favor of the FOSS Codeberg.
Free, compatible virtual machines:
If you are just interested in poking around LensorOS, and not editing code, I recommend a pre-built release from the releases page. It will include all the necessary resources and instructions on how to run LensorOS. Keep in mind that this will be missing a lot of features to ensure maximum compatibility across systems. By building from source, you are able to build for your exact system and get every possible feature enabled.
NOTE: There is no automation for anything except QEMU for now. There are, however, instructions on how to setup a virtual machine in VirtualBox and VMWare Workstation Player.
When the CMake build system is generated, it looks for QEMU on your system; if it finds it, it will add the following targets to the project. Invoke them to launch QEMU from the corresponding LensorOS boot media, after building it if it isn't up to date.
The targets:
run_qemu
-- Straight from directory that mimics LensorOS.imgrunimg_qemu
-- LensorOS.imgruniso_qemu
-- LensorOS.isorunhda_qemu
-- LensorOS.bin (most common)For targets that do not currently support GPT partitions (i.e. iso, img, and straight from directory), there is no userspace available, really. I mean, it's possible, but you would have to modify things to put userspace processes and libraries in the boot partition instead of in the userspace data partition, and then also modify the kernel to load them from there.
Assuming the CMake build system was generated in the bld/
subdirectory, invoke like:
cmake --build bld --target <name of target>
New
button to create a new virtual machine (VM).Other
and Version of Other/Unknown (64-bit)
.Do not add a virtual hard disk
option.Create
button to create the new virtual machine.Settings
button.System
within the list on the left.
ICH9
.Enable EFI (special OSes only)
.Storage
within the list on the left.
IDE
), and select Remove Controller
.Storage Devices
, and select AHCI (SATA)
.Optical Drive
or Hard Disk
depending on whether you'd like to boot from the .iso
or .bin
, respectively.Add
in the new Virtual Media Selector window that pops up.Optical Drive
or Hard Disk
was selected, choose either LensorOS.iso
or LensorOS.bin
.Network
within the list on the left.
Serial Ports
within the list on the left.
Enable Serial Port
is checked, COM1
is selected, IRQ
is 4
, and I/O Port
is 0x3F8
.Home
in the list on the left side. Click Create a New Virtual Machine
on the right.I will install the operating system later.
option.Other
, and a Version of Other 64-bit
.Customize Hardware...
.
New CD/DVD
on the left, then click Advanced...
on the right.SATA
, then click OK
.Use ISO image file
, and then click Browse...
.LensorOS.iso
image file (located in bin/
).Remove
button near the bottom center.Close
in the bottom right to close the hardware configuration window.Finish
..vmx
in a text editor.firmware="efi"
.You will have to select UEFI Shell
once VMware Workstation
boots into LensorOS (even if it says something like Unsupported
).
There are multiple steps in the LensorOS build process, outlined here.
NOTE: All blocks of shell commands given are expected to start with the working directory at the root of the repository.
Download and install the following project-wide dependencies if you don't have them already, or if the version you have isn't up to date.
sudo apt install build-essential make
Next, clone the source code from the repository. If you would like to edit the code and make contributions, be sure to fork first and clone from that repository.
git clone https://codeberg.org/LensPlaysGames/LensorOS.git
This will create a subdirectory titled LensorOS
with the contents of
this repository in the current working directory.
NOTE: This section is going to change, and any information here may become incorrect or out of date at any moment. This is due to being in the middle of migrating bootloaders to the self-created RADII bootloader.
The bootloader is an EFI application; specifically an OS loader written for the UEFI spec. (currently V2.9). That specification outlines the use of PE32+ executables with a specific subsystem. As you may know, the PE32+ format is also used by Windows as it's executable format. This means that a compiler that generates Windows executables will generate the proper format of executable for an EFI application, given the subsystem modification. However, twenty or so years ago, GNU decided to write custom relocation linker scripts that create PE32+ executables from ELF executables. This means that a compiler that generates ELF executables is used, then that executable is transformed into a PE32+ executable with the proper subsystem for an EFI application. Luckily, all of this is handled by the build system.
If you already have a build system, you can use the following to update the bootloader (target exists on Unix only):
cmake --build bld --target bootloader
When starting fresh, you can run the bootloader build system manually.
Build the dependencies for the bootloader:
cd gnu-efi
make
That only ever has to be done once, to generate libgnuefi.a
.
From here, the bootloader executable can be built using the
bootloader
make target:
cd gnu-efi
make bootloader
Once the toolchain is usable, continue on here.
I recommend taking a look at toolchain/config.cmake
and seeing what
there is to fiddle with, but going with the defaults is just as well.
First, generate a build system using CMake. If you choose a different
build system, keep in mind not all build systems honour our request to
use a custom toolchain. I recommend Ninja, as it can speed up build
times. Another tip to speed up build times; install ccache
. The CMake
scripts in this project detect and use it automatically.
cmake -G Ninja -B bld
PLEASE BE ADVISED that there are critical messages in the output of the above command that may detail critical targets haven't been created due to programs not being found on the system.
To build libc, userspace programs, and finally the kernel executable, invoke the build system generated by CMake:
cmake --build bld
CMake will create certain targets if the proper dependencies are detected on the system.
To see a list of all available targets, use the following command:
cmake --build bld --target help
Lens' most-used targets:
runhda_qemu
image_gpt
image_vdi
userspace
kernel
Here is a list of the current build targets relating to boot media generation, as well as their dependencies listed underneath each.
image_raw
--
Combine built executables and resources to generate UEFI-compatible FAT32 boot media.
gnu-efi/x86_64/bootloader/main.efi
.Kernel
build target (relies on boot/LensorOS/kernel.elf
).sudo apt install mtools
image_gpt
--
Create GPT-partitioned, bootable hard drive image from FAT32 boot media.
image_raw
scripts
subdirectory.image_iso
--
Create ISO-9660 "El-Torito" bootable CD-ROM image from FAT32 boot media.
image_raw
sudo apt install xorriso
image_vdi
--
Convert GPT-partitioned raw disk image into Virtual Disk Image format (.vdi
).
image_gpt
As an example, a FAT32 formatted UEFI-compatible boot image may be generated using the following command:
cmake --build bld --target image_raw
It takes just one command to build the LensorOS kernel, generate new boot media, and then launch the QEMU virtual machine into LensorOS.
cmake --build bld --target runhda_qemu
Work on LensorOS began on January 9th, 2022.