Xous SDK (pinned for betrusted transpilation)
Find a file
bunnie affe4e6c54 move APIs out of cramium-hal
So the organization of the code is now the following tiers:

libs/cramium-api: contains hardware-abstracted API code to the hardware
layers (traits, some constants, enums, etc.). For example, "here is
an IO trait that lets you configure and set GPIO pins", which could
then be implemented in hardware or emulation. The APIs aren't entirely
generic across all SoCs because they are tweaked to accommodate
quirks of the cramium SoC.

libs/cramium-hal: contains board-specific driver codes that do not
require persistent services to be started. Possibly misnamed because
it also includes not just cramium-chip items, but also e.g. peripherals
to the cramium SoC, such as the PMIC and camera.

services/cramium-hal-service: contains the `main` process that manages
shared resources, such as UDMA, IO pins, IFRAM. These drivers cannot
be delegated to a `lib` crate because there can be only one instance
of these resources, and instead we have to dynamically allocate
access to these through IPC messaging.

services/cramium-emu: hosted mode emulation of things in
cramium-hal-service.

services/bao-video: contains a `main` process that integrates
the camera and OLED driver. This means that all graphic drawing
primitives also interface with this crate. These are condensed
into a single process space to speed up execution, and kept
separate from cramium-hal-services because we want the video
services to not be blocked by, for example, a thread that is
handling I2C things.
2025-02-20 13:54:46 +08:00
.cargo deal with deprecation notice in rust 1.38 2024-05-07 17:02:15 +08:00
.github/workflows modify format CI flow to generate template files prior to checks 2024-01-15 01:53:02 +08:00
.vscode this was not supposed to be checked in. 2024-05-12 21:21:36 +08:00
api stage tomls for version bump: try_send added to xous-ipc 2024-12-16 18:50:11 +08:00
apps formatting changes due to changes in nightly rust 2025-02-01 22:26:40 +08:00
devkey
docs a few more drawings 2024-12-24 00:59:09 +08:00
emulation renode: vexriscv: fix CPU on newer Renode versions 2024-08-20 09:05:10 +08:00
imports stage tomls for version bump: try_send added to xous-ipc 2024-12-16 18:50:11 +08:00
kernel adjust kernel dependencies to match new tree 2025-02-20 13:32:21 +08:00
libs move APIs out of cramium-hal 2025-02-20 13:54:46 +08:00
LICENSES Move license file to top level so github can detect it 2023-11-16 20:59:16 -08:00
loader update maintenance notes 2025-02-17 18:27:17 +08:00
locales small revision 2024-12-10 23:23:45 +09:00
planning update num-derive dependency 2024-12-02 18:52:59 +08:00
precursors chore: cleanup typos in docs, comments 2024-01-15 02:16:43 +08:00
services add a crate dedicated to hosted-mode emulation of baosec-target items 2025-02-20 13:26:33 +08:00
svd2repl update formatting to latest nightly rules 2024-09-24 01:49:45 +08:00
svd2utra commit the version bump 2024-09-23 01:46:25 +08:00
tools formatting changes due to changes in nightly rust 2025-02-01 22:26:40 +08:00
utralib update generated artifacts 2025-01-12 00:35:30 +08:00
xous-ipc stage tomls for version bump: try_send added to xous-ipc 2024-12-16 18:50:11 +08:00
xous-rs commit the version bump 2024-09-23 01:46:25 +08:00
xtask specify hosted for kernel build in baosec-emu target 2025-02-20 13:28:33 +08:00
.gitattributes
.gitignore add app manifest for cramium target 2024-06-13 22:03:16 +08:00
analyze-bloat.sh refactor paths to use xpack instead of sifive toolchain 2023-02-21 17:43:31 +08:00
API.md regex search/replace instances of xous_ipc::String to String 2024-09-22 14:14:55 +08:00
Cargo.lock add emulation target to lockfile 2025-02-18 23:22:48 +08:00
Cargo.toml add emulation target to workspace 2025-02-18 23:22:35 +08:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md chore: cleanup typos in docs, comments 2024-01-15 02:16:43 +08:00
ct_eq.txt add ct_eq disassembly listings so we can discuss in issue #416 2023-09-19 01:00:51 +08:00
FORMATTING.md add a formatting document 2024-01-11 22:21:50 +08:00
LICENSE Move license file to top level so github can detect it 2023-11-16 20:59:16 -08:00
publish.py re-add the kernel publish argument 2024-12-16 18:55:08 +08:00
README.md note requirement of --doc-deps to build documentation 2025-02-18 10:14:34 +08:00
RELEASE-v0.8.md ...and a pretty obvious one i missed 2024-01-15 02:17:28 +08:00
RELEASE-v0.9.md note requirement of --doc-deps to build documentation 2025-02-18 10:14:34 +08:00
rustfmt.toml 2024 style is the least disruptive to the code base... 2024-09-23 01:34:12 +08:00

Xous Core

Core files for the Xous microkernel operating system.

