Raspberry Pi Zero as a USB virtual network gadget

An extremely simple new way to setup Raspberry Pi Zero as a USB virtual network gadget, allowing SSH, SFTP, VNC etc over a single USB cable. All without need of a keyboard, mouse, screen etc to setup!
To make it clear though, this can only work with the Raspberry Pi Zero.

Part 1 and part 2 blog here!

Oberon version for the Raspberry Pi

(Found in the Oberon mailing list today!)

Josef Tampl has announced the availability of an Oberon version for the Raspberry Pi running 32-bit Raspbian.
You can download it from http://www.software-templ.com/shareware.html.

This version of Oberon is based on ofront 1.4, an Oberon-2 to C translator.
It comes with a set of command line tools and an integrated version based
on the Oberon V4 system.
Oberon modules can be compiled and linked into shared object libraries(.so) and loaded and unloaded
from within the Oberon system.

A complete Oberon interface for the popular ‘Wiring’ library (libwiring.so) is included.
This library can be used for convenient access to the Raspberry’s I/O hardware.

You may also want to download manual pages, additional fonts, and platform independent Oberon V4 source and resource files.
The Ofront source files as well as a makefile are hosted on Github.

Clean up Raspbian

Find out what takes up room

dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n

Obvious candidates:

Libre Office


Another Raspi.tv kickstarter!


RasPiO Pro Hat is a small Raspberry Pi add-on which…

  • protects the Pi’s ports in case you make a wiring error
  • arranges the Pi’s ports in numerical order to make tinkering easier
  • works “out of the box” with GPIO Zero – the new easy-to-use Python library included in Raspbian
  • requires no soldering or assembly
  • requires no software installation
  • includes a 170pt mini-breadboard to build your circuits on
  • gives you direct access to the ports if you need it
  • requires no additional resistors for use with LEDS
  • will have RasPi.TV-style tutorial experiments suitable for beginners and experts alike



Network scanning: find your RPi

When using a Raspberry Pi in your network it is very convenient to let it use DHCP to assign IP addresses, Setting up with fixed IP can be a pain to configure and be sure to use an address out of the IP range used by your DHCP router!
Nearly all DHCP servers try to assign the same IP address to a network device, by remembering its Mac address. And since Bonjour is running on current Raspbians, you can access the RPi with <RPI name>.local

But when you run headless, and have no clue, easy to use tools are available:

On an Raspberry/Linux machine use nmap.

$ sudo apt-get install nmap

Scan your network
sudo nmap -sP

On a Windows system: Install Advanced IP Scanner, startup and press the scan button

On Android install from the Playstore ezNEtscan and press the Scan button.



Low level graphics Raspberry Pi: framebuffer


Basic, get screen info


PArt 2 goes into actually drawing


The details of the mapped display memory

and so on


All code here: https://github.com/rst-/raspberry-compote


Ralink wireless device MediaTek MT7601


I bought on ebay a year ago several wireless adapters with a large external antenna. Good range, recognized by wheezy and jessie Raspbian.
The lsusb command showed me those were RT5370 IC based Ralink devices, with driver support in the 3.x and 4.x kernel.

Witht he growing amount of Raspberry Pi’s here I thought it was a good idea to buy some more, and the Ebay adverts showed the identical looking device:

Mini 150Mbps 802.11N/G/B USB 2.0 WiFi Antenna Wireless Network LAN Card Adapter, about Euro 3

After several weeks they arrived, and the first test in the Windows PC’s showed a working wireless interface. So far so good.

In a Raspberry Pi alas, no WLAN0 device showed up. Time to troubleshoot!

lsusb showed there was a new USB device:

$ lsusb

Bus 001 Device 005: ID 148f:7601 Ralink Technology, Corp.

$ lsmod

<no device driver shown for this device>

The older working Ralink adapter had a different usb output:

$  lsusb

Bus 001 Device 006: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

$ lsmod

rt2800usb 17716 0

