CarPC v1.0

As our collection of MP3 CD’s was wearing out I thought why not put a small embedded board with a big drive in our car? I dug up a Cubieboard2 that was gathering dust and started hacking. The goal:

  • Small system based on Debian Jessie
  • MPD to serve the audio files
  • Remote control via WiFi
  • Big drive
  • Acceptable boot time
  • Basic protection against file system corruption

Putting a bog standard Debian Jessie on the Cubieboard2 was quite straightforward with the help of the linux-sunxi.org wiki. The board booted with the standard kernel but unfortunately no sound. Luckily I had just received some ultra-cheap PCM2704 USB audio interfaces and these worked and sounded great too. WiFi worked out of the box but the rtl8192cu driver of the 3.16 kernel for the Realtek RTL8192CU chipset has the tendency to quickly go into suspension and as this driver doesn’t have any power management options I ended up with a hacky for loop in /etc/rc.local that pings all IP’s in the DHCP range. I quickly dropped this iffy set-up as it just didn’t work out that well and ended up using a DKMS based solution that made it possible to control power management of the WiFi dongle. Next hurdle was hostapd that stopped working with this alternative driver. But with the help of the hostapd-rtl871xdrv GitHub repo I managed to cook up a fully working hostapd Debian package.

Next up was the hard drive. I first tried a USB drive but the Cubieboard2 just couldn’t provide enough juice to power the drive properly together with the WiFi dongle. I also tried with my Raspberry Pi’s but those had the same issues. So I had to resort to a SATA drive. Of course I bought a 3.5″ drive first because those are cheaper. But you can’t power a 3.5″ drive with the SATA cable that comes with the Cubieboard2 and as I had a bit of a deadline I returned it for a 2.5″ drive and that works like a charm. I installed MPD, copied my music collection to the hard drive, fired up MPD and was greeted with a segmentation fault. Apparently the Jessie MPD package has issues with the sticker database file so I installed MPD from the backports repo and that version runs without any complaints so far.

For some basic protection against corruption by sudden power loss I created separate partitions for /home and /var on the SD card that are mounted rw with a couple of options to reduce corruption (sync,commit=1,data=journal) and / is mounted ro, just like the big hard drive with the audio files. /tmp is being mounted as tmpfs in RAM. Boot time is about 15 seconds and I’m OK with that. To remotely shut down the CarPC via WiFi I use a JuiceSSH homescreen shortcut of a connection that runs a simple shutdown -h now snippet.

After I had mounted everything in our car the thing wouldn’t boot though. Swapped the 1A USB car adapter for a 2.1A version and then the CarPC came up properly. Installed MPDroid on my Nexus 5 to control MPD via WiFi and so far, so good!

 

Cubieboard2 based CarPC

 

Addendum

Sometimes the CarPC became unreachable via WiFi. The culprit was that the DHCP service (udhcpd) didn’t always come up because it was sometimes started before hostapd. I fixed this by copying /var/run/systemd/generator.late/udhcpd.service to /etc/systemd/system/udhcpd-custom.service and adding hostapd.service to the After line and adding a Requires=hostapd.service line. I also added a [Install] stanza with the line WantedBy=multi-user.target. I then disabled udhcpd.service and enabled udhcpd-custom.service.

Addendum 2

Hostapd didn’t always start flawlessly either so I copied /var/run/systemd/generator.late/hostapd.service to /etc/systemd/system/hostapd-custom.service and added sys-subsystem-net-devices-wlan0.device to the After and Wants lines. Also added an [Install] stanza, disabled hostapd.service and enabled hostapd-custom.service.

CarPC v1.0

Exit BeagleBone Black, hello Cubieboard2!

Put up my BeagleBone Black for sale. It was gathering dust, somehow this board doesn’t appeal to me. Biggest drawback is that it seems to be very picky with power adapters. If you don’t use a linear power adapter USB devices might not work properly. And that was exactly the issue I was facing, I just couldn’t get my USB audio interfaces to work on the BBB. So I lost interest because well, that’s what I bought the device for, to get sound out of it with the help of an USB audio interface. Add to this that there is no realtime kernel or RT patchset available for the BBB and that the BBB is quite a complex little device (it’s actually a REAL dev board). It would’ve cost me too much time to completely fathom it. No bad feelings though, the BBB is a very nice product and it sure has the slickest looks of all ARM SoC dev boards around.

