Skip to content

Instantly share code, notes, and snippets.

@xypron
xypron / vloxei64.v.test.c
Last active September 2, 2026 20:06
vloxei64.v.test.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define PAGE_SIZE 4096
// Robust 16-bit bit reversal using mask-and-swap layers (bytes -> nibbles -> pairs -> bits)
uint16_t reverse_16_bits(uint16_t x, uint32_t bit_width) {
// 1. Swap bytes: 0xAABB -> 0xBBAA
x = ((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8);
@xypron
xypron / Screenshot.png
Last active July 31, 2026 07:50
U-Boot: incorrect graphics output for efi-x86_app64_defconfig
Screenshot.png
@xypron
xypron / pow.c
Last active July 25, 2026 07:06
Avoid poweroff on SpacemiT Com260
// SPDX-License-Identifier: MIT
// gcc -O2 -static -s -o pow.shutdown pow.c
// sudo cp pow /usr/lib/systemd/system-shutdown/pow.shutdown
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <linux/reboot.h>
#include <sys/syscall.h>
@xypron
xypron / linux-keymap.c
Last active April 27, 2026 14:31
linux-keymap.c
// SPDX-License-Identifier: MIT
/**
* The layout of Google crosswire keyboards (compatible = "google,cros-ec-keyb")
* are described in the device-tree by the linux,keymap property.
*
* The program below shows how to translate the property to human readable form.
*/
#include <stdio.h>
struct keydef {

Create a x86 VM with multipass

multipass launch \
  -n jammy 22.04 \
  --cpus 4 \
  --disk 16G \
  --memory 16G
multipass shell jammy
The following GUIDs are present in /EFI/BOOT/BOOTAA64.efi of memtest86-usb.zip
(https://www.memtest86.com/downloads/memtest86-usb.zip)
D2 E8 A4 EB 58 38 EC 41 A2 81 26 47 BA 96 60 D0
#define EFI_DEBUGPORT_PROTOCOL_GUID \
{0xEBA4E8D2,0x3858,0x41EC,\
{0xA2,0x81,0x26,0x47,0xBA,0x96,0x60,0xD0}}
DE A9 42 90 DC 23 38 4A 96 FB 7A DE D0 80 51 6A
@xypron
xypron / Makefile
Last active July 23, 2026 18:24
Makefile to create SiFive HiFive Premier P550 firmware
#!/usr/bin/make -f
# SPDX-License-Identifier: MIT
UBOOT_VERSION=eab538b697011b866aba64938ef045e67fa08dc2
OPENSBI_VERSION=EIC7X-2024.11
NSIGN_VERSION=74e7c69b812923f68ef3eeb0c1cbbee90f80b566
all:
make uboot
make sbi
@xypron
xypron / DeepComputing_Roma_II_UART.jpg
Last active November 21, 2024 16:18
Roma II laptop UART
DeepComputing_Roma_II_UART.jpg
@xypron
xypron / Milk-V_Mars_Boot_Source_Selection_SD_card.jpg
Last active March 8, 2024 02:22
Boot select switches on Milk-V Mars
Milk-V_Mars_Boot_Source_Selection_SD_card.jpg
@xypron
xypron / gist:43b58aac1232e73b8eff749fbcc3b4b3
Created March 6, 2024 15:26
OpenOCD specification for PolarFire Icicle Board
#**************************************************************************
# Copyright (C) 2015-2020 by Microchip Technology Inc. *
# http://www.microchip.com/support *
# *
# This program is free software; you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published by *
# the Free Software Foundation; either version 2 of the License, or *
# (at your option) any later version. *
# *
# This program is distributed in the hope that it will be useful, *