Skip to content

Instantly share code, notes, and snippets.

View abrodkin's full-sized avatar

Alexey Brodkin abrodkin

View GitHub Profile
@abrodkin
abrodkin / recvRawEth.c
Last active April 7, 2021 05:11 — forked from austinmarton/recvRawEth.c
Receive raw Ethernet frames in Linux
/*
* 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 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
@abrodkin
abrodkin / chocolate-doom-qemu.txt
Last active March 27, 2024 18:47
Chocolate-doom execution in QEMU or simple embedded Linux board with framebuffer.
fbset > /etc/fb.modes
export SDL_NOMOUSE=1
chocolate-doom

To run glibc test-suite on target without native toolchain we need to have the following 2 requirements:

  1. Host executes tests on target via SSH so we need to have SSH server up and running on target. Moreover we need to either enable paswordless login via SSH or install user's SSH key on target so that execution scripts may connect to target via SSH without asking user for entering pasword all the time (there're 5k+ tests).

  2. Host's filesystem must be accessible from target. Moreover paths must match exactly on both devices (i.e. "/home/username/glibc-testsuite" in both cases must be available and contain exectly the same data) because tests are being built on the fly and immediately get executed via SSH. Thus we need to mount host's filesystem with glibc testsuite on target.

SSH SERVER

CROSS-TOOLCHAIN (with GNU tools from ARC GitHub):

CT_EXPERIMENTAL=y
CT_PREFIX_DIR="${PWD}/toolchain_cross"
CT_ARCH_ARC=y
CT_ARCH_CPU="hs38_linux"
# CT_DEMULTILIB is not set
CT_TARGET_VENDOR="snps"
CT_KERNEL_LINUX=y
CT_BINUTILS_SRC_DEVEL=y
@abrodkin
abrodkin / cpython-2.x-no-usr-local.md
Created September 25, 2018 11:25
Build CPython 2.x with crap in /usr/local/
diff --git a/setup.py b/setup.py
index 33cecc6875..52265a58fc 100644
--- a/setup.py
+++ b/setup.py
@@ -454,10 +454,6 @@ class PyBuildExt(build_ext):
             os.unlink(tmpfile)
 
     def detect_modules(self):
- # Ensure that /usr/local is always used
@abrodkin
abrodkin / emdk-load-elf-metaware.md
Created October 2, 2018 10:26
EMDK: Load Elf with MetaWare

First we need to enable write into "ROM" and we do it with "preloadexec" command:

mdb -dll=opxdarc.so -OK -preloadexec="eval *(int*)0xf0001000=0" u-boot

VirGL

./configure --target-list=arc-softmmu --enable-sdl --enable-opengl --enable-virglrenderer --enable-gtk --enable-spice
./arc-softmmu/qemu-system-arc -M simhs -nographic -kernel vmlinux -cpu archs -append "root=/dev/vda ro" -drive file=rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -vga virtio -spice gl=on

Save console output to file

qemu-system-arc -M simhs -nographic -no-reboot -monitor none -cpu archs -chardev stdio,id=char0,logfile=serial.log,signal=off -serial chardev:char0 -kernel vmlinux
@abrodkin
abrodkin / ARC-GNU-tools-build.md
Last active December 19, 2019 10:34
Manual ARC GNU toolchain building with Synopsys scripts

Install dependencies

Ubuntu/Debian: apt-get update && apt-get install -y texinfo byacc flex libncurses5-dev zlib1g-dev libexpat1-dev texlive build-essential git wget gawk bison xz-utils make python3 rsync locales

CentOS/RHEL 7: yum install -y autoconf automake binutils bison byacc flex gcc gcc-c++ libtool patch texinfo-tex ncurses-devel ncurses-compat-libs flex zlib-devel expat-devel git texlive-collection-latexrecommended wget make xz rsync diffutils which

Fedora, CentOS/RHEL 8: dnf install -y autoconf automake binutils bison byacc flex gcc gcc-c++ libtool patch texinfo-tex ncurses-devel ncurses-compat-libs flex zlib-devel expat-devel git texlive-collection-latexrecommended wget make xz rsync diffutils which

Get all the sources

IoTDK

west -v -v -v flash --serial=251642517567 --use-elf

HSDK

west -v -v -v flash --serial=25164200001f --use-elf

Preparation of the build host:

  1. Clone osxcross repo: git clone https://github.com/tpoechtrager/osxcross
  2. cd osxcross
  3. Download MacOS SDK: curl -sLo tarballs/MacOSX10.10.sdk.tar.xz https://www.dropbox.com/s/yfbesd249w10lpc/MacOSX10.10.sdk.tar.xz
  4. Run container for building

CentOS 8.x

docker run -v $PWD:/osxcross --name centos8-osxcross -i -t centos:centos8 /bin/bash