Category Archives: 开源(软|硬)件

Utiliser VMPK et Cardinal avec PIpeWire, Jack et les baies de brassage Helvum et Qpwgraph

Sommaire
VMPK, clavier de piano MIDI virtuel
Cardinal, fork de VCV Rack, synthétiseur modulaire Eurorack
PipeWire et les baies de brassage
Petit ensemble simple sous Cardinal

Arch Linux, ainsi que de nombreuses autres distributions Linux, ont définitivement basculé la pile audio sous PipeWire. Celui-ci à l’avantage de centraliser de façon simple Jack (temps réel pour l’audio de qualité studio, nécessite des réglages en fonction des besoins) et PulseAudio (plus simple, pour l’utilisation en informatique de bureau ou de jeu). PipeWire, permet aussi de synchroniser plusieurs sources et destinations video de différentes tailles et format, en même temps que le son. Les baies de brassage Helvum et Qpwgraph permettent d’établir simplement à la souris les connexions. QJackCtl ne semble plus fonctionner pour cette tâche.

VMPK, clavier de piano MIDI virtuel

VMPK (Virtual MIDI Piano Keyboard, signifiant clavier de piano MIDI virtuel) est un contrôleur MIDI logiciel, permettant d’utiliser le clavier de l’ordinateur, la souris ou autre dispositif de pointage (tablette, écran tactile) sur un clavier de piano logiciel, et d’envoyer des signals MIDI soit via l’interface MIDI du système, soit aux synthétiseurs logiciels General MIDI FluidSynth (paquet fluidsynth) ou SoniVoxEAS. Les distributions Linux contiennent des fontes sonores libres compatibles General MIDI, (sous Arch, paquet soundfont-fluid, complet, mais de qualité moyenne et freepats-general-midi, moins étendue en nombre d’instruments, mais de bien meilleure qualité). Si vous avez besoin de sélectionner leur emplacement, ces fontes sont placées dans le dossier /usr/share/soundfonts/ après installation. Le site de Freepats regroupe également des fontes spécialisées par instruments d’encore meilleures qualité, mais dont le poids des fichiers sont beaucoup plus grands.

réglage de la fonte midi ou de la sortie MIDI

Pour choisir le mode synthétiseur logiciel ou MIDI system, en suivant l’image ci-dessus :
* 1. Menu Éditer -> Paramètres MIDI
* 2. choisir dans le champs Pilote MIDI OUT, choisir soit Alsa pour le signal MIDI système, soit FluidSynth pour le synthétiseur MIDI logiciel permettant de produire directement les sons.
* 3. Dans le cas de FluidSynth, si c’est votre premier réglage, il faut cliquer sur le bouton [...]; à droite du bouton-menu ou vous avez sélectionné FluidSynth dans le champs Paramètres MIDI OUT.
La fenêtre Paramètres du pilote FluidSynth s’ouvre alors, il est possible dans le champs Pilote Audio de choisir Alsa, Jack, PulseAudio, SDL et d’autres.
# Dans le champs Soundfont, vous pouvez choisir la fonte sonore en ouvrant un sélecteur de fichier avec [...] ou de taper le chemin directement. Comme dis précédemment, les fontes sont placées par défaut dans le dossier /usr/share/soundfonts/.

Cardinal, fork de VCV Rack, synthétiseur modulaire Eurorack

Voici un aperçu des nombres plugins du synthétiseur modulaire Cardinal, il s’agit d’un fork, par le projet DISTRHO (dont le but est de regrouper les systèmes de plugins audio) de VCV Rack, intégrant de base tous les modules sous license libre en un seul paquet, et comme vous pouvez voir sur cette vidéo de la version d’avril 2022, ils sont nombreux :

VCV Rack est une version logicielle de synthétiseur modulaire au format standardisé ouvert de modules de synthétiseurs analogiques, Eurorack créé par l’allemand Dieter Döpfer1. Il est d’ailleurs possible d’interfacer, notamment via MIDI, des modules matériel de ce format. Les échanges s’y font principalement par un signal électrique analogique en utilisant des câbles avec connecteurs jack, mais les modules peuvent faire des traitements numériques ou utiliser des connexions numériques de type MIDI ou différents formats audio comme la connexion optique S/PDIF. Certains modules logiciels de VCV Rack sont d’ailleurs fait par des créateurs de modules matériels, à l’image des auteurs des excellents modules Mutable Instruments qui en ont porté certains sous le nom de Audible Instruments ou encore de Befaco. Ceux-ci comportement notamment de la synthèse granulaire et de la simulation numérique de sons. La version Cardinal supporte également différents formats de plugins audio LV2, VST, etc..

Je maintien les paquets Arch AUR de VCVRack-git en version 1.x qui ont l’avantage de pouvoir être utilisé avec ALSA directement (plus simple que Jack) et de comporter directement un module de saisie au clavier. Ce que ne propose pas encore Cardinal, mais cela devrait arriver ce mois-ci avec l’ajout des modules Fundamentals.