So we have a new device, it is the MediaTek MT7601. Quick search with the ID 148F:7601 revealed this is indeed a new device. And it is supported with firmware in Linux kernel 4.2, the Raspbian kernel is still 4.1 and is not so far yet.

But a helpful post in the raspberrypi.org forums by MrEngman pointed me to the (now deprecated for kernel 4.2) to this command to load the driver:

$ sudo wget https://github.com/porjo/mt7601u/blob/master/src/mcu/bin/MT7601.bin -O /lib/firmware/mt7601u.bin

$ reboot

$ lsmod


mt7601u 73787 0


and all was well again.

Note this is tested on jessie

$ uname -a
Linux raspberrypwhplus 4.1.15-v7+ #830 SMP Tue Dec 15 17:02:45 GMT 2015 armv7l GNU/Linux

If you want to rebuild the driver, from the Mediatek driver source without debug info, follow this recipe.



Raspberry Pi Zero Case

Inevitable, some weeks after the limited appearance of the Zero, cases are appearing on the market, First in the UK, where some had prerelease information and could grab the first profitable sales.

But now China has kicked in:

DX.com Euro 3.32 including postage.

Now some weeks to wait 😉

And it looks good! Even cheaper versions on AliExpress with the same quality. Recommended!



The VAP11G-300 is a unique device with a fixed ethernet to wireless bridge that helps in situations where:

  • You want a fixed ethernet connection, but none is available at the location.
  • Wireless is available, but the device either has no wireless capabilities.
  • A wireless capability can be added but to configure it, a working network connection is required.
  • USB ports are scarse.
  • Wireless USB adapters are too powerhungry.
  • You want two wireless devices to communicate without a wireless router available.

Read More


Freepascal and Lazarus installation on RPi

freepascal logo
A page describing how to get the latest Freepascal and Lazarus development systems on the Raspberry Pi in optimal format, targeted at ARMV6 (all Raspberri Pi’s) and ARMV7 (RPi 2).

Updated March  2020, for current FPC/Lazarus/Raspbian versions.

The easy method, not recommended

sudo su
apt-get install fp-compiler
apt-get install lazarus

On Raspbian wheezy you get Freepascal 2.6.0 and Lazarus version dating from 2012. Working but not quite bleeding edge. Perfect for a first session!

On Raspbian jessie you get more recent versions: Freepascal 2.6.4 and Lazarus 1.2.4.
Note that for me Lazarus did not show up in the Programming menu on the desktop on jessie, but easy to add yourself with the menu editor (Lazarus is located somewhere in /usr/local/). Freepascal is missing the character based fp IDE alas. And the programs compiled on the Raspberry Pi 2 B crashed on the older Raspberry Pi for me. So far so good for most of us. But not what I wanted. I have both Raspberry Pi’s Version 1 and the newer Version 2 systems. All systems run Lazarus on the desktop, but the older version 1 systems are running Lazarus quite slow due to the ARM V6 CPU and lack of memory. But the resulting programs are running fast enough, we have a real compiler here!

On Buster you get even more recent versions. Alas the package maintainers did a not perfect job, much is not working …

Install pre-compiled .deb’s

Lazarus forum post for discussion and .to download deb packages using the following Wiki article.

You may have to install some dependencies libgtk2.0-dev libgpm-dev libncurses-dev

sudo apt install libgtk2.0-dev libgpm-dev libncurses-dev

sudo dpkg -i fpc-laz_3.0.4_armhf.deb
sudo dpkg -i fpc-src_3.0.4_armhf.deb 
sudo dpkg -i lazarus-project_2.0.6-0_armhf.deb

To add packages: increase swap file to 1000 MB (see below)!

Wiki article to get fpc3.04 and Lazarus 2.06  deb packages on Raspbian Buster RPI 4 as build machine

You may get a few linker messages, like crtbegin.0 missing. Harmless but annoying.

Get rid of them with

sudo apt-get install libgcc-8-dev

and add this line to /etc/fpc.cfg

# path to the gcclib

