Skip to content

Instantly share code, notes, and snippets.

View xobs's full-sized avatar

Sean Cross xobs

View GitHub Profile
@xobs
xobs / config.xous.toml
Last active December 22, 2023 15:21
A config.toml for running tests with Rust on Xous
# Includes one of the default files in src/bootstrap/defaults
profile = "library"
change-id = 116998
[build]
# When building the standard library, you almost never want to build the compiler itself.
build-stage = 2
test-stage = 2
bench-stage = 2
target = ["riscv32imac-unknown-xous-elf"]
@xobs
xobs / Cargo.toml
Last active August 5, 2023 13:05
Sample implementation of rust's `unwind` crate using `unwinding` as a backend
[package]
name = "unwind"
version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
edition = "2021"
include = [
'/libunwind/*',
]
@xobs
xobs / disasm.rs
Created March 17, 2023 00:47
Risc-V disassembler in pure, `no_std` Rust, ported from spike-dasm
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
pub type rv_inst = u64;
#[derive(Clone, Copy, PartialEq)]
pub enum RvIsa {
Rv32 = 0,
Rv64 = 1,
@xobs
xobs / my.S
Created March 14, 2023 08:19
Demo program showing that Renode is incorrectly generating exceptions
// This program tests `ecall` and `ebreak`. Link with the
// following linker script:
//
//-- linker.x ----------------------------------------------
// MEMORY { FLASH : ORIGIN = 0x80000000, LENGTH = 512K }
// SECTIONS { .text : { *(.text .text.*); } > FLASH }
//----------------------------------------------------------
//
// Compile and link into a binary with:
// riscv-none-elf-gcc -march=rv32imac_zicsr -g my.S -o my.elf -nostdinc -nostdlib -T my.ld
@xobs
xobs / thread_local_key.rs
Created February 20, 2023 12:36
Newer version of thread_local_key
use crate::os::xous::ffi::{map_memory, unmap_memory, MemoryFlags};
use core::arch::asm;
use core::cell::Cell;
use core::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering};
const TLS_KEY_COUNT: usize = 128;
const TLS_MEMORY_SIZE: usize = 4096;
pub type Key = usize;
pub type Dtor = unsafe extern "C" fn(*mut u8);
@xobs
xobs / siliwiz-design-noout.json
Created February 13, 2023 05:40
Files that cause siliwiz to fail
{
"version": 1,
"app": "siliwiz",
"timestamp": 1676266623,
"rects": [
{ "x": 14.4, "y": 18, "height": 363, "width": 372, "layer": "p substrate" },
{ "x": 118.4, "y": 147, "height": 118, "width": 152, "layer": "n diffusion" },
{ "x": 341.4, "y": 350, "height": 28, "width": 39, "layer": "p tap" },
{ "x": 180.4, "y": 129, "height": 158, "width": 31, "layer": "polysilicon" },
{ "x": 345.4, "y": 352, "height": 24, "width": 32, "layer": "metal1 via" },
@xobs
xobs / plan9.patch
Created December 6, 2022 14:56
Get things building for rust-1.65.0
diff --git a/library/std/src/sync/condvar.rs b/library/std/src/sync/condvar.rs
index eb1e7135a6e..ba270d2aee5 100644
--- a/library/std/src/sync/condvar.rs
+++ b/library/std/src/sync/condvar.rs
@@ -122,10 +122,10 @@ impl Condvar {
/// let condvar = Condvar::new();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
+ // #[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
@xobs
xobs / build.sh
Created November 10, 2022 02:35
Testing rustc crashes with GAM
#!/bin/bash
set -e
set > /opt/Xous/environment
export PATH=/opt/gcc/xpack-riscv-none-elf-gcc-12.1.0-2/bin/:$PATH
echo "Building rust..."
cd /opt/Xous/rust-next
rm -rf target-*
rustup override set $RUSTUP_TOOLCHAIN
target\debug\create-image.exe `
target\riscv32imac-unknown-xous-elf\release\xous_presign.img `
--kernel target/riscv32imac-unknown-xous-elf/release/xous-kernel `
--init target/riscv32imac-unknown-xous-elf/release/xous-ticktimer `
--init target/riscv32imac-unknown-xous-elf/release/xous-log `
--init fake-root-keys\target\riscv32imac-unknown-xous-elf\debug\fake-root-keys `
--init pddb-raw\target\riscv32imac-unknown-xous-elf\debug\pddb-raw `
--init target/riscv32imac-unknown-xous-elf/release/xous-names `
--init target/riscv32imac-unknown-xous-elf/release/xous-susres `
--init target\riscv32imac-unknown-xous-elf\release\pddb `
Creating path test-create...
ERR :pddb: got msg: Envelope { sender: Sender { data: 181c0007 }, body: MutableBorrow(MemoryMessage { id: 28, buf: MemoryRange { addr: 40000000, size: 1000 }, offset: None, valid: None }) } (services\pddb\src\main.rs:639)
TRCE:pddb::backend::hw: alloc fast_space_len: 2041, log_len 0, has 3 pages: true (services\pddb\src\backend\hw.rs:1431)
DBG :pddb::backend::basis: dict: key not in cache test-create (services\pddb\src\backend\basis.rs:1649)
TRCE:pddb::backend::hw: block: [30, 83, c3, 29, cb, 71, 82, 19, d6, 5e, a0, 5, 73, e4, b0, c] (services\pddb\src\backend\hw.rs:1365)
TRCE:pddb::backend::hw: patch: [6f, f3, 20, 7, 9f, 63, f4, 1, 27, e5, 87, e3, 8b, 58, e1, 5f] (services\pddb\src\backend\hw.rs:1368)
DBG :pddb::backend::basis: adding dictionary test-create (services\pddb\src\backend\basis.rs:342)
DBG :pddb::backend::basis: syncing dict test-create with 0 keys (services\pddb\src\backend\basis.rs:1472)
TRCE:pddb::backend::hw: Error decrypting page: Error (services\pddb\src\backend