À ce propos, David Louapre, l’auteur de la chaîne Youtube de vulgarisation scientifique « Science étonnante » à fait une vidéo explicative des principes des synthétiseurs analogiques et modulaires intitulée « La Science des synthétiseurs ».

PipeWire et les baies de brassage

La baie de brassage Helvum permet de gérer de façon graphique et interactive, les connexions des différents éléments audio ou vidéo au sein de PipeWire, il est bien évidement également possible de les gérer par des programmes ou scripts directement dans PipeWire.

Helvum affiche les différents éléments sous forme de boîte et les liaisons via des courbes ou fils. D’après ce que j’en ai compris, les courbes en pointillées montrent les connexions automatiques de la partie PulseAudio, et les courbes pleine, montrent les connexions manuelles pour Jack.

Pour ajouter une connexion, il suffit de cliquer sur une boîte, puis de déplacer le petit icône de fichier affiché vers l’autre point de liaison. Voici comment faire dans le cas de VMPK avec Cardinal et de Cardinal avec la sortie audio :

Qpwgraph, à l’avantage de détecter d’avantages de choses. Il a notamment détecté VokoscreenNG que j’ai utilisé ici pour la capture vidéo du bureau. Mais ça n’est pas un problème, celui-ci ayant permis de sélectionner l’entrée audio sans doute via pulseaudio à utiliser. Il comporte également des annuler/refaire, et l’ouverture et sauvegarde de la configuration en fichier, ce qui peut rapidement devenir indispensable.

Voici donc les manipulations équivalentes sous Qpwgraph :

À noter que dans cet vidéo j’avai une sortie MIDI de VMPK, mais dans un autre cas, comme sur cette capture d’écran, je ne l’avais pas. VMPK étant connecté au bridge (passerelle) MIDI du port 0, il suffit alors de connecter la sortie de la passerelle MIDI du port 0 pour avoir le même résultat.

Utilisation du bridge MIDI du port 0 pour récupérer la sortie de VMPK

Petit ensemble simple sous Cardinal

Voici un exemple simple d’ensemble fonctionnant avec VMPK et cette configuration. Cela permet de comprendre le fonctionnement de base de Cardinal/VCV Rack.

Les sorties de contrôle MIDI sont récupérées vers les entrées de contrôle du rack « Modal Synthesizer » d’Audible Instrument dont j’aime bien la sonorité, proche de carillons :
* La sortie V/Oct (volt/octave) vers l’entrée V/Oct. Elle donne la hauteur de la note en fonction de la tension électrique (ici virtuelle).
* La sortie Gate (porte) vers l’entrée Gate. Elle transmet le moment où une touche est pressée (signal 0 relâchée ou 1 pressée). Il est intéressant de noter dans ce montage que lorsque la touche suivante est pressée avant que la touche précédente ne soit relâché on a un glissendo, plutôt qu’une nouvelle percussion de la note avec attaque initiale.
* La sortie velocity (vélocité) permet de donner de l’expression au son en variant l’attaque, sur un clavier texte AZERTY d’ordinateur, il n’y a pas ce genre de paramètres, mais il est possible de le lier à l’entrée strength (force), du module, et de lui transmettre ainsi l’expression du touché.

Pour la sortie du module d’Audible Instrument, c’est simple, la sortie gauche (L comme left) vers le port de sortie audio 1 et la sortie droite (R comme right) sur le port audio 2, comme nous avions définit dans la baie de brassage. Il ne reste plus qu’à presser les touches du clavier virtuel pour entendre les notes et tourner les molettes pour modifier les effets.

Comme on peut le voir sur cette vidéo, la saisie directe du clavier comme le permettent les modules Fundamentals ou un veritable instrument midi sont tout de même plus pratique pour ne pas avoir à passer sans arrêt de l’un à l’autre. Mais cela permet déjà de faire des enregistrement ou contrôle simple. Différents outil comme Qjackctl permettent d’enregistrer une séquence MIDI puis de la retransmettre. Il est aussi possible de passer un morceau midi en fichier .MID dans la passerelle MIDI et de lui ajouter des effets avec Cardinal et/ou des nombreux modules au format LV2 ou VST.

Principe de synthétiseur analogique modulaire

Les synthétiseurs analogiques modulaires suivent le principe similaire à UNIX, du KISS (keep It Simple and Stupid), garder les choses simples et stupides. Les modules sont très simples, et la force du système réside dans la possibilité d’échanger entre ces différents éléments. Les échanges se font principalement via des câbles électrique via un courant qui peut varier en tension (en Volt) de façon analogique (continue), plutôt que numérique (discrète). Il est tout de même possible de transmettre un signal numérique (1 ou 0) et c’est ce que fait la fonction gate (porte).

