post

Raspberrry Pi 400, first steps

First steps with the Raspberry Pi 400, first impressions
November 2, 2020. My birthday!
Early, checking twitter. Eben Upton says good morning. The Pihut responds and some tweets about children follow.
I recognize the pattern: if Eben is up this early online, it must be an announcement. And yes, there it is: the new Pi 400!
A Pi 4 in a keyboard, a homage to the home computers of the 80ties, a relief for those who worry about a naked PCB with untidy cabling in a school class, and all that value and performance for a low price!

So I gave myself a present, and ordered the Pi 400 immediately at The Pi Hut. After a week (quite fast this time for UK mail!) it arrives, a small rectangular package. Inside the Pi 400 and a power supply. I ordered the Pi 400 itself, not the package. I have enough cables, mouse etc.. And I do not want to use a SD card.

After installation and configuration, covered below, the fun starts. What a nice little machine! Reminds me of the home computers in the 80ties of previous century, which I tested and wrote so much about then. But in an modern format, with a modern and capable operating system, hardware fast enough for the most tasks, easy to integrate in my home network and systems.
Cool, compact, well protected, a mature operating system, Linux Debian nicely adapted to the Pi 400 and satisfies the needs of a regular user like me, with a Windows 10, Synology NAS and Pi’s network. You can see a lot of thought and work has gone into the design of the Pi 400 and it pays off!

Will it be my main PC? No, not really. That will be the Intel with Windows 10 power for photo and video editing, large software development, ergonomic and excellent Microsoft keyboard and mouse with three large displays,  large fast disks, lots of memory and CPU power.

Will it be my second PC? Yes, there is enough I/O and enough performance for web browsing, mail, media center, software and hardware development for the Pi with e.g.  Lazarus, for the other Pi’s here. With some cheap simple USB and SSD devices it keeps affordable and good enough.

All in all, it has found a place on my desk and in my network, it will be of real value to me!

What I cover here is:
Configuration
Installation to SSD
Audio: USB Audio and fight with Bluetooth
Camera, USB webcam
Overclocking
File Manager, access my Windows and Synology network shares
GPIO connector


Configuration
I opted for the Pi 400, US keyboard, and not the package. I have enough cables and mouses, and plan to skip the SD card completely.

Nicely packaged, online documentation only. Here is the (hard to find!)  Beginner’s Guide, 4th edition pdf download. Well written, recommended for new users. After many years working with Pi’s (since 2012) and keeping up to date with the blog and the forum, I found configuring and setting up the PI 400 quite easy.
As you can see in the photo I added to the Pi 400:
– USB hub into the USB 2 port, four USB ports for the next USB devices
– mouse (any USB mouse will do, I use the Raspberry Pi Mouse)
– USB audio adapter (a cheap one)
– USB webcam (an older simple one)
– HDMI mini to HDMI female  adapter cable to a DVI adapter to  (no HDMI on this Displayport/DVI/VGA)  IIyama monitor!.
– CAT5 Ethernet cable to the GHz network
– USB C power adapter, the official one
– USB-3 Eluteng adapter to SATA 120GB SSD disk (this Eluteng, has ASM IC, works fine)


Installation to SSD, no SD required!
I am not that fond of the SD card as system disk for a computer. Though in the real world it does work fine for most of us, it not designed for heavy computer use, wears out and is not that fast. For embedded usage it is ok, for a desktop a real larger computer hard disk is better. So for the Pi 400 I choose a SSD with an Eluteng USB 3 adapter. USB booting is now working well on the Pi 4 out of the box.

So I took the SSD to my WIndows PC, started the Raspberry PI Imager, choose the “Raspberry Pi OS (32-bit) with desktop” as OS and the SSD as “SD card” (yes, that is supported!).
Writing the image was very fast compared to imaging an SD card!

The SSD was then attached to a USB-3 port of the Pi 400, and power switched on. It took some time, be patient, not too much status messages shown, file system expanded, reboot and then the Raspberry PI OS screen appeared and the usual questions asked. Which HDMI port? It seems not to matter!
The automatic updating/upgrading took quite some time, but after another reboot, the Pi 400 was up and running. Subsequent boots are very fast compared to SD booting!
The SD card reader? Not required for the OS, free to use, with automatic mounting.


