2020-03-10 04:04:17 +00:00
# Xous Core
Core files for the Xous microkernel operating system.
This repository contains everything necessary to build the Xous kernel
from source. It consists of the following projects:
* **kernel**: core memory manager, irq manager, and syscallhandler
* **loader**: initial loader used to start the kernel
* **tools**: programs used to construct a final boot image
* **docs**: documentation on various aspects of Xous
* **emulation**: Renode scripts used to emulate Xous
* **xous-rs**: userspace library
2020-03-10 06:45:18 +00:00
## Generating an image
You can build all Xous packages by running:
```sh
$ rustup target add riscv32imac-unknown-none-elf
$ cargo build --target riscv32imac-unknown-none-elf
$ cd kernel
$ cargo build -p kernel --target riscv32imac-unknown-none-elf
$ cd ..
2020-03-12 05:33:37 +00:00
$ cd loader
$ cargo build -p loader --target riscv32imac-unknown-none-elf
$ cd ..
2020-03-10 06:45:18 +00:00
```
This will compile all runtime packages for `riscv32imac-unknown-none-elf` .
2020-03-12 05:33:37 +00:00
Note that the kernel and loader must currently be built separately, due
to the fact that they have custom linker scripts.
2020-03-10 06:45:18 +00:00
These need to be packaged into a loadable binary. You can generate such
a binary by running the following:
```sh
$ cargo run -p tools --bin create-image -- \
2020-03-12 05:33:37 +00:00
--csv emulation/csr.csv \
2020-09-25 09:11:52 +00:00
--kernel kernel/target/riscv32imac-unknown-none-elf/debug/kernel \
2020-03-10 06:45:18 +00:00
--init target/riscv32imac-unknown-none-elf/debug/shell \
target/args.bin
```
2020-09-22 15:54:32 +00:00
2020-09-25 09:11:52 +00:00
## Targeting Real Hardware
The following files need manual adjustment:
* emulation/csr.csv should map to the csr.csv of the final SoC
* examples/graphics-server/src/backend/betrusted.rs needs a correct address for the "control" data structure (based on csr.csv)
* kernel/src/debug.rs:7 needs a correct UART base, based on csr.csv
2020-09-25 17:37:51 +00:00
* loader/src/debug.rs:31 needs a correct UART base, based on csr.csv
* kernel/src/main.rs:67 needs a corret UART base, based on csr.csv
2020-09-25 09:11:52 +00:00
2020-09-25 09:31:44 +00:00
Create the loader.bin from the .elf. `objcopy` adds several hundred megabytes of zero at the end of `loader.bin` so just
2020-09-25 09:37:18 +00:00
take the first 64kiB, which is the exact size allocated for it anyways in hardware. The final loadable image is created by
2020-09-25 09:38:11 +00:00
`cat` ing the loader and the kernel together.
2020-09-25 09:16:44 +00:00
```
2020-09-25 09:31:44 +00:00
riscv64-unknown-elf-objcopy loader/target/riscv32imac-unknown-none-elf/release/loader -O binary loader_raw.bin
dd if=loader_raw.bin of=loader.bin bs=1024 count=64
2020-09-25 09:37:18 +00:00
cat loader.bin target/args.bin > xous.img
2020-09-25 09:16:44 +00:00
```
2020-09-25 09:38:11 +00:00
The image should be written to location 0x2050_0000 (SPI ROM offset 0x50_0000), using
the `provision-xous.sh` script inside [betrusted-scipts ](https://github.com/betrusted-io/betrusted-scripts/blob/master/provision-xous.sh )
2020-09-25 18:01:48 +00:00
running on a Betrusted provisioning harness, that is a Raspberry Pi 4 with the appropriate debug hat attached, and the Precursor hardware plugged into the debug hat. You can also check out the `dvt-hardware` branch for the WIP integration of all the above commands.
2020-09-25 09:16:44 +00:00
2020-09-22 15:54:32 +00:00
## Try It Out on a Desktop
Clone this repository, and run
`cargo xtask run`