Les différents modules de base sont généralement (je donne les termes anglais et leurs abréviations utilisée, ainsi que la traduction du terme en français entre parenthèses :
* VCO Voltage Controled Oscillator (oscillateur commandé en tension), Il s’agit d’un générateur de signal, généralement sinusoïdal, comme le faisait le premier synthétiseur, le Thérémine, du nom de son inventeur, le Russe Lev Sergueïevitch Termen. Certains plus avancés permettent de fournir des singaux carrés, en dent de scie, différentes couleurs de bruits (blanc, rose, etc).
* VCF Voltage Controled Filter (filtre contrôlé en tension), permet de filtrer l’entrée en fonction de fréquences définies.
* VCA Voltage Controled Amplifier (Amplificateur commandé en tension). Permet d’amplifier le signal.
* ADSR Attack, Delay, Sustain, Release (généralement traduit par : Attaque, chute, entretien, extinction. Il s’agit des paramètres standard d’enveloppe sonore, dont les principes ont été crées par Vladimir Ussachevsky. Pour faire une analogie avec les instruments acoustiques, L’attaque (attack) correspond à la montée au moment où l’on actionne le sonophore de l’instrument. La corde frappée d’un piano ou pincée d’une guitare ou d’un clavecin. L’archet qui commence à frotter la corde, La percussion sur la peau d’un tambour, la première impulsion de la vibration des lèvres d’un trompettiste. La chute (delay) est la durée de l’attaque, c’est à dire le délai de l’attaque initiale. l’entretien (sustain) est la hauteur du palier de la vibration produisant le son continu. Enfin l’extinction (release) est la phase d’arrêt du son.
* LFO Low Frequency Oscillator (Oscillateur basse fréquence), il est utilisé principalement pour les modulation de l’instrument, comme un trémolo ou une trille par exemple.
* Arpeggiator (arpégiateur). Il est destiné à produire une succession de note. Un accord correspond à plusieurs notes produites simultanément, et un arpège est son équivalent avec cet ensemble de notes décalées dans le temps. Par exemple les notes do mi sol do jouées successivement correspondant à un accord de do majeur. Cela permet de produire simplement des éléments de base de mélodies.

Pour aller plus loin

La page PipeWire du wiki d’Arch.

RISC-V based ESP32c3 with ESP-IDF part 3, OLED screen, and potentiometer

Table of Content

* Introduction
* ADC Limitations on some ESP32 SoCs
* Potentiometer
* OLED I²C Screen
* Building the project and flashing

Introduction

This piece of software was done for new year 2022, but procrastination helped me to delay the release of the tutorial, it continue the traditionnal (but with detailed explanations) LED blinking introduction tutorial. The goal of this tutorial is to learn to use potentiometer and little I²C screens (4 pins are I²C only, SPI versions use more pins) in EPE-IDF, with ESP32 microcontroller SoC based. I use here a really cheap (<5€) but powerful AI thinker ESP-C3-32S, that use an efficient low power RISC-V microcontroller.

Full schema with part 2 and 3

You can find the complete sources files and prebuild RISC-V firmware for ESP32-C3 on my files repository.

This example contain two main parts in the single file adc/esp32c3/adc/main/adc_dma_example_main.c, called in app_main(void), at the end of the file :
* One simple example single_read(NULL);, that make only one read of the state of the ADC, it uses ADC 1, channels 2,3,4) and ADC 2 (channel 0) and display datas on terminal.
* One more complex example continuous_read(NULL);, that reads 256 times the state of the channels and display them in the console, and then make continuous reading and change the onboard RGB Led blue colour light intensity.

The official documentation of the ADC.

ADC Limitations on some ESP32 SoCs

Limitations differs depending on ESP SoC, they have both 2 ADC, and one can’t be used when using WiFi:
* ESP32, based on Xtensa LX6 has 10 channels on ADC1 and 8 channels on ADC2, and ADC2 is used when Wifi is on.
* ESP32-S2 (no WiFi/BT) and ESP32-S3 (Wifi/BT), based on Xtensa LX7 (this last one has a RISC-V coprocessor for a more efficient ULP deep sleep mode), has 10 channels on both ADC, and ADC2 can’t be used when WiFi is on.
* ESP32-C3, based on RISC-V, ADC1 can’t be used with WiFi on, both ADC1 and ADC2 can’t be read simultaneously, you must read them alternately. ADC1 have 6 channels (6 pins) and ADC2 only one.

NodeMCU-series ESP-C3-32S-kit pinoutESP-C3-32S kit Pinout schema from JC François, with ADC pins in pink.

Full schema with part 2 and 3
Whole Breadboard montage with previous part tutorial and this one.

Potentiometer and OLED screen connexions
Connexions of potentiometer and OLED screen.

Potentiometer

* The first top-left pin (ADC1_CH0 / ADC_CHECK in pink) is connected to the middle pin of the potentiometer (et right on the picture) using the white wire.
* The  3.3V , here 5th pin starting from the bottom left, but other 3.3V can be choosen, is connected to the left pin of the potentiometer (at right on the picture).
* The  GND , here 6th pin starting from the bottom left, but any ground pin can be used is connected using black wire to the right pin of the potentiometer.

V Red and GND black-blue breadboard lanes
Red lane and blue/black lane of the bread board.

Both  Vcc  and Ground are transiting by dedicated lane of the breadboard, on the top of the picture painted with red (meaning Vcc) and blue (meaning for black/Ground) lines. It is very important to keep black and red wire to these roles to avoid to burn components, any other colour can be used for data links. There is another lane at bottom. This is not clear on the picture, but the screen is connected on but on the first row of the inner part.

We need to include the adc.h headers, and we also add esp_log.h header here for debug purpose.

#include "esp_log.h"
#include "driver/adc.h"

Here are the presets used for potentiometer ADC (Analog-Digital Converter) in the source code.

/* ADC vars */

esp_err_t ret;
int adc1_reading[1] = {0xcc};
int adc2_reading[1] = {0xcc};
const char TAG_CH[][9] = {"ADC1_CH0", "ADC2_CH0"};

void init_adc()
{
  adc1_config_width(ADC_WIDTH_BIT_DEFAULT);
  adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_0);
  adc2_config_channel_atten(ADC2_CHANNEL_0, ADC_ATTEN_DB_0);
}

