Posts Tagged ‘rpi’

No Comments

Running Raspberry Pi OS on a RPI Zero without SD card

Saturday, January 2nd, 2021

I’ve blogged before about how to boot a Raspberry Pi Zero over USB without an SD card, just powering it with an USB cable in the middle USB connector, and connecting at the same time.

This Christmas I tried it with a new Buster version and a trusty old Raspberry Pi Zero and following the tutorial it’s still running fine with the latest Raspberry Pi OS 2020-12-02-raspios-buster-armhf-lite.img.

Time for some improvements. Updating and upgrading was always possible, but not always successful: you could easily run into disk-space problems.

Default images are shipped/downloaded as small as possible and the default action of booting a Pi with a new image is resizing the root partition to claim all available space on the SD card.

We’re mounting over NFS and of course the resizing did not happen in our case. Luckily, otherwise your guest OS would end up with no space and the Pi would have a partition size of 1GB (or so).

But for upgrades we need more space than the default.

How to increase the image size of an mounted image over NFS?

The image I have downloaded is `2020-12-02-raspios-buster-armhf-lite.zip`, and we have to follow 4 simple steps.

Step 1: unpack it:

unzip 2020-12-02-raspios-buster-armhf-lite.zip 2020-12-02-raspios-buster-armhf-lite.img

Step 2: resize raw image:

Then use qemu-img (QEMU disk image utility) to resize the raw image.

sudo qemu-img resize 2020-12-02-raspios-buster-armhf-lite.img 3G

Here we resize it to 3G, that must be enough to install some extra programs, and download and install updates.

Step 3: set it up as loop device:

sudo losetup -P /dev/loop101 2020-12-02-raspios-buster-armhf-lite.img

These day I set it up as loop101 instead of loop0 as I did in the blogpost of 2018 to avoid conflicting loop devices. Snaps are also installed as loop devices.

Step 4: resize root partition

start gparted with the loop device to resize the root partition.

sudo gparted /dev/loop101

Normally gparted never shows loop devices, but it does when you explicitly start with a loop device.

Then simply push the slider to resize the image, and apply the changes and you’ve gained 900MB of disk-space.

More than enough to do updates and upgrades for years to come.

No Comments

Macro Photography with the Raspberry Pi HQ camera and reverse mounted lens III

Saturday, June 6th, 2020

Another try with some extra lighting, and post-processing with Darktable. See my earlier posts about photographing with the Raspberry Pi HQ Camera: part I and part II.

This time I used a special build of raspistill that offers a Field of Merit function to assist focusing. The Raspberry Pi Forum is full of helpful people and is very informative.

Fruit-fly taken with a Raspberry Pi HQ Camera and a reverse mounted Pentax 35mm lens

Fruitflies are the really minuscule flies that hang around you garbage bin, or home plants in the windowsill.

Not sure what the yellow blob is, maybe I caught the fly eating a piece of banana.

 

3 Comments

Macro Photography with the Raspberry Pi HQ camera and reversing the lens

Wednesday, June 3rd, 2020

The Raspberry Pi is a small computer, but it is a great machine for experimenting with all sorts of technology. The Raspberry Pi Foundation just introduced a new High Quality camera with changeable lenses, so let’s find out if that new camera board can be used for photographing small objects.

FruitflyRaspberry Pi HQ Camera

Fruitfly

And I’m gone a use a rather surprising but cheap technique: reversing the lens.

(more…)

3 Comments

Trying out DeepSpeech on a Raspberry Pi 4

Friday, January 3rd, 2020

Deep Speech is an open speech-to-text engine by Mozilla. Speech synthesis and Speech to text are fun to try out, and I read that it could run on a Raspberry Pi4 with ease on one core, so I decided to give it a try.

The Raspberry Pi version is using Google’s TensorFlow Lite for an implementation of Baidu’s DeepSpeech architecture.