Audio, USB Audio and fight with Bluetooth
A desktop PC without audio is not done. The Pi 400 has standard audio via HDMI. Now HDMI monitors may have a loudspeaker, but not high quality.
HDMI to DVI does not support audio. Other PI’s have analog audio out, the PI 400 does not have this, and it is not a real loss, it is of mediocre quality).

 

 

So what options for audio do I have?
– a cheap and good quality USB Audio adapter. That works well, good stereo analog audio to the soundbar on my desk.
– Bluetooth audio. Connecting and pairing to my soundbar Bluetooth succeeded, VLC plays audio fine.

But Chromium refuses to play. Known bug it seems with the current version of Chromium, I read more complaints on the forum. Note that I did not install any additional Bluetooth component, PulseAudio seems to break any chance of audio. Builti-n Bluetooth support is enough (but not pleasant to work with, as on all OS’es it seems). Chromium will hopefully be repaired soon.

Update: Fixed in New Raspberry Pi OS release — December 2020

Bluetooth sound now works for all web sites I tried, youtube, radio stations.
Do the update as https://www.raspberrypi.org/blog/new-ra … mber-2020/ describes.

Camera, USB webcam

A desktop PC without a webcam is not done, So I searched in my drawers and found an older USB Webcam. Not the best quality, but it shows a normal USB webcam works fine on the Pi 400.

 

 

 

 

 

This requires an additional software install, in a terminal type:

sudo apt install fswebcam.

A simple test with a webcam testpage showed it functions fine. as shown in the photo.


Overclocking
The Pi 400 runs un 1.8GHz and stays cool with that large metal cooling plate.
Overclocking is not really necessary, but some extra is always welcome. And the Pi stays just as cool!
Stay with recommended values not violating warranty:, perform the following in a terminal

sudo nano /boot/config.txt

Change the line with arm_freq to:

arm_freq=2000

Add the line

over_voltage=6

and reboot.


File Manager, access my Windows and Synology network shares
My network is made up of many systems. My main workstation is a power Windows 10 notebook with more screens. Further I ahev many Raspberry Pi’s, ESP8266, ESP32 nodes around. Arduino and propriety media servers, Chromecast. Several security camera’s served by Synology . My main storage is made up of two Synology NAS servers

So I took a look at what the Raspberry Pi OS Filemanager offers, And I was pleasantly surprised with the current state and posiibilities!

First I unleashed the ‘hidden’ things:


Uncheck:
Display simplified user interface and menus
Check
– Filesystem root
– Devices
– Networks
– Volume and Mounts


Now when I click on Networks in the left folderview, I see part of my network, the two Synology NAS systems.

Clicking on the Synology NAS (File Sharing) gives a list of shares on this NAS server (SMB network)

Now the file manager asks for username and password (and workgroup name). It offers to remember those, but most of the time it forgets anyway.
If you make a mistake in name or password, the fields are just cleared, no error appears.

Now you see the folders in the share and can work with the files. Depending on share and user also writing, determined by the NAS admin.


When you choose the Windows Network, nothing is shown but an empty panel and in the top field the text ‘smb:///’. Change smb:/// to smb://<computername>, where <computername> is the name of a Windows PC.
In my case it is smb://asusho


The shares of the Windows PC are now shown, select one and the usual username password form is shown. Fill in a LOCAL user on the Windows PC, which has access to the share you want. The usual Windows username, an email address, does not work. Create if needed a local Windows user and grant access to the share.


If all checks out, you have now access to the share, in this case the data disk of my Windows PC asusho.


GPIO connector
The well known 40 pin GPIO connector is available, on the backside. Now that is not too handy for the many HATs available.

I expect to see some aftermarket solutions for that with cables and cases!

A short 40 pin flatcable female-female, e,g, as supplied with a T-Cobbler makes it easy to connect to a breadboard as seen in the photo.

Note that these 40pin connecters have notches on the top, which fit nicely in the Pi 400 and the T-Cobbler connector. So no mistakes in orientation may be made, as with the other Pi’s.

