Skip to content

Instantly share code, notes, and snippets.

View zeldin's full-sized avatar

Marcus Comstedt zeldin

View GitHub Profile
@zeldin
zeldin / main.cpp
Created September 9, 2026 18:04
PS3 program for testing readdir and stat file types
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#!/bin/sh
KERNEL="$(dirname "$0")"/Image
CMDLINE="earlycon console=ttyAMA0 quiet $@"
exec taskset 0x39 qemu-system-aarch64 -machine virt -cpu host -enable-kvm -nographic -smp 1 -m 2048 -virtfs local,path=/usr/aarch64_be-unknown-linux-gnu,mount_tag=root9p,security_model=passthrough,id=root9p -virtfs local,path=/home,mount_tag=home9p,security_model=passthrough,id=home9p -kernel "$KERNEL" -append "$CMDLINE"
@zeldin
zeldin / Dockerfile
Last active October 15, 2023 20:13
Building stable-diffusion-webui on ppc64le
# This work is marked with CC0 1.0. To view a copy of this license,
# visit http://creativecommons.org/publicdomain/zero/1.0
ARG WEBUI_VERSION=1.5.2
ARG TORCH_VERSION=2.0.1
ARG VISION_VERSION=0.15.2
ARG MAX_JOBS=8
FROM debian:11 AS base
@zeldin
zeldin / softcore_shootout.md
Last active August 29, 2023 18:32
Comparison between AVR and RISC-V softcore in a real application

This is a comparison between an AVR softcore and the picorv32 when used in a real application. The numbers are for the entire application, not for the cores in isolation. Only minimal changes were made to the HDL and firmware code to adapt to the new core (the peripherals were updated to handle a 32-bit bus, and the interrupt handling was adapted to picorv32, otherwise the code is identical) and the same optimization flags (-Os -mrelax) were used with both cores.

The following were the relevant design constraints:

  • Synthetizable on an iCE40 HX8K
  • fCPU = 17 MHz
@zeldin
zeldin / Dockerfile
Created April 2, 2023 07:29
Recipe for reproducing breezy bug on Debian
FROM debian:11.6
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'deb-src http://deb.debian.org/debian bullseye main' >> \
/etc/apt/sources.list && apt-get update
RUN apt-get install -y --no-install-recommends dpkg-dev
WORKDIR /tmp
@zeldin
zeldin / Dockerfile
Created April 2, 2023 06:41
Recipe for reproducing breezy bug on Ubuntu
FROM ubuntu:jammy
ENV DEBIAN_FRONTEND=noninteractive
RUN sed -i -e '/deb-src/s/^#//' /etc/apt/sources.list && apt-get update
RUN apt-get install -y --no-install-recommends dpkg-dev
WORKDIR /tmp
RUN apt-get source breezy
@zeldin
zeldin / bootstrap_haskell_packages_test.txt
Last active December 6, 2022 17:35
The most(?) efficient way of bootstrapping haskell packages with tests enabled
FEATURES=test USE=test emerge -1a dev-haskell/mtl dev-haskell/text dev-haskell/fail dev-haskell/transformers dev-haskell/parsec dev-haskell/transformers-compat dev-haskell/cabal dev-haskell/tagged dev-haskell/splitmix dev-haskell/primitive dev-haskell/colour dev-haskell/nanospec dev-haskell/cabal-doctest dev-haskell/th-abstraction dev-haskell/clock dev-haskell/setenv dev-haskell/stm dev-haskell/random dev-haskell/call-stack dev-haskell/ansi-terminal dev-haskell/quickcheck dev-haskell/hunit dev-haskell/tf-random dev-haskell/quickcheck-io dev-haskell/hspec-expectations
FEATURES=-test USE=-test emerge -1a dev-haskell/hspec-discover dev-haskell/hspec-core # check only these 2 are merged
FEATURES=test USE=test emerge -1a dev-haskell/hspec-discover dev-haskell/hspec-core
FEATURES=test USE=test emerge -a @preserved-rebuild # Should rebuild dev-haskell/hspec
Only three rebuilds are needed; dev-haskell/hspec-discover dev-haskell/hspec-core and dev-haskell/hspec
Build list for first command (25 builds)
// Copyright Oliver Kowalke 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// libcontext adaptation by Marcus Comstedt 2022
#include <cstdlib>
#include <iostream>
#include <memory>
Debian patches needed for riscv64:
latomic-subword.patch
Debian patches needed for ppc (32-bit):
latomic-subword.patch
latomic-64bit.patch
#!/bin/sh
version="$@"
if [ -z "$version" ]; then
version="`equery l -F '$fullversion' -p dev-lang/ghc | tail -1`"
fi
PKGDIR="/tmp/`uname -m`/packages"
[ -d "$PKGDIR" ] || mkdir -p "$PKGDIR"
export PKGDIR
CFLAGS="-O2 -pipe"
export CFLAGS