Xous SDK (pinned for betrusted transpilation)
Find a file
bunnie aaf16dcf5e light refactor to the GAM to solve a deadlock issue
This is a "no good choice" situation but there is a problem with
progress bars.

You want progress bars to update quickly, and you don't want
to have to context switch out for the entire graphics stack to
come back to you to approve the drawing of your progress bar update.

On the other hand, you don't want to short-circuit all the checks
on drawing stuff to the screen for the sake of progress bars --
right now, there are a number of checks in place to make sure you
can't draw stuff on parts of the screen you shouldn't, to avoid
fake messages and dialog boxes.

I had managed to work out a way to get a dialog box to redraw without
violating the security rules -- each redraw is checked by the defacing
routine -- however, due to the way I was computing the height of
the modal I was causing the dialog box to be resized to its largest
size and then shrunk again to fit the text every iteration. This
in essence also caused the defacement routine to run repeatedly,
which caused the GAM to also issue repeated redraw requests to
the main loop.

These redraw requests can't be serviced until the task being tracked
by the progress bar is completed. As the progress bar gets redrawn
almost a hundred times as part of the task, roughly a hundred messages
arrive in the server's queue before it can handle a single one.

This results in a deadlock situation on completion of the progress
bar, because we want to fire off a message to ourselves to go to
the next state in the Ux routine.

There are a few possible solutions to this:

1. Multi thread the heck out of the routine doing the progress bar,
so the dialog box and the slider are each in their own threads
with their own responders and then the thing doing the computation
is doing some Mutex-guarded-Arc thing.

2. Do some very unsafe bodge to allow sliders to do direct draws
that are unchecked

3. Add a check so that if the size of the dialog box doesn't change,
defacement isn't recomputed and thus redraw messages aren't sent back.

(1) doesn't work for a number of reasons -- in a general case, it's
probably OK, but it does cause a lot more memory usage (and we are
lean on memory); but more importantly, for this use case, our routine
is interacting with CSRs and those don't implement Send so you can't
pass them into a thread via a closure. You could maybe put the dialog
boxes themselves into an Arc Mutex thing but because this routine
was heavily coded to re-use the heavyweight Ux resources this becomes
a bit cumersome to code.

(2) is terrible

(3) ended up working and what is in this commit. I think it's OK
because a progress bar generally doesn't require changing the
size of a window to update its state; therefore the redraw is
deface-safe (since you aren't changing the bounds of what you were
already approved to draw in). Of course, if you have some sort
of a progress bar implementation that changes the size of the messages
reported up top so that the dialog box has to change size over and
over again, you still end up in the deadlock situation!
2021-08-12 01:25:35 +08:00
.cargo xtask: add cargo xtask command 2020-08-17 19:42:39 +08:00
.vscode fix minor issues for std integration 2021-08-03 18:23:04 +08:00
devkey beginnings of image signing 2021-07-06 17:31:09 +08:00
docs Update flash.md 2021-07-21 00:03:29 +08:00
emulation emulation: use riscv32imac-unknown-xous-elf 2021-08-04 10:14:56 +08:00
imports imports: blitstr: support xous target triple 2021-08-02 18:11:09 +08:00
kernel remove now-unused stub 2021-08-04 23:29:00 +08:00
LICENSES creating LICENSES directory 2021-01-25 14:52:31 +01:00
loader loader: add small comment 2021-08-04 12:50:20 +08:00
locales locales: generate locales as part of normal build 2021-08-04 12:19:06 +08:00
macros fix right shift overflow in main macro 2021-08-01 15:06:09 +08:00
precursors initial key provisioning demo working 2021-08-07 22:21:49 +08:00
services light refactor to the GAM to solve a deadlock issue 2021-08-12 01:25:35 +08:00
svd2repl emulation: add spinor_soft_int and wfi 2021-08-02 17:10:10 +08:00
svd2utra add compiler fences to the UTRA 2021-07-26 19:22:45 +08:00
tools self-signing working, but the patch to use the SHA hash engine seems to be disregarded... 2021-08-09 03:27:43 +08:00
utralib utralib: use canonicalized path for svd in rebuilding 2020-11-23 17:18:44 +08:00
xous-ipc add from_raw_parts and to_raw_parts methods 2021-07-28 17:34:51 +08:00
xous-rs xous-rs: support riscv32imac-unknown-xous-elf 2021-08-02 18:10:31 +08:00
xtask jtag server now reporting ID 2021-08-10 22:46:00 +08:00
.gitattributes gitattributes: add txt as lf 2021-03-10 17:36:41 +08:00
.gitignore emulation: ignore obj/ directory 2021-06-21 14:13:52 +08:00
buildpush.bat start to remove heapless and commit to libstd flow 2021-08-04 00:07:47 +08:00
buildpush.sh start to remove heapless and commit to libstd flow 2021-08-04 00:07:47 +08:00
Cargo.lock add jtag commands, reboot after burn 2021-08-11 06:15:04 +08:00
Cargo.toml stash to figure out build issue 2021-08-10 22:41:22 +08:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md
README.md update with some hints that hopefully make installation easier 2021-07-11 17:00:38 +08:00
RELEASE-v0.8.md add reference counting on connections between servers 2021-05-21 16:24:30 +08:00
start-gdb.sh try to layer in the fcc agent 2020-12-31 19:31:12 +08:00
wb-gdb.sh add helper script for wishbone gdb 2021-01-13 23:18:30 +08:00

Xous Core

Core files for the Xous microkernel operating system.

You might find this collection of Xous documentation handy.

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

There's some Python scripts to help deal with firmware signing. Ensure the following python packages are available in your environment: pycryptodome (signing - PEM read), cryptography (signing - x509 read), pynacl (signing - ed25519 signatures). If you plan on doing USB firmware updates, you'll also need progressbar2 (updates), pyusb (updates).

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.

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.

Download Renode and ensure it is in your path. Then, build Xous:

rustup target add riscv32imac-unknown-none-elf
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.

An example file may be found under svd2utra/, but this is probably out of date and won't work with your device.

Pass this .svd file to the hw-image xtask command:

cargo xtask hw-image svd2utra/examples/soc.svd

This will compile all runtime packages for riscv32imac-unknown-none-elf, and will generate a release image under the target/ directory, which will be printed on the output.

The image should be written to location 0x2050_0000 (SPI ROM offset 0x50_0000), using the provision-xous.sh script inside betrusted-scripts 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.