Skip to content

Commit

Permalink
WIP: Raspberry Pi 5 support
Browse files Browse the repository at this point in the history
This commit implements a first basicly working Raspberry Pi 5 support
which is able to boot into the main RaspberryMatic system and seems to
work as expected with the following exceptions/todo:

1. No U-boot bootloader: due to no bcm2712/pi5 support in the upstream
   U-Boot sources, there is currently also no u-boot support like with
   the other rpi platforms/boards. That means, there is currently no
   possibility to boot into the recovery system, thus no way to update
   this system via standard update packages/procedures.
2. No framebuffer console: due to the missing u-boot support and also
   potentially due to the stripped down kernel configs there is
   currently no framebuffer console available for direct login via a HDMI
   connected monitor.
3. High carrier sense with RPI-RF-MOD@GPIO: Unfortunately, it
   seems that a RPI-RF-MOD rf module directly connected to the GPIO
   of a Raspberry Pi 5 does exhibit quite a high CarrierSense (> 80%)
   due to massive RF interferences. More analyses and work seems to be
   required to try to reduce this, thought.
  • Loading branch information
jens-maus committed Nov 19, 2023
1 parent fa79fa7 commit e9401bb
Show file tree
Hide file tree
Showing 27 changed files with 1,394 additions and 4 deletions.
58 changes: 58 additions & 0 deletions buildroot-external/board/rpi5/boot.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# modify bootargs, load kernel and boot it
# fallback defaults
setenv load_addr ${ramdisk_addr_r}
setenv console "tty2"
setenv loglevel "0"
setenv bootfs 1
setenv rootfs 2
setenv userfs 3
setenv gpio_button "GPIO12"
setenv kernel_img "Image"
setenv recoveryfs_initrd "recoveryfs-initrd"
setenv usbstoragequirks "174c:55aa:u,2109:0715:u,152d:0578:u,152d:0579:u,152d:1561:u,174c:0829:u,14b0:0206:u,174c:225c:u"

# output where we are booting from
itest.b ${devnum} == 0 && echo "U-boot loaded from SD"
itest.b ${devnum} == 1 && echo "U-boot loaded from eMMC"

# import environment from /boot/bootEnv.txt
if test -e ${devtype} ${devnum}:${bootfs} bootEnv.txt; then
load ${devtype} ${devnum}:${bootfs} ${load_addr} bootEnv.txt
env import -t ${load_addr} ${filesize}
fi

# test if the gpio button is 0 (pressed) or if .recoveryMode exists in userfs
# or if Image doesn't exist in the root partition
gpio input ${gpio_button}
if test $? -eq 0 -o -e ${devtype} ${devnum}:${userfs} /.recoveryMode -o ! -e ${devtype} ${devnum}:${rootfs} ${kernel_img}; then
echo "==== STARTING RECOVERY SYSTEM ===="
# load the initrd file
load ${devtype} ${devnum}:${bootfs} ${load_addr} ${recoveryfs_initrd}
setenv rootfs_str "/dev/ram0"
setenv initrd_addr_r ${load_addr}
setenv kernel_img "recoveryfs-Image"
setenv kernelfs ${bootfs}
else
echo "==== NORMAL BOOT ===="
# get partuuid of root_num
part uuid ${devtype} ${devnum}:${rootfs} partuuid
setenv rootfs_str "PARTUUID=${partuuid}"
setenv initrd_addr_r "-"
setenv kernelfs ${rootfs}
fi

# load devicetree
fdt addr ${fdt_addr}
fdt get value bootargs /chosen bootargs

# set bootargs
setenv bootargs "dwc_otg.lpm_enable=0 sdhci_bcm2708.enable_llm=0 console=${console} root=${rootfs_str} ro rootfstype=ext4 fsck.repair=yes rootwait rootdelay=5 consoleblank=120 logo.nologo quiet loglevel=${loglevel} init_on_alloc=1 init_on_free=1 slab_nomerge iomem=relaxed net.ifnames=0 usb-storage.quirks=${usbstoragequirks} ${extraargs} ${bootargs}"

# load kernel
load ${devtype} ${devnum}:${kernelfs} ${kernel_addr_r} ${kernel_img}

# boot kernel
booti ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr}

echo "Boot failed, resetting..."
reset
1 change: 1 addition & 0 deletions buildroot-external/board/rpi5/cmdline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dwc_otg.lpm_enable=0 sdhci_bcm2708.enable_llm=0 console=tty2 root=PARTUUID=deedbeef-02 ro rootfstype=ext4 fsck.repair=yes rootwait rootdelay=5 consoleblank=120 logo.nologo quiet loglevel=0 init_on_alloc=1 init_on_free=1 slab_nomerge iomem=relaxed net.ifnames=0
67 changes: 67 additions & 0 deletions buildroot-external/board/rpi5/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# enable aarch64 bit support
arm_64bit=1

