Skip to content

Instantly share code, notes, and snippets.

View dhilst's full-sized avatar
😻

Daniel Hilst dhilst

😻
View GitHub Profile
@dhilst
dhilst / Kbuild
Last active August 29, 2015 14:04
How to export out-of-tree ioctls to userspace?
CFLAGS_mymodule.o := -DDEBUG
obj-m := mymodule.o
header-y += mymodule.h
@dhilst
dhilst / gpio
Created September 8, 2015 17:12
/*
* MCP23S08 SPI/GPIO gpio expander driver
*/
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
/*
* MCP23S08 SPI/GPIO gpio expander driver
*/
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
@dhilst
dhilst / Makefile
Created February 2, 2016 15:59
respawn - a small utility to respawn process that exists when should keep up.
CFLAGS_respawn += -Wall
respawn: respawn.c
$(CC) $(CFLAGS_$@) $(LDFLAGS_$@) $(CFLAGS) $(LDFLAGS) -o $@ $<
clean:
rm -f respawn
@dhilst
dhilst / framebuffer-vncserver_git.bb
Created February 5, 2016 13:06
Yocto's framebuffer-vncserver & libvncserver recipes tested with Daisy (1.6)
DESCRIPTION = "VNC server running on top of framebuffer"
HOMEPAGE = "https://github.com/ponty/framebuffer-vncserver"
LICENSE = "GPLv2"
DEPENDS = "libvncserver"
RDEPENDS_${PN} = "libvncserver"
SRC_URI = "git://github.com/ponty/framebuffer-vncserver.git"
LIC_FILES_CHKSUM = "file://LICENSE;md5=8264535c0c4e9c6c335635c4026a8022"
PR = "r1"
PR_append = "+gitr${SRCPV}"
SRCREV = "83586bf6bbb1cbc8ccd72db602d4d4b75d2c2b04"
@dhilst
dhilst / Makefile
Last active June 24, 2016 18:51
unix socket
libus: libus.c libus.h
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
clean:
rm libus
. $1
export BUILD_SYS=$(echo $CONFIGURE_FLAGS | tr -s ' ' '\n' | grep host | cut -f2 -d=)
export HOST_SYS=$(echo $CONFIGURE_FLAGS | tr -s ' ' '\n' | grep build | cut -f2 -d=)
export STAGING_INCDIR=${OECORE_TARGET_SYSROOT}/usr/include
export STAGING_LIBDIR=${OECORE_TARGET_SYSROOT}/usr/lib
export PATH=${OECORE_NATIVE_SYSROOT}/usr/bin/python-native:${PATH}
# remove stripping, I face used symbols being stripped
# this has to do with linker option order
export LDFLAGS=${LDFLAGS/-Wl,--as-needed/}
@dhilst
dhilst / arm-env.sh
Created June 28, 2016 13:33
Kernel crosscompile environments
export ARCH=arm
export CROSS_COMPILE=arm-poky-linux-gnueabi-
# u-boot mkimage is inside Yocto's sysroot
# edit acordingly
export PATH=${PATH}:/opt/poky/1.6.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi:/opt/poky/1.6.2/sysroots/x86_64-pokysdk-linux/usr/bin/
@dhilst
dhilst / example-core-image.bbclass
Created July 1, 2016 13:15
example-core-image.bbclass
inherit core-image
disable_getty () {
sed -e 's,^1:2345:respawn:/sbin/getty 38400 tty1$,# 1:2345:respawn:/sbin/getty 38400 tty1,' -i ${IMAGE_ROOTFS}/etc/inittab
}
ROOTFS_POSTPROCESS_COMMAND += "diable_getty; "
@dhilst
dhilst / parse_macaddr.c
Created July 9, 2016 03:38
parse_macaddr
#include <string.h>
#include <stdio.h>
static unsigned char b[6];
#include <assert.h>
#if !defined(__KERNEL__)
#define BUG_ON(cond) assert(!(cond))
#endif