OLED I²C Screen

An author made an interesting list of available colour display managed by ESP32 on Instructables.

I used the driver esp-idf-ssd1306 by nopnop2002 available on github (local archive)

There are 4 connector pins on the I²C only version:
*  GND , I use black wire and connect it to GND lane.
*  VCC , I use red wire and connect it to Vcc lane.
*  VCL  (sometimes VCK, VCLK as V clock), is for the clock signal, I choose green colour wire here, I connect it to  GPIO9 , at 4th pin starting from top right.
*  VDA  (VDA as V data), I choose white colour wire here, I connect it to  GPIO10 , at 6th pin starting from top right.

The SDA/SCL GPIO can be set by two way:

By editing the sdkconfig file at the root of the project and changing the following values to the values you want:

CONFIG_SCL_GPIO=9
CONFIG_SDA_GPIO=10

Or in the menu using:

make menuconfig

Then go to submenu SSD1306 Configuration ---> Then defining the number in (9) SCL GPIO number and (10) SDA GPIO number field.

By default, this application print the current settings in the monitor console via these functions:

#if CONFIG_I2C_INTERFACE
        ESP_LOGI(tag, "INTERFACE is i2c");
        ESP_LOGI(tag, "CONFIG_SDA_GPIO=%d",CONFIG_SDA_GPIO);
        ESP_LOGI(tag, "CONFIG_SCL_GPIO=%d",CONFIG_SCL_GPIO);
        ESP_LOGI(tag, "CONFIG_RESET_GPIO=%d",CONFIG_RESET_GPIO);
        i2c_master_init(&dev, CONFIG_SDA_GPIO, CONFIG_SCL_GPIO, CONFIG_RESET_GPIO);
#endif // CONFIG_I2C_INTERFACE

The example of the driver is used for the screen. It pre-include the necessary headers files. ssd1306.h is the driver itself, font8x8_basic.h is a 8×8 pixels ASCII font set, and driver/i2c.h is the i²C protocol header, used to communicate with the screen microcontroller.

#include "ssd1306.h"
#include "font8x8_basic.h"
#include "driver/i2c.h"

I removed the demo, and set all the specific code in the #if CONFIG_SSD1306_128x64 section, as this is the model of my screen.

#if CONFIG_SSD1306_128x64
        top = 2;
        center = 3;
        bottom = 8; // 8 lines
        int n=200;
        int pos=0; // initial position = 0

Le main loop (while(n) {}):
I read ADC1 channel 0 (first pin) of the potentiometer and print the current value into the console

  adc1_reading[0] = adc1_get_raw(ADC1_CHANNEL_0);
  printf("chan[%d] 0x%x = %d\n", 0, adc1_reading[0],adc1_reading[0]);

Then I compute the current p position after a constant I predetermined, after test I seen that the specific potentiometer I use, as values in range [20 ; 2920]. And I have 8 text lines on screen, so I rounded to 3000/8 = 375. Output value / 8 compute the current line on screen.

  pos=adc1_reading[0]/375; // 20~2920  => need to calibrate 3000/8=375
  printf("pos=%d\n",pos);

Clearing the 8 text lines of the buffer, but the current line

  for (int i=0;i<8;i++) {
    if ( i != pos) {
      ssd1306_clear_line(&dev, i,false);
    }
  }

Printing 2022!! at the current line. the two space, allow to center a bit the text.

  ssd1306_display_text(&dev, pos, "  2022!!", 11, false);

And finally, wait a delay of 50 milliseconds before refreshing to avoid uselessly saturating processor and overloading.

  vTaskDelay(50 / portTICK_PERIOD_MS);

That's all ! We just have to build the project and put in on the board now.

Building the project and flashing

Build the example for AI thinker ESP-C3-32S

Initialising esp-idf:


ESPIDF=/PATH/OF/YOUR/INSTALLATION/OF/esp-idf
. $ESPIDF/export.sh

Then go the the project root:

cd myproject/
 idf.py set-target esp32c3

