Skip to content

Instantly share code, notes, and snippets.

View xobs's full-sized avatar

Sean Cross xobs

View GitHub Profile
@xobs
xobs / xds110.c
Last active May 2, 2025 03:46
XDS110 opcodes
/// The following is a list of opcodes for talking with the XDS110 probe.
/// The actual arguments aren't listed here, because they are not yet known.
/// The original list (i.e. anything not labeled ???) came from openocd,
/// which has an implementation using this device.
/* XDS API Commands */
#define XDS_ECHO 0x00 /* ??? */
#define XDS_CONNECT 0x01 /* Connect JTAG connection */
#define XDS_DISCONNECT 0x02 /* Disconnect JTAG connection */
#define XDS_VERSION 0x03 /* Get firmware version and hardware ID */
@xobs
xobs / cmsis-dap-swd-check.c
Last active April 16, 2025 13:53
Demonstrate an error in ARM CMSIS-DAP implementations, where the value is shifted by one bit.
// Demonstrate the off-by-one error with the ARM CMSIS-DAP DAP_SWD_SEQUENCE command. On projects
// using ARM-supplied code, the IDR will be shifted by one.
//
// Compile with:
//
// Bash:
// gcc $(pkg-config libusb-1.0 --libs --cflags) usb-breakage.c -o usb-breakage; ./usb-breakage
//
// Fish:
// gcc (pkg-config libusb-1.0 --libs --cflags | string split -n " ") usb-breakage.c -o usb-breakage; and ./usb-breakage
@xobs
xobs / hacky-probers-manual-probe.patch
Created March 29, 2025 04:12
A hacky patch to probe-rs to allow manually specifying a probe without discovering it first.
diff --git a/probe-rs-tools/src/bin/probe-rs/cmd/info.rs b/probe-rs-tools/src/bin/probe-rs/cmd/info.rs
index 8fcbd62b3..af949976a 100644
--- a/probe-rs-tools/src/bin/probe-rs/cmd/info.rs
+++ b/probe-rs-tools/src/bin/probe-rs/cmd/info.rs
@@ -14,9 +14,12 @@ use termtree::Tree;
use crate::{
rpc::{
client::RpcClient,
- functions::info::{
- ApInfo, ComponentTreeNode, DebugPortInfo, DebugPortInfoNode, DebugPortVersion,
@xobs
xobs / relink.ps1
Last active March 10, 2025 08:06
Relink a directory after extracting it with 7zip. Replace all symlinks with `mklink /d`
@xobs
xobs / usb-test.c
Created February 14, 2025 04:45
dap42 probe test
#include <assert.h>
#include <libusb.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
typedef struct bmda_probe
{
@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);