Boot to Sonic Pi from a USB stick (no SD card) on Pi3

Recently I ran up an image on a USB stick which can be used to boot a Pi3 (NOT Pi2 or earlier) straight into Sonic Pi 2.11, without needing an SD card. This is based on excellent documentation on the Raspberry Pi website at https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md and I claim no credit for this whatsoever other than having tried it out successfully.

Note this is still an experimental procedure to a certain extent, although with the USB drive I specify below I had no problem in getting to to work with two different Pi3. Your Pi3 will still be bootable as normal from a standard SD card after you have carried out this procedure.

In order to set this up you will need the following:
1 A Pi3 (it will not work on a Pi2 as it uses bootcode built into the Pi3)****
2 A freshSD card on which to build the image which will be transferred to your USB stick. I used a 16Gb Sandisk Ultra miscroSDHC
3 A usb stick. I used a Sandisk Cruzer SDCZ50 16GB from Amazon for £4.99 (not every usb stick will work. The article give a list of some which have been tested)
4 An internet connection for your Pi3

*** It is possible to change this to boot from a Pi2 or earlier, using just one boot file on an SD card. Thereafter the USB stick takes over. See https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/ for details.

Follow the details of the first part of the article to build up your SD card image Use the Raspbian image dated 2016-09-23 from raspberrypi.org/downloads  Before the second stage, where you transfer the image to your USB stick, install Sonic Pi 2.11 (just released) onto the SD card. You can get it from
http://sonic-pi.net/files/releases/v2.11.0/
download the file sonic-pi_1-2.11.0-2_armhf.deb
I downloaded this via the Chromium browser on the Pi3 to the Downloads folder
Then I installed it with:-

cd ~/Downloads
sudo dpkg -i sonic-pi_1-2.11.0-2_armhf.deb
sudo apt-get install -f

You may find it then lists some redundant packages which you can remove as suggested with

sudo apt-get autoremove

I also added dtoverlays for my IQaudio amp to config.txt using sudo nano /boot/config.txt

dtoverlay=iqaudio-dacplus,auto_mute_amp
dtoverlay=i2s-mmap

which you can do also if you have one, or else any overlays required for an alternative eg HiFiBerry card.

In order to add an auto boot into Sonic Pi you do the following.

mkdir -p ~/.config/autostart
cp /usr/share/applications/sonic-pi.desktop ~/.config/autostart

If you have an IQaudio (or alternative audio card) installed on your Pi3, you should select it as the default card in the Audio Device Settings on the Menu -> Preferences tab

Once you are happy with the SD card, you should complete the second section of the article setting up the USB stick with parted as discussed in the raspberry pi boot documentation article.

All being well, once you have finished you should be able to boot your Pi3 from the usb stick you have set up. Note it does take some time to boot, as it first checks to see if you have an SD card installed, and then switches to search for a USB card after a 5 second timeout. You will see a large rainbow coloured square on your monitor during this process.

I advise you to remove the line added to config.txt

program_usb_boot_mode=1

which was added to program the One Time Programmable memory (OTP) in your Pi3 to enable USB booting. This is an irreversible process, and you may not wish to inflict it on any other Pi3 that the card is subsequently used to boot, although the Pi3 can still boot normally with an SD card even if this has been programmed.

The original github page for the procedure is at
https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/bootmodes/msd.md

and there is more useful information in the parent folder (bootmodes)

This project requires some care to follow the procedures accurately, and it takes a little time to transfer the card contents to the USB stick. Although the boot time is quite long, the performance thereafter is not noticeably different from that of the SD card. Apparently you can add a resistor to one of the GPIO pins to speed up the booting by getting it to ignore the SD card, but I haven’t managed to find out documentation as to which pin is involved. You can also leave a blank SD card in the Pi3 which will also speed up the boot time, by eliminating the timeout wait.

WiFi to ethernet adapter for an ethernet-ready TV New Version Published

Today I have published a new version of one of the most popular projects on this blog to create a WiFi to ethernet adapter for an ethernet-ready TV. The new version is written for the latest Raspbian distribution Lite or “pixel” published on 2016-09-23, and reflects changes in the way in which ip addresses are now handled using systemd.

Full details can be found here

Sonic-Pi controlled conversation between two McRoboFaces

IMG_4843

