Skip to content

Instantly share code, notes, and snippets.

View xobs's full-sized avatar

Sean Cross xobs

View GitHub Profile
@xobs
xobs / list_devices.rs
Last active November 28, 2025 00:36
Display devices connected to a machine along with their bus listing
#!/usr/bin/env cargo
---
package.edition = "2024"
dependencies.nusb = { version = "0.2.1" }
---
use nusb::MaybeFuture;
fn main() {
let mut bt = std::collections::BTreeMap::new();
@xobs
xobs / serialcat.rs
Last active October 29, 2025 03:25
Simple script to cat a serial port at a given baud
#!/usr/bin/env -S cargo +nightly -Zscript
---
[dependencies]
serialport = "4.8.1"
---
use std::{
env,
error::Error,
io::{ErrorKind, Write},
@xobs
xobs / log_sequence.rs
Last active November 21, 2025 02:51
probe-rs Sequence that logs everything
//! Example sequences that log things
#[derive(Debug)]
struct DefaultArmDebugSequence;
impl probe_rs::architecture::arm::sequences::ArmDebugSequence for DefaultArmDebugSequence {}
/// Example of an ARM debug sequence
#[derive(Debug)]
pub struct ExampleSequence;
@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/*',
]