Skip to content

Instantly share code, notes, and snippets.

@alepez
alepez / boost-android-build.sh
Created October 3, 2017 20:13
Build boost for android
#!/bin/bash
version=1.65.1
echo "Building boost $version..."
set -eu
toolchain=$PWD/toolchain
if [ ! -d "$toolchain" ]; then
echo "Building toolchain..."
@alepez
alepez / cross-compile-rpi3-kernel.sh
Last active September 28, 2017 14:52
Cross Compile Raspberry Pi 3 Kernel
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- bcm2709_defconfig
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- -j9 zImage modules dtbs
cp arch/arm/boot/zImage /mnt/raspberrypiroot/boot/ ; cp arch/arm/boot/dts/*.dtb /mnt/raspberrypiroot/boot/ ; cp arch/arm/boot/dts/overlays/*.dtb* /mnt/raspberrypiroot/boot/overlays/ ;
sudo make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- INSTALL_MOD_PATH=/mnt/raspberrypiroot modules_install
@alepez
alepez / gentoo-arm-chroot-cross-build.md
Created September 27, 2017 14:19
gentoo arm chroot cross build

Install qemu in host

Add this to make.conf:

QEMU_SOFTMMU_TARGETS="arm"
QEMU_USER_TARGETS="arm"

Add this to package.use:

@alepez
alepez / install-peak-drivers-linux.md
Last active September 29, 2017 15:54
Install Peak driver in Linux

Attenzione!

Non installare i driver scaricabili dal sito peak, ma usare quelli nel kernel vanilla.

Il driver giusto è peak_usb:

modprobe peak_usb
@alepez
alepez / android-sdcard-cid.java
Created September 26, 2017 11:44
android sdcard cid
try {
BufferedReader input = new BufferedReader(new FileReader("/sys/block/mmcblk1/device/cid"));
String sd_cid = input.readLine();
Log.i(TAG, "cid:");
Log.i(TAG, sd_cid);
} catch (Exception e) {
Log.e(TAG, "Can not read SD-card cid");
}
/*
* Example 1: exits on SIGINT
*/
#include <iostream>
#include <signal.h>
#include <unistd.h>
bool continueRunning = true;
void sighandler(int signum) {
@alepez
alepez / core-dump.md
Last active June 7, 2017 08:53
core dump

Sistema per salvare lo stato dell'applicazione al momento del crash, per poter debuggare anche dopo il crash.

Possiamo anche usare gdb da x86 per debuggare un'applicazione che girava su arm.

Dal sistema in cui gira applicazione:

Per mettere al massimo il limite della dimensione disponibile per i core dump:

ulimit -c unlimited
@alepez
alepez / 0001-fix-missing-boost-array.patch
Created May 31, 2017 07:12
fix missing boost::array
From 10328d6d369a2218832315162741bd04d35fe85d Mon Sep 17 00:00:00 2001
From: Alessandro Pezzato <[email protected]>
Date: Wed, 31 May 2017 09:06:03 +0200
Subject: [PATCH] fix missing boost::array
---
include/crow/websocket.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/crow/websocket.h b/include/crow/websocket.h
@alepez
alepez / beep.cpp
Created May 8, 2017 14:50
openal beep with volume
#include <AL/alut.h> // OpenAl
#include <cmath>
#include <iostream>
#include <thread>
using namespace std;
void init_al() {
const char* defname = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
ALCdevice* dev = alcOpenDevice(defname);
@alepez
alepez / beep.cpp
Last active May 29, 2017 14:02
openal beep
#include <cmath>
#include <iostream>
#include <thread>
using namespace std;
#include <AL/alut.h> // OpenAl
void init_al()
{