2021-05-29 16:58:11 -07:00
|
|
|
# The Little Kernel Embedded Operating System
|
2013-02-09 13:25:38 -08:00
|
|
|
|
2021-05-29 16:58:11 -07:00
|
|
|
The LK kernel is an SMP-aware kernel designed for small systems ported to a variety of platforms and cpu architectures.
|
2015-06-25 14:31:13 -07:00
|
|
|
|
2016-02-20 11:47:50 -08:00
|
|
|
See https://github.com/littlekernel/lk for the latest version.
|
|
|
|
|
|
2021-05-29 16:58:11 -07:00
|
|
|
### High Level Features
|
2015-06-25 14:31:13 -07:00
|
|
|
|
2021-06-04 13:25:52 -07:00
|
|
|
- Fully-reentrant multi-threaded preemptive kernel
|
|
|
|
|
- Portable to many 32 and 64 bit architectures
|
|
|
|
|
- Support for wide variety of embedded and larger platforms
|
|
|
|
|
- Powerful modular build system
|
|
|
|
|
- Large number of utility components selectable at build time
|
2016-05-01 23:35:08 -07:00
|
|
|
|
2021-05-29 16:58:11 -07:00
|
|
|
### Supported architectures
|
2016-05-01 23:35:08 -07:00
|
|
|
|
2024-03-09 17:58:08 -08:00
|
|
|
- ARM32
|
2024-06-14 14:34:44 -07:00
|
|
|
- Cortex-M class cores (armv6m - armv8m)
|
|
|
|
|
- ARMv7+ Cortex-A class cores
|
2024-03-09 17:58:08 -08:00
|
|
|
- ARM64
|
2024-06-14 14:34:44 -07:00
|
|
|
- ARMv8 and ARMv9 cores
|
2024-03-09 17:58:08 -08:00
|
|
|
- RISC-V 32 and 64bit bit in machine and supervisor mode
|
2024-06-14 14:34:44 -07:00
|
|
|
- x86-32 and x86-64
|
2024-03-09 17:58:08 -08:00
|
|
|
- Motorola 68000
|
|
|
|
|
- Microblaze
|
|
|
|
|
- MIPS
|
|
|
|
|
- OpenRISC 1000
|
|
|
|
|
- VAX (experimental)
|
2021-05-29 16:58:11 -07:00
|
|
|
|
|
|
|
|
### [TODO](docs/todo.md)
|
|
|
|
|
|
2024-06-14 14:34:44 -07:00
|
|
|
### To build and test for ARM64 on linux
|
2015-06-25 14:31:13 -07:00
|
|
|
|
2015-10-13 10:12:26 -07:00
|
|
|
1. install or build qemu. v2.4 and above is recommended.
|
2024-06-14 14:34:44 -07:00
|
|
|
2. install gcc for arm64 (see note 1)
|
|
|
|
|
3. run scripts/do-qemuarm -6 (from the lk directory)
|
2015-06-25 14:31:13 -07:00
|
|
|
4. you should see 'welcome to lk/MP'
|
|
|
|
|
|
|
|
|
|
This will get you a interactive prompt into LK which is running in qemu
|
2024-06-14 14:34:44 -07:00
|
|
|
arm64 machine 'virt' emulation. type 'help' for commands.
|
2015-06-25 14:31:13 -07:00
|
|
|
|
2024-06-14 14:34:44 -07:00
|
|
|
Note: for ubuntu x86-64
|
|
|
|
|
sudo apt-get install gcc-aarch64-linux-gnu
|
2015-10-13 10:12:26 -07:00
|
|
|
or fetch a prebuilt toolchain from
|
2024-06-14 14:34:44 -07:00
|
|
|
https://newos.org/toolchains/aarch64-elf-14.1.0-Linux-x86_64.tar.xz
|
2025-01-08 10:33:34 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
### Building with LLVM-based toolchains
|
|
|
|
|
|
|
|
|
|
To build LK with a LLVM-based toolchain you will have to manually specify the compiler and linker in the environemnt.
|
|
|
|
|
Unlike GCC clang is a cross-compiler by default, so the target needs to be specified as part of the CC/CXX/CPP variables.
|
|
|
|
|
For example, assuming LLVM is in `/opt/llvm/bin/`, the following command will work to build for 64-bit RISC-V:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
gmake qemu-virt-riscv64-test 'CC=/opt/llvm/bin/clang --target=riscv64-unknown-elf' 'CPP=/opt/llvm/bin/clang-cpp --target=riscv64-unknown-elf' 'CXX=/opt/llvm/bin/clang++ --target=riscv64-unknown-elf' 'LD=/opt/llvm/bin/ld.lld' TOOLCHAIN_PREFIX=/opt/llvm/bin/llvm- CPPFILT=/opt/llvm/bin/llvm-cxxfilt
|
|
|
|
|
```
|
|
|
|
|
TOOLCHAIN_PREFIX can be set to use the LLVM binutils, but due to the different naming of `llvm-cxxfilt` vs `c++filt` it needs to be set explicitly.
|
|
|
|
|
|
|
|
|
|
To build for AArch64 the command looks similar, just with a different `--target=` flag.
|
|
|
|
|
```
|
|
|
|
|
gmake qemu-virt-arm64-test 'CC=/opt/llvm/bin/clang --target=aarch64-unknown-elf' 'CPP=/opt/llvm/bin/clang-cpp --target=aarch64-unknown-elf' 'CXX=/opt/llvm/bin/clang++ --target=aarch64-unknown-elf' 'LD=/opt/llvm/bin/ld.lld' TOOLCHAIN_PREFIX=/opt/llvm/bin/llvm- CPPFILT=/opt/llvm/bin/llvm-cxxfilt
|
|
|
|
|
```
|