An experimental modular operating system (or unikernel) written in Rust.
ArceOS was inspired a lot by Unikraft.
🚧 Working In Progress.
- Architecture: x86_64, riscv64, aarch64, loongarch64
- Platform: QEMU pc-q35 (x86_64), virt (riscv64/aarch64/loongarch64)
- Multi-thread
- FIFO/RR/CFS scheduler
- VirtIO net/blk/gpu drivers
- TCP/UDP net stack using smoltcp
- Synchronization/Mutex
- SMP scheduling with per-cpu run queue
- File system
- Compatible with Linux apps
- Interrupt driven device I/O
- Async I/O
Install Docker in your system.
Then build all dependencies through provided dockerfile:
docker build -t arceos -f Dockerfile .Create a container and build/run app:
docker run -it -v $(pwd):/arceos -w /arceos arceos bash
# Now build/run app in the container
make A=examples/helloworld ARCH=aarch64 runInstall cargo-binutils to use rust-objcopy and rust-objdump tools, and axconfig-gen for kernel configuration, and cargo-axplat for platform configuration:
cargo install cargo-binutils axconfig-gen cargo-axplat# for Debian/Ubuntu
sudo apt-get install qemu-system
# for macos
brew install qemuInstall libclang-dev:
sudo apt install libclang-devDownload & install musl toolchains:
# download
wget https://musl.cc/aarch64-linux-musl-cross.tgz
wget https://musl.cc/riscv64-linux-musl-cross.tgz
wget https://musl.cc/x86_64-linux-musl-cross.tgz
wget https://github.com/LoongsonLab/oscomp-toolchains-for-oskernel/releases/download/loongarch64-linux-musl-cross-gcc-13.2.0/loongarch64-linux-musl-cross.tgz
# install
tar zxf aarch64-linux-musl-cross.tgz
tar zxf riscv64-linux-musl-cross.tgz
tar zxf x86_64-linux-musl-cross.tgz
tar zxf loongarch64-linux-musl-cross.tgz
# exec below command in bash OR add below info in ~/.bashrc
export PATH=`pwd`/x86_64-linux-musl-cross/bin:`pwd`/aarch64-linux-musl-cross/bin:`pwd`/riscv64-linux-musl-cross/bin:`pwd`/loongarch64-linux-musl-cross/bin:$PATHOther systems and arch please refer to Qemu Download
# build app in arceos directory
make A=path/to/app ARCH=<arch> LOG=<log>Where path/to/app is the relative path to the application. Examples applications can be found in the examples directory or the arceos-apps repository.
<arch> should be one of riscv64, aarch64, x86_64, loongarch64.
<log> should be one of off, error, warn, info, debug, trace.
More arguments and targets can be found in Makefile.
For example, to run the httpserver on qemu-system-aarch64 with 4 cores and log level info:
make A=examples/httpserver ARCH=aarch64 LOG=info SMP=4 run NET=yNote that the NET=y argument is required to enable the network device in QEMU. These arguments (BLK, GRAPHIC, etc.) only take effect at runtime not build time.
You can write and build your custom applications outside the ArceOS source tree. Examples are given below and in the app-helloworld and arceos-apps repositories.
-
Create a new rust package with
no_stdandno_mainenvironment. -
Add
axstddependency and features to enable toCargo.toml:[dependencies] axstd = { path = "/path/to/arceos/ulib/axstd", features = ["..."] } # or use git repository: # axstd = { git = "https://github.com/arceos-org/arceos.git", features = ["..."] }
-
Call library functions from
axstdin your code, just like the Rust std library.Remember to annotate the
mainfunction with#[unsafe(no_mangle)](see this example). -
Build your application with ArceOS, by running the
makecommand in the application directory:# in app directory make -C /path/to/arceos A=$(pwd) ARCH=<arch> run # more args: LOG=<log> SMP=<smp> NET=[y|n] ...
All arguments and targets are the same as above.
-
Create
axbuild.mkandfeatures.txtin your project:app/ ├── foo.c ├── bar.c ├── axbuild.mk # optional, if there is only one `main.c` └── features.txt # optional, if only use default features
-
Add build targets to
axbuild.mk, add features to enable tofeatures.txt(see this example):# in axbuild.mk app-objs := foo.o bar.o# in features.txt alloc paging net -
Build your application with ArceOS, by running the
makecommand in the application directory:# in app directory make -C /path/to/arceos A=$(pwd) ARCH=<arch> run # more args: LOG=<log> SMP=<smp> NET=[y|n] ...
You need to manually link your application with the appropriate platform packages:
// Add this line to your application (for raspi4 platform)
extern crate axplat_aarch64_raspi;Then set the MYPLAT variable when run make:
# Build helloworld for raspi4
make MYPLAT=axplat-aarch64-raspi SMP=4 A=examples/helloworldYou may also need to select the corrsponding device drivers by setting the FEATURES variable:
# Build the shell app for raspi4, and use the SD card driver
make MYPLAT=axplat-aarch64-raspi SMP=4 A=examples/shell FEATURES=page-alloc-4g,driver-bcm2835-sdhci BUS=mmio
# Build httpserver for the bare-metal x86_64 platform, and use the ixgbe and ramdisk driver
make PLAT_CONFIG=$(pwd)/configs/custom/x86_64-pc-oslab.toml A=examples/httpserver FEATURES=page-alloc-4g,driver-ixgbe,driver-ramdisk SMP=4# In Cargo.toml
[dependencies]
axalloc = { git = "https://github.com/arceos-org/arceos.git", tag = "v0.2.0" } # modules/axalloc
axhal = { git = "https://github.com/arceos-org/arceos.git", tag = "v0.2.0" } # modules/axhal