Now the -T warning is also harmless, bug in LD and the trunk version of FPC seems to have a solution. .

Install from source

Tutorial: Installation of Lazarus to Raspberry Pi 3 + 4
written by Linkat Version: 16.08.2019

Using 2019-07-10-raspbian-buster

1. Download:
(or use the newer releases)

2. Install the libs:
sudo apt-get install libgtk2.0-dev libghc-x11-dev -y

3. Unpack fpc-3.0.4.arm-linux-eabihf-raspberry.tar,
fpc-3.0.4.source.zip and lazarus-2.0.4.zip. (PCmanFM “Extract Here”)

4. Move the extracted folders as root:
sudo mv fpc-3.0.4.arm-linux/ /usr/local
sudo mv fpc-3.0.4/ /usr/share
sudo mv lazarus/ /usr/lib

5. Installation of fpc
Start the terminal and cd /usr/local/fpc-3.0.4.arm-linux
“sudo ./install.sh”

Answer the questions:
Install prefix -> /usr
the next 4 questions by “Yes”
Now the Free-Pascal-Compiler should be installed.

6. Now cd /usr/lib/lazarus
with “sudo make clean bigide” you can build the Lazarus-IDE.
(this needs abt. 10 min)
then you can start with “./startlazarus”

Older methods, outdated, may still be of value due to optimized RP1 1 Zero etc. compiler.

The easy method

precompiled versions at getlazarus.org! This will give you the latest (as of January 2016 this will be FPC 3.0.0 and Lazarus 1.7) precompiled versions, which can be used alongside system wide installations The builds are for ARMV6, so executables will run on all Raspberry Pi’s. Just a simple script to download and execute! Note that this is not the bigide, you may have to compile more packages.

The script delivers an icon for Lazarus on the desktop. The Freepascal terminal icon does not work, but the underlying script does, ~/Development/FreePascal/fpc/bin/fpc-terminal.sh in a console to make fpc available.
Note the (harmless) crtbegin.o warning in Lazarus, a solution is described later in this article.

Using the Debian method

Install from source

What I really want is:

  • compile and test on the Raspberry Pi 2 and 3 and enjoy the speed.
  • Run on all Raspberry Pi models, so limited to ARMV6.
  • Run on older wheezy and modern jessie Raspbian.
  • The RPi 2, 3 have four ARM V7 cores, Freepascal and Lazarus will benefit in speed from this architecture if compiled for ARMV7.

So I set out to build images of Raspbian with more current versions of Freepascal and Lazarus on both latest Raspbian jessie and wheezy.

Some opening remarks:

  • Newer versions of FPC and Lazarus appear regular,  you may substitute those newer versions in the recipes.
  • Recipe for ARM V6 RPi versions 1 and 2 Model A, A+, B, B+, 2B, Zero
  • Recipe for ARM V7  version 2, 3 Model B

Building any version of Freepascal from source requires a seed compiler. For the current version (july 2016) this is version 3.0. This is available as binary for ARM,  a generic version, from getlazarus.org, not from the official distributions.

The trick in building Lazarus  is making sure the Freepascal compiler is targeted for the same architecture, so first we have to build a Freepascal compiler for the same architecture.

The following steps are my steps, after a lot of reading and experiments, to get fpc and Lazarus in folders of user pi.
On the bottom of this pageyou will find a recipe by rvk, nearly identical but leading to a system wide installation in /usr/local.

Setup a fresh system

First a fresh system, get the latest jessie and/or wheezy from raspberrypi.org. These are the steps I perform for a new system. I do most work from my desktop PCere, including remote access via SSH and xRDP to the Pi’s.

Image SD card (Win32DiskImager), 16GB minimal. 8 GB may work, but I often get problems with installing Lazarus due to out of disk space.

Boot and login (user pi, password raspberry) locally

With raspi-config at least change

  •  Expand file system
  •  Boot into commandline (desktop is in the way during the build!)
  • Change password
  • Overclock (medium for older, high for RPi 2B, n.a. for RPi 3)
  • Advanced options:
  •  enable ssh
  •  memory split to 16 MB, you may change that back later for graphics work
  •  change hostname and reboot

