Other articles

  1. Comparing CPU/GPU memory bandwidth on shared-memory systems

    Did you know that you could enable tons of examples in pocl?


    Intallation of pocl on Ubuntu 16.04 with AMDSDK2.9 examples:

    apt install build-essential cmake git pkg-config make ocl-icd-libopencl1 ocl-icd-dev ocl-icd-opencl-dev libhwloc-dev zlib1g zlib1g-dev clinfo
    apt install libclang-5.0-dev clang-5.0 llvm-5.0
    mkdir pocl
    cd pocl …
    read more
  2. How to make my array

    Let's make a friendly array for CPU/GPU processing

    (A) Very well-supported, but impractical to use and error prone.
    (B) Cannot be memcpy'ed. Contains a pointer. Indexing is indirect.
    (C) Perfect if the array does not change.
    (D) Need to unpack. No direct indexing possible.

    (C) is memcpy-able, does no …

    read more
  3. OpenCL zerocopy


    This is both CPU and GPU main memory. How to avoid copying buffers from and to the same memory?

    Allocate aligned memory

    // note: buffer_size is re-written in place
    void *zerocopy_alloc(size_t &buffer_size)
        // OpenCL zero-copy buffers need to be aligned on a page size (i.e., 4KB),
        // and the allocated …
    read more
  4. OpenCL with pocl

    pocl will convert your opencl kernels into AVX-vectorized CPU binaries

    pocl stands for portable compute language [1].

    Building pocl

    For sweet and crispy pocl, you'll need:

    • warm up your favorite C++ compiler
    • prepare the follow baking packages (if you have an Ubuntu 16.04 kitchen)
    # llvm clang 5.0 or …
    read more
  5. OpenCL 2.0 overview

    What's possible with OpenCL 2.0 today?


    AMDGPU-PRO is the closed-source implementation of OpenCL 2.x for AMD. It only targets AMD GPU. AMD used to provided a CPU target, but it is OpenCL 1.2 only.

    rocm is the heterogeneous computing effort of AMD, and is open-source. It …

    read more
  6. Building lldb

    Trying to build the latest lldb.

    A good introduction about lldb is this presentation at the Apple developper conference [1]. For something more focused on ARM, see [2], and for something more focused on FreeBSD, see [3] and [4].

    Building from svn

    The official build guide is [5]. There are …

    read more
  7. Build all-target gdb on ARM

    Trying to build the latest GNU gdb on Scaleway ARM instance.

    Build command:

    apt install bison flex
    configure --with-python --without-ncurses --enable-targets=all --prefix=/opt/gdb
    make -j4

    Neither the version 7.12 nor 8.1 (or even the git sources [1]) build out-of-the-box, while there are no issues on x86_64 …

    read more
  8. Using Fetch and WebSocket as promised

    read more
  9. Raspberry Pi 3 Ethernet over serial

    Old school internet!

    There is some trickery because of the Raspberry 3 bluetooth feature. See [1].

    By default, the nice hardware serial port /dev/ttyAMA0 is dedicated to the bluetooth connection.

    Disable bluetooth in /boot/config.txt:


    Disable kernel use of the serial port by removing from /boot …

    read more
  10. How to build a safe demo with admin access on Linux hosts?

    Wouldn't it be nice to let people play with gdb and inapp from the internet?

    Yeah, but wait a minute, people would take control of the host computer and use its network connectivity of other and unintended purposes. Especially since the demo gives you access to a working gdb session …

    read more
  11. Web Fetch API

    Howto download a binary as a stream using javascript?

    It may look easy to do with good old XMLHttpRequest, but actually, it is not as obvious. In binary mode, the response object returned by XMLHttpRequest is always complete. Chunked responses are only possible using non-standard moz-chunked-arraybuffer transfer mode (only support …

    read more
  12. Readline menu-complete

    Activate readline menu-complete, back-menu-complete, and keep normal 'tab' completion.

    About completion styles

    Normal complete style is the one expected to happen when hitting Tab on any Linux distribution.

    menu-complete style is the one expected to happen on MS-DOS. This one is more convenient when using a gamepad as input, since …

    read more
  13. FriendlyARM NanoPi NEO Mainline and docker

    FriendlyARM has an image for the NanoPi NEO with mainline linux kernel.


    Look! There is a 4.11 kernel image packed with Ubuntu 16.04 (see [1]).

    Unfortunately, the image does not support docker out-of-the-box, because the kernel was not built with the required options.

    Initial error

    The flag …

    read more
  14. DTS and DTB files

    The conversion from DTS to DTB and back to DTS.


    In the Linux kernel source tree, there are .dts (i.e., device tree source) and .dtsi (i.e., device tree source include).

    .dtb is the binary form of the .dts in a similar sense what a binary exectuable is …

    read more
  15. qemu + freedos + novnc

    Back to DOS!


    Did you know that:
    • qemu [1] can use vnc as display output?
    • FreeDOS [2] can replace MSDOS?
    • novnc [3] is a vnc client which only need HTML5 and WebSocket?

    Let's mix everything together~


    Install qemu:

    apt install qemu
    qemu-img create -f raw freedos.img 100M …
    read more
  16. NanoPi Neo USB OTG with Armbian mainline 4.x kernel

    The long awaited quest of the USB On-the-Go with mainline Linux kernel 4.x.


    As already documented here before, it is possible to configure FriendlyARM's NanoPi Neo to behave as an USB Ethernet/RNDIS gadget device. Unfortunately this functionality relied on legacy/hacked sunxi kernel. This kernel (3.x …

    read more
  17. gdb - frame decorator example

    The FrameDecorator example given in the documentation does not work?

    If you naïvely try the implement your own MyFrameFilter following the example of the InlineFilter given in the gdb (holy?) documentation [1], you may face the following python errors.

    Import issue

      class MyFrameDecorator(FrameDecorator):
    TypeError: Error when calling the metaclass …
    read more
  18. Starting with nginx

    How to begin with nginx?

    First steps

    Easy, just start at the beginners' guide [1].

    user www-data;
    pid /run/nginx.pid;
    http {
            # Basic Settings
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            keepalive_timeout 65;
            include /etc/nginx/mime.types;
            default_type application/octet-stream;
            # Logging Settings
            access_log /var/log/nginx/access.log;
            error_log /var …
    read more
  19. Jenkins start parameterized task with curl

    How to start a parameterized task on a jenkins server with curl?

    Start a task

    The answer to this question seems simple at first after seen this page [1]. Unfortunately, it does not work as described:

    vjp@inabox:~$ curl -i -X POST http://localhost:8080/job/inapp_GenerateDocs/build --form file0 …
    read more
  20. Control docker from the inside

    How to run a docker container from another docker container?

    Create a docker image which runs jenkins. A jenkins task will prepare a data folder to be used along with another docker container. At the end the two containers will run side by side. The container spawned by the jenkins …

    read more
  21. jenkins logo

    You have your shinny new Jenkins installation, but how to make it more personal? How to change the logo of Jenkins?

    The Problem

    The butler face is nice, but what if I wanted to add something to the logo?

    In <jenkins_home>, there is an interesting file named title.png coming …

    read more
  22. docker image from usb

    Store and load a docker image from USB storage.

    # docker save -o /mnt/docker/inapp-v0.1-armhf.tar inapp
    # ls -l /mnt/docker/inapp-v0.1-armhf.tar
    -rwxr-xr-x 1 root root 212420096 Mar 28 19:27 /mnt/docker/inapp-v0.1-armhf.tar
    # docker load -i /mnt/docker/inapp-v0.1-armhf.tar
    Loaded image: inapp …
    read more
  23. inapp docker container

    Build a docker container for inapp.

    Stage 1: Build manually on x86

    Run a Debian image for tests:

    sudo docker run -ti --rm debian:jessie-slim bash

    ...and validate the build sequence:

    apt-get update
    apt-get install make
    apt-get install g++
    apt-get install qtbase5-dev
    apt-get install libqt5websockets5-dev
    apt-get install liblttng-ust-dev
    apt-get install …
    read more
  24. NanoPi NEO docker with armbian

    Is it possible to run docker containers on NanoPi NEO?

    Your Linux kernel version 3.4.113-sun8i is not supported for running docker. Please upgrade your kernel to 3.10.0 or newer.

    Unfortuntely no, it does not work with the default legacy kernel 3.4.113-sun8i.

    Embrace your dark …

    read more
  25. JSON command-line operations

    Preparing JSON files from command-line using Python base library.

    Python has a library to process JSON by default. See [1].

    Using Python on command-line, simple scripts can be written for preparing JSON configurations (e.g., with a Makefile).


    Want to stringify a JSON file in order to embedded it …

    read more
  26. inapp software

    Installing inapp on Armbian.

    Update everything after the fresh installation to get the latest kernel and packages:

    apt-get update
    apt-get upgrade

    Disable the NetworkManager deamon and save ~6MB of RAM:

    root@nanopineo:~# systemctl disable NetworkManager
    Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
    Removed symlink /etc/systemd/system/multi-user …
    read more
  27. inapp OTG ethernet

    Setting-up the USB OTG port as an Ethernet 'gadget' device.

    About "sunxi"

    sunxi is the community working on the open-source environment for Allwinner chips... but it has to be kept in mind, and they write it right on the top of the front page [1], that:

    Allwinner [...] is violating the …
    read more
  28. inapp qmake install

    make install

    The easy way to install your Qt program with qmake is to add this to your .pro file:

    target.path = /usr/local/myprogram
    INSTALLS += target

    qmake will find itself what is the binary to copy to the target path. According to the documentation [1], only target and dlltarget …

    read more
  29. inapp software (OS) 2

    Now the operating system. Take two with Armbian.

    Step 1: Get the SD-card image

    Get the OS image Armbian_5.25_Nanopineo_Ubuntu_xenial_default_3.4.113.7z at [1].

    Step 2: Write the SD-card image

    Write the image to the SD-card (4GB min):

    sudo dd if=Armbian_5.25_Nanopineo_Ubuntu_xenial_default_3.4.113.img of=/dev/mmcblk0 …
    read more
  30. inapp software (OS)

    Now the operating system. Take one with the official image from FriendlyArm.

    Step 1: Get the SD-card image

    Get the OS image nanopi-neo-ubuntu-core-qte-sd4g-20170204.img.zip at [1].

    Step 2: Write the SD-card image

    Write the image to the SD-card (4GB min):

    sudo dd if=nanopi-neo-ubuntu-core-qte-sd4g-20170204.img of=/dev/mmcblk0 bs …
    read more
  31. inapp hardware

    Cute little ARM board (inner active ingredient) + Tiny 3D-printed housing (color plastic hull) + Transparent sticker (attractive branding) = your new medication for pretty printing.

    The Nano Pi NEO

    The Nano Pi Neo is a cheap Chinese ARM board with everything needed (Ethernet, On-the-Go USB) and a tiny 40x40mm form-factor [1].

    The …

    read more
  32. Lighttpd multiple base folders with vhost

    How to serve a website by merging multiple base folders?

    mod_alias is the answer! [1]

    alias.url += ( "/all" => "/opt/ina/all/www/" )
    alias.url += ( "/term" => "/opt/ina/term/www/" )


    server.modules += ( "mod_alias" )
    alias …
    read more
  33. Qt socket and systemd

    How to create a systemd-friendly QWebSocket server?

    Surprisingly, there does not seem to be any official Qt documentation for this use-case. Enjoy.

    Introduction to systemd socket-based services

    The keyword here is socket-based activation. [1]

    systemd will create the socket first and listen to incoming connections. On first incoming connection, the …

    read more
  34. About Linux kernel printk timestamps

    What is this timestamp in each kernel printk message?

    Quote from [1].

    Printk-time uses the routine sched_clock() in the kernel. On some platforms, sched_clock() only has a resolution of 1 jiffy (which may be 10 milliseconds or longer). This means that you will only see the time increment at this …
    read more
  35. Debian build image with virtualbox

    Prepare a Debian virtual image to build packages.

    Step 1: Get Debian install image

    Get the netinstall 248MB image (e.g., debian-8.7.1-amd64-netinst.iso) at this address [1], and start a new virtualbox machine.

    Only need a minimalistic system.


    Step 2: Prepare for package build

    A short introduction …

    read more
  36. SSH and user account without password

    Highly insecure!

    Step 1: Create user with no password

    Create a user with a password, and delete it later ([1]):

    root@inabox:/home/ina# adduser test
    [...give a password...]
    root@inabox:/home/ina# passwd -d test
    passwd: password expiry information changed.

    Step 2: Let the user log in

    In /etc …

    read more
  37. kprobes to DLT

    Initial example for setting a kernel tracepoint and forward the trace output over DLT (Autosar Diagnostic Log and Trace).

    Howto set a kprobe

    This example is taken straight out of the Linux kernel documentation at [1]. For details about the kprobes internals, see [2].

    # The tracing facility is in the …
    read more
  38. How Linux kprobes works

    How do Linux kernel probes (kprobes) work

    Everything below comes from reading kprobes.txt at [1].


    There are kprobes and jprobes. jprobes are specialized kprobes for function calls, making it easier to get the function parameters. It is usually useful to filter function call traces according to the value …

    read more
  39. GNU/Linux system performence

    What else is happening again?

    (process:704): GLib-WARNING **: poll(2) failed due to: Invalid argument.

    Using sysctl

    $ sysctl net.core.somaxconn
    net.core.somaxconn = 128
    $ find /usr/include -name socket.h
    /usr/include/x86_64-linux-gnu …
    read more
  40. Javascript onChange event and IME

    But wait! What happens when I use Chinese input? ...types CTRL+Space and start composing... Oh shit!~ [1]

    Capturing key strokes is nice, but it does not support virtual keyboard like on tablet or smartphones and more advanced input methods such as Chinese/Japanese or other writing systems.

    The problem …

    read more
  41. Reading UTF-8 from a pipe

    This works

    std::string l;
    // Read lines here
    while(std::getline(std::cin, l))
        // Send Unicode string
        emit newLine(QString::fromStdString(l));

    This works because \n (newline) is a single byte in UTF-8.

    This does not work

    char c;
    // Read bytes here
        // Send Unicode single …
    read more
  42. <KeyCode>-<TerminalCode>-<CharCode>

    A story which begins on the keyboard, goes through a pseudo-terminal, and ends up on the screen.

    Now that you love ptypipe (see previous post), we are ready to pipe everything and finally control gdb:

    $ makefifo input.cli
    $ python ptypipe.py "" "gdb -q" < input.cli | myGreatControlProgram > input.cli

    Step 1 …

    read more
  43. Yes, you want working completion in your gdb

    You can pipe commands to gdb, but how to have auto-complete on those commands?

    Naive attempts

    A initial little try is promising, we can pipe commands to gdb:

    ~$ echo "show endian" | gdb -q
    (gdb) The target endianness is set automatically (currently little endian)
    (gdb) quit

    The command show endian was …

    read more
  44. <CPU>-<vendor>-<OS>

    Questioning about the "target triplet" <CPU>-<vendor>-<OS> used by the GNU build system to describe a target

    When building gdb targeting a different platform, one must choose --host, --build, and --target parameters.

    The target parameter has the following format [1]:


    You can get the target of …

    read more

Page 1 / 2 »