Installing it on a Raspberry 4 Buster distribution was not straightforward. First I read instructions on the Github page and tried to download and install the git version and, but I ran into problems. It was taking ages and I ran into the famous `wheels` problem.

Failed building wheel for scipy

After tweaking and trying a few times, i gave up on the Github version and tried the instructions here, but also that was a bumpy road. But success waits in the end.

Let’s go, how to install DeepSpeech on the RPI4

Create a dev directory:

mkdir dev
cd dev

Create a Python Virtual environment.

python3 -m venv deepspeech-train-venv

Activate the virtual environment

source dev/deepspeech-train-venv/bin/activate

Create the deepspeech directory

mkdir deepspeech
cd deepspeech

Install deepspeech

pip install deepspeech

Download pre-trained English model

curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz
tar xvf deepspeech-0.6.0-models.tar.gz

Download example audio files

curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/audio-0.6.0.tar.gz
tar xvf audio-0.6.0.tar.gz

Done, run, well , eh, I tried to run the example on the instruction page

deepspeech --model deepspeech-0.6.0-models/output_graph.pbmm --lm deepspeech-0.6.0-models/lm.binary --trie deepspeech-0.6.0-models/trie --audio audio/2830-3980-0043.wav

Errors!?!  I installed a missing dependency:

sudo apt install libatlas3-base

Still errors

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

So I check if I had numpy installed

pip install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: numpy in /home/pi/dev/deepspeech-train-venv/lib/python3.7/site-packages (1.15.4)

I decided to update numpy:

pip install --upgrade numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting numpy
Using cached https://www.piwheels.org/simple/numpy/numpy-1.18.0-cp37-cp37m-linux_armv7l.whl
tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 40.8.0 which is incompatible.
Installing collected packages: numpy
Found existing installation: numpy 1.15.4
Uninstalling numpy-1.15.4:
Successfully uninstalled numpy-1.15.4
Successfully installed numpy-1.18.0

So i decided to update setuptools too:

pip install --upgrade setuptools
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/f9/d3/955738b20d3832dfa3cd3d9b07e29a8162edb480bf988332f5e6e48ca444/setuptools-44.0.0-py2.py3-none-any.whl
Installing collected packages: setuptools
Found existing installation: setuptools 40.8.0
Uninstalling setuptools-40.8.0:
Successfully uninstalled setuptools-40.8.0
Successfully installed setuptools-44.0.0

I tried to run the example on the instruction page again
# Transcribe an audio file

deepspeech --model deepspeech-0.6.0-models/output_graph.pbmm --lm deepspeech-0.6.0-models/lm.binary --trie deepspeech-0.6.0-models/trie --audio audio/2830-3980-0043.wav

Another error

Loading model from file deepspeech-0.6.0-models/output_graph.pbmm
TensorFlow: v1.14.0-21-ge77504a
DeepSpeech: v0.6.0-0-g6d43e21
ERROR: Model provided has model identifier '='+;', should be 'TFL3'

Didn’t work. I needed to change the model to `tflite`

deepspeech --model deepspeech-0.6.0-models/output_graph.tflite --lm deepspeech-0.6.0-models/lm.binary --trie deepspeech-0.6.0-models/trie --audio audio/2830-3980-0043.wav

Success in the end!

Loading model from file deepspeech-0.6.0-models/output_graph.tflite
TensorFlow: v1.14.0-21-ge77504a
DeepSpeech: v0.6.0-0-g6d43e21
INFO: Initialized TensorFlow Lite runtime.
Loaded model in 0.0019s.
Running inference.
why should one hault on the way
Inference took 4.091s for 2.735s audio file.

Then I played the audio-file:

aplay audio/4507-16021-0012.wav

Must say DeepSpeech is much smarter then me, I couldn’t understand it:
why should one hault on the way

BTW good question. No I need another engine to answer that!

Way to go, folks.

1 Comment

4 ways to connect your Raspberry Pi 4 to the internet

Wednesday, June 26th, 2019