You might find this wiki handy, as well as the Xous Book.

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

Dependencies

  • Xous requires its own Rust target, riscv32imac-unknown-xous-elf. If you run cargo xtask from the command line, you should be prompted to install the target automatically if it does not already exist.
  • You may need to remove the target/ directory before building, if rustc continues to behave like it can't find the xous target even after it is installed.
  • If you plan on doing USB firmware updates, you'll need progressbar2 (updates) and pyusb (updates). Note that pyusb has name space conflicts with similarly named packages, so if updates aren't working you may need to create a venv or uninstall conflicting packages.
  • If you are doing development on the digital signatures with the Python helper scripts, you will need: pycryptodome (signing - PEM read), cryptography (signing - x509 read), pynacl (signing - ed25519 signatures) (most users won't need this).
  • Some system packages are needed, which can be installed with sudo apt install libssl-dev libxkbcommon-dev or similar
  • If you receive an error about feature resolver is required, try installing a newer version of rustc and cargo via rustup

Building Documentation

A flag of --feature doc-deps must be passed when running cargo doc, like this:

cargo doc --no-deps --feature doc-deps

This flag is required because Xous requires a target board to be specified in all build configurations. doc-deps specifies a set of dummy dependencies that satisfy board requirements for the purpose of building documentation.

Local-vs-crates.io Verification

By default the xtask resolver runs a check to confirm that your local files match the ones referenced in crates.io. For a handful of core crates, the build preferentially runs from what is on crates.io, so local changes have no effect until they are pushed as an update to an existing crate. If you see an error complaining about local source files not being published, make sure you have the correct patches in place in your top level Cargo.toml file, and bypass the check with --no-verify.

Quickstart using Hosted Mode

You can try out Xous in a "hosted mode" wherein programs are compiled for your native platform and are run locally as processes within your current operating system. System calls are replaced with network calls to a kernel that simply shuffles messages around.

Xous uses the xtask convention, where various complex build commands are stored under cargo xtask. This allows for us to create arbitrarily complex build sequences without resorting to make (which is platform-dependent), sh (which requires a lot of external tooling), or another build system.

To build a set of sample programs and run them all using the kernel for communication, clone this repository and run:

cargo xtask run

This will build several servers and a "shell" program to control them all. Most notably, a graphics-server will appear and kernel messages will begin scrolling in your terminal.

Hosted Mode UI navigation

Precursor Host
D-pad middle button Home
D-pad up up arrow
D-pad down down arrow
D-pad left left arrow
D-pad right right arrow

Quickstart using an emulator

Xous uses Renode as the preferred emulator, because it is easy to extend the hardware peripherals without recompiling the entire emulator.

Due to a breaking change in Renode, this codebase is only compatible with Renode equal to or later than 1.15.2.7965 (e6e79aad-202408180425)

Download Renode and ensure it is in your path. For now, you need to download the nightly build, until DecodedOperation is included in the release.

Then, build Xous:

cargo xtask renode-image

This will compile everything in release mode for RISC-V, compile the tools require to package it all up, then create an image file.

Finally, run Renode and specify the xous-release.resc REnode SCript:

renode emulation/xous-release.resc

Renode will start emulation automatically, and will run the same set of programs as in "Hosted mode".

Generating a hardware image

To build for real hardware, you must specify an .svd file. This file is generated by the SoC build process and describes a single Betrusted core. These addresses will change as hardware is modified, so if you distribute a modified Betrusted core, you should be sure to distribute the .svd file.

The UTRA abstracts the details of the register locations, by wrapping them in logical names that don't change. For Precursor, the SVD files are tracked inside utralib/precursor/soc-<gitref>.svd. Since each soc.svd can potentially change with a git reference, a gitref is coded into the filename by convention.

Generally, one can create an image for hardware using the following command:

cargo xtask app-image-xip

And it will pull from the default soc.svd configuration.

The currently selected config is set by the constant PRECURSOR_SOC_VERSION in xtask/src/main.rs; it is one of the first constants near the top.

If you have built your own custom soc.svd file, the most convenient way to update to this is to simply replace the file referenced in the default with yours, and then run cargo build inside the utralib directory (not in the Xous root -- the build command must happen inside the directory to force a regeneration of the generated UTRA bindings). This will likely result in a complaint when you run xtask that your local tree does not match what is checked into git; if you are building from your own configuration, that is correct, and thus you should add --no-verify to your xtask command to suppress the check.

Note that adding a full extra custom gitrev is more involved, it involves editing the utralib/Cargo.toml and utralib/build.rs to reference your new artifact as a brand new feature flag.

The resulting images are in your target directory (typically target/riscv32imac-unknown-xous-elf/release/) with the names xous.img (for the kernel) and loader.bin (for its bootloader). The corresponding gateware is in precursors/soc_csr-<gitref>.bin. These can be written to your device by following the update guide.

Acknowledgement

This project is funded through the NGI0 PET Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825310.

NLnet foundation logo NGI0 logo