If you have the following error:

Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Directory '/data/arc/esp/esp-idf/test/adc/esp32c3/adc/build' doesn't seem to be a CMake build directory. Refusing to automatically delete files in this directory. Delete the directory manually to 'clean' it:

You simply need to clean build subdirectory if it exists

rm -R build
mkdir build

and in any case to create the CMake:

cd build
cmake ..
cd ..

Then configure the project for your SoC target, in ESP32-C3 case:

idf.py set-target esp32c3

If you need to change some settings of your porject, like GPIO ports for screen driver, you can edit the sdkconfig file or use make menuconfig now.

you will not have to redo all this procedure at each rebuild now, you can play with source code and build or rebuild/flash with the following last command:

idf.py build flash monitor
You can quit the monitor by making the CTRL + ] keys combination.

relatively full Debian desktop, server or both environnement on RISC-V based LicheeRV.

Table of Contents


* Introduction
* Installing the Image
* Connecting serial
* Booting
* Setting the WiFi
* Audio
* Some minors but useful tuning
* What is working

* Update 2022-03-12: Someone made a full tutorial to build a working image with own kernel and standard debian buildroot.
* Update 2022-04-06: Sehraf made RISC-V Arch Linux builder for Lichee-RV and D1

Image used in this tutorial use a kernel that doesn’t support firewall so don’t forget to use it only behind a well configured router (or box) connexion and don’t use confidential things on it.

Introduction

I managed to have a working Debian desktop environment on RISC-V after previous test and some exchanges on different Sipeed/D1 channels. Most informations are today available on Linux-SunXI.org Wiki dedicated page.

See also the previous article Booting Ubuntu Linux on a LicheeRV.

This image seems to manage more of the SoC features, or at least it announce lot of flags (IMAFDCVU):

$ cat /proc/cpuinfo 
processor	: 0
hart		: 0
isa		: rv64imafdcvu
mmu		: sv39

* IMAF = base ISA, Mul/div, Atomic instruction, (single precision) Float
* D = Double precision float
* V = Vector processor extension
* C = Compressed instructions
* U = User mode hyperverisor

The main problem was to have a working image with Debian, AllWinner and Speed give only a Linux image that can be made on Windows using PhoenixCard tool.

Someone of a Sipeed chat that have access to a Windows installed computer, made the conversion and give it available here (my mirror copy) sha256sum of the image: cf73baf3ed67d480e7606c666ccb81fce21295ba8fbba10e0ad86939065be6ffw. You need an at least 16GB microSD card to use it with LicheeRV and it’s Dock..

As a video exemple of the working image, Glaxnimate animation suite (own made RISC-V version of Debian package) , goes-up quickly to 6 of load, as most applications, but it is still usable:

Installing the Image

To install it, you can follow the following steps:

Install aria2 (Debian based (Debian, Ubuntu, …) sudo apt install aria2, Archlinux based (Arch, Manjaro, …): pacman -S aria2)

Update: someone said me he had problems with aria2, as wrote at the top of this article, you can still download the image from here: give it available here (my mirror copy). Please, verify the sha256sum of the image at the end of the download (Aria2 does automatically): cf73baf3ed67d480e7606c666ccb81fce21295ba8fbba10e0ad86939065be6ffw.

