Skip to content

Instantly share code, notes, and snippets.

View troglobit's full-sized avatar
🎯
Focusing

Joachim Wiberg troglobit

🎯
Focusing
View GitHub Profile
@troglobit
troglobit / linux-leds.md
Created October 19, 2023 16:22
Blinking LEDs in Linux

Blinking LEDs in Linux

First check you have the timer trigger loaded:

root@gimli:~# lsmod |grep led
snd_ctl_led            24576  0
input_leds             16384  0
snd                   135168  45 snd_ctl_led,snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_sof,snd_timer,snd_compress,thinkpad_acpi,snd_soc_core,snd_pcm,snd_rawmidi
soundcore              16384  2 snd_ctl_led,snd
@troglobit
troglobit / shell-script-tips.md
Last active May 12, 2023 14:17
Shell Scripting Tips

Debug a script callback to console

exec >/dev/console 2>&1
set -x

Ignore error on a particular line in set -e

possibly-failing-command ||:

Redirect STDERR to STDOUT

@troglobit
troglobit / unicode-in-emacs.md
Created December 19, 2022 16:24
Unicode in Emacs
grep Vm /proc/$(ps aux | grep inadyn |head -1 |awk '{print $2}')/status
@troglobit
troglobit / mping-howto.md
Created May 23, 2022 08:10
Using mping to script multicast switching/routing verification

HowTo: using mping for (fun and) profit

Ever since I started working with multicast back in the early 2000's, I've had to make my own tools. There weren't that many useful ones available, at least not in the Open Source space where I worked.

The first tool made, mcjoin, was based on an example an IBM'er had made public. I used that, the standard ping(1) tool, and tcpdump(1), to check my multicast flows.

@troglobit
troglobit / libnl-debug.md
Last active April 22, 2022 14:10
Developing and debugging libnl

Developing & debugging libnl

When I started out learning about libnl, around 10 years ago, I did not fully understand it. Mostly because I didn't (want to) understand Netlink. A great way to learn something is to try to fix a bug, or develop a new feature, because then you will want to write both tests and demo applications, which you may end up having to debug! Debuggers give you backtraces, which will help you understand how your program works.

Note: for debugging embedded systems using gdb-server, see the following blog post I wrote

@troglobit
troglobit / local.mk
Created April 5, 2022 08:50
Buildroot local.mk extensions and overrides
#BR2_ROOTFS_OVERLAY := $(BR2_ROOTFS_OVERLAY) $(BR2_EXTERNAL_NETBOX_PATH)/jocke
LINUX_OVERRIDE_SRCDIR = /home/jocke/src/linux
#IPROUTE2_OVERRIDE_SRCDIR = /home/jocke/src/iproute2
#MDIO_TOOLS_OVERRIDE_SRCDIR = /home/jocke/src/github.com/jocke/mdio-tools
#MDIO_TOOLS_AUTORECONF = YES
#PLY_OVERRIDE_SRCDIR = /home/jocke/src/github.com/jocke/ply
#PLY_AUTORECONF = YES
#TCPDUMP_OVERRIDE_SRCDIR = /home/jocke/src/github.com/the-tcpdump-group/tcpdump
#LIBPCAP_OVERRIDE_SRCDIR = /home/jocke/src/github.com/the-tcpdump-group/libpcap
@troglobit
troglobit / ANSI.md
Created January 18, 2022 06:33 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@troglobit
troglobit / u-boot.txt
Last active July 9, 2021 18:19
Marvell MacchiatoBin U-Boot
Marvell>> printenv
baudrate=115200
bootargs=console=ttyS0,115200 root=/dev/nfs rw ip=0.0.0.0:0.0.0.0:10.4.50.254:255.255.255.0:marvell:eth0:none nfsroot=0.0.0.0:/srv/nfs/
bootcmd=run get_env; run get_images; run set_bootargs; booti $kernel_addr $ramfs_addr $fdt_addr
bootdelay=2
console=console=ttyS0,115200
eth1addr=00:51:82:11:22:01
eth2addr=00:51:82:11:22:02
eth3addr=00:51:82:11:22:03
ethact=mvpp2-0
@troglobit
troglobit / world.sh
Created June 18, 2021 13:10
Sets up a complete network world inside a network namespace
#!/bin/sh -x
# Sets up a complete network world inside a network namespace
ns=world
ip netns add $ns
for i in 1 2 3 4; do
ip netns exec $ns ip link add eth$i type veth peer p$i
done