Skip to content

Instantly share code, notes, and snippets.

View cyyself's full-sized avatar

Yangyu Chen cyyself

View GitHub Profile
@cyyself
cyyself / k1-mainline-opensbi.md
Last active February 11, 2025 21:39
Replace OpenSBI on Spacemit K1

Steps to replace OpenSBI on Spacemit K1

The Spacemit Version of OpenSBI is outdated and disabled printf and consumes the wrong dts with wrong isa string, causing some debugging features that needs printf does not work, and zicboz can not be activated.

This file will tell you how to replace OpenSBI to mainline (v1.4+) on Spacemit K1, and it also compatible with factory sdk kernel.

Prerequisites

You have flashed Bianbu or Armbian for BPI-F3 and flashed to SD Card.

#!/usr/bin/env sh
wg_filter="wg0 wg1" # EDITME
current_time=$(date +%s)
wg show all dump | awk '{if ($5 != "off") print $1,$6}' | while read -r each_dump; do
interface=$(echo $each_dump | cut -d' ' -f1)
last_handshake=$(echo $each_dump | cut -d' ' -f2)
if echo $wg_filter | grep -q $interface; then
if [ $((current_time - last_handshake)) -gt 240 ]; then
#!/usr/bin/env python3
PREFIX = "2001:470:19:a65:"
SUFFIX = "/64"
LEN = 14
print("brctl addbr pathgen")
print("ip link set pathgen up")
print("ip addr add %sffff:ffff:ffff:ffff%s dev pathgen" % (PREFIX, SUFFIX))
#!/usr/bin/env sh
# Check if multiple IPv6 addresses are assigned to the usb0 interface
# If so, we have deprecated addresses and need to restart the interface.
if [ $(cat /proc/net/if_inet6 | grep usb0 | wc -l) -gt 2 ]; then
ifdown wwan6
ifup wwan6
fi
# ip-full kmod-veth iptables-nft ip6tables-mod-nat ip6tables-nft
ip6tables -t nat -A POSTROUTING -s fd05::1/64 -j MASQUERADE
ip link add 5g_lan type veth peer 5g_lan_peer
ip netns add 5g_lan
ip link set dev 5g_lan_peer netns 5g_lan
ip netns exec 5g_lan sh <<EOF
sysctl -w net.ipv4.conf.all.forwarding=1
sysctl -w net.ipv6.conf.all.forwarding=1
ip link set dev lo up
ip link set dev 5g_lan_peer up

We can trust the use of _dl_lookup_symbol_x during elf_machine_runtime_setup in SHARED is safe

Prove

These discussions are based on recent glibc commit a4c414796a.

I know it's hard to prove _dl_lookup_symbol_x being called at elf_machine_runtime_setup without l_relocated == 1 when we have #ifdef SHARED is safe. But if we trust another place it is being called is safe, and there is no change for the requested data structure between these 2 times , then it's natural to trust we call it here is safe.

We can prove this by debugging lib/ld-linux-riscv64-lp64d.so.1 in gdb. First, compile glibc commit a4c414796a with && l->l_relocated removed in sysdeps/riscv/dl-machines.h.

Build SPECCPU 2017 Tools for LoongArch64

Tested on LoongArch Archlinux (2023-10-09).

Fix config.guess

wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
cp config.* ./make-4.2.1/config/

Related

issue: https://github.com/flatpak/xdg-desktop-portal/issues/1032

Error log:

~ systemctl --user status xdg-desktop-portal
● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal.service; static)
     Active: activating (start) since Tue 2024-11-26 12:41:59 CST; 1min 5s ago
#!/usr/bin/env python3
import sys
from pathlib import Path
def read_csv(file_path: Path):
filename = file_path.name
with open(file_path, 'r') as file:
lines = file.readlines()
result_line_idx = lines.index('"Selected Results Table"\n')
# This is a sample config file for CPU2006. It was tested with:
#
# Compiler name/version: [gcc, g++, gfortran 4.3.4]
# [gcc, g++, gfortran 4.4.4]
# [gcc, g++, gfortran 4.6.0]
# Operating system version: [SLES 11 SP1, 64-bit, gcc 4.3.4 and 4.6.0]
# [RHEL 6, 64-bit, gcc 4.4.4]
# Hardware: [Opteron]
#
# If your platform uses different versions, different