For an USB microSD card reader (I use /dev/sdd for /dev/sdX in my case you can verify which one is your by sudo fdisk -l:

DEVICE=/dev/sdX
aria2c https://popolon.org/depots/RISC-V/D1/images/LicheeRV/20211230_LicheeRV_debian_d1_hdmi_8723ds.ddimg.xz.metalink

It is very important to wipefs to avoid any problems with detections, then write, the downloaded image:

sudo wipefs -a ${DEVICE}
xzcat 20211230_LicheeRV_debian_d1_hdmi_8723ds.ddimg.xz | sudo dd bs=1MB status=progress of=${DEVICE}

Then delete the partition 8:

sudo fdisk ${DEVICE}
d
8
w

Resize the partition 7 to use the remaining space:

sudo parted ${DEVICE}
print

You will see the exact size of your partition (here in bold) that will be used later:

Model: SD ACLCE (sd/mmc)
Disk /dev/mmcblk0: 63.9GB

Then reuse the same value here to use the whole end of the card:

(parted) resizepart 7
End?  [??.?GB]? 63.9GB
(parted) quit

Then now grow the fs itself.
* for an USB sdcard reader (/dev/sdX):

sudo resize2fs ${DEVICE}7

* for an internal sdcard reader (/dev/mmcblkX):

sudo resize2fs ${DEVICE}p7

Now sync (flush data in memory on disk) the card:

sync

You can now extract the card from your reader and put it in the LicheeRV board.

Connecting serial

You should connect the way described on this picture. You can also connect the red wire on one of the 5V pin to power the board if you want:
picture of UART connectors pinout, upper row from left, 5V, 5V, GND, TX, RX

You can then connect using one of the methods I previously described here.

screen /dev/ttyUSB0 115200
Package             commande
busybox             busybox microcom -t 5000 -s 115200 /dev/ttyUSB0
minicom             minicom -D /dev/ttyUSB0 
gtkterm-git (AUR)   gtkterm -s 115200 -p /dev/ttyUSB0
python-pyserial     python -m serial.tools.miniterm /dev/ttyUSB0 115200
screen              screen /dev/ttyUSB0 115200
tinyserial          com /dev/ttyUSB0 115200
picocom             picocom --baud 115200 /dev/ttyUSB0

On the Login prompt, use:
* Login: sipeed
* Password: licheepi

Just for information about PinOut, used to know the serial pins:

You can find a Pineout of the board on the LicheeRV HDK Schematic PDF (local mirror):

And the pineout of the dock in the Dock Datasheet (local mirror)

LicheeRV Dock pineout

Booting

There has several problems at boot due to cgroup not enable in this kernel.

You can disable this problems by:

sudo dpkg -P rtkit
sudo systemctl disable e2scrub_reap
sudo systemctl disable systemd-hostnamed

The first line allow to have more HDMI (including sound) working and stop loop message on all consoles. The second one avoid 2+minutes of wait at booting time. The third one seems to have no effect, the message continue at boot.

Details of the problems:

H2MI to DVI and HDMI to USB dongles I used
Then boot it plugged on a 1080p HDMI screen. It doesn’t work with my HDMI->DVI (tried on a 1680×1050 DVI-A and a 1080p DVI-D) or with my 1080p HDMI->USB dongle. Someone else reported it worked with an HDMI-DVI dongle (reference: 6140063500G).

Update: This was resolved partially by removing rfkit, a watchdog daemon that tried to kill something, probably on a wrong test. The message that come in loop on the console disappear then, the HDMI output on the HDMI to USB dongle worked, this will allow me to record/stream video output, and audio output on HDMI now work too. It could be suggestive, but I feel like system also work a bit faster (testing/killing/restarting things can take a lot of resources) :

sudo dpkg -P rtkit

The error message loops like this in dmesg :

Jan 18 10:50:33 sipeed systemd[1]: Starting RealtimeKit Scheduling Policy Service...
Jan 18 10:50:33 sipeed kernel: Unable to handle kernel paging request at virtual address ffffffdf8099707e
Jan 18 10:50:33 sipeed kernel: Oops [#52]
Jan 18 10:50:33 sipeed kernel: Modules linked in: xt_time xt_multiport xt_mark xt_mac xt_limit xt_comment xt_TCPMSS xt_LOG uvcvideo videobuf2_vmallo>
[…]
Jan 18 10:50:33 sipeed systemd[1]: rtkit-daemon.service: Main process exited, code=killed, status=11/SEGV
[…]
Jan 18 10:50:58 sipeed systemd[1]: rtkit-daemon.service: Failed to get cgroup ID on cgroup /sys/fs/cgroup/system.slice/rtkit-daemon.service, ignorin>

The problem of missing cgroup management in kernel is also the source of long boot and messages:

[FAILED] Failed to start Remove Sta…ext4 Metadata Check Snapshots.
See 'systemctl status e2scrub_reap.service' for details.
[   ***] A start job is running for Raise ne…rk interfaces (1min 7s / 5min 14s)

Looking at journalctl:

journalctl -xeu e2scrub_reap.service

You will see the following message:

e2scrub_reap.service: Failed to get cgroup ID on cgroup /sys/fs/cgroup/system.slice/e2scrub_reap.service, ignoring: Function not implemented
journalctl -xeu systemd-hostnamed.service

systemd-hostnamed.service: Failed to get cgroup ID on cgroup /sys/fs/cgroup/system.slice/systemd-hostnamed.service, ignoring: Fu

If you disable it, the boot will now be 2 minutes faster:

sudo systemctl disable e2scrub_reap
sudo systemctl disable systemd-hostnamed

You can see the whole boot sequence by connecting to UART. See this ASCIInema record of the boot sequence (local copy of the cast).

LigthDM connexion prompt

At the LightDM Login and pass prompt use:
* Login: sipeed
* Password: licheepi

Then you will have after about less than 1 minutes (yes, that’s a bit slow) the desktop.

Setting the WiFi

You can set your WiFi connexion (and even BlueTooth) with connexion manager. It is accessible from the main menu (the most left-bottom gray icon) by Preferences > Connman Settings, see this picture

access to Connman from menu

Then choose Wireless at left of the new box.Activate the Wifi connexion in Connman
* Click on the gray button to start the wifi (1 in red on the picture).
* Select the network you want to connect to (2 in red)
* Click on connect (3 in red).
* A prompt will open, where you will need to enter the passphrase of the WiFi.
Authentication required

The connexion should be established now, with “Connected” wrote at top of the window and “Online” beside the name of the Wifi router name (as on the picture at right.

You can by pressing on the gear at the right of the router name (2) in previous right picture, have access to some control to have the connexion set automatically at each boot.

click on the greyed autoconnect button, it should become blue meaning autoconnect is activated

Click on the IPv4 at left and then on the Method (set to None) button, choose automatic in the menu as shown in the following picture, then apply at bottom right.

Don’t forget to check also that NameServers is set as you want (by DHCP or static).

I noticed it worked better if I uncommented the following lines in /etc/network/interfaces using

sudo vi /etc/network/interfaces

, it seems to work far better when it’s uncommented (there is a typo: wpa-deriver instead of wpa-driver, but works as is. to remove the # comments, just move the cursors to them and press x one time.

auto wlan0 #(wlp3s0 为网卡名)
iface wlan0 inet dhcp
	wpa-deriver wext
 	wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

When finished, quit and save with the sequence of keys: “:“, “x!“, ["enter"] key

You can sync your card and reboot safely now:

sync
sudo reboot

It should work fine the next time. you can verify the ip address on your router, or by connecting on the console or interface, and typing:

sipeed@sipeed:~$ ip address
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: sit0@NONE:  mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
3: wlan0:  mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 74:ee:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.xx.xx/24 brd 192.168.xx.xx scope global dynamic wlan0
       valid_lft 41822sec preferred_lft 41822sec
4: wlan1:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 76:ee:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.xx.xx/24 brd 192.168.xx.xx scope global wlan1
       valid_lft forever preferred_lft forever

or, like the former way:

sipeed@sipeed:~$ sudo ifconfig
[sudo] password for sipeed: 
lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 13  bytes 1793 (1.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13  bytes 1793 (1.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=-28669  mtu 1500
        inet 192.168.xx.xx  netmask 255.255.255.0  broadcast 192.168.xx.xx
        ether 74:ee:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=-28605  mtu 1500
        inet 192.168.xx.xx  netmask 255.255.255.0  broadcast 192.168.xx.xx
        ether 76:ee:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 582  bytes 80736 (78.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 504  bytes 82357 (80.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

To be more comfortable I suggest to make a swap file on the microSD if you want to use some desktop application, because, 512MB is really short:

Create a swap file of 1GB (1024M) and format it:

sudo dd bs=1M count=1024 status=progress if=/dev/zero of=/swap
sudo mkswap /swap

Add this to /etc/fstab for automatic mount after reboot:

echo "/swap none swap defaults 0 0" |sudo tee -a /etc/fstab/

Then mount it immediately

sudo swapon -a

For more comfortable serial (UART) console usage, you could also install xterm package. It will give you the resize command. When you type resize from your serial connexion, the serial view will adapt to you local Xterm, VTE term, or whatever terminal you use.

Audio

On this default image to have audio working on HDMI I suggest ton install and use PAVUcontrol, the best tool I know to manage PulseAudio and PipeWire audio daemons.

sudo apt install pavucontrol

You can launch it in a term like the following line or in menu like on this picture:

pavucontrol

With the GUI menu, choose Sound & Video > PulseAudio Volume Control
select Pavu control in menu

Then for HDMI default output in PulseAudio, that is wrapped on PipeWire, select, the Output Devices tab, as blue underlined on picture, then press the green rounded check (I added red square on this picture) beside Build-in Audio Stereo where Analog Output, the first Entry with Headphones is probably the speaker connector on the board (need to try it).
Select Analog Output for HDMI output

Some minors but useful tuning

Crontab installation is broken by default, group crontabs is missing:

apt reinstall cron

To use your language:

sudo vi locale.gen

Uncomment your corresponding line (ex: for french: fr_FR.UTF-8 The two first chars (here fr) are language and the second (here FR) are the country (here France).

You can then set the locale, and the keyboard
You can list available languages layout by:

localectl  list-x11-keymap-layouts
localectl set-locale fr_FR.UTF-8
set-keymap fr
set-x11-keymap fr_FR

To gain some KB you can replace lightdm by xdm (the first default display manager, or nodm that doesn’t prompt for login/password.

For nodm:

sudo apt install nodm

For xdm:

sudo apt install xdm

Anyway you can install both and during the installation, dpkg-configure will ask you in a menu the one you want to use.

By default with nodm, root user will be used, this is really not a good idea. You can change it by editing the nodm config file from root to sipeed:

sudo sed -i s/NODM_USER=root/NODM_USER=sipeed/ /etc/default/nodm

.
or by using debian dpkg-reconfigure that will ask you several question and change the user:

sudo dpkg-reconfigure nodm

Then reboot or stop LightDM and start another dm:

sudo systemctl stop lightdm
sudo systemctl start xdm

As LicheeRV is a very cheap card, the goal is to have an available board to test RISC-V integration, there is no dedicated Video RAM. You can gain lot of performances by disabling X. Stop lightdm will free the resources of X automatically. You will gain RAM and resources for compilation or other tasks.

sudo systemctl stop lightdm

To disable it permanently use systemctl disable, it will keep this state after reboot

sudo systemctl disable lightdm

You can still re-enable it by using systemctl enable:

sudo systemctl enable lightdm

What is working

MuseScore, Scribus and FontForge
Among application working well, I found:
* Graphics tools: GIMP, Krita work a bit slowly. The first time, need to wait long time, and then go to preferences to disable GL acceleration before creating an image, else it will be awfully slow. Everything will go far faster after that.
* Edition tools: MuseScore (see vidéo), FontForge, Scribus, Inkscape.
* Animation tool: Pencil2D, UPDATE: Glaxnimate (see videos below), I made a Debian package.
* Chat: IRC client Hexchat, and Telegram-desktop client (FOSS Android version)
* Blender work but is totally unusable
* Web browser:: They are generally unusable, the exception is Netsurf (package netsurf-gtk, see screenshot below), that is still slow but a minimum usable, a framebuffer version (netsurf-fb) is pre-installed, but should be used in terminal console view, that is not setup by default. Text browsers like w3m, eLinks, etc, can work. Firefox is unavailable (there is an unofficial method to patch it and compile it for RISC-V, need to test it, but I doubt it will be efficient, a 3 or 4 year old version, could be better. There is an official patch but seem to be no more available? As often, Firefox like to block progress on new technologies….
screenshot with Gimp, Pencil2D, Hexchat (irc client)
* Web server: HTTPd Apache and Nginx works You can test my installation of Nginx, when it is up, here. I let up for few days (it should consume 2,5W maximum (5V*0.5A power via serial or sometime USB), but could some times reboot for update, I wait for solar panels to plug it on.

I put checkers on name to not display private informations:
Screenshot with Blender and Telegram

Netsurf-GTK has little display bugs, but is relatively usable. Still not reactive for typing URL in URL bars.
Screenshot of Netsurf-GTK

Telegram rendering of the Glaxnimate animation:

Launching of MuseScore:

Booting Ubuntu Linux on a LicheeRV


Sipeed made a microSD card image to boot Ubuntu on RISC-V based Allwinner D1 SoC. with their LicheeRV SoM.

Boot sequence on ASCIInema (local copy)

I made a copy of the image in my own repository, that’s faster/easier to download.
* SHA256sum: 4a414a36ba5ae8000bd2f8ee088ea399b502527e1868662427bc00676d65ca79

Just download the archive, untar and follow the instruction in the README. There is an error, the primary partition should start at 80MB (163840), not 40MB (81920). The is limited to 4Go, so it should be grown with resize2fs to have more place to work.

The whole process so:

You must first set the SDCARD device name. For me it was /dev/sdd warning if you are wrong you can delete your system ^^. You can have it’s value by using dmesg just after plugging it:

sudo dmesg | tail

or by using fdisk -l. You need a microSD card with 16GB or more space.

export SDCARD=/dev/sdd

Then follow the following script:

wget https://popolon.org/depots/RISC-V/D1/LicheeRV/Sipeed_mirror/LicheeRV/image/licheerv_d1_1.14lcd_ub2004.tgz
tar xf licheerv_d1_1.14lcd_ub2004.tgz
cd licheerv_d1_ub2004_20220104a
sudo wipefs -a "${SDCARD}"
sudo fdisk "${SDCARD}"

In fdisk:

n
p
1
163840
[press_the_return_key]
w

then continue the process:

sudo dd if=boot0_sdcard_sun20iw1p1.bin of="${SDCARD}" bs=512 seek=16
sudo dd if=d1-kernel.toc1 of="${SDCARD}" bs=512 seek=32800 status=progress

Then depending on the name of the device on your system, if its of kind /dev/mmcblk0 then you should use /dev/mmcblk0p1 for partition 1, if it’s a /dev/sdd then, it’s /dev/sdd1.

if you use a /dev/mmcblkX type of device (typically internal SDcard reader) use this:

sudo dd if=ub2004_rootfs.img of="${SDCARD}p1" bs=1M status=progress
sudo resize2fs "${SDCARD}p1"
sync

if you use a /dev/sdX type of device (typically an USB SDcard reader) use this:

sudo dd if=ub2004_rootfs.img of="${SDCARD}1" bs=1M status=progress
sudo resize2fs "${SDCARD}1"
sync

After the sync, you can unplug the microSD card, plug it in your Lichee RV turn on the SoM, wait few seconds, after OpenSBI have booted it will open the kernel and you will see the Ubuntu boot sequence on screen.

Here is the boot with the LicheeRV dock, allowing to plug USB keyboard or other device, and HDMI, still need to manage it. There are some Debian image with HDMI working, but need proprietary Windows tools to make the microSD card :(.

Update: Another interesting image with more features Debian Bulleseye 11 from RVBoards, but with very strange FS (Android ?) and only 4GB partition (the /opt could be hacked). On their mirror (can be slow), local copy
* Sha256sum: e4a042d3a7c0658ffa009185488164eb18bd49fd92928cdec190a80f15b0c86b
* Just need to unzip and dd to the microSDcard.
* ASCIInema record of the boot sequence (local copy). This image is for Allwinner Nezha, so lot of things will not work and throw error message. But on the other side, most peripherals are detected, could be interesting for tuning. Linux condig.gz of the kernel