Also I got a Cubieboard2 in recently. And that board has absorbed me for the last week and a half. It’s quite easy to set up (not as easy as the RPi though), has a lot of IO (yes, it has audio in and out!) and it blows both the RPi and BBB away when it comes to performance with its dual core A20 Allwinner SoC that can easily be overclocked to 1.2 GHz. Alas, no realtime kernel or RT patchset either but hey, I managed to get a RT kernel running on a Rockchip RK3066 based device so I could at least give it a try. And it worked out well. I’m now running a 3.4.61-rt77 kernel on it with a custom Debian Wheezy installation. This time I used git to keep track of the modifications I made so it was a lot easier to create a usable diff. I also patched the driver for the onboard audio codec because the hardcoded defaults were just unusable for realtime audio. Minimum number of periods was 4 and minimum buffer size was 1024. Don’t ask me why. So I’ve changed these to 2 and 16 respectively and managed to get JACK running at a respectable -p64 -n2 -r44100. Fired up some JACK clients and this little monster keeps up very well. USB audio interfaces are no problem either, I can run my Edirol UA25 in Advanced mode with -p64 -n3 -r48000 without any hitch. This is probably because the Cubieboard2 doesn’t use a Synopsys DesignWare OTG controller with out-of-tree dwc_otg drivers like the RPi but a better supported USB controller. At the moment the Cubieboard2 is the nicest ARM dev board I have laid my hands on so far.


text-align: center;

Cubieboard2

RT patchset 3.4.61-rt77 for linux-sunxi, sunxi-3.4 branch

Low latency defaults patch for sunxi-codec driver

Exit BeagleBone Black, hello Cubieboard2!

More ARM goodies II

Received the BeagleBone Black (BBB) and the MK808 with a RK3066 SoC. My first impressions are really positive. Especially the BBB is quite an awesome device that I’m probably going to use a lot in favor of the Raspberry Pi. At first glance I had something like, the BBB blows the RPi away, but as soon as I started looking for documentation on how to put Debian on it for instance it became clear that the RPi is still the device to beat. The RPi community is huge, documentation for it is well laid out and working with the RPi is just so easy. The BBB on the other hand lacks a vivid community, is $10 more expensive and a lot more difficult to work with. Take the Debian install for example, seems quite some work to get that going.

The MK808 is surely an improvement over the UG80X I already own. It comes with a HDMI port instead of a HDMI plug, has an extra USB OTG port, a heatsink, hardware serial console access, a reset button and a power indicator LED. The pre-installed Android version looks better too. I flashed my RT kernel recovery image on it, inserted the Micro SD from my UG80X and it booted without any issues. So I’m going to pursue my goal to get a real-time, low-latency environment running on a RK3066 based device on the MK808 and find another purpose for the UG80X.

Edit: Getting Debian to work on the BBB is actually quite easy: http://elinux.org/BeagleBoardDebian#Demo_Image
Next time I’ll promise to make better use of my Google skills.

More ARM goodies II

Workshops Music Production with Open Source Software

Starting September 7th I’m going to conduct a series of 6 workshops on music production with open source software at De Bakkerij in Castricum. With software I also mean the operating system so the OS I’m going to use will be an open source based one (probably Ubuntu or Debian). So basically it’s a series of workshops on music production with Linux Audio.

Last week I had something like, what the heck, I’m just going to mail De Bakkerij to ask if they’re interested since they host more DIY initiatives like the workshops inititiative I proposed. I didn’t expect much of it but I immediately got an enthusiastic e-mail back from the promotor of De Bakkerij. So after a few mails back and forth it was a done deal.

Rough outline of the workshops:

  1. Introduction and base principles of open source software and using it for music production. What is open source, why use it, how does the open source audio ecosystem look like and will my hardware work?
  2. Recording with open source software. What software is available (DAW), how to use it during the recording process, base principles of recording instruments and vocals (I’ll be focusing on home recording and not recording complete bands).
  3. Making music with open source software. Softsynths, samplers, drum machines, amp/cabinet modeling, sequencers, trackers, DAWs, MIDI/OSC, plugin frameworks etc.
  4. Mixing and mastering with open source software. What software is available, what kind of hardware do I need, base principles of mixing and mastering.
  5. Showcasing the possibilities of the usage of open source software with the focus on low-cost solutions like the Raspberry Pi and RockChip based devices.
  6. Concluding workshop: listen to and discuss the musical projects made by the attendees, discussion on music production with open source software.

There’s no fee for attending the workshops but you do need a notebook or netbook and an empty USB memory stick of at least 4GB.

Workshops Music Production with Open Source Software

Asterisk op ARM (SheevaPlug)

De Digium repository heeft geen armel (ARM) pakketjes maar wel de benodigde bronbestandjes zodat je toch op een makkelijke manier de nieuwe releases kunt packagen en installeren. De snelste manier om dat te doen is door de repository van Digium toe te voegen aan je Apt sources:

# echo -e "# Asterisk sourcesn deb-src http://packages.asterisk.org/deb squeeze main"
| tee -a /etc/apt/sources.list

En even iniesniejalieseren:

# apt-get update

En vervolgens kun je met één simpel commando de bronbestanden downloaden, uitpakken en packagen:

apt-get source -b asterisk

Even laten pruttelen en daarna kun je de benodigde pakketten installeren of updaten:

dpkg -i asterisk-config_1.8.11.1-1digium1~squeeze_all.deb
asterisk_1.8.11.1-1digium1~squeeze_armel.deb

Asterisk op ARM (SheevaPlug)

Asterisk geüpdatet

Draai nu Asterisk 1.8.9.0 en terwijl ik 1.8.8.x niet werkende kreeg met Budgetphone werkt het nu wel goed. Helaas kon ik geen pakketjes vinden voor Squeeze op de Asterisk site dus heb het bronpakketje voor Natty maar gedownload, uitgepakt en dpkg-buildpackage erop losgelaten. Heb nou eenmaal de voorkeur voor pakketjes. Ging nog best snel op m’n SheevaPlug.

Kreeg wel een melding bij het opstarten:

WARNING[17830]: chan_sip.c:28490 reload_config: No valid transports available, falling back to 'udp'.

Maar na het toevoegen van de volgende regel was die melding weg:

transport=udp

Asterisk geüpdatet

Asterisk configuratie

We bellen nu thuis via Voipbuster aangezien dat gewoon de goedkoopste aanbieder is. Tientje ex. BTW en dan kun je vier maanden gratis bellen naar een aantal landen (waaronder Nederland en Frankrijk waar mijn ouders wonen). Na die vier maanden ga je de normale tarieven betalen maar die zijn nog steeds zeer aantrekkelijk. Neem Frankrijk, bij Ziggo kost dat €0,08 per minuut met een starttarief van eveneens €0,08. Bij Voipbuster €0,015 en géén starttarief! Ok, bij Voipbuster ronden ze af op de minuut en bij Ziggo rekenen ze per seconde maar dan nog scheelt bellen met Voipbuster aanzienlijk. Bij Voipbuster kun je echter géén lokaal telefoonnummer aanvragen dus dat heb ik bij Budgetphone gedaan. Niet dat dat echt nodig is maar het prepaid abbo van Budgetphone met een lokaal nummer is zo goedkoop (ook een tientje per jaar) dat ik het maar heb aangeschaft, op deze manier kan ik ook thuis lekker klooien met Asterisk en meerdere trunks van verschillende VoIP aanbieders.

Ik gebruik het Asterisk pakketje van Debian Squeeze (1.6.2.9). Heb wel 1.8.8.x geïnstalleerd gehad maar dat werkte niet met Budgetphone aangezien Budgetphone de “From:” SIP headers van deze versie van Asterisk niet accepteerde. Volgens mij werkt het met 1.8.9.2 inmiddels weer wel als ik het Budgetphone forum mag geloven dus wellicht dat ik Asterisk binnenkort ga proberen te updaten. Dus vooralsnog Asterisk 1.6.2.9 met onderstaande configuratie.

/etc/asterisk/sip.conf

[general]
context=default
allowoverlap=no
externip=www.xxx.yyy.zzz
localnet=192.168.1.0/255.255.255.0
bindport=5060
nat=yes
srvlookup=yes
useragent=AutoStatic PBX
disallow=all
allow=alaw
allow=ulaw
allow=g726
allow=ilbc
allow=gsm
allow=g723
allow=g722
allow=g729
language=nl
dtmfmode=auto

;###########################
;## Register    ############
;###########################

#include "/etc/asterisk/register/*.conf"

;###########################
;##  Templates  ############
;###########################

#include "/etc/asterisk/templates/*.conf"

;###########################
;##  Trunks     ############
;###########################

#include "/etc/asterisk/trunks/*.conf"

;###########################
;##  Accounts   ###########
;###########################

#include "/etc/asterisk/accounts/*.conf"

/etc/asterisk/register/budgetphone.conf

register => budgetphonegebruikersnaam:budgetphonewachtwoord@sip1.budgetphone.nl/budgetphonegebruikersnaam

Je Budgetphone gebruikersnaam is tevens je telefoonnummer. Vandaar de schuine streep op het einde met daarachter nog een keer de gebruikersnaam. Op deze manier worden binnenkomende telefoontjes op dat nummer doorgezet naar de gelijknamige context.

/etc/asterisk/trunks/budgetphone.conf

[budgetphone]
disallow=all
allow=ulaw
allow=alaw
allow=g726
allow=g723
allow=gsm
allow=g722
allow=g729
context=pstn-in
dtmfmode=rfc2833
host=sip1.budgetphone.nl
insecure=port,invite
qualify=yes
type=user

De context voor inkomende telefoontjes op het Budgetphone nummer heet dus pstn-in.

/etc/asterisk/trunks/voipbuster.conf

[voipbuster]
disallow=all
allow=ulaw
allow=alaw
allow=g726
allow=g723
allow=gsm
context=pstn-out
dtmfmode=rfc2833
host=sip.voipbuster.com
qualify=yes
type=peer
defaultuser=voipbustergebruikersnaam
secret=voipbusterwachtwoord
fromuser=voipbustergebruikersnaam
fromdomain=sip.voipbuster.com

Met Voipbuster bellen we naar buiten, de context heet dan ook pstn-out en we moeten onze gebruikersgegevens opgeven anders accepteert Voipbuster onze telefoontjes niet. Voor Budgetphone is dit niet nodig aangezien we daar alleen telefoontjes mee ontvangen.

/etc/asterisk/templates/phones.conf

[phones](!)
type=friend
qualify=yes
nat=yes
context=phones
host=dynamic
canreinvite=no
dtmfmode=rfc2833
allowtransfer=yes
disallow=all
allow=ulaw
allow=alaw
allow=g726
allow=g723
allow=gsm
allow=g722
allow=g729

Dit sjabloon gebruik ik voor mijn accounts, dan hoef ik dat niet voor iedere account toe te voegen.

/etc/asterisk/extensions.conf

;###########################
;## Contexts    ############
;###########################

#include "/etc/asterisk/contexts/*.conf"

/etc/asterisk/contexts/pstn-in.conf

[pstn-in]
exten => budgetphonetelefoonnummer,1,Dial(SIP/10,25,tT)
 same => n,Hangup()

Oftewel, stuur alles wat binnenkomt op het Budgetphone nummer door naar toestel met extensie 10 (onze Gigaset C610 IP huistelefoon).

/etc/asterisk/contexts/pstn-out.conf

[pstn-out]
exten => _00X.,1,Set(CALLERID(num)=budgetphonetelefoonnummer-internationaalformaat)
 same => n,Dial(SIP/${EXTEN}@voipbuster)
 same => n,Hangup()

exten => _0XXXXXXXXX,1,Set(CALLERID(num)=budgetphonetelefoonnummer-nationaalformaat)
 same => n,Dial(SIP/${EXTEN}@voipbuster)
 same => n,Hangup()

/etc/asterisk/contexts/internal.conf

[internal]
exten => 10,1,Dial(SIP/10,25,tT)
 same => n,Hangup()

exten => 20,1,Dial(SIP/20,25,tT)
 same => n,Hangup()

exten => 30,1,Dial(SIP/30,25,tT)
 same => n,Hangup()

exten => 40,1,Dial(SIP/40,25,tT)
 same => n,Hangup()

De interne extensies zodat er ook intern gebeld kan worden. Extensie 10 wordt gebruikt voor binnenkomende telefoontjes die van Budgetphone vandaan komen.

/etc/asterisk/contexts/phones.conf

[phones]
include => internal
include => pstn-in
include => pstn-out

De phones context die alle andere contexts ‘include’.

/etc/asterisk/accounts/10.conf

[10](phones)
callerid=Thuis <10>
secret=***

(phones) geeft aan dat voor dit account het phones sjabloon gebruikt moet worden. In de /etc/asterisk/accounts directory staan verder nog configuratiebestandjes voor mijn mobiele telefoon, mijn werktelefoon en mijn softphone applicatie.

Er kunnen nog wat fouten zitten in bovenstaande configuratie. En ik moet nog even goed kijken naar de codecs, volgens mij is dat nu nog een rommeltje.

Asterisk configuratie

Lenny, you were so good to me

M’n SheevaPlug geüpgrade naar Squeeze. Debian is inmiddels volledig geport naar armel dus Debian ondersteunt de SheevaPlug nu volledig. Zit er wel aan te denken een nieuwe plugcomputer aan te schaffen, wil allebei onze omvormers van de zonnepanelen aan kunnen sluiten en eSATA kunnen gebruiken. De SheevaPlug heeft maar één USB poort en met een hub werken terwijl je besturingssysteem op een USB harde schijf staat is vragen om problemen. Ook heb ik een gigabit netwerk thuis maar heb er weinig aan aangezien ik maar met 20Mb/s dingen op deze harde schijf kan zetten. Zat eerst te kijken naar de opvolger van de SheevaPlug, de DreamPlug, maar dat is overkill dus waarschijnlijk wordt het gewoon weer een SheevaPlug maar dan met een eSATA aansluiting.

Lenny, you were so good to me

foo-yc20 pakketjes voor Lucid

foo-yc20 is een emulator van de Yamaha YC-20, een orgel van eind jaren ’60. Redelijk nieuw projectje maar begin december is er een bruikbare en redelijk klinkende versie van uitgekomen. Nog geen Ubuntu packages van gezien dus heb snel een bronpakketje in elkaar gesleuteld en geüpload naar mijn PPA. Daarna kwam ik erachter dat het Debian Multimedia Maintainers team deze softsynth al wel heeft opgepikt, had me weer wat werk gescheeld.

Inmiddels is de ontwikkelaar van deze emulator ook begonnen met het maken van een foo-yc20 LV2 plug-in. Goeie zaak aangezien er nog maar bijzonder weinig LV2 synth plug-ins voor handen zijn.

foo-yc20 pakketjes voor Lucid

Het Karmische Koalabeertje

Omdat de Nvidia drivers of Compiz niet lekker werkten onder 9.04 op mijn notebook heb ik er gisteren maar 9.10 op gezet. En tot nu toe draait het lekker! En het start ook nog eens allemaal zo’n 15 seconden sneller op. Kan volgens mij nog sneller, het opstarten van mijn notebook blijft namelijk even hangen op een bug:

[    3.240007] pci 0000:00:1a.7: EHCI: BIOS handoff failed (BIOS bug?) 01010001
[    5.240007] pci 0000:00:1d.7: EHCI: BIOS handoff failed (BIOS bug?) 01010001

Onder 9.04 bleef de boel hier veel langer op hangen, een seconde of 8, en dat is dus teruggebracht naar 2 seconden. Zou dan toch deze patch in de Karmic kernel zitten?1 Dat zou betekenen dat het nog sneller kan. Wat me verder opviel na de installatie was dat er een hoop icoontjes misten nadat ik de Tango icoontjes had geïnstalleerd. Bleek dat onder System – Preferences – Appearance – Interface – Show icons in menus stond uitgevinkt. Ook moest ik even wennen aan de nieuwere Gnome-Do, zat te zoeken naar de optie dat Gnome-Do altijd het bovenste venster is maar dat is voor het Docky theme vervangen door “intellihide”. Werkt best lekker. Ook kreeg ik Guake niet lekker draaiende, druk je op F12 en verschijnt dat ding op de onderste helft van het scherm terwijl ik het bovenin wil hebben. Dit heb ik op kunnen lossen met de Place Windows plugin van Compiz. En ik vind FF 3.5 best traag, maar daar schijn je een add-on voor te hebben. FF doet er nogal lang over om URL’s te resolven, geen idee waarom dat zo veel langer moet duren dan met 3.0.x.2 Voor de rest ben ik geen rare dingen tegengekomen, ziet er allemaal goed uit en vooralsnog draait het prima. Ben benieuwd hoe het beertje zich houdt als hij de nodige data van externe geluidskaarten en MIDI controllers te verstouwen krijgt en daar tegelijkertijd ook nog eens wat mee moet gaan doen.

1 Heb de ehci_ho_to parameter inmiddels getest maar die doet niks dus waarschijnlijk is de Karmic kernel niet voorzien van deze patch.
2 Kan aan ipv6 instellingen liggen. En FF3.5 kun je nog het nodige tweaken.

Het Karmische Koalabeertje