Skip to content

Instantly share code, notes, and snippets.

@agners
agners / esp32-c3.yaml
Last active January 2, 2022 11:18
ESPHome ESP32-C3 configuration
# This is a ESPHome yaml configuration skeleton for
# ESP32-C3 (RISC-V) based boards.
# It is known to work on ESP32-C3-DevKitM-1
# This is using stable release of Arduino 2.0.2 as base
esphome:
name: esp32-c3-test
platformio_options:
board_build.flash_mode: dio
@agners
agners / README.md
Created February 22, 2022 13:33
Silicon Labs OpenThread native git repositories

Silicon Labs OpenThread native git repositories

Background: Silicon Labs offers OpenThread with modifications to support multi-protocol operations as described in AN1333. At least since Gecko SDK release 4.0.0 (Silicon Labs OpenThread release 2.0.0.0) the OpenThread repositories are available through their unified Gecko SDK releases at https://github.com/siliconLabs/gecko_sdk.

However, this repositories has several flaws:

  • It combines all their SDKs in a single big repository
@agners
agners / serial_asyncio_test.py
Created April 2, 2022 10:36
Test serial_asyncio with socat
import asyncio
import serial_asyncio
import serial
class Output(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
print('port opened', transport)
# This causes an exception
#transport.serial.rts = False
@agners
agners / main.py
Last active May 9, 2022 11:48
asyncio aiohttp timeout
import aiohttp
import asyncio
async def work(i: int):
#print(f"start working on {i}")
for i in range(50):
pass
async def main():
tasks = []
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Stefan Agner
import os
import sys
import time
import usb
BITMODE_CBUS = 0x20
@agners
agners / gist:5785663
Last active August 17, 2022 19:44 — forked from anonymous/gist:5785661
TS-7250 Reflash root
See
http://wiki.embeddedarm.com/wiki/Getting%20Started%20with%20TS-Linux%20ARM
http://wiki.embeddedarm.com/wiki/Linux_for_ARM_on_TS-72XX_User%27s_Guide
ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7250-linux/
# apt-get install nfs-kernel-server tftpd xinetd
Setup TFTP
# vi /etc/xinetd.d/tftp
@agners
agners / rpi-eeprom-ver.sh
Created January 30, 2023 14:10
Get Raspberry Pi EEPROM version (CM4/RPi4, inspired by https://github.com/raspberrypi/rpi-eeprom/blob/master/rpi-eeprom-update)
#!/bin/sh
DT_BOOTLOADER_TS=${DT_BOOTLOADER_TS:-/proc/device-tree/chosen/bootloader/build-timestamp}
BOOTLOADER_CURRENT_VERSION=$(printf "%d" "0x$(od "${DT_BOOTLOADER_TS}" -v -An -t x1 | tr -d ' ' )")
date -u "-d@${BOOTLOADER_CURRENT_VERSION}"
@agners
agners / glc006p.py
Created April 29, 2023 07:14
ZHA custom device (quirk) to override GL-C-006P warm-white/cold-white color temperature
"""GLEDOPTO GL-C-006P device."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
@agners
agners / iomonitor.sh
Created August 18, 2023 13:35
Simple IO monitoring script usful on Home Assistant OS
#!/bin/sh
#
# IO monitoring for Linux
#
# Taken from armbianmonitor
# https://github.com/armbian/build/blob/master/packages/bsp/common/usr/bin/armbianmonitor
# Adjusted to rely on diskstats only.
#
MonitorIO() {
@agners
agners / prune-corrupted-layer-metadata.sh
Last active November 30, 2023 21:18
Prune corrupted Docker layers in overlayfs2 storage
#!/bin/sh
# (c) 2023 Stefan Agner
# This scripts attempts to clear corrupted Docker overlay2 storage metadata
# which can be left over after a power failure.
# See also: https://github.com/moby/moby/issues/42964
#
# Typically the error message when attempting to pull the image for which
# corrupted layers are in the storage looks like:
# failed to register layer: error creating overlay mount to /mnt/data/docker/overlay2/6ee02298ee75a4f96e77f90551673cb700f29867f9ad1c4e20b8c816bfcf0735/merged: too many levels of symbolic links