RPI_HAL

rpi_hal from https://github.com/rudiratlos/rpi-hal is an incredible rich and uptodate unit for Freepascal to use the I/O of the Raspberry.

From Freepascal programs all works as expected when run as root. Otherwise accessing /dev/mem is causing real problems.

The unit can be used from Lazarus also (avoid the test procedures with writeln’ 😉 ) but also require root access and setting cthreads in the program heading.

For X apps  running as root is not possible with just sudo.
Seems I found a solution here: https://wiki.archlinux.org/index.php/Running_GUI_applications_as_root

I applied method 2:

sudo nano /etc/profile

and added this line as last line

export XAUTHORITY=/home/pi/.Xauthority

Now i can do

$ sudo ./testinit (my simple test program with only the init line of rpi_hal)

and this worked without error, init succeeded.

If you want debugging the app in Lazarus, start Lazarus as root (and ignore all the warnings)

xhost +localhost
sudo /usr/bin/startlazarus

Original text from https://wiki.archlinux.org/index.php/Running_GUI_applications_as_root

Method 2: Globally in /etc/profile
Add the following line to /etc/profile:

export XAUTHORITY=/home/username/.Xauthority
This will permanently allow root to connect to a non-root user’s X server.

Or, merely specify a particular app:

XAUTHORITY=/home/username/.Xauthority appname
where appname is the name of the particular app. (e.g. kwrite

Install FPC 3.0.0 on Raspbian, Build Ultibo

By Paul Breneman:

Raspbian Lite is the only OS selected

-When reboots, login (user pi and password raspberry)
– Everytime boot up, hit the   key an extra time (as first prompt is erased)
– Enter the following lines (without bold comment text) in the terminal:

sudo apt-get update
sudo apt-get upgrade
sudo dpkg-reconfigure tzdata 
sudo apt-get install binutils-arm-none-eabi
sudo apt-get install fpc-3.0.0 --fix-missing 
fpc -i | more 
wget http://turbocontrol.com/easyultibo121517.zip
mkdir hello
unzip easyultibo121517.zip -d hello
cd hello
./uin.sh
export PATH=/home/pi/ultibo/core/fpc/bin:$PATH
fpc -i | more 
cd QEMU 
../helloqv.sh
cd ..
cd RPi
../hellob.sh
cd ..
cd RPi2
../hello2b.sh
cd ..
cd RPi3
../hello3b.sh
cd ..

Install Ultibo on Stretch

On a new build of RaspBian 2017-09-07-raspbian-stretch.zip

sudo apt-get install libgtk2.0-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libatk1.0-dev libghc-x11-dev
sudo apt-get install binutils-arm-none-eabi
sudo apt-get install gcc-arm-none-eabi
dpkg -l | wc
1403 14260 197899
Edit the CONF_SWAPSIZE value to be 1000 or greater
./ultiboinstaller.sh

On Ubutu 16.04
The following 2 cmds
cd ultibo/core
./startlazarus

post

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 0.9.30.4. 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
-Fl/usr/lib/gcc/arm-linux-gnueabihf/8

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:
fpc-3.0.4.arm-linux-eabihf-raspberry.tar
fpc-3.0.4.source.zip
lazarus-2.0.4.zip
(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.

Type

 ifconfig 

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

exit
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
./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 :( )
ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/arm-linux/fpc-3.0.4.arm-linux-eabihf-raspberry.tar
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 

ARMv7

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

ARMv6

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
export OLDPATH=$PATH
(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
export PATH=$PPC_CONFIG_PATH:$PATH
(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
PATH="$HOME/fpc-3.1/bin:$PATH"

Lazarus

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 
or 
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
/usr/lib/gcc/arm-linux-gnueabihf/4.9/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

to

# path to the gcclib
-Fl/usr/lib/gcc/arm-linux-gnueabihf/4.9

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

Start Lazarus

You can start Lazarus from the desktop

startx

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:

/home/pi/fpc3-1.1/source

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
reboot
 
# ======================================================
# 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
# ======================================================