Changes

Jump to navigation Jump to search
Added cross compiling instructions for Pi3 and Pi4
Line 4: Line 4:  
<!-- # development related information                          # -->
 
<!-- # development related information                          # -->
 
<!-- ############################################################ -->
 
<!-- ############################################################ -->
[[Category:Development]]
+
[[Category:Software]]
 +
{{Infobox PTTLink
 +
| image = Raspberry-Pi-3-B.webp
 +
| caption = Example PTTLink Node
 +
| category = Development
 +
}}
 +
{{ Note|'''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.
 
Welcome to the Development section for the AllStarLink/PTTLink system.
    
= Compiling =
 
= Compiling =
 
Information related to compiling app_rpt and other various software.
 
Information related to compiling app_rpt and other various software.
== Cross compiling ==
+
 
 +
*[[Compiling]] - Building PTTLink from source
 +
 
 +
= 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.
 
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.
   −
=== Raspberry PI 3 ===
+
== 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
 +
<syntaxhighlight lang="bash">
 +
mkdir ~/Pi3-Kernel && cd ~/Pi3-Kernel
 +
</syntaxhighlight>
 +
 
 +
*Clone the Raspbverry Pi repository and pre-built binaries (removing the pre-built 32bit Kernel)
 +
<syntaxhighlight lang="bash">
 +
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
 +
</syntaxhighlight>
 +
 
 +
*Load stock Raspbery Pi 3 configuration
 +
<syntaxhighlight lang="bash">
 +
cd linux
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcmrpi3_defconfig
 +
</syntaxhighlight>
 +
 
 +
*Update config using nconfig (if required.  Skip if using stock config)
 +
<syntaxhighlight lang="bash">
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- nconfig
 +
</syntaxhighlight>
 +
 
 +
*Build Kernel with optimizations for the Pi 3 Arm Cortex A53 CPU
 +
<syntaxhighlight lang="bash">
 +
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 ..
 +
</syntaxhighlight>
 +
 
 +
*Copy new Kernel from build machine and cleanup build folder.
 +
Note: we are copying the files to a network share mounted under /mnt/pi3dev
 +
<syntaxhighlight lang="bash">
 +
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
 +
</syntaxhighlight>
 +
 
 +
=== Update Raspberry Pi 3 ===
 +
==== Startup configuration ====
 +
*Create cmdline.txt and config.txt to boot (as required).  Keep a copy in home directory for now
 +
<syntaxhighlight lang="text">
 +
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
 +
</syntaxhighlight>
 +
 
 +
==== Kernel installation ====
 +
*Remove old Kernel and install the one we compiled from our network share (you'll need to mount it)
 +
<syntaxhighlight lang="bash">
 +
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
 +
</syntaxhighlight>
 +
 
 
=== Raspberry PI 4 ===
 
=== 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
 +
<syntaxhighlight lang="bash">
 +
mkdir ~/Pi4-Kernel && cd ~/Pi4-Kernel
 +
</syntaxhighlight>
 +
 +
*Clone the Raspbverry Pi repository and pre-built binaries (removing the pre-built 32bit Kernel)
 +
<syntaxhighlight lang="bash">
 +
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
 +
</syntaxhighlight>
 +
 +
*Load stock Raspbery Pi 4 configuration
 +
<syntaxhighlight lang="bash">
 +
cd linux
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig
 +
</syntaxhighlight>
 +
 +
*Update config using nconfig (if required.  Skip if using stock config)
 +
<syntaxhighlight lang="bash">
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- nconfig
 +
</syntaxhighlight>
 +
 +
*Build Kernel with optimizations for the Pi 4 Arm Cortex A72 CPU
 +
<syntaxhighlight lang="bash">
 +
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 ..
 +
</syntaxhighlight>
 +
 +
*Copy new Kernel from build machine and cleanup build folder.
 +
Note: we are copying the files to a network share mounted under /mnt/pi4dev
 +
<syntaxhighlight lang="bash">
 +
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
 +
</syntaxhighlight>
 +
 +
=== Update Raspberry Pi 4 ===
 +
==== Startup configuration ====
 +
*Create cmdline.txt and config.txt to boot (as required).  Keep a copy in home directory for now
 +
<syntaxhighlight lang="text">
 +
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
 +
</syntaxhighlight>
 +
 +
==== Kernel installation ====
 +
*Remove old Kernel and install the one we compiled from our network share (you'll need to mount it)
 +
<syntaxhighlight lang="bash">
 +
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
 +
</syntaxhighlight>

Navigation menu