Skip to content

Instantly share code, notes, and snippets.

@mdaffin
mdaffin / .gitignore
Last active January 1, 2024 16:21
bare metal assembly on the teensy 3.1
*.swp
*.elf
*.hex
*.o
@mdaffin
mdaffin / wifi
Last active December 3, 2021 12:59
A script to make connecting with wpa_cli easier (Work in progress)
#!/bin/bash
# Wraps aursync command to mount an amazon s3 bucket which contains a repository
set -uo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
INTERFACE=wlp58s0
wpa() {
wpa_cli -i "${INTERFACE}" "$@"
}
@mdaffin
mdaffin / a
Created January 8, 2020 18:38
a

Keybase proof

I hereby claim:

  • I am mdaffin on github.
  • I am mdaffin (https://keybase.io/mdaffin) on keybase.
  • I have a public key whose fingerprint is 742D 825A 69EA B6A2 9096 1378 09A6 B699 E384 25B5

To claim this, I am signing this object:

@mdaffin
mdaffin / flasher
Last active May 6, 2018 22:48
A simple wrapper around ddrescue that reduces the error involved in burning images to SD cards.
#!/bin/bash
#
# Usage: ./flasher path/to/rpi.img
#
# A interactive wrapper around ddrescue that offers a menu to select which
# removable media to write the given image to. This makes it easier and
# safer to flash images to SD Cards then simply using dd.
#
set -uo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
@mdaffin
mdaffin / Vagrantfile
Last active April 16, 2016 10:22
A set of scripts to automate formatting/installing and configuring a raspberry pi sd card.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "shell", inline: <<-SHELL
apt-get update -y
apt-get install -y qemu qemu-user-static binfmt-support
SHELL
end

C on the teensy 3.1

An example of writing pure c on the teensy 3.1.

Prerequisites

You will need the C compiler, linker and objcopy from the arm-none-eabi toolkit:

  • arm-none-eabi-gcc
  • arm-none-eabi-ld
  • arm-none-eabi-objcopy
@mdaffin
mdaffin / main.rs
Created January 24, 2016 11:56
A bare metal example of blink written in rust for the teensy 3.1
#![feature(lang_items,no_std,core_intrinsics,asm,start)]
#![no_std]
#![crate_type="staticlib"]
use core::intrinsics::{volatile_store};
#[lang="stack_exhausted"] extern fn stack_exhausted() {}
#[lang="eh_personality"] extern fn eh_personality() {}
#[lang="panic_fmt"]
#[no_mangle]
@mdaffin
mdaffin / .gitignore
Created January 13, 2016 12:29
bare metal assembly on the teensy 3.1
*.swp
*.elf
*.hex
*.o
/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/home/james/sketchbook/libraries/Blink /tmp/build4026121571324884541.tmp/sketch_sep05a.cpp -o /tmp/build4026121571324884541.tmp/sketch_sep05a.cpp.o
/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/home/james/sketchbook/libraries/Blink -I/home/james/sketchbook/libraries/Blink/utility /home/james/sketchbook/libraries/Blink/Blink.cpp -o /tmp/build4026121571324884541.tmp/Blink/Blink.cpp.o
/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -O