Sunday, April 8, 2018

The blog has moved

I know, who cares?

I think that I will no longer update this blog.
I want to explore new ways to spread my crappy ideas and rubbish. :-)
I want to try the way to self host a blog. Nothing serious, as always.

However you can find my further posts here:

Monday, November 27, 2017

micro:bit, bluetooth and Linux

After various efforts I was able to read micro:bit sensors data from Linux. While temperature, and accelerometer data is not too difficult to collect, the UART service took a little more time, mainly due to a known issue in the micro:bit BLE implementation.

Here you can find my observations and experiments, with sample Python scripts:

Saturday, August 5, 2017

Add speech to your Fedora system

This article first appeared on Fedora Magazine

By default, Fedora Workstation ships a small package called espeak. It adds a speech synthesizer — that is, text-to-speech software.
In today’s world, talking devices are nothing impressive as they’re very common. You can find speech synthesizers even in your smartphone, a product like Amazon Alexa, or in the announcements at the train station. In addition, synthesized voices are nowadays more or less similar to human speech. We live in a 1980s science fiction movie!
The voice produced by espeak may sound a bit primitive compared to the aforementioned tools. But at the end of the day espeak produces good quality speech. And whether you find it useful or not, at least it can provide some amusement.

Running espeak

In espeak you can set various parameters using command line options. Examples include:
  • amplitude (-a)
  • pitch adjustment (-p)
  • speed of sentences (-s)
  • gap between words (-g)
Each of these options produces various effects and may help you achieve a cleaner voice.
You can also select different voice variants with command line options. For example, try -ven+m3 for a different English male voice, and -ven+f1 for a female one. You can also use different languages. For a list, run this command:
espeak --voices
Note that many languages other than English are experimental attempts.
To create a WAV file instead of actually speaking something, use the -w option:
espeak -w out.wav "Audio file test"
The espeak utility also reads the content of a file for you.
espeak -f plaintextfile
Or you can pass the text to speech from the standard input. In this way, as a simple example, you can build a talking box that alerts you to an event using a voice. Your backup is completed? Add this command to the end of your script:
echo "Backup completed" | espeak -s 160 -a 100 -g 4
Suppose an error shows up in a log file:
tail -1F /your/log/file | grep --line-buffered 'ERROR' | espeak
Or perhaps you want a speaking clock telling you every minute what time it is:
while true; do date +%S | grep '00' && date +%H:%M | espeak; sleep 1; done
As you can guess, use cases are limited only by your imagination. Enjoy your new talking Fedora system!

Friday, July 14, 2017

Firefox: usare la CNS su Fedora

La presente guida ha funzionato per me, su Fedora 26. Probabilmente è valida per altre distribuzioni di GNU/Linux (usando il gestore di pacchetti opportuno).
Guida per modo di dire, poiché i passi da seguire sono veramente semplici.
Alla fine del conto per installare il lettore e la Carta Nazionale dei Servizi (o Tessera Sanitaria), la procedura descritta sul sito della Regione Toscana  si rivela macchinosa e inutile.
Viene qui usato un lettore di smartcard B4ID
La carta invece è quella che sul sito della Regione viene identificata come modello 2 (AT2012).

Installare i pacchetti

Installate PC/SC Lite (Middleware to access a smart card using SCard API)

sudo dnf install pcsc-tools

Collegate il lettore e lanciare il comando:

pcsc_scan -n

Inserite la carta nel lettore. Dovrebbe apparire qualcosa del genere:

Fri Jul 14 19:51:49 2017
Reader 0: ACS ACR 38U-CCID 00 00
  Card state: Card inserted,

Quindi ok, il lettore funziona.
Se non funziona: SPIPPOLATE.

Abilitate il servizio e fatelo partire:

sudo systemctl start pcscd
sudo systemctl enable pcscd.service

Installate OpenSC (Open source smart card tools and middleware):

sudo dnf install opensc


Andate in Preferenze -> Avanzate -> Certificati
Quindi Dispositivi di Sicurezza
Pigiate sul tasto Carica
Come nome del modulo mettete quel che vi pare
Specificate quindi il percorso della libreria: /usr/lib64/
Premete ok.

A questo punto dovreste vedere un nuovo device.

Inserendo la carta dovrebbe apparire il nominativo e il codice fiscale.

Premendo su Login dovrebbe venire richiesto il PIN della carta.

Ora potete
provare l'effettivo funzionamento collegandovi a un sito che richiede l'autenticazione via CNS, come per esempio (dove trovate, fra l'altro, il Fascicolo Sanitario elettronico), oppure (per i pagamenti online della Regione Toscana). oppure il sito dell'INPS.

Con la tessera sanitaria è anche possibile richiedere le credenziali SPID, il Sistema Pubblico di Identità Digitale:

Wednesday, July 12, 2017

How to install Fedora 26 on the Raspberry Pi (Headless and Wireless)

The Raspberry Pi is the most famous SBC (Single-Board Computer). It is a recent news that over five millions of units were sold since it came out.

There are a lot of Linux-based and not Linux-based operating systems that runs on the Raspberry: Fedora is one of the latest landed in this platform. Due to this fact, many things still don’t work: for instance, according to what you can read on the Fedora wiki, expansion HATs, composite TV out, analog sound port and the add-on camera are not yet supported; support for displays other than the official one is not currently planned, GPIO isn't well supported. In addition Fedora supports only Pi version 2 and later.
Obviously the Raspberry Pi Foundation recommends the use of Raspbian, a Debian-based Linux operating system. And as stated before, there are many distributions that have been around for a long time, therefore they probably work better on such platform. Compared to the rest of the world Fedora on ARM could look at early stages of development.
Then, due to these facts the question could be: why using Fedora on the Raspberry Pi when there are more feature rich and widely used distributions? The answer is: isn’t Fedora our favorite distro? So let’s give a try to the ARM version.
Side note: ARM is an architecture officially supported by Fedora.

Let’s get started.

Preparing the SD card

The installation of the Fedora ARM image on an SD card is simple as these two steps:

- download the raw image of your choice (in this case Minimal) from

- run this command (supposing you are running Fedora on your PC and that you have installed the fedora-arm-installer package via DNF)

sudo arm-image-installer --image=Fedora-Minimal-armhfp-26-1.5-sda.raw.xz --target=rpi3 --norootpass --resizefs --media=/dev/mmcblk0 -y

Please refer to the Fedora wiki.

Such command will blanks the root password (remember to subsequently set one during first setup) and it will automatically resize the root partition in order to fill up the SD card size.

Once done, remove the SD card from your PC.

The serial console

If you do not have an HDMI screen to connect to the Raspberry Pi, or if you want to run a completely headless box, you have to enable the serial console.

The task is different between the Raspberry 2 and 3. These steps are for the version 3:

- insert the SD card in your PC, it should automatically mount three partitions

- edit the file extlinux.conf

sudo vim /run/media/youruser/__boot/extlinux/extlinux.conf

add "console=tty0 console=ttyAMA0,115200" to the end of the append line

append ro root=UUID=<uuid-uuid> console=tty0 console=ttyS0,115200

- edit the config.txt file in the root partiton

sudo vim /run/media/youruser/sometinglike-4AC9-BABE/config.txt
uncomment the enable_uart line:


The onboard wifi adapter

If you want to enable the onboard WiFi adapter, you have to download a file that Fedora can not currently redistribute in the raw image:

sudo curl -o /run/media/youruser/__/lib/firmware/brcm/brcmfmac43430-sdio.txt

Booting the Raspberry

Umount the three partitions, using something like

umount /run/media/youruser/__boot ; umount /run/media/youruser/__ ; umount /run/media/youruser/sometinglike-4AC9-BABE

Then insert the SD card in the Raspberry Pi, connect an Usb to Serial/TTL Adapter (the pin 8 on the Raspberry is the TX and pin 10 is the RX). Then power up the device.

You can look at the boot process using a terminal emulator program like minicom or GTKterm, or even the simple screen command:

screen  /dev/ttyUSB0 115200

Once the boot process will reach the end, you should see the Fedora initial setup where you can create an account, set the root password, configure the timezone, etc.

As soon as you log in, if the Raspberry is connected to the network using the Ethernet interface, and there is a DHCP server in the LAN, you are almost done. Check if you are really online and perform a system update:

sudo dnf update

Setup the wifi

If for some reason you can’t use the Ethernet interface and you need to connect to the WiFi network, you have to configure the wireless interface using the Network Manager command line interface (nmcli).

For instance, if your network uses WPA or WPA2, and there is a DHCP this task is pretty simple:

nmcli radio

nmcli device wifi connect YOURSSID password secretpassword

If you need to set up a static IP there are instead various steps to perform:

Add a connection profile and set the IP/netmask and the default gateway

nmcli con add con-name ConnectionName ifname wlan0 type wifi ssid YOURSSID ip4 gw4

Set up the DNS

nmcli con modify ConnectionName ipv4.dns ""

Configure the wireless security (in this case wpa-psk) and the password

nmcli con modify ConnectionName wifi-sec.key-mgmt wpa-psk

nmcli con modify ConnectionName wifi-sec.psk verysecurepassword

Now you can bring up the connection:

nmcli con up ConnectionName


Here we have an headless and wireless Raspberry Pi 3 running our favorite GNU/Linux distribution!

Please refer to the Fedora Project wiki for more and up to date informations:

Tuesday, May 23, 2017

How to print ZFS filesystems ordered by space used

How to print ZFS filesystems ordered by space used

zfs get -o value,name -Hp used|sort -n

Saturday, May 20, 2017

rpmbuild random notes

sudo dnf install rpmdevtools



sudo dnf download --source package