# disable HDMI port on blanking
hdmi_blanking=1

# disable HDMI audio
hdmi_drive=1

# pretend hdmi is connected so that the system
# starts booting even if the system is headless
hdmi_force_hotplug=1

# make sure to use less memory for the GPU and
# all total memory available
gpu_mem=32

# Disable overscan assuming the display supports displaying the full resolution
# If the text shown on the screen disappears off the edge, comment this out
disable_overscan=1

# enable i2c and spi
dtparam=i2c_arm=on
dtparam=i2c1=on
dtparam=spi=on

# enable the UART
enable_uart=1

# switch the bluetooth UART to the miniuart
# for basic bluetooth support
dtoverlay=miniuart-bt

# for disabling bluetooth alltogether
# you can uncomment the following two lines
#dtoverlay=disable-bt
#dtparam=uart1=off

# disable the splash screen
disable_splash=1

# activating the hardware watchdog
dtparam=watchdog=on

# Uncomment to disable continous SD-card poll (for USB SSD)
#dtparam=sd_poll_once=on

# start with heartbeat on PWR led and mmc0 on ACT led
dtparam=pwr_led_trigger=timer,act_led_trigger=mmc0

# add device tree overlay for RPI-RF-MOD
dtoverlay=rpi-rf-mod

# make sure gpio12 is set as input and pull_up
gpio=12=ip,pu

# use fixed names for start.elf/fixup.dat
start_file=start.elf
fixup_file=fixup.dat

# lets u-boot take over the boot process
#kernel=u-boot.bin
kernel=Image

# user config options shoule be put in
# /boot/extraconfig.txt
include extraconfig.txt
56 changes: 56 additions & 0 deletions buildroot-external/board/rpi5/genimage.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
image boot.vfat {
vfat {
extraargs = "-n bootfs"

files = {
"VERSION",
"bcm2712-rpi-5-b.dtb",
"cmdline.txt",
"config.txt",
"rpi-firmware/overlays",
"rpi-eeprom/pieeprom.upd",
"rpi-eeprom/pieeprom.sig",
"u-boot.bin",
"recoveryfs-initrd",
"recoveryfs-Image",
"boot.scr",
"Image"
}

file fixup.dat {
image = "rpi-firmware/fixup4.dat"
}

file start.elf {
image = "rpi-firmware/start4.elf"
}

file overlays/rpi-rf-mod.dtbo {
image = "rpi-rf-mod.dtbo"
}
}
size = 256M
}

image sdcard.img {
hdimage {
disk-signature = 0xDEEDBEEF
partition-table-type = "mbr"
}

partition boot {
partition-type = 0xC
bootable = "true"
image = "boot.vfat"
}

partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
}

partition userfs {
partition-type = 0x83
image = "userfs.ext4"
}
}
1 change: 1 addition & 0 deletions buildroot-external/board/rpi5/kernel-patches
23 changes: 23 additions & 0 deletions buildroot-external/board/rpi5/kernel.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# disable old framebuffer for video display to work
# CONFIG_FB_BCM2708 is not set

# disable sound
# CONFIG_SND_BCM2835 is not set

# disable video camera support
# CONFIG_VIDEO_BCM2835_UNICAM is not set

# disable touchscreen
# CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY is not set

# enable mmc support
CONFIG_MMC_BCM2835=y

# use pl011 serial as a kernel module and
# disable serial console on amba
CONFIG_SERIAL_AMBA_PL011=m
# CONFIG_SERIAL_AMBA_PL011_CONSOLE is not set

# nvme support
CONFIG_NVME_CORE=y
CONFIG_BLK_DEV_NVME=y
19 changes: 19 additions & 0 deletions buildroot-external/board/rpi5/post-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# Stop on error
set -e

# copy the kernel image to rootfs
cp -a "${BINARIES_DIR}/Image" "${TARGET_DIR}/"

# create VERSION file
echo "VERSION=${PRODUCT_VERSION}" >"${TARGET_DIR}/VERSION"
echo "PRODUCT=${PRODUCT}" >>"${TARGET_DIR}/VERSION"
echo "PLATFORM=rpi5" >>"${TARGET_DIR}/VERSION"

# fix some permissions
[ -e "${TARGET_DIR}/etc/monitrc" ] && chmod 600 "${TARGET_DIR}/etc/monitrc"