Following on from my previous project with a single McRoboFace, 4Tronix have kindly supplied me with a second face to enable me to develop the idea to control two McRoboFaces with Sonic Pi. I have amended the previous project to feed the outputs of the left and right audio channels to two separate adc inputs on the piconzero board, and daisy chained the two McFaces (you merely connect the Dout pin of the first to the Din pin of the second) and then address the leds on the second McRoboFace with an offset of 17. I have developed routines in the python driver program to control each face separately. Each mouth can be set to a fixed position: closed, open, smile or sad, or can be fed from the audio input via the adc, so that it is triggered to open when the signal exceeds a preset threshold.

In order to provide greater control, and to synchronise it to the audio feed from Sonic Pi, I have added Ruby routines to the Sonic Pi program which can send text strings to the python program via a text file. These strings can set the mouth state for each face, and also alter the colours of the leds. because there is only a common brightness setting for both faces (using pwm) If only one face is receiving audio I use that output to control the brightness of both faces. If both faces are set to receive audio then I set the brightness at a fixed value.

The conversation is entirely controlled from Sonic Pi. It plays the audio for each face via a series of pre-recorded samples, and plays each face with a separate audio channel by setting the pan: value either to -1 or to 1. Before each sample is played, control signals are sent via the text file to set up the required state for each face. At the end of the presentation both faces receive audio input together as they “sing” along to a round of Frere Jaques. Finally a control signal is sent to reduce the brightness to zero, effectively switching off all the leds.

Writing and reading the data via a text file is perhaps not the most elegant way to do things, but does seem to work OK. I used a technique I developed previously when reading in large numbers of sample files to “hold up” the Sonic Pi program utilising a cue and sync while the writing completes. Otherwise you can run into “too far behind errors”. On the reception side, at the start of the main program loop the python program polls for the existence of the text file, and if it finds one, reads the data, then deletes the file. It then alters parameters according to the received data. It took quite a lot of experimentation to get the timings and consistent operation of the two programs correct, but having done so, the final system is quite stable. I boost the audio levels to amp: 4 in Sonic Pi, which gives a good signal for the adc inputs to latch on to.

Setup is fairly straight forward. The calibrate button used in the single face project us utilised again, and sets separate offsets for each channel, and the code used to modulate the mouths is very similar to that used in the previous project. Once set, the Sonic Pi program can be run several times, leaving the python program running continuously..

I have enjoyed this project, which had brought together Sonic Pi, Ruby and Python in an interesting way, not to mention recording and processing the samples with Audacity., and I hope you enjoy the video of the final system. I hope it may be possible to write up teh system more fully in the future, but it will be quite a big job to do so.

You can see the video here

 

Sonic Pi driven Sound Bar Graph built on RasPiO ProHat

SPBarGraphMainLayout

Ive recently added an article describing how to use the RasPiO ProHat to build a 4 led bar graph which can be driven by Sonic Pi. It also uses components from RasPiO’s Experimenter’s Kit. The article contains full constructional details with links to the python program, and videos showing the construction and use of the project.

Read the article here

McRoboFace project to singalong with Sonic Pi

IMG_4773

Recently I was sent a pre-production version of 4Tronix McRoboFace, which is a small face whose features light up with 17 Neopixel leds. It is ideally suited as a companion to their Picon Zero controller board, which already has software in its library to accommodate it. I experimented with the item, and the result was a project to produce a talking/singing face, which could respond to an audio input either fed from a microphone, or internally from a raspberry pi running Sonic Pi.

An article here gives full constructional details and links to the software used.

4Tronix hope to launch a kickstarter project for the McRoboFace soon. If you support it, this will give you a nice project with which to use it.

video link to the project in action, explaining itself!

PS3 controlled Edukit robot

ps3robot

Edukit 3 robot kit, revamped with 4Tronix picon zero board and python program to control it with a ps3 wireless controller. The pizero has the dongle for the ps3 controller in its single usb port, and is arranged to boot automatically into the python program driving the robot. A red led lights when the system is ready for action. The left hand joystick is sensed and used to control the motor speed and direction. A button on the controller is sensed to initiate shutdown when finished, so the whole process is automatic and doesn’t require any keyboard, mouse or screen. software is availabe for download at:
https://gist.github.com/rbnpi/ee3b60f200a4ef9b927d2faa0241f7b0

video of the robot in operation is here