Development

From "PTTLink Wiki"
Jump to navigation Jump to search
Development
Raspberry-Pi-3-B.webp
Example PTTLink Node
This document is a work in progress and is still being updated by the author.

Welcome to the Development section for the AllStarLink/PTTLink system.

Compiling

Information related to compiling app_rpt and other various software.

Cross compiling

Compiling on the Raspberry PI is both extremely slow and an exercise in pain. Thankfully there are ways to cross compile the software using a standard desktop computer with the Raspberry PI as the target.

Installing cross compiling toolchain

Linaro has a recent version of the GCC 4.9 compiler that can be used to cross compile binaries for the Raspberry PI.

1. Install tools:

apt install git make gcc device-tree-compiler bison flex libssl-dev libncurses-dev

2. Install latest GCC 4.9 cross compiler and associated toolset:

32 bit

wget http://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/arm-linux-gnueabihf/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz
sudo tar xf gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz -C /opt

64 bit

wget http://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/aarch64-linux-gnu/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz
sudo tar xf gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz -C /opt

Raspberry PI 3

Note: These instructions will use the 64bit Kernel for the Raspberry PI 3.

Kernel versions

  • Replace the 4.19 with the specific version of the Linux kernel you want in the git clone command below.

You will need to already have a Debian build machine setup to do this.

Configure Debian Build Machine

  • Create build directory
mkdir ~/Pi3-Kernel && cd ~/Pi3-Kernel
  • Clone the Raspbverry Pi repository and pre-built binaries (removing the pre-built 32bit Kernel)
git clone --depth=1 -b rpi-4.19.y https://github.com/raspberrypi/linux.git
svn export https://github.com/raspberrypi/firmware/trunk/boot
rm boot/kernel*
rm boot/*.dtb
rm boot/overlays/*.dtbo
  • Load stock Raspbery Pi 3 configuration
cd linux
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcmrpi3_defconfig
  • Update config using nconfig (if required. Skip if using stock config)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- nconfig
  • Build Kernel with optimizations for the Pi 3 Arm Cortex A53 CPU
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j4 \
    CXXFLAGS="-march=armv8-a+crypto+crc -mtune=cortex-a53" \
    CFLAGS="-march=armv8-a+crypto+crc -mtune=cortex-a53" \
    bindeb-pkg
cp arch/arm64/boot/Image ../boot/kernel8.img
cp arch/arm64/boot/dts/overlays/*.dtbo ../boot/overlays/
cp arch/arm64/boot/dts/broadcom/*.dtb ../boot/
cd ..
  • Copy new Kernel from build machine and cleanup build folder.

Note: we are copying the files to a network share mounted under /mnt/pi3dev

sudo cp *.deb /mnt/pi3dev/Pi3-Kernel/
sudo cp -r boot /mnt/pi3dev/Pi3-Kernel/
sudo rm ~/Pi3-Kernel/linux*
sudo rm -r ~/Pi3-Kernel/boot

Update Raspberry Pi 3

Startup configuration

  • Create cmdline.txt and config.txt to boot (as required). Keep a copy in home directory for now
echo 'dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait net.ifnames=0' > ~/cmdline.txt
echo $'kernel=kernel8.img\ngpu_mem=16\narm_64bit=1' > ~/config.txt

Kernel installation

  • Remove old Kernel and install the one we compiled from our network share (you'll need to mount it)
sudo cp /mnt/pi3dev/Pi3-Kernel/*.deb /home/pi/
cd ~/
mkdir temp && cd temp
sudo apt purge linux-headers-* linux-image-*
cd .. && rm -r temp
sudo rm -r /boot/*
sudo dpkg -i linux-headers-*.deb linux-image-*.deb linux-libc-*.deb
sudo cp -r /mnt/pi3dev/Pi3-Kernel/boot/* /boot/
sudo cp ~/cmdline.txt /boot/
sudo cp ~/config.txt /boot/
sudo reboot

Raspberry PI 4

Note: These instructions will use the 64bit Kernel for the Raspberry Pi 4.

Kernel versions

  • Replace the 4.19 with the specific version of the Linux kernel you want in the git clone command below.
  • Support for hardware with more than 3GB of RAM is only available in 4.19 and above.
    • A workaround is to add total_mem=3072 to config text when using other Kernel version with the 4GB Pi 4.
  • FKMS 3D driver fixes are only available in version 4.19 of the Kernel
    • 3D acceleration does not work and it falls back to software emulation

You will need to already have a Debian build machine setup to do this.

Configure Debian Build Machine

  • Create build directory
mkdir ~/Pi4-Kernel && cd ~/Pi4-Kernel
  • Clone the Raspbverry Pi repository and pre-built binaries (removing the pre-built 32bit Kernel)
git clone --depth=1 -b rpi-4.19.y https://github.com/raspberrypi/linux.git
svn export https://github.com/raspberrypi/firmware/trunk/boot
rm boot/kernel*
rm boot/*.dtb
rm boot/overlays/*.dtbo
  • Load stock Raspbery Pi 4 configuration
cd linux
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig
  • Update config using nconfig (if required. Skip if using stock config)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- nconfig
  • Build Kernel with optimizations for the Pi 4 Arm Cortex A72 CPU
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j4 \
    CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a72" \
    CFLAGS="-march=armv8-a+crc -mtune=cortex-a72" \
    bindeb-pkg
cp arch/arm64/boot/Image ../boot/kernel8.img
cp arch/arm64/boot/dts/overlays/*.dtbo ../boot/overlays/
cp arch/arm64/boot/dts/broadcom/*.dtb ../boot/
cd ..
  • Copy new Kernel from build machine and cleanup build folder.

Note: we are copying the files to a network share mounted under /mnt/pi4dev

sudo cp *.deb /mnt/pi4dev/Pi4-Kernel/
sudo cp -r boot /mnt/pi4dev/Pi4-Kernel/
sudo rm ~/Pi4-Kernel/linux*.deb
sudo rm -r ~/Pi4-Kernel/boot

Update Raspberry Pi 4

Startup configuration

  • Create cmdline.txt and config.txt to boot (as required). Keep a copy in home directory for now
echo 'dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait net.ifnames=0' > ~/boot/cmdline.txt
echo $'kernel=kernel8.img\ngpu_mem=512\narm_64bit=1\ndtoverlay=vc4-fkms-v3d' > ~/boot/config.txt

Kernel installation

  • Remove old Kernel and install the one we compiled from our network share (you'll need to mount it)
sudo cp /mnt/pi4dev/Pi4-Kernel/*.deb /home/pi/
cd ~/
mkdir temp && cd temp
sudo apt purge linux-headers-* linux-image-*
cd .. && rm -r temp
sudo rm -r /boot/*
sudo dpkg -i linux-headers-*.deb linux-image-*.deb linux-libc-*.deb
sudo cp -r /mnt/pi4dev/Pi4-Kernel/boot/* /boot/
sudo cp ~/boot/cmdline.txt /boot/
sudo cp ~/boot/config.txt /boot/
sudo reboot