The just introduced Raspberry Pi 4 has delivered some much wished features: faster internet/network, a gigabit Ethernet connection, and faster USB, 2 USB 3.0 ports. This will open the door to a Raspberry Pi driven NAS solution that will offer high speed in combination with the new USB3 ports.

This post is about exploring the USB OTG  (On The Go) feature of the Raspberry Pi 4. We will find out if it’s possible to power and connect a RPI4 with just a USB cable.

Ethernet is easiest way to connect internet, the second is wireless, using WiFi. The new RPI4 offers dual-band 802.11ac wireless networking. Not as fast as the gigabit Ethernet internet, but it will offer speeds like 100 Mbps, around a 100Mb Ethernet connection. That’s quite speedy too.

The third way is using Bluetooth. Like connecting your laptop to a Bluetooth hot-spot on your phone. That will be a bit slower. Will try that later.

The fourth way is using a trick we know from the smallest Raspberry Pi, the Raspberry Zero. The Raspberry Pi 4 has a USB-C power connector, but that USB-C port is also an USB OTG connector, so the Raspberry Pi can be used as a USB Gadget: the USB port can switch USB states (MASTER/SLAVE or HOST/DEVICE) and be used like a keyboard or mouse, or USB Ethernet modem.

Actually you can power and connect to a Raspberry Pi 4 with just an USB-cable. I tried it with the new Raspbian Buster and it’s working fine. I used the same Samsung cable I used for my Zero (and phone), added an 1 euro micro-USB to USB-C adapter, and it’s just working fine. It seems my laptop is offering enough power for a headless, and armless Pi.

To enable OTG networking, add this to `/boot/config.txt`:

# enable USB OTG
dtoverlay=dwc2

Then add this to `/boot/cmdline.txt` after rootwait:

modules-load=dwc2,g_ether

Reboot your Raspberry pi and convert the new wired connection to `shared` in the connection manager on your laptop (e.g. Ubuntu 18.04), and connect to your new Raspberry Pi 4.

It will have an IP like: 10.42.0.xxx.

If you have added  a empty file `ssh` to the boot sector of your SD card touch /boot/ssh, the Pi will start with SSH enabled.

So you can connect from your laptop with:

ssh pi@raspberrypi.local

For more details, see these posts Connecting to a Raspberry Pi Zero with just an USB cable (I) or Connecting to a Raspberry Pi Zero with just an USB cable (II)

I wonder if it will be possible to boot the Raspberry Pi 4 entirely over USB, without a SD card, like the RPI Zero. Not at the moment though.

37 Comments

How to run or boot Raspbian on a Raspberry Pi Zero without an SD-card.

Thursday, March 22nd, 2018

In an earlier post I explained how you can run and connect to a Raspberry Pi Zero with just an USB cable. Still the RPI Zero was using a micro SD card.

Luckily the great minds of the Raspberry Pi Foundation developed new boot modes: ethernet boot and USB Mass Storage Device (MSD) boot for the Raspberry Pi 3.

Now they came up with USBBoot, a tiny program that pushes the bootcode over the USB to the Raspberry Pi Zero (Raspberry Pi model A, Compute Module, Compute module 3 and Raspberry Pi Zero and Raspberry Pi Zero W), so it can boot without a micro SD-card.

Boot a RPI Zero from your laptop without SD card

In this post we will boot the Zero with the latest Raspbian Stretch (lite) from an common Ubuntu laptop, running 16.04LTS. It is surprisingly comfortable once you’ve set it up. And remember we’re running the Zero without any SD card, which costs are higher then a Raspberry Pi Zero. You do not need an SD card at all.

Yes, we use a standard USB cable to power,  connect, provide internet-access, an OS and storage for the Pi Zero.

So we gonna run the poor Raspberry Pi headless (=no monitor), armless (=no keyboard or mouse) and brainless (=no memorycard). And you know what? Back to the basics make the little gem shine!!

(more…)