# link VERSION in /boot on rootfs
mkdir -p "${TARGET_DIR}/boot"
ln -sf ../VERSION "${TARGET_DIR}/boot/VERSION"
28 changes: 28 additions & 0 deletions buildroot-external/board/rpi5/post-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Stop on error
set -e

BOARD_DIR="$(dirname "$0")"
BOARD_NAME="$(basename "${BOARD_DIR}")"

# Use our own cmdline.txt+config.txt
cp "${BR2_EXTERNAL_EQ3_PATH}/board/${BOARD_NAME}/cmdline.txt" "${BINARIES_DIR}/"
cp "${BR2_EXTERNAL_EQ3_PATH}/board/${BOARD_NAME}/config.txt" "${BINARIES_DIR}/"

#
# Create user filesystem
#
echo "Create user filesystem"
mkdir -p "${BUILD_DIR}/userfs"
touch "${BUILD_DIR}/userfs/.doFactoryReset"
rm -f "${BINARIES_DIR}/userfs.ext4"
"${HOST_DIR}/sbin/mkfs.ext4" -d "${BUILD_DIR}/userfs" -F -L userfs -I 256 -E lazy_itable_init=0,lazy_journal_init=0 "${BINARIES_DIR}/userfs.ext4" 3000

#
# VERSION File
#
cp "${TARGET_DIR}/boot/VERSION" "${BINARIES_DIR}"

# create *.img file using genimage
support/scripts/genimage.sh -c "${BR2_EXTERNAL_EQ3_PATH}/board/${BOARD_NAME}/genimage.cfg"
28 changes: 28 additions & 0 deletions buildroot-external/board/rpi5/post-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Stop on error
set -e

#BOARD_DIR=${1}
PRODUCT=${2}
PRODUCT_VERSION=${3}
BOARD=$(echo "${PRODUCT}" | cut -d'_' -f2-)

# change into release dir
cd ./release

# copy the *.img and create checksum
cp -a "../build-${PRODUCT}/images/sdcard.img" "./RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.img"
sha256sum "RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.img" >"RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.img.sha256"

# prepare the release *.zip
rm -f "./RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.zip"
zip --junk-paths "./RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.zip" "./RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.img" "./RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.img.sha256" ../LICENSE "./updatepkg/${PRODUCT}/EULA.de" "./updatepkg/${PRODUCT}/EULA.en"
sha256sum "RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.zip" >"RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.zip.sha256"

# create manifest file with checksum+sizes
rm -f "RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.mf"

# shellcheck disable=SC2129
echo "$(stat -c %s "./RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.img") $(cat "RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.img.sha256")" >>"RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.mf"
echo "$(stat -c %s "./RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.zip") $(cat "RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.zip.sha256")" >>"RaspberryMatic-${PRODUCT_VERSION}-${BOARD}.mf"
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
From 01b4d231cbb66ca193ba422a22d25c75d21ff8ee Mon Sep 17 00:00:00 2001
Message-Id: <01b4d231cbb66ca193ba422a22d25c75d21ff8ee.1682350496.git.stefan@agner.ch>
From: Pascal Vizeli <[email protected]>
Date: Tue, 10 Dec 2019 09:48:46 +0000
Subject: [PATCH] rpi: Use CONFIG_OF_BOARD instead of CONFIG_EMBED

Signed-off-by: Pascal Vizeli <[email protected]>
---
configs/rpi_0_w_defconfig | 2 +-
configs/rpi_2_defconfig | 2 +-
configs/rpi_3_32b_defconfig | 2 +-
configs/rpi_3_defconfig | 2 +-
configs/rpi_defconfig | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/configs/rpi_0_w_defconfig b/configs/rpi_0_w_defconfig
index baa8c37810..f20aa164e5 100644
--- a/configs/rpi_0_w_defconfig
+++ b/configs/rpi_0_w_defconfig
@@ -23,7 +23,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig
index baae6d4871..60987ad91a 100644
--- a/configs/rpi_2_defconfig
+++ b/configs/rpi_2_defconfig
@@ -24,7 +24,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_3_32b_defconfig b/configs/rpi_3_32b_defconfig
index f51f3de596..e6de8669d0 100644
--- a/configs/rpi_3_32b_defconfig
+++ b/configs/rpi_3_32b_defconfig
@@ -23,7 +23,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig
index bc1a318db4..70f4f8ed70 100644
--- a/configs/rpi_3_defconfig
+++ b/configs/rpi_3_defconfig
@@ -22,7 +22,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig
index 1d356b4b2e..6f345c790b 100644
--- a/configs/rpi_defconfig
+++ b/configs/rpi_defconfig
@@ -23,7 +23,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
--
2.40.0

Loading

0 comments on commit e9401bb

Please sign in to comment.