Skip to content

Instantly share code, notes, and snippets.

View fhunleth's full-sized avatar
🦖

Frank Hunleth fhunleth

🦖
View GitHub Profile
@fhunleth
fhunleth / nerves-todo.md
Last active June 24, 2016 09:03
Master nerves project TODO list

nerves project management

  1. Find sponsorship or grants
  2. Find more collaborators

nerves website

  1. docs
  2. tutorials
  3. pretty picture pass to make site look more professional
#!/bin/sh
#
# Upload new firmware to a target running nerves_firmware_ssh
#
# Usage:
# upload.sh [destination IP] [Path to .fw file]
#
# If unspecifed, the destination is nerves.local and the .fw file
# is naively guessed
#include <stdio.h>
#include <math.h>
/*
Experiment with the lgamma function. This function makes it possible to approximate
factorials of very large numbers and runs incredibly fast.
See https://github.com/bminor/musl/blob/master/src/math/lgamma_r.c for how lgamma is
calculated.
@fhunleth
fhunleth / strace.md
Created December 19, 2018 17:22
strace cheatsheet

Only trace calls to exec

strace -s 1024 -e abbrev=none -qfeexecve <program and args>
@fhunleth
fhunleth / cookbook.md
Created February 16, 2019 18:06
NervesHub Cookbook

Publish and deploy the currently built firmware

mix nerves_hub.firmware publish --key fwsigner1 mix nerves_hub.deployment update qa firmware

@fhunleth
fhunleth / fwup_to_slack.sh
Created April 26, 2019 13:15
fwup metadata to slack
./jq-linux64 -n \
--arg meta_uuid $(grep 'meta-uuid' <<< $FW_META | awk -F"=" '{ print $2}') \
--arg meta_version "$(grep 'meta-version' <<< $FW_META | awk -F"=" '{ print $2}')" \
--arg meta_vcs_identifier "$(grep 'meta-vcs-identifier' <<< $FW_META | awk -F"=" '{ print $2}')" \
--arg meta_platform "$(grep 'meta-platform' <<< $FW_META | awk -F"=" '{ print $2}')" \
--arg meta_creation_date "$(grep 'meta-creation-date' <<< $FW_META | awk -F"=" '{ print $2}')" \
--arg meta_misc "$(grep 'meta-misc' <<< $FW_META | awk -F"=" '{ print $2}')" \
'{channel: "C41SHHGQ5", as_user: true, blocks: [
{type: "section", block_id: "text1", text: {type: "mrkdwn", text: "*A new FarmBot Firmware is available*"}},
{type: "context", elements: [
@fhunleth
fhunleth / barometer.ex
Created July 17, 2019 14:15
BMP280 sample
defmodule Barometer do
alias ElixirALE.I2C
@sealevel_pa 101325
@doc """
Put the BMP280 in normal mode and sample the temperature and
pressure sensor at ultra high resolution.
"""
def enable() do
@fhunleth
fhunleth / ble.md
Last active December 7, 2023 19:55
Bluetooth with Nerves notes

UPDATE: THIS WAS WRITTEN BEFORE BlueHeron EXISTED

This is a braindump of my progress over the weekend to look into Bluetooth support on Nerves. While Bluetooth has a lot of specs, supporting a subset of BLE that makes it easy for Nerves devices to communicate with cell phones and back would be generally useful.

There are two options for BLE support on Nerves:

  1. Make a custom Nerves system that uses bluez
  2. Use Harald
umask 0022 && make -C /home/fhunleth/nerves/nerves_system_br/buildroot-2020.05 O=/home/fhunleth/nerves/nerves_system_br/o/rpi0/.
for p in https+https://github.com/erlang/otp/archive/OTP-23.0.2.tar.gz ; do \
if test ! -e /home/fhunleth/dl/erlang/`basename $p` ; then \
echo ">>> erlang 23.0.2 Downloading" ; \
break ; \
fi ; \
done
mkdir -p /home/fhunleth/dl/erlang
PATH="/home/fhunleth/nerves/nerves_system_br/o/rpi0/host/bin:/home/fhunleth/nerves/nerves_system_br/o/rpi0/host/sbin:/home/fhunleth/.asdf/shims:/home/fhunleth/.asdf/bin:/home/fhunleth/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin" BR2_DL_DIR="/home/fhunleth/nerves/nerves_system_br/buildroot-2020.05/dl" BUILD_DIR=/home/fhunleth/nerves/nerves_system_br/o/rpi0/build O=/home/fhunleth/nerves/nerves_system_br/o/rpi0 flock /home/fhunleth/dl/erlang/ support/download/dl-wrapper -c '23.0.2' -d '/home/fhunleth/dl/erlang' -D '/home/fhunleth/dl' -f 'OTP-23.0.2.tar.gz' -H 'package/erlang//erlang.hash' -n 'erlang-23.0.2' -N 'er
@fhunleth
fhunleth / 2 GB eMMC (pSLC mode)
Created September 1, 2020 20:21
mmc extcsd read /dev/mmcblk0
=============================================
Extended CSD rev 1.8 (MMC 5.1)
=============================================
Card Supported Command sets [S_CMD_SET: 0x01]
HPI Features [HPI_FEATURE: 0x01]: implementation based on CMD13
Background operations support [BKOPS_SUPPORT: 0x01]
Max Packet Read Cmd [MAX_PACKED_READS: 0x3c]
Max Packet Write Cmd [MAX_PACKED_WRITES: 0x3c]
Data TAG support [DATA_TAG_SUPPORT: 0x01]