Skip to content

Instantly share code, notes, and snippets.

View fhunleth's full-sized avatar
🦖

Frank Hunleth fhunleth

🦖
View GitHub Profile
@fhunleth
fhunleth / mndp_discover.exs
Last active September 6, 2024 13:11
MNDP Discovery Script
#!/usr/bin/env elixir
# Run as host even if invoked with MIX_TARGET set
Mix.start()
Mix.target(:host)
Mix.install([
{:mndp, github: "kevinschweikert/mndp", start_applications: false},
{:owl, "~> 0.11.0"}
])
@fhunleth
fhunleth / bench.md
Last active May 28, 2023 19:39
Comparison of RPi Zero 2 W running OTP 26, 32-bit vs 64-bit

RPi Zero 2 W, 32-bit, OTP 26

EStone test completed
**** CPU speed UNKNOWN MHz ****
**** Total time 17.605631 seconds ****
**** ESTONES = 38607 ****

    Title                            Millis        Estone       %    Loops
@fhunleth
fhunleth / nerves-gprof.md
Created February 16, 2023 00:13
Running gprof with Nerves

Add this to erlang.mk:

define ERLANG_BUILD_GPROF
        $(TARGET_MAKE_ENV) $(ERLANG_CONF_ENV) TARGET='riscv64-buildroot-linux-gnu' $(MAKE) -C $(@D)/erts/emulator gprof
endef

ERLANG_POST_BUILD_HOOKS += ERLANG_BUILD_GPROF
@fhunleth
fhunleth / notes.md
Last active February 7, 2023 04:27
pSLC mode on BBBW

Putting the BBBW's eMMC into pSLC mode on Nerves

WARNING: I don't believe there's a way to undo this.

The BBBW has a 4 GB eMMC. For better reliability, I'm trying to put it into pSLC mode. Since the 4 GB eMMC is an MLC Flash with 2-bits per cell, converting it to pseudo-SLC mode (1-bit per cell) halves the total size.

Here's the original eMMC information:

ElixirConf Demo

Introduction

This is a simplified version Masatoshi Nishiguchi's bmp280.livemd notebook that's included in Nerves Livebook. Check out that notebook if you'd like to try this out yourself.

Setup

@fhunleth
fhunleth / binary_patterns.md
Last active September 20, 2020 17:17
Elixir binary pattern conventions

See the Elixir binary pattern docs

Goals

  1. Consistency between code bases
  2. Conciseness of patterns

Conventions for integer and float fields

  1. All integers are specified with the fields in --- order
@fhunleth
fhunleth / upload.sh
Created September 20, 2020 12:48
nerves_firmware_ssh upload script
#!/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
@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]
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 / ble.md
Last active October 22, 2024 09:08
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