Skip to content

Instantly share code, notes, and snippets.

View waveform80's full-sized avatar

Dave Jones waveform80

View GitHub Profile

ZMQEventLoop / SelectEventLoop "hang"

The following scripts can be used to reproduce the ZMQEventLoop (and the default SelectEventLoop) in urwid "hanging" when watched queues (or file descriptors) are ready but aren't serviced by their respective handlers.

The zmq_send.py and zmq_recv_1.py scripts can be run together to demonstrate a simple urwid application that receives messages from a SUB socket and displays them next to a clock. The zmq_recv_2.py script demonstrates what happens when the SUB socket is "ready" but isn't cleared by the handler; it's simply called repeatedly in preference to anything else. The display doesn't update unless draw_screen() is

@waveform80
waveform80 / README.md
Last active September 17, 2020 12:11 — forked from cleverca22/uptime.c
rpi firmware load time

From the original comment:

@Yoshqu there is a much simpler way to measure boot time to the usec, without having to use that custom bootloader

basically, ST_CLO begins counting at 1mhz, the instant the SoC comes out of reset and /proc/uptime begins counting seconds when linux starts up its internal clocks

the code in the gist, will then print both of them at once, and if you find the difference, youll see how long it took for linux to gain control of the core

{%- extends "basic/layout.html" %}
{% block relbar1 %}{% endblock %}
{% block relbar2 %}{% endblock %}
{% block footer %}{% endblock %}
{% block content %}
<div id="content">
<div class="header">
<h1 class="heading"><span>{{ docstitle|striptags|e }}</span></h1>
</div>
<div class="relnav" role="navigation">
@waveform80
waveform80 / mux-logs.py
Created May 7, 2020 12:05
A rough script for mux'ing the main cloud-init log and systemd's journal output
#!/usr/bin/python3
import io
import re
import datetime as dt
from subprocess import run, PIPE
from itertools import chain
def cloud_init_log():
with io.open('/var/log/cloud-init.log', 'r', encoding='utf-8') as log:
@waveform80
waveform80 / ubuntu-classic-boot.dot
Created January 30, 2020 18:11
Some graphs of the ubuntu boot sequence
# Build with dot -Tpng ubuntu-classic-boot.dot | display png:-
digraph G {
graph [rankdir=TB];
node [fontsize=10, fontname="Arial"];
edge [fontsize=10, fontname="Arial"];
/* files */
node [shape=rect, style=filled, fillcolor="#7ec2cc", penwidth=0];
bootcode_bin [label="/boot/bootcode.bin"];
@waveform80
waveform80 / README.md
Last active April 16, 2024 14:46
Script for editing / dumping / graphing a uboot environment

U-Boot Environment Tools

A simple Python script for editing U-Boot environments. Should automatically detect the size of the U-Boot environment, and whether the "redundand" (sic) byte is included in it.

The script can be renamed (or linked) to "dump-env" for a simple tool to dump U-Boot environments too, or to "dot-env" for a tool that'll attempt to generate a Graphviz dot graph by parsing the U-Boot environment from $bootcmd (please note this last function is quite experimental, although I've found it useful in the past for figuring out the dependencies and execution paths of certain scripts).

Summary

  • edit-env env - Edit U-Boot environment env in the system editor
@waveform80
waveform80 / scat.sh
Created January 30, 2020 14:59
a brutally simple serial term
#!/bin/bash
# Derived from https://unix.stackexchange.com/a/311680/295309
if [[ $# -lt 1 ]]; then
echo "Usage:"
echo " $0 <serial-port> [ <speed> [ <stty-options> ...] ]"
echo " Example: $0 /dev/ttyS0 115200"
echo " Use ^Q to quit"
exit 1
@waveform80
waveform80 / openvpn-in-lxd.txt
Created November 14, 2019 11:54 — forked from wastrachan/openvpn-in-lxd.txt
OpenVPN in LXD Container
# On the host
=============
lxc config set openvpn raw.lxc 'lxc.cgroup.devices.allow = c 10:200 rwm'
lxc config device add openvpn tun unix-char path=/dev/net/tun
# In the container
==================
1. mknod /dev/net/tun c 10 200
@waveform80
waveform80 / scan_for_symlinks.py
Last active October 25, 2018 22:55
Quick hack to scan for symlinks in wheels on piwheels master
@waveform80
waveform80 / README.rst
Created October 16, 2018 22:07
opencv-python piwheels build scripts

opencv-python build scripts

This is all extremely hacky so you'll probably need to play around with it to get it working. On a fresh Raspbian Jessie or Raspbian Stretch install, add all the build-deps we usually have on a piwheels build slave (see https://github.com/bennuttall/piwheels/blob/master/deploy_slave.sh and install all the -dev stuff and python libs, basically). Next, add a 1Gb swap file.

In the default "pi" user, make a "packaging" directory and stuff opencv-python-build and opencv-setup.py under there. Make opencv-python-build executable and edit the for-loops