A fixed Ethernet connection is recommended. Wifi will work,  see my other pages how to install/configure that.

Get the IP address assigned to the Pi.



and note the IP address assigned to the RPi. Now you can use PuTTY or other SSH client from your desktop to access the command line of your Pi or continue on the RPi itself. The advantage of working via SSH is obvious, you can copy for this webpage and paste (right mouse click) into PuTTY.

Make some room,

Software I do not intend to use at all and take up a lot of disk space

sudo su
apt-get -y remove --purge oracle-java8-jdk openjdk-7-jre oracle-java7-jdk openjdk-8-jre
apt-get -y purge libreoffice*
apt-get -y autoremove 
apt-get -y clean 
df -h 

Get an update system and get subversion, unzip and libraries for Lazarus

apt-get update
apt-get upgrade
apt-get install -y subversion unzip
apt-get install -y libgtk2.0-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libatk1.0-dev libghc-x11-dev
apt-get install -y libx11-dev libgdk-pixbuf2.0-dev  gir1.2-coglpango-1.0  xorg-dev 

Increase swapfile to prevent ‘out of memory’ during compilation

change the line in dphys-swapfile the size from 100 to 1000 and check it is 1000M now. Remember to cut that back to the default after the builds!
nano /etc/dphys-swapfile
/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start
ls -lh /var
exit (from su)

Build Freepascal

July 2016: this will be trunk FPC 3.1.1. Substitute if newer.

