Raspberry Pi: Added rpi5 support and removed flash-kernel dependency (#6039)
* Disable flash kernel and rearrage functions inorder they are executed * Add board config for raspberry pi 5 * Change config.txt and cmdline.txt to match official rpi version * Install Rpi related packages from Armbian repository * Remove ddk branch aka RASPI (Ubuntu) kernel * We still have unsupported releases, but for different reason * Lower kernel output at booting to meet our other builds. Default is too mouch for end user * Add more info where we import packages * Add testing targets --------- Co-authored-by: Igor <igor@armbian.com> Co-authored-by: Igor Pecovnik <igor.pecovnik@gmail.com>
This commit is contained in:
parent
ca2ecf556e
commit
1c3b7ec36c
@ -3,58 +3,5 @@ declare -g BOARD_NAME="Raspberry Pi 4"
|
||||
declare -g BOARDFAMILY="bcm2711"
|
||||
declare -g BOARD_MAINTAINER="viraniac teknoid PanderMusubi"
|
||||
declare -g KERNEL_TARGET="legacy,current,edge"
|
||||
declare -g FK__MACHINE_MODEL="Raspberry Pi 4 Model B" # flash kernel (FK) configuration
|
||||
declare -g ASOUND_STATE="asound.state.rpi"
|
||||
|
||||
# Our default paritioning system is leaving esp on. Rpi3 is the only board that have issues with this.
|
||||
# Removing the ESP flag from the boot partition should allow the image to boot on both the RPi3 and RPi4.
|
||||
pre_umount_final_image__remove_esp() {
|
||||
display_alert "Removing ESP flag from FAT partition" "rpi4 / rpi3" "info"
|
||||
run_host_command_logged parted -s "${LOOP}" set 1 esp off
|
||||
}
|
||||
|
||||
# configure stuff at the appropriate time in flash-kernel
|
||||
pre_initramfs_flash_kernel__write_raspi_config() {
|
||||
declare comment_if_debug=""
|
||||
declare not_comment_if_debug="#"
|
||||
if [[ "${RPI_DEBUG_CONSOLE}" != "yes" ]]; then
|
||||
comment_if_debug="#"
|
||||
not_comment_if_debug=""
|
||||
# for serial console, there is also 'BOOT_UART=1' in 'rpi-eeprom-config' but that is for an earlier stage.
|
||||
# look at with it rpi-eeprom-config, change with 'EDITOR=nano rpi-eeprom-config --edit'
|
||||
fi
|
||||
|
||||
cat <<- EOD > "${FIRMWARE_DIR}/config.txt"
|
||||
[pi4]
|
||||
max_framebuffers=2
|
||||
over_voltage=2
|
||||
arm_freq=1800
|
||||
|
||||
[all]
|
||||
kernel=vmlinuz
|
||||
cmdline=cmdline.txt
|
||||
initramfs initrd.img followkernel
|
||||
disable_overscan=1
|
||||
hdmi_drive=2
|
||||
arm_64bit=1
|
||||
disable_splash=1
|
||||
|
||||
# enable audio (loads snd_bcm2835)
|
||||
dtparam=audio=on
|
||||
|
||||
# bootloader logs to serial, second stage
|
||||
${not_comment_if_debug}enable_uart=1
|
||||
|
||||
# overclock. requires decent thermals. COMMENT OUT IF DON'T USE A GREAT COOLER OR HEATSINK.
|
||||
# over_voltage=6
|
||||
# arm_freq=2000
|
||||
|
||||
# uncomment to disable wifi or bt.
|
||||
#dtoverlay=disable-wifi
|
||||
${comment_if_debug}dtoverlay=disable-bt
|
||||
|
||||
# gpu and 3d stuff.
|
||||
gpu_mem=256
|
||||
dtoverlay=vc4-fkms-v3d
|
||||
EOD
|
||||
}
|
||||
declare -g KERNEL_TEST_TARGET="current,edge"
|
||||
|
||||
31
config/boards/rpi5b.conf
Normal file
31
config/boards/rpi5b.conf
Normal file
@ -0,0 +1,31 @@
|
||||
# Broadcom BCM2712 quad core 1-8Gb RAM SoC USB3 GBE USB-C WiFi/BT
|
||||
declare -g BOARD_NAME="Raspberry Pi 5"
|
||||
declare -g BOARDFAMILY="bcm2711"
|
||||
declare -g BOARD_MAINTAINER="viraniac"
|
||||
declare -g KERNEL_TARGET="current,edge"
|
||||
declare -g ASOUND_STATE="asound.state.rpi"
|
||||
declare -g KERNEL_TEST_TARGET="current,edge"
|
||||
|
||||
function post_family_config__rename_linux_family() {
|
||||
display_alert "rpi5b" "Changing LINUXFAMILY" "info"
|
||||
declare -g LINUXFAMILY=bcm2712
|
||||
}
|
||||
|
||||
function armbian_kernel_config__rpi5b_16k_variant() {
|
||||
display_alert "rpi5b" "Enabling 16K page size" "info"
|
||||
kernel_config_modifying_hashes+=(
|
||||
"CONFIG_ARM64_16K_PAGES=y"
|
||||
"CONFIG_ARCH_MMAP_RND_BITS=18"
|
||||
"CONFIG_ARCH_MMAP_RND_COMPAT_BITS=11"
|
||||
)
|
||||
|
||||
# As kernel config is shared between two variants, override the settings
|
||||
# but make sure not to write them back to config/kernel directory
|
||||
if [[ -f .config ]] && [[ "${KERNEL_CONFIGURE:-yes}" != "yes" ]]; then
|
||||
display_alert "Enabling 16K page size" "armbian-kernel" "debug"
|
||||
kernel_config_set_y CONFIG_ARM64_16K_PAGES
|
||||
run_host_command_logged ./scripts/config --set-val CONFIG_ARCH_MMAP_RND_BITS 18
|
||||
run_host_command_logged ./scripts/config --set-val CONFIG_ARCH_MMAP_RND_COMPAT_BITS 11
|
||||
run_kernel_make olddefconfig
|
||||
fi
|
||||
}
|
||||
@ -6,25 +6,23 @@
|
||||
# This file is a part of the Armbian Build Framework
|
||||
# https://github.com/armbian/build/
|
||||
#
|
||||
enable_extension "flash-kernel"
|
||||
declare -g LINUXFAMILY=bcm2711
|
||||
declare -g ARCH=arm64
|
||||
declare -g UEFI_FS_LABEL="RPICFG" # Windows/Mac users will see this if they mount the SD card. Configurable, but should be uppercase always
|
||||
declare -g SKIP_BOOTSPLASH="yes" # video is init-ed before us
|
||||
declare -g FK__PUBLISHED_KERNEL_VERSION="raspi" # flash kernel (FK) configuration
|
||||
declare -g FK__KERNEL_PACKAGES=""
|
||||
declare -g SKIP_ARMBIAN_REPO=no # rpi specific packages are inside armbian repository
|
||||
declare -g CPUMIN=500000
|
||||
declare -g CPUMAX=2000000
|
||||
declare -g CPUMAX=2900000
|
||||
declare -g GOVERNOR=ondemand
|
||||
declare -g INSTALL_ARMBIAN_FIRMWARE=no
|
||||
declare -g UEFISIZE=256 # in MiB. Not really UEFI, but partition layout is the same.
|
||||
declare -g BOOTSIZE=0 # No separate /boot, flash-kernel will "flash" the kernel+initrd to the firmware part.
|
||||
declare -g BOOTCONFIG=none # We are currently not using U-boot for Raspberry Pi boards
|
||||
declare -g UEFI_MOUNT_POINT="/boot/firmware" # mount uefi partition at /boot/firmware
|
||||
|
||||
case "${BRANCH}" in
|
||||
|
||||
ddk)
|
||||
declare -g RASPI_DISTRO_KERNEL=yes # This will cause board to include distro's prebuilt kernel, not from source
|
||||
;;
|
||||
|
||||
legacy)
|
||||
declare -g RASPI_DISTRO_KERNEL=no
|
||||
declare -g KERNELSOURCE='https://github.com/raspberrypi/linux'
|
||||
declare -g KERNEL_MAJOR_MINOR="5.15" # Major and minor versions of this kernel. For mainline caching.
|
||||
declare -g KERNELBRANCH="branch:rpi-5.15.y"
|
||||
@ -33,7 +31,6 @@ case "${BRANCH}" in
|
||||
;;
|
||||
|
||||
current)
|
||||
declare -g RASPI_DISTRO_KERNEL=no
|
||||
declare -g KERNELSOURCE='https://github.com/raspberrypi/linux'
|
||||
declare -g KERNEL_MAJOR_MINOR="6.1" # Major and minor versions of this kernel. For mainline caching.
|
||||
declare -g KERNELBRANCH="branch:rpi-6.1.y"
|
||||
@ -42,7 +39,6 @@ case "${BRANCH}" in
|
||||
;;
|
||||
|
||||
edge)
|
||||
declare -g RASPI_DISTRO_KERNEL=no
|
||||
declare -g EXTRAWIFI="no"
|
||||
declare -g KERNELSOURCE='https://github.com/raspberrypi/linux'
|
||||
declare -g KERNEL_MAJOR_MINOR="6.7" # Major and minor versions of this kernel. For mainline caching.
|
||||
@ -52,52 +48,197 @@ case "${BRANCH}" in
|
||||
;;
|
||||
esac
|
||||
|
||||
pre_initramfs_flash_kernel__write_raspi_cmdline() {
|
||||
if [[ "${RPI_DEBUG_CONSOLE}" == "yes" ]]; then
|
||||
cat <<- EOD > "${FIRMWARE_DIR}/cmdline.txt"
|
||||
root=LABEL=${ROOT_FS_LABEL} rootfstype=ext4 rootwait fixrtc cgroup_enable=memory cgroup_memory=1 console=tty1 console=ttyAMA0 loglevel=7 splash=verbose
|
||||
EOD
|
||||
else
|
||||
cat <<- EOD > "${FIRMWARE_DIR}/cmdline.txt"
|
||||
root=LABEL=${ROOT_FS_LABEL} rootfstype=ext4 rootwait fixrtc cgroup_enable=memory cgroup_memory=1 console=tty1 logo.nologo loglevel=1 splash=verbose
|
||||
EOD
|
||||
fi
|
||||
}
|
||||
|
||||
pre_flash_kernel__symlink_dtb_and_kernel() {
|
||||
if [[ "${RASPI_DISTRO_KERNEL}" != "yes" ]]; then # and firmware.
|
||||
display_alert "Configuring flash-kernel DB..." "bcm2711" "info"
|
||||
cat <<- EOD >> "${MOUNT}"/etc/flash-kernel/db
|
||||
# Armbian kernels don't have a 'flavour'. Ignore flavors for all rpi revisions.
|
||||
Machine: Raspberry Pi *
|
||||
Kernel-Flavors: any
|
||||
EOD
|
||||
fi
|
||||
}
|
||||
|
||||
extension_prepare_config__prepare_rpi_flash_kernel() {
|
||||
display_alert "Preparing bcm2711" "${RELEASE}, distro kernel?: ${RASPI_DISTRO_KERNEL}" "info"
|
||||
declare -g RASPI_DISTRO_KERNEL="${RASPI_DISTRO_KERNEL:-no}" # Include a distro-built kernel?
|
||||
function post_family_config__add_rpi_packages() {
|
||||
display_alert "Preparing bcm2711" "${RELEASE}" "info"
|
||||
unset BOOTSOURCE # To try and convince lib/ to not build or install u-boot.
|
||||
declare -g SERIALCON="${RASPI_SERIALCON:-tty1}" # HDMI etc, not serial. most people don't have UART on rpi
|
||||
|
||||
local usable_releases="jammy|kinetic|lunar|mantic"
|
||||
# those older releases are not working as we don't provide binaries for libraspberrypi-bin
|
||||
local not_usable_releases="bullseye|buster|focal"
|
||||
|
||||
# if RELEASE is set, make sure it is one of the ones we support.
|
||||
if [[ -n "${RELEASE}" ]]; then
|
||||
if [[ "$RELEASE" =~ ^(${usable_releases})$ ]]; then
|
||||
declare -g FK__EXTRA_PACKAGES="rpi-eeprom linux-firmware linux-firmware-raspi pi-bluetooth libraspberrypi-bin cloud-initramfs-growroot busybox"
|
||||
FK__EXTRA_PACKAGES="${FK__EXTRA_PACKAGES} raspi-config" # Add raspi-config for those releases that have it; it might be useful.
|
||||
|
||||
if [[ "${RASPI_DISTRO_KERNEL}" == "yes" ]]; then # and firmware.
|
||||
unset KERNELSOURCE # Make sure Armbian will not try to compile from source.
|
||||
declare -g FK__KERNEL_PACKAGES="${FK__KERNEL_PACKAGES} linux-tools-raspi linux-raspi linux-image-raspi "
|
||||
# Ubuntu Impish+ split the kernel modules, add the extra ones too.
|
||||
if [[ "$RELEASE" =~ ^(jammy|kinetic)$ ]]; then
|
||||
declare -g FK__KERNEL_PACKAGES="${FK__KERNEL_PACKAGES} linux-modules-extra-raspi"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
exit_with_target_not_supported_error "Can't use release '${RELEASE}' for ${BOARD}. Try: '${usable_releases}'" "'${RELEASE}' not supported"
|
||||
if [[ "$RELEASE" =~ ^(${not_usable_releases})$ ]]; then
|
||||
exit_with_target_not_supported_error "Can't use release '${RELEASE}' for ${BOARD}. Invalid releases: '${not_usable_releases}'" "'${RELEASE}' not supported"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Make sure we don't try to install or remove /boot/dtb-$kvers directory
|
||||
function post_family_tweaks_bsp__add_hooks_to_move_kernel_initrd_and_dtb() {
|
||||
run_host_command_logged mkdir -p "${destination}"/etc/kernel/post{inst,rm}.d
|
||||
|
||||
# Copy new files to /boot/firmware
|
||||
run_host_command_logged cat <<- 'z50-raspi-firmware' > "${destination}"/etc/kernel/postinst.d/z50-raspi-firmware
|
||||
#!/bin/bash -e
|
||||
|
||||
# We are using same name as the debian's raspi-firmware script, but we
|
||||
# only need to run this script on ubuntu. Debian's package has a postinst
|
||||
# section capable of copying files, but Ubuntu relies on flash-kernel
|
||||
[[ -d /usr/lib/linux-firmware-raspi ]] || exit 0
|
||||
|
||||
# Play nice when run under debconf.
|
||||
exec </dev/null >&2
|
||||
|
||||
# Ensure the target directory exists.
|
||||
mkdir -p /boot/firmware
|
||||
|
||||
for file in /usr/lib/linux-firmware-raspi/*
|
||||
do
|
||||
file=$( basename "$file" )
|
||||
cp "/usr/lib/linux-firmware-raspi/$file" "/boot/firmware/$file"
|
||||
sync -f "/boot/firmware/$file" || true
|
||||
done
|
||||
|
||||
exit 0
|
||||
z50-raspi-firmware
|
||||
|
||||
# Copy new files to /boot/firmware
|
||||
run_host_command_logged cat <<- 'zzz-copy-new-files' > "${destination}"/etc/kernel/postinst.d/zzz-copy-new-files
|
||||
#!/bin/bash -e
|
||||
|
||||
# Play nice when run under debconf.
|
||||
exec </dev/null >&2
|
||||
|
||||
abi=$1
|
||||
target=/boot/firmware
|
||||
dtb_dir=/usr/lib/linux-image-$abi/
|
||||
|
||||
cp /boot/vmlinuz-${abi} ${target}/vmlinuz
|
||||
cp ${dtb_dir}/broadcom/*.dtb ${target}/
|
||||
cp -r ${dtb_dir}/overlays ${target}/
|
||||
sync -f ${target}/vmlinuz || true
|
||||
|
||||
exit 0
|
||||
zzz-copy-new-files
|
||||
|
||||
# Remove old files from /boot/firmware
|
||||
run_host_command_logged cat <<- 'zzz-remove-old-files' > "${destination}"/etc/kernel/postrm.d/zzz-remove-old-files
|
||||
#!/bin/bash -e
|
||||
|
||||
# Play nice when run under debconf.
|
||||
exec </dev/null >&2
|
||||
|
||||
abi=$1
|
||||
target=/boot/firmware
|
||||
|
||||
rm ${target}/vmlinuz
|
||||
rm ${target}/*.dtb
|
||||
rm -r ${target}/overlays
|
||||
|
||||
exit 0
|
||||
zzz-remove-old-files
|
||||
|
||||
run_host_command_logged chmod a+rx "${destination}"/etc/kernel/postinst.d/z50-raspi-firmware
|
||||
run_host_command_logged chmod a+rx "${destination}"/etc/kernel/postinst.d/zzz-copy-new-files
|
||||
run_host_command_logged chmod a+rx "${destination}"/etc/kernel/postrm.d/zzz-remove-old-files
|
||||
|
||||
run_host_command_logged rm "${destination}"/etc/initramfs/post-update.d/99-uboot
|
||||
|
||||
# copy new initramfs file
|
||||
run_host_command_logged cat <<- 'zzz-update-initramfs' > "${destination}"/etc/initramfs/post-update.d/zzz-update-initramfs
|
||||
#!/bin/bash -e
|
||||
|
||||
# Play nice when run under debconf.
|
||||
exec </dev/null >&2
|
||||
|
||||
abi=$1
|
||||
initrd_file=$2
|
||||
target=/boot/firmware
|
||||
|
||||
cp ${initrd_file} ${target}/initrd.img
|
||||
sync -f ${target}/initrd.img || true
|
||||
|
||||
exit 0
|
||||
zzz-update-initramfs
|
||||
|
||||
run_host_command_logged chmod a+x "${destination}"/etc/initramfs/post-update.d/zzz-update-initramfs
|
||||
}
|
||||
|
||||
function post_family_tweaks__populate_boot_firmware_directory() {
|
||||
# We install kernel before we install bsp package. This means hooks present in bsp are not executed.
|
||||
# Running the hooks from bsp to populate /boot/firmware directory.
|
||||
modules_dir="$(find "${SDCARD}/lib/modules"/ -maxdepth 1 -type d -name "*${IMAGE_INSTALLED_KERNEL_VERSION}*")"
|
||||
kern_ver="$(basename "$modules_dir")"
|
||||
run_host_command_logged mkdir -p "${SDCARD}"/boot/firmware
|
||||
chroot_sdcard /etc/kernel/postinst.d/z50-raspi-firmware "${kern_ver}"
|
||||
chroot_sdcard /etc/kernel/postinst.d/zzz-copy-new-files "${kern_ver}"
|
||||
}
|
||||
|
||||
function pre_install_distribution_specific__add_rpi_packages() {
|
||||
# we store Rpi firmware packages in our repository
|
||||
# https://github.com/armbian/os/wiki/Import-3rd-party-packages
|
||||
display_alert "Enable Armbian repository to fetch Rpi packages" "" "info"
|
||||
mv "${SDCARD}"/etc/apt/sources.list.d/armbian.list.disabled "${SDCARD}"/etc/apt/sources.list.d/armbian.list
|
||||
do_with_retries 3 chroot_sdcard_apt_get_update
|
||||
chroot_sdcard_apt_get_install rpi-eeprom linux-firmware-raspi pi-bluetooth libraspberrypi-bin busybox raspi-config
|
||||
# disable armbian repository
|
||||
mv "${SDCARD}"/etc/apt/sources.list.d/armbian.list "${SDCARD}"/etc/apt/sources.list.d/armbian.list.disabled
|
||||
}
|
||||
|
||||
# Our default paritioning system is leaving esp on. Rpi3 is the only board that have issues with this.
|
||||
# Removing the ESP flag from the boot partition should allow the image to boot on both the RPi3 and RPi4.
|
||||
function pre_umount_final_image__remove_esp() {
|
||||
display_alert "Removing ESP flag from FAT partition" "rpi4 / rpi3" "info"
|
||||
run_host_command_logged parted -s "${LOOP}" set 1 esp off
|
||||
}
|
||||
|
||||
# configure stuff at the appropriate time in flash-kernel
|
||||
function pre_umount_final_image__write_raspi_config() {
|
||||
cat <<- EOD > "${MOUNT}"/boot/firmware/config.txt
|
||||
# For more options and information see
|
||||
# http://rptl.io/configtxt
|
||||
# Some settings may impact device functionality. See link above for details
|
||||
|
||||
# Uncomment some or all of these to enable the optional hardware interfaces
|
||||
#dtparam=i2c_arm=on
|
||||
#dtparam=i2s=on
|
||||
#dtparam=spi=on
|
||||
|
||||
# Enable audio (loads snd_bcm2835)
|
||||
dtparam=audio=on
|
||||
|
||||
# Additional overlays and parameters are documented
|
||||
# /boot/firmware/overlays/README
|
||||
|
||||
# Automatically load overlays for detected cameras
|
||||
camera_auto_detect=1
|
||||
|
||||
# Automatically load overlays for detected DSI displays
|
||||
display_auto_detect=1
|
||||
|
||||
# Automatically load initramfs files, if found
|
||||
auto_initramfs=1
|
||||
|
||||
# Enable DRM VC4 V3D driver
|
||||
dtoverlay=vc4-kms-v3d
|
||||
max_framebuffers=2
|
||||
|
||||
# Don't have the firmware create an initial video= setting in cmdline.txt.
|
||||
# Use the kernel's default instead.
|
||||
disable_fw_kms_setup=1
|
||||
|
||||
# Disable compensation for displays with overscan
|
||||
disable_overscan=1
|
||||
|
||||
# Run as fast as firmware / board allows
|
||||
arm_boost=1
|
||||
|
||||
[cm4]
|
||||
# Enable host mode on the 2711 built-in XHCI USB controller.
|
||||
# This line should be removed if the legacy DWC2 controller is required
|
||||
# (e.g. for USB device mode) or if USB support is not required.
|
||||
otg_mode=1
|
||||
|
||||
[all]
|
||||
kernel=vmlinuz
|
||||
initramfs initrd.img followkernel
|
||||
arm_64bit=1
|
||||
EOD
|
||||
}
|
||||
|
||||
function pre_umount_final_image__write_raspi_cmdline() {
|
||||
cat <<- EOD > "${MOUNT}"/boot/firmware/cmdline.txt
|
||||
console=serial0,115200 console=tty1 loglevel=1 root=LABEL=${ROOT_FS_LABEL} rootfstype=${ROOTFS_TYPE} fsck.repair=yes rootwait logo.nologo
|
||||
EOD
|
||||
}
|
||||
|
||||
@ -88,8 +88,8 @@ update_initramfs() {
|
||||
fi
|
||||
|
||||
# Convert to bootscript expected format, by calling into the script manually.
|
||||
if [[ -f "${chroot_target}"/etc/initramfs/post-update.d/99-uboot ]]; then
|
||||
chroot_custom "$chroot_target" /etc/initramfs/post-update.d/99-uboot "${initrd_kern_ver}" "/boot/initrd.img-${initrd_kern_ver}"
|
||||
if [[ -d "${chroot_target}"/etc/initramfs/post-update.d/ ]]; then
|
||||
chroot_custom "$chroot_target" /usr/bin/run-parts -a "${initrd_kern_ver}" -a "/boot/initrd.img-${initrd_kern_ver}" /etc/initramfs/post-update.d/
|
||||
fi
|
||||
else
|
||||
display_alert "Cache miss for initrd cache" "${initrd_cache_key}" "debug"
|
||||
@ -113,9 +113,11 @@ update_initramfs() {
|
||||
# clean old cache files so they don't pile up forever.
|
||||
if [[ "${SHOW_DEBUG}" == "yes" ]]; then
|
||||
display_alert "Showing which initrd caches would be removed/expired" "initrd" "debug"
|
||||
# 60: keep the last 30 initrd + manifest pairs. this should be higher than the total number of kernels we support, otherwise churn will be high
|
||||
find "${SRC}/cache/initrd" -type f -printf "%T@ %p\\n" | sort -n -r | sed "1,60d" | xargs rm -fv
|
||||
# 80: keep the last 40 initrd + manifest pairs. this should be higher than the total number of kernels we support, otherwise churn will be high
|
||||
find "${SRC}/cache/initrd" -type f -printf "%T@ %p\\n" | sort -n -r | sed "1,80d"
|
||||
fi
|
||||
|
||||
find "${SRC}/cache/initrd" -type f -printf "%T@ %p\\n" | sort -n -r | sed "1,80d" | xargs rm -fv
|
||||
fi
|
||||
|
||||
display_alert "Re-enabling" "initramfs-tools hook for kernel"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user