Linux ALSA capture device sharing

To split audio input device stream use dsnoop plugin from ALSA. Be sure to access dsnoop device simultanously, not dsnoop and physical device! This feature is not documented officially!

FFMPEG dos not work with dsnoop device (official remark in source code). Use arecord and plain LAME codec instead.

Trying to use snoop device us pointless in case of BeagleBoneBlack. Suprisingly, two arecord instances are able to work with dsnoop device. But VLC or FFMPEG does not work, being unable to open device.

Working solution is going higher in software stack using shell and tee to named pipe.

/bin/su user -c "mkfifo `pwd`/myfifo"
/bin/su user -c "arecord -D hw:1,0 -f cd -t wav -c 1 | tee myfifo | lame -x -r - | mp3splt -f -t 30.0 m-" &
/bin/su root -c "killall vlca"
/bin/su user -c "vlca -vvv -I "dummy" stream://`pwd`/myfifo vlc://quit --sout \"#transcode{acodec=flac,ab=32}:standard{access=http,mux=ogg,dst=:8082}\"" &

Data flow is as follows:

– arecord processes raw microphone input into wav
– wav is being copied to a named pipe
– wav is being encoded by LAME
– LAME output is MP3
– MP3 will be splitted if size (duration) is greater than X
– named pipe is read by VLC via stream muxer and transcoded to FLAC over OGG container streamed via HTTP

FreeBsd kernel development preparations (amd64 on bhyve VM)

The plan is just to get kernel’s early start phase trace to be able to cross check the sources for initialization order. It shall be an exemplary for further development of BeagleBoneBlack platform device driver.
I just wonder why there is no documentation considering kernel early boot phase. But on the other side, FreeBSD is not worse than Linux…
There is a tiny piece which can be considered as a seed for further investigations:
Clock management for am335x is provided by /usr/src/sys/arm/ti/am335x/am335x_prcm.c. Device is “am335x,prcm” aka “AM335x Power and Clock Management”.
Clock management device “AM335x Power and Clock Management” is used by /usr/src/sys/arm/ti/ti_prcm.c. Generally only ti_clk_devmap[] array seems to be relevant.
Modules like ti_sdma.c or ti_priuss.c enable peripherial clock by calling ti_prcm_clk_enable(…) and using callbacks from am335x_prcm.c wrapper via structs. See ti_prcm.h for available clocks in clk_ident_t enum. Pin muxers are configured by am335x_scm_padconf.c module.

Using bhyve (works without modifications and quirks): Just install basic system configuration. It is done amazingly fast.

Using mdconf to mount virtualized disk as loop device: Watch out not to use -t option while mounting. It results in “Operation not permitted”. If you are unsure what kind of slice do you have, just use file -s /dev/ada0sX to inspect it. Be sure to have a clean slice, otherwise it will not mount – as physical partition does not. Run fsck if needed. See dmesg output if something goes wrong. It contains additional info.

Cool command to make you proud of SSD disk:
diskinfo -t /dev/ada0s1a

SH script for running VM:



if [ -z "$2" ]

destroy_interface () {
i=`ifconfig tap0 2>&1|grep "does not"`
  if [ -z "$i"  ]
      ifconfig $1 destroy; echo "Interface $1 destroyed";

create_bridge () {
echo "Creating bridge"
ifconfig tap0 create
ifconfig bridge0 create
ifconfig bridge0 addm $NET_INTERFACE addm tap0
ifconfig bridge0 up    

echo "Preparing bhyve network environment"
destroy_interface bridge0
destroy_interface tap0


echo "Starting VM"
sh /usr/share/examples/bhyve/ -c 4 -m 1024M -t tap0 -d ./$VM_IMG_NAME fbsd_10_3_amd64_test_guest

echo "Cleanup network environment"
ifconfig bridge0 down
destroy_interface bridge0
destroy_interface tap0

Shell programming help:

Git ignore file tolerating only SH scripts in repository:


Booting FreeBSD with GRUB2 on MBR


menuentry “FreeBSD 9.0 (1)” –class freebsd –class bsd –class os


echo Chainloading slice hd0,2 … chainloader (hd0,2)+1



Two other possibilities from this post. Third one eliminates boot1, boot2 and loader stage leaving the job to grub2. Stuff like loader.conf will be entirely ignored… Mountroot will require manual ufs:/dev/da0xxx entry.


This procedure does not work for another PC, what works is:

menuentry "FreeBSD" {
insmod ufs2
insmod part_gpt
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 574744019d04da3b
kfreebsd /boot/kernel/kernel
kfreebsd_loadenv /boot/device.hints
set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada0s1a
set kFreeBSD.vfs.root.mountfrom.options=rw

To find out fs_uuid under linux (debianoid): sudo grub-probe -t fs_uuid -d /dev/sda1

This GRUB2 crap is not funny anymore!

VLC audio streaming over http


for working VLC command streaming audio over http. Vlca is just like vlcv a symlink to vlc (making killall on separate vlc process possible).

Hardware is Olinuxino A13 running standard Wheezy (I am cowardly not updating to Jesse because of USB errors seen on BeagleBoneBlack ).

CAN bus and Linux kernel drivers

SocketCAN vs. Can4Linux

Is not the best idea in my opinion to make CAN a networking subsystem. CAN bus is tightly bound to hardware it is using, and above all, this bus concept is very strong real-time oriented. Too much overhead is deadly. I observed serious malfunction on D_CAN driver in kernel 3.2.42, where busload of > 30% lead to total failure of the driver. I  had to create a workaround via MCP2515 driver to be able to deliver my product. C_CAN driver, having merged D_CAN functionality in 3.8, appears to be more stable, at least on BeagleBoneBlack.  I’ts drawback is lacking Device Tree support for CAN on BBB – manual intervention into DT is and recompiling is neccesary (for now).

The main problem was the lacking ability to set hardware filter in D_CAN/D_CAN driver. Stock MCP2515 was not any better, but heavy ISR load did not cause a crash – only a rising overrun statistics and frame loss, not dramatic in this appliance.

Alternative to official kernel SocketCAN subsystem is Can4Linux. It seems to have the ability to set hardware filter, at least in case of MCP2515. But ist’s main strength is the old-style chardev interface. The problem is, being not a mainstream project it lacks supporters.

Found something very interesting: . C_CAN implementation is included and needs to be adjusted to D_CAN structure. Filtering and chardev structure possible!