Get seed compiler fpc 3.0. installed  (from http://www.getlazarus.org/setup/minimal/), must be run in user mode, so leave SU. On current Raspbian (March 2020)  apt-get update fpc

mkdir /home/pi/Development
cd /home/pi/Development
wget http://cache.getlazarus.org/archives/fpc-3.0.0.raspberry-min.tar.gz
tar xvf fpc-3.0.0.raspberry-min.tar.gz
chmod +X setup.sh
rm /home/pi/Development/fpc-3.0.0.raspberry-min.tar.gz
rm /home/pi/Development/fpc-3.0.0.tar.gz

Do not install/start this seed compiler, we will use it only to compile fpc trunk.

For Lazarus 1,8 you will need FPC 3.04

From the forum by RvK:

Question is, is there any 3.0.4 version fpc minimal compiler available for Raspberry Pi platform?

 No, there is not. (at least not officially)

There is also no bootstrap fpc version 3.0.4. For some reason they refused to make one. (not sure of what the exact reason is again)

You can “just” download FPC 3.0.4 and use ppcarm from it. (It’s a 52MB download just to use ppcarm :( )
You don’t need to install this version. Just extract it all and use it with the PP option:

make all install OPT=$OPTIONS PREFIX=$BASE/fpc PP=$BASE/compiler3/lib/fpc/3.0.4/ppcarm
(where $BASE/compiler3 is where I unpacked the tar and $BASE is where I want the installation of fpc and Lazarus)

Get fpc 3.0 sources (you might check http://svn.freepascal.org/svn/fpc trunk for the latest)

md /home/pi/fpc-3.1 
cd /home/pi/fpc-3.1 
svn co http://svn.freepascal.org/svn/fpc/tags/release_3_0_0_rc2/ source 
cd source 


make clean all install OPT=-dFPC_ARMHF INSTALL_PREFIX=/home/pi/fpc-3.1 PP=/home/pi/Development/fpc-3.0.0/bin/ppcarm 


make clean all install OPT="-dFPC_ARMHF -CpARMV6 -OpARMV6" INSTALL_PREFIX=/home/pi/fpc-3.1 PP=/home/pi/Development/fpc-3.0.0/bin/ppcarm
rm -f "/home/pi/fpc-3.1bin/ppcarm"
ln -sf "/home/pi/fpc-3.1/lib/fpc/3.1.1/ppcarm" "/home/pi/fpc-3.1/bin/ppcarm"
rm -f ln /home/pi/fpc-3.1/share/fpcsrc
ln -sf /home/pi/fpc-3.1/source /home/pi/fpc-3.1/share/fpcsrc
(used to be) /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PPC_CONFIG_PATH=/home/pi/fpc-3.1/bin
(add this to the default user settings in /home/pi/.profile
cd /home/pi/fpc-3/1/bin
./fpcmkcfg -d basepath=/home/pi/fpc-3.1/lib/fpc/3.1.1/ &gt; fpc.cfg
nano /home/pi/.fppkg/config/default
change line GlobalPrefix=/home/pi/fpc-3.1
copy fpg.cfg from the bin folder  to the home directory .fpc.cfg
Add the fpc bin path to the path in the home directory, 
nano /home/pi/.profile


Get the source from svn

Check what is available at http://svn.freepascal.org/svn/lazarus

mkdir /home/pi/lazarus
cd /home/pi/lazarus
svn co http://svn.freepascal.org/svn/lazarus/trunk source
cd source 
sudo su
make all 
make bigide

make install 

Now continue with the Post build steps.

Set swapfile to default

nano /etc/dphys-swapfile
/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start
ls -lh /var

change back from 1000 to 100 and check its 100M now.

Use raspi-config to set the memory split back to 64 or higher, depending on your usage.

Fixing the GCC Library path

Locate crtbegin.o using (jessie june 2016)

sudo find / -name crtbegin.o

For jessie may 2016 it is in /usr/lib/gcc/arm-linux-gnueabihf/4.9

nano /home/pi/fpc-3.1/lib/fpc/3.1.1/fpc.cfg

Change the line

# path to the gcclib


# path to the gcclib

Copy the fpc.cfg also to /pi/home.fpc.cfg to be sure.

Start Lazarus

You can start Lazarus from the desktop


With jessie the Lazarus entry did not appear in the menu programming. Add this yourself with the Menu editor, browse the computer to find the startlazarus executable , the desktop icon is there also in the folders.

Lazarus asks the first time run where the fpc sources are. I did not perform ‘make sourcefiles’ so this will do:


Now you are ready to run!

Resources from which I learned how to write the steps above! Thank you!

Scripted steps by rvk

Found in http://forum.lazarus.freepascal.org/index.php?topic=33254.msg215426#msg215426
Leads to fpc and Lazarus system wide in /usr/local

# ======================================================
# Based on clean 2016-05-27-raspbian-jessie.img
# Total install time: 38 minutes (from complete scratch)
# by rvk (v.1.1, 2016-07-08)
# ======================================================

# ======================================================
# first some essentials (5.5 minutes)
# ======================================================
sudo -i
apt-get update
apt-get upgrade -y
apt-get autoremove
apt-get autoclean
# ======================================================
# install remote descktop serveer for rdp session win10
# only neede is headless RPI (1 minute)
# ======================================================
# https://www.maketecheasier.com/enabling-remote-desktop-access-on-raspberry-pi/
sudo apt-get -y install xrdp
sudo nano /etc/xrdp/xrdp.ini
bitmap_compression: no   # &lt;-- change this line
# ======================================================
# some other essentials (2 minutes)
# ======================================================
sudo apt-get -y install build-essential p7zip-full subversion
sudo apt-get -y install libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev lpango-1.0 libpangox-1.0-dev xorg-dev libatk1.0-dev libgtk2.0-dev

# ======================================================
# we NEED to extend the swapfile (1 minute)
# ======================================================
sudo nano /etc/dphys-swapfile
CONF_SWAPSIZE=512   # &lt;-- change this line
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

# ======================================================
# if you're not on raspbian-jessie this could work too
# ======================================================
# dd if=/dev/zero of=/path/to/swapfile bs=1M count=512 # For 512MB swap file
# mkswap /path/to/swapfile
# swapon /path/to/swapfile

# ======================================================
# install fpc and lazarus trunk (total 28.5 minutes)
# ======================================================
sudo -i

# ------------------------------------------------------
# first fpc
# ------------------------------------------------------
mkdir /usr/local/fpc
cd /usr/local/fpc

# ------------------------------------------------------
# We need a bootstrap compiler fpc 3.0.0 (2.5 minutes)
# There is NONE AVAILABLE so we need to download complete
# fpc-3.0.0.arm-linux-raspberry1wq.tar
# ------------------------------------------------------
wget ftp://ftp.freepascal.org/pub/fpc/dist/3.0.0/arm-linux/fpc-3.0.0.arm-linux-raspberry1wq.tar
tar xvf fpc-3.0.0.arm-linux-raspberry1wq.tar
cd fpc-3.0.0.arm-linux
tar xvf binary.arm-linux.tar
tar zxvf base.arm-linux.tar.gz
cd ..

# ------------------------------------------------------
# checkout fpc trunk (3 minutes)
# ------------------------------------------------------
svn co http://svn.freepascal.org/svn/fpc/trunk trunk
svn export --force trunk trunktmp
cd trunktmp

# ------------------------------------------------------
# compile fpc trunk (11 minutes)
# ------------------------------------------------------
make all OPT="-dFPC_ARMHF" PP=/usr/local/fpc/fpc-3.0.0.arm-linux/lib/fpc/3.0.0/ppcarm

# ------------------------------------------------------
# install fpc trunk (2 minutes)
# ------------------------------------------------------
make install OPT="-dFPC_ARMHF" PREFIX=/usr/local PP=/usr/local/fpc/trunktmp/compiler/ppcarm
rm /usr/local/bin/ppcarm
rm /usr/local/bin/sameplecfg
ln -sf /usr/local/lib/fpc/3.1.1/ppcarm /usr/local/bin/ppcarm
ln -sf /usr/local/lib/fpc/3.1.1/samplecfg /usr/local/bin/samplecfg
make install sourceinstall OPT="-dFPC_ARMHF" PREFIX=/usr/local
rm /usr/share/fpcsrc
ln -sf /usr/local/share/src/fpc-3.1.1/fpc /usr/share/fpcsrc

# /usr/local/bin/fpcmkcfg -d basepath=/usr/local/lib/fpc/3.1.1 -o /usr/local/bin/fpc.cfg
# this doesn't seem to work correctly ???

samplecfg /usr/local/lib/fpc/3.1.1 /etc
# Running on linux
# Write permission in /etc.
# Writing sample configuration file to /etc/fpc.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.ini
# Writing sample configuration file to /etc/fppkg.cfg
# Writing sample configuration file to /etc/fppkg/default

# ------------------------------------------------------
# then Lazarus
# ------------------------------------------------------
mkdir /usr/local/lazarus
cd /usr/local/lazarus

# ------------------------------------------------------
# checkout lazarus trunk (1.5 minutes)
# ------------------------------------------------------
svn co http://svn.freepascal.org/svn/lazarus/trunk trunk
svn export --force trunk trunktmp
cd trunktmp

# ------------------------------------------------------
# compile lazarus trunk  (6.5 minutes)
# ------------------------------------------------------
make all OPT="-dFPC_ARMHF"

# ------------------------------------------------------
# install lazarus trunk  (2 minutes)
# ------------------------------------------------------
make install OPT="-dFPC_ARMHF" PREFIX=/usr/local

# ------------------------------------------------------
# remove menu-cache to make Lazarus visible in menu
# ------------------------------------------------------
exit  # from sudo
killall lxpanel
find ~/.cache/menus -name '*' -type f -print0 | xargs -0 rm
exit  # from pi

# ------------------------------------------------------
# connect on Windows via Remote Desktop Connecton (mstsc.exe)
# user pi password rapberry
# Menu &gt; Programming &gt; Lazarus
# create small test-project and run
# ------------------------------------------------------

# ======================================================
# note: recompiling lazarus as use pi
# will create a working copy under ~/.lazarus/bin
# ======================================================