Skip to content

Instantly share code, notes, and snippets.

@kevinmehall
kevinmehall / verify.rs
Created July 18, 2015 22:59
Check Saleae CSV dumps from Tessel 2 bridge for timing margin
use std::io;
use std::io::prelude::*;
use std::fs;
use std::env;
use std::cmp::Ordering;
fn main() {
let args: Vec<String> = env::args().collect();
let file = io::BufReader::new(fs::File::open(&args[1]).unwrap());
@kevinmehall
kevinmehall / build-libs.sh
Created May 29, 2015 19:14
Rust OpenWrt cross compile (full bootstrap)
#!/bin/bash
set -e -u
# Run this in a rust-lang/rust checkout with the above patch applied
git fetch
git checkout $1
mkdir -p build-cross
cd build-cross
@kevinmehall
kevinmehall / rust-cross-libs.sh
Last active November 3, 2023 13:23
Cross-compile Rust standard library for Tessel without full bootstrap build [A work in progress]
#!/bin/bash
# THIS IS A GIANT HACK
# if you think this would be a good idea if it weren't so terrible, go read https://github.com/rust-lang/rfcs/pull/1133
set -e
# Parse args
for i in "$@"
do
@kevinmehall
kevinmehall / xplained.py
Created May 7, 2015 21:44
PyOCD on Atmel SAM D21 Xplained
import pyOCD
from pyOCD.interface import INTERFACE, usb_backend
from pyOCD.board.board import Board
from pyOCD.gdbserver import GDBServer
import traceback
boards = INTERFACE[usb_backend].getAllConnectedInterface(0x03eb, 0x2111)
board = Board('cortex_m', 'cortex_m', boards[0])
board.init()
@kevinmehall
kevinmehall / _t2-swd.md
Last active April 4, 2017 06:47
Tessel 2 onboard SWD

Needs a more recent openocd than is currently available in openwrt/packages:

opkg update
wget https://kevinmehall.net/tmp/openocd_d3c2679bcb8e8ba25e7b6e443b39f57474afc099-2_ramips_24kec.ipk -O /tmp/openocd.ipk
opkg install /tmp/openocd.ipk
rm /tmp/openocd.ipk

In another terminal:

@kevinmehall
kevinmehall / node-gyp-cross.sh
Created January 30, 2015 21:15
node-gyp cross-compile
#!/bin/bash
set -e
if [ ! -d "$STAGING_DIR" ]; then
echo "STAGING_DIR needs to be set to your cross toolchain path";
exit 1
fi
ARCH=${ARCH:-mipsel}
NODE=${NODE:-0.10.33}
@kevinmehall
kevinmehall / output
Created December 22, 2014 04:27
LLVM immediate offset missed optimization for ARM thumb register access
Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
00008000 <main>:
8000: 4802 ldr r0, [pc, #8] ; (800c <main+0xc>)
8002: 2101 movs r1, #1
8004: 6001 str r1, [r0, #0]
8006: 4802 ldr r0, [pc, #8] ; (8010 <main+0x10>)
8008: 6001 str r1, [r0, #0]
800a: 4770 bx lr
800c: 10001004 .word 0x10001004
8010: 10001008 .word 0x10001008
@kevinmehall
kevinmehall / Dockerfile
Created November 3, 2014 19:20
connect cross-compile in docker
FROM fedora:20
RUN yum install -y git cmake make libtool \
mingw32 mingw32-binutils mingw32-runtime mingw32-gcc-c++ \
mingw32-boost mingw32-boost-static.noarch \
&& yum clean all

Fractal Components

A code generation platform for distributed embedded systems.

Most of the code in an embedded system deals with IO, both with sensors and actuators, as well as communicating with a PC, phone, or server. Typically the domain logic implementing the unique behavior that the developer actually cares about is a small portion of the code, but ends up intertwined with all the IO, making it hard to introspect and port between platforms.

Fractal is about breaking the IO into reusable chunks, called components, with structured interfaces defined by state machines, and automatically generating code for them to communicate with each other, whether they're on the same physical hardware or across a network. By simplifying IO, developers can focus on the domain logic unique to their application.

Code in multiple languages can be mixed and matched, so developers can pick the right language for each task -- Rust and C for size and speed, JS or Lua for familiarity, ease of prototyping, and existing netw

@kevinmehall
kevinmehall / README.md
Last active May 31, 2021 18:44
Tessel + Bus Blaster + OpenOCD

Setup

  1. Install OpenOCD. You need version >= 0.8.0.
  1. Save the openocd script below as tessel-busblaster.cfg.

  2. Plug the JTAG cable into the Bus Blaster's adapter board and the Tessel. Pin one is towards the USB port; the cable goes over the center of the board.

  3. Run