-
Notifications
You must be signed in to change notification settings - Fork 0
Building ModuOS
Detailed instructions for building ModuOS from source.
- Docker Desktop - Cross-compilation environment
- QEMU - x86_64 emulator for testing
- Git - Version control
- Make - Build automation
- GDB - Debugging
- Log Viewer - COM port log viewing
Download and install from docker.com
Windows:
# Download installer and run
# Or use winget
winget install Docker.DockerDesktopDownload from qemu.org
Windows:
# Download installer or use chocolatey
choco install qemuLinux:
sudo apt install qemu-system-x86git clone https://github.com/NtinosTheGamer2324/ModuOS.git
cd ModuOSdocker build buildenv -t modu-osWhat's Inside:
- Base: Ubuntu with build essentials
- Cross-compiler: x86_64-elf-gcc
- Assembler: NASM
- Bootloader: GRUB tools (grub-mkrescue)
- ISO tools: xorriso
Dockerfile (buildenv/Dockerfile):
FROM randomdude/gcc-cross-x86_64-elf
RUN apt-get update && apt-get install -y \
nasm \
grub-pc-bin \
grub-common \
xorriso \
mtoolsdocker images | grep modu-osrun.batThis script:
- Checks Docker is running
- Builds kernel
- Creates bootable ISO
- Launches QEMU
- Opens log viewers
Step 1: Build Kernel
docker run --rm -it -v "%cd%":/root/env modu-os make build-AMD64Step 2: Output Files
-
build/- Object files -
dist/AMD64/mdsys.sqr- Kernel binary -
dist/AMD64/kernel.iso- Bootable ISO
# Build for AMD64
make build-AMD64
# Clean build artifacts
make clean
# Rebuild from scratch
make clean build-AMD64Current architecture: AMD64 (x86-64)
Future architectures may include ARM64, RISC-V.
ModuOS/
├── build/ # Intermediate object files
│ ├── kernel/
│ ├── drivers/
│ ├── fs/
│ └── arch/AMD64/
├── dist/ # Final build output
│ └── AMD64/
│ ├── mdsys.sqr # Kernel binary
│ └── kernel.iso # Bootable ISO
mdsys.sqr: ELF64 executable
- Entry point:
long_mode_start→kernel_main - Load address: 0x100000 (1MB)
- Format: ELF64 (x86-64)
kernel.iso/
├── boot/
│ └── grub/
│ ├── grub.cfg # GRUB configuration
│ └── *.pf2 # Font files
├── ModuOS/
│ ├── System64/
│ │ └── mdsys.sqr # Kernel binary
│ ├── bin/ # System binaries
│ └── Modules/ # Kernel modules (future)
└── Apps/ # User applications
├── cat.sqr
├── echo.sqr
├── sh.sqr
└── ...
CFLAGS = -c -I include -ffreestandingExplanation:
-
-c: Compile only, don't link -
-I include: Include directory for headers -
-ffreestanding: Freestanding environment (no standard library)
NASMFLAGS = -f elf64Explanation:
-
-f elf64: Output ELF64 format
LDFLAGS = -n -T targets/AMD64/linker.ldExplanation:
-
-n: Do not page-align sections -
-T linker.ld: Use custom linker script
File: targets/AMD64/linker.ld
ENTRY(start)
SECTIONS {
. = 1M;
.boot : {
*(.multiboot_header)
}
.text : {
*(.text)
}
.rodata : {
*(.rodata)
}
.data : {
*(.data)
}
.bss : {
*(.bss)
}
}cd userland
./build.shProcess:
- Compile each
.cfile - Link with user linker script
- Output
.sqrfiles totargets/AMD64/iso/Apps/
User Linker Script (userland/user.ld):
ENTRY(_start)
SECTIONS {
. = 0x400000;
.text : { *(.text) }
.rodata : { *(.rodata) }
.data : { *(.data) }
.bss : { *(.bss) }
}Issue: Cannot pull base image
Error response from daemon: pull access denied
Solution: Check internet connection, try alternative base image
Issue: x86_64-elf-gcc: command not found
Solution: Docker image not built correctly, rebuild:
docker build buildenv -t modu-os --no-cacheIssue: Undefined reference to function
Solution: Check that all source files are included in Makefile
Issue: grub-mkrescue: command not found
Solution: GRUB tools not installed in Docker image
Make changes to source files in src/ or include/
docker run --rm -it -v "%cd%":/root/env modu-os make build-AMD64qemu-system-x86_64 -cdrom dist/AMD64/kernel.iso -m 1024MCheck com1.log for kernel output
Repeat steps 1-4
Add to CFLAGS:
CFLAGS += -O2 # Optimize for speed
CFLAGS += -Os # Optimize for size
CFLAGS += -O3 # Maximum optimizationCFLAGS += -g # Include debug info- Host OS: Your development machine (Windows/Linux/macOS)
- Target OS: ModuOS (freestanding x86-64)
Cannot use host compiler because:
- Host compiler targets host OS
- ModuOS has no standard library
- Need specific ABI and format
x86_64-elf-gcc:
- Target: x86-64 ELF format
- No C standard library
- Bare metal code generation
- Running and Testing - Test the OS
- Debugging Guide - Debug techniques
- Contributing - Contribute to development