User:Treutwein/sandbox

OSTree saved from OSTree
OSTree is an upgrade system for Linux-based operating systems that performs atomic upgrades of complete filesystem trees. It is not a package system; rather, it is intended to complement them. A primary model is composing packages on a server, and then replicating them to clients.The underlying architecture might be summarized as "git for operating system binaries". It operates in userspace, and it works on top of any Linux filesystem. At its core is a git-like content-addressed object store, and layered on top of that is the bootloader configuration, the management of /etc, and other functions to perform an upgrade beyond just replicating files.

OSTree is a system for versioning updates of Linux-based operating systems. It can be considered as "git for operating system binaries".

It is used by endless OS, Flatpak, Fedora (operating system), CentOS, Atomic Host, and the GNOME project for continuous delivery.

Building Free Pascal (Ultibo Edition)
Assuming you have a working FPC 3.0.0 installation as discussed above, you can now proceed with the first stage of the process which is to build a Raspbian native version of the Ultibo edition of FPC.

These instructions assume that FPC 3.0.0 from GetLazarus was installed to:

/home/pi/Development/FreePascal/fpc/bin

You should now download the sources of the FPC Ultibo edition from GitHub and unzip the contents to the folder:

/home/pi/ultibo/core

After extracting the files rename the folder  to   so the contents of the zip will be in

Now download the source of Ultibo core from GitHub and extract the  folder to the location:

/home/pi/ultibo/core/fpc/source/rtl

Once this is done, open a terminal window and change to the folder containing the Ultibo sources:

cd /home/pi/ultibo/core/fpc/source

Add the path to FPC 3.0.0 to the environment:

export PATH=/home/pi/Development/FreePascal/fpc/bin:$PATH

Do the following steps in order, checking that each was completed successfully before continuing:

make distclean

make all OPT=-dFPC_ARMHF

make install OPT=-dFPC_ARMHF PREFIX=/home/pi/ultibo/core/fpc

Once those steps have completed you should now have a Raspbian native version of the FPC Ultibo edition. Copy it to the  directory as follows so we can find it later:

cp /home/pi/ultibo/core/fpc/source/compiler/ppcarm /home/pi/ultibo/core/fpc/bin/ppcarm

Run the following to check that it shows as version 3.1.1 and lists  under the supported targets.

/home/pi/ultibo/core/fpc/bin/fpc -i

Use fpcmkcfg to create our default configuration file like this:

/home/pi/ultibo/core/fpc/bin/fpcmkcfg -d basepath=$HOME/ultibo/core/fpc/lib/fpc/3.1.1 -o /home/pi/ultibo/core/fpc/bin/fpc.cfg

Installing the arm-none-eabi Toolchain
You may wonder why a toolchain is required when Raspbian runs native on the Raspberry Pi and therefore we are not cross compiling to create our Ultibo applications, the reasons are many but simply the tools included with Linux are configured for Linux specific settings which are not suitable for bare metal development, see this page for more information.

On Raspbian Jessie the arm-none-eabi tools are available as a package which can be installed like this:

sudo apt-get install -y binutils-arm-none-eabi

Once completed we can move on to building the Ultibo RTL.

Building the Ultibo RTL
The Ultibo RTL comes in 2 versions, one for ARMv6 which works on the Raspberry Pi A/B/A+/B+/Zero and another for ARMv7 which only works on Raspberry Pi 2B and 3B. These instructions allow for both to exist in different folders so you can have both versions available. If you choose not to build one or the other simply skip the relevant steps, you will need to perform this process each time you download an updated copy of the Ultibo RTL.

Ultibo RTL for ARMv7

Open a new terminal window (NOT the one you used above !!) and change to the  folder

cd /home/pi/ultibo/core/fpc/source

Export the path to our FPC 3.1.1 Ultibo edition:

export PATH=/home/pi/ultibo/core/fpc/bin:$PATH

Build the ARMv7 RTL as follows, checking that each step was successful before continuing:

make rtl_clean CROSSINSTALL=1 OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make rtl OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make rtl_install CROSSINSTALL=1 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a FPC=/home/pi/ultibo/core/fpc/bin/fpc INSTALL_PREFIX=/home/pi/ultibo/core/fpc INSTALL_UNITDIR=/home/pi/ultibo/core/fpc/units/armv7-ultibo/rtl

Packages for ARMv7

Open a new terminal or continue with the one used to build the RTL, change to the  folder and ensure the path is updated:

cd /home/pi/ultibo/core/fpc/source

export PATH=/home/pi/ultibo/core/fpc/bin:$PATH

Build the ARMv7 Packages using the following commands:

make rtl_clean CROSSINSTALL=1 OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make packages_clean CROSSINSTALL=1 OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make packages OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH -Fu/home/pi/ultibo/core/fpc/units/armv7-ultibo/rtl" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make packages_install CROSSINSTALL=1 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a FPC=/home/pi/ultibo/core/fpc/bin/fpc INSTALL_PREFIX=/home/pi/ultibo/core/fpc INSTALL_UNITDIR=/home/pi/ultibo/core/fpc/units/armv7-ultibo/packages

Ultibo RTL for ARMv6

The process for the ARMv6 RTL is very similar but there are many differences in the parameters, careful you don't use the wrong ones.

Open a new terminal window and change to the  folder

cd /home/pi/ultibo/core/fpc/source

Export the path to our FPC 3.1.1 Ultibo edition:

export PATH=/home/pi/ultibo/core/fpc/bin:$PATH

Build the ARMv6 RTL as follows, checking that each step was successful before continuing:

make rtl_clean CROSSINSTALL=1 OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make rtl OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make rtl_install CROSSINSTALL=1 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 FPC=/home/pi/ultibo/core/fpc/bin/fpc INSTALL_PREFIX=/home/pi/ultibo/core/fpc INSTALL_UNITDIR=/home/pi/ultibo/core/fpc/units/armv6-ultibo/rtl

Packages for ARMv6

Open a new terminal or continue with the one used to build the RTL, change to the  folder and ensure the path is updated:

cd /home/pi/ultibo/core/fpc/source

export PATH=/home/pi/ultibo/core/fpc/bin:$PATH

Build the ARMv6 Packages as follows:

make rtl_clean CROSSINSTALL=1 OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make packages_clean CROSSINSTALL=1 OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -OoFASTMATH" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make packages OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -OoFASTMATH -Fu/home/pi/ultibo/core/fpc/units/armv6-ultibo/rtl" FPC=/home/pi/ultibo/core/fpc/bin/fpc

make packages_install CROSSINSTALL=1 BINUTILSPREFIX=arm-none-eabi- FPCFPMAKE=/home/pi/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 FPC=/home/pi/ultibo/core/fpc/bin/fpc INSTALL_PREFIX=/home/pi/ultibo/core/fpc INSTALL_UNITDIR=/home/pi/ultibo/core/fpc/units/armv6-ultibo/packages

Creating the Configuration files
To allow switching between ARMv6 and ARMv7 the Ultibo installation includes configuration files that are passed to FPC to specify certain parameters for each model, you can easily create these for Raspbian as well like this.

Open a terminal window and change to the location where FPC Ultibo edition is installed:

cd /home/pi/ultibo/core/fpc/bin

Create a new  file:

nano rpi.cfg

And paste these lines into the file:

# # -CfVFPV2 -CIARM -OoFASTMATH -Fu/home/pi/ultibo/core/fpc/units/armv6-ultibo/rtl -Fu/home/pi/ultibo/core/fpc/units/armv6-ultibo/packages
 * 1) Raspberry Pi (A/B/A+/B+/Zero) specific config file

Save the file and do the same for the  and   files:

Contents of rpi2.cfg

# # -CfVFPV3 -CIARM -OoFASTMATH -Fu/home/pi/ultibo/core/fpc/units/armv7-ultibo/rtl -Fu/home/pi/ultibo/core/fpc/units/armv7-ultibo/packages
 * 1) Raspberry Pi 2B specific config file

Contents of rpi3.cfg

# # -CfVFPV3 -CIARM -OoFASTMATH -Fu/home/pi/ultibo/core/fpc/units/armv7-ultibo/rtl -Fu/home/pi/ultibo/core/fpc/units/armv7-ultibo/packages
 * 1) Raspberry Pi 3B specific config file

Compiling an Application
Compiling an application from the command line is quite simple, you just need to remember some extra parameters because of the different environment. To compile something like the Hello World example open a terminal window, change to the folder where the application is located and add the path to FPC 3.1.1 Ultibo edition like this:

export PATH=/home/pi/ultibo/core/fpc/bin:$PATH

Then compile the application using this command:

fpc -B -Tultibo -Parm -CpARMV7A -WpRPI2B -XParm-none-eabi- @/home/pi/ultibo/core/fpc/bin/rpi2.cfg -O2 HelloWorld.lpr

This example is for a Raspberry Pi 2B but can easily be adjusted for any other model by changing the appropriate parameters, so to compile for Raspberry Pi B instead try this:

fpc -B -Tultibo -Parm -CpARMV6 -WpRPIB -XParm-none-eabi- @/home/pi/ultibo/core/fpc/bin/rpi.cfg -O2 HelloWorld.lpr

Or for a Raspberry Pi 3B use this one:

fpc -B -Tultibo -Parm -CpARMV7A -WpRPI3B -XParm-none-eabi- @/home/pi/ultibo/core/fpc/bin/rpi3.cfg -O2 HelloWorld.lpr