diff mbox series

[v5,3/3] board/raspberrypi: add support for Raspberry Pi 5

Message ID 20240715160941.90353-3-foss@athaariq.my.id
State New
Headers show
Series [v5,1/3] package/rpi-firmware: bump version to 1.20240529 | expand

Commit Message

Athaariq Ardhiansyah July 15, 2024, 4:09 p.m. UTC
Since the last Raspberry Pi 5 submission has no progress, I'm submitting
these patches anyway. The newly released Raspberry Pi 5 board shares
similar software structure except it has less proprietary API.
Therefore, rpi-userland and all of raspberry-centric GPIO utilities are
no longer supported.

Keep in mind that RPi 5 has no native 32-bit support due to Cortex-A76
processor specification. That is the reason why I did not add _64.

Signed-off-by: Athaariq Ardhiansyah <foss@athaariq.my.id>

---
Changes v1 -> v2:
  - Fix missing newlines due to terminal issue

Changes v3 -> v4:
  - Rebase to master
  - Drop 4K page size, until we figured out how to run 32bit userspace
    on top of 64bit kernel
  - Change back from commit ID to commit tag
  - Rewrite the commit description
  - Fix incorrect CPU from upstream config, RPi5 has no LITTLE.big
  - Revert the config_5.txt to keep the GPU and UART working

Changes v4 -> v5:
  - Remove the commented line for better clarity
  - Remove miniuart-bt due to different console for RPi5 (suggested by
    Gaël PORTAY)
  - Fix mistake on git send-email command which causes duplicated
    'Signed-off-by' at the bottom
  - Default UART should be RPi5's default UART, which is UART0
  - Change Linux commit ID to currently latest tag and must match with
    its DTB firmware version, which is stable_20240529 (suggested by
    Gaël PORTAY)
---
 board/raspberrypi/cmdline_5.txt               |  1 -
 board/raspberrypi/config_5.txt                | 36 +++++++++++++++++++
 board/raspberrypi/linux-4k-page-size.fragment |  1 -
 .../patches/linux-headers/linux-headers.hash  |  1 -
 board/raspberrypi/patches/linux/linux.hash    |  2 +-
 configs/raspberrypi5_defconfig                | 19 ++++------
 6 files changed, 44 insertions(+), 16 deletions(-)
 delete mode 100644 board/raspberrypi/cmdline_5.txt
 delete mode 100644 board/raspberrypi/linux-4k-page-size.fragment
 delete mode 120000 board/raspberrypi/patches/linux-headers/linux-headers.hash

Comments

Gaël PORTAY July 16, 2024, 6:06 p.m. UTC | #1
Hello Athaariq,

On Mon Jul 15, 2024 at 6:09 PM CEST, Athaariq Ardhiansyah wrote:
> Since the last Raspberry Pi 5 submission has no progress, I'm submitting
> these patches anyway. The newly released Raspberry Pi 5 board shares
> similar software structure except it has less proprietary API.
> Therefore, rpi-userland and all of raspberry-centric GPIO utilities are
> no longer supported.
>
> Keep in mind that RPi 5 has no native 32-bit support due to Cortex-A76
> processor specification. That is the reason why I did not add _64.
>

It seems the commit title and the commit message are outdated.

Would you mind rewording them?

> diff --git a/board/raspberrypi/config_5.txt b/board/raspberrypi/config_5.txt
> index bbed19fe46..e624086247 100644
> --- a/board/raspberrypi/config_5.txt
> +++ b/board/raspberrypi/config_5.txt
> @@ -9,6 +9,42 @@ kernel=Image
>  # To use an external initramfs file
>  #initramfs rootfs.cpio.gz
>  
> +# Automatically load initramfs files, if found
> +auto_initramfs=1
> +

It would make sense to have auto_initramfs=1 (or at least commented)
since there is the iniramfs[1] command commented above.

I would be nice to have the config.txt files similar as much as
possible; I guess that change should be made in every config.txt.

Alternatively, the initramfs was introduced and never been used since
then; I wonder if it should just gone instead.

> +# Uncomment some or all of these to enable the optional hardware interfaces
> +#dtparam=i2c_arm=on
> +#dtparam=i2s=on
> +#dtparam=spi=on
> +

Note that the size for config.txt is limited to 4k (on Pi 5); the
current files weight ~1k so, so the limit is "far" from beeing reached.

So I guess, it is preferable do not add too many unused options that are
unset by default in order to save space and to not confuse the user.

> +# Enable audio (loads snd_bcm2835)
> +dtparam=audio=on
> +

I found this[3], the comment is probably outdated if the pi5 has no
snd_bcm2835 audio driver. Does it have one?.

Do you really need it? Was it tested w/ or w/out dtparam=audio=on?

Note: Also, if the purpose is to enable audio on HDMI, "on" is already
the default[4].

> +# Automatically load overlays for detected cameras
> +camera_auto_detect=1
> +
> +# Automatically load overlays for detected DSI displays
> +display_auto_detect=1
> +
> +# Enable DRM VC4 V3D driver
> +dtoverlay=vc4-kms-v3d-pi5
> +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
> +

I tend to think the config.txt and defconfig files must stay minimals.
Anyone can modify them for its own needs by selecting packages from the
menuconfig and by setting a custom config.txt thanks to the config
BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE.

The other defconfigs do not set things related to graphic or audio.

Do you mind keeping these changes for yourself? or maybe try to convince
that theses changes should be added?

> +# enable 64bits support
> +arm_64bit=1
> +

The online documentation says[5]:

	Raspberry Pi 5 only supports a 64-bit kernel, so this parameter
	has been removed for that device.

So it can be dropped, right?

> +# Run as fast as firmware / board allows
> +arm_boost=1
> +

This online documentation says[6]:

	arm_boost (Raspberry Pi 4 Only)

So it can be dropped, right? Unless you know that the documentation is
outdated, and it can apply to pi5 as well.

> +# Raspberry PI 5 won't use UART0 as terminal out of the box. We need to enable
> +# this through config.txt
> +enable_uart=1
> +dtoverlay=uart0-pi5

The Raspberry Pi 5 is the first hardware h, aving a dedicated UART for
console. I there any reason why you want to not use the default console?

> diff --git a/board/raspberrypi/linux-4k-page-size.fragment b/board/raspberrypi/linux-4k-page-size.fragment
> deleted file mode 100644
> index 5df91df1aa..0000000000
> --- a/board/raspberrypi/linux-4k-page-size.fragment
> +++ /dev/null
> @@ -1 +0,0 @@
> -CONFIG_ARM64_4K_PAGES=y

That chunk is required as BR cannot guess for now how the page-size is
setup by the external toolchains.

Removing these changes would not let you boot your pi5 with an external
toolchain that does not match the expected page-size (for example, the
one shipped by bootlin). The init process fails at startup IIRC.

Do you mind telling why you want it to be removed? Using the default 16k
page-size maybe?

> diff --git a/configs/raspberrypi5_defconfig b/configs/raspberrypi5_defconfig
> index 3c88ce46cd..10cbe6fea3 100644
> --- a/configs/raspberrypi5_defconfig
> +++ b/configs/raspberrypi5_defconfig
> @@ -1,8 +1,9 @@
>  BR2_aarch64=y
> -BR2_cortex_a76_a55=y
> -BR2_ARM_FPU_VFPV4=y
> +BR2_cortex_a76=y
>  

Oh good catch, thanks!

> -BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,576cc10e1ed50a9eacffc7a05c796051d7343ea4)/linux-576cc10e1ed50a9eacffc7a05c796051d7343ea4.tar.gz"
> +BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,stable_20240529)/linux-stable_20240529.tar.gz"

As requested by Thomas, you can add the following comment:

        # Please keep in sync with package/rpi-firmware/rpi-firmware.mk

Also, you should apply that bump to every raspberrypi defconfig files.

> -BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
> -# BR2_TARGET_ROOTFS_TAR is not set
> +BR2_TARGET_ROOTFS_EXT2_SIZE="256M"

To you really need to double the size by two? and to tar the rootfs?

Regards,
Gaël

[1]: https://www.raspberrypi.com/documentation/computers/config_txt.html#initramfs
[2]: https://www.raspberrypi.com/documentation/computers/config_txt.html#auto_initramfs
[3]: https://github.com/raspberrypi/linux/pull/6153
[4]: https://www.raspberrypi.com/documentation/computers/config_txt.html#hdmi-audio
[5]: https://www.raspberrypi.com/documentation/computers/config_txt.html#arm_64bit
[6]: https://www.raspberrypi.com/documentation/computers/config_txt.html#arm_boost-raspberry-pi-4-only
diff mbox series

Patch

diff --git a/board/raspberrypi/cmdline_5.txt b/board/raspberrypi/cmdline_5.txt
deleted file mode 100644
index ac457353e2..0000000000
--- a/board/raspberrypi/cmdline_5.txt
+++ /dev/null
@@ -1 +0,0 @@ 
-root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA10,115200
diff --git a/board/raspberrypi/config_5.txt b/board/raspberrypi/config_5.txt
index bbed19fe46..e624086247 100644
--- a/board/raspberrypi/config_5.txt
+++ b/board/raspberrypi/config_5.txt
@@ -9,6 +9,42 @@  kernel=Image
 # To use an external initramfs file
 #initramfs rootfs.cpio.gz
 
+# Automatically load initramfs files, if found
+auto_initramfs=1
+
+# 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
+
+# Automatically load overlays for detected cameras
+camera_auto_detect=1
+
+# Automatically load overlays for detected DSI displays
+display_auto_detect=1
+
+# Enable DRM VC4 V3D driver
+dtoverlay=vc4-kms-v3d-pi5
+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 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 64bits support
+arm_64bit=1
+
+# Run as fast as firmware / board allows
+arm_boost=1
+
+# Raspberry PI 5 won't use UART0 as terminal out of the box. We need to enable
+# this through config.txt
+enable_uart=1
+dtoverlay=uart0-pi5
diff --git a/board/raspberrypi/linux-4k-page-size.fragment b/board/raspberrypi/linux-4k-page-size.fragment
deleted file mode 100644
index 5df91df1aa..0000000000
--- a/board/raspberrypi/linux-4k-page-size.fragment
+++ /dev/null
@@ -1 +0,0 @@ 
-CONFIG_ARM64_4K_PAGES=y
diff --git a/board/raspberrypi/patches/linux-headers/linux-headers.hash b/board/raspberrypi/patches/linux-headers/linux-headers.hash
deleted file mode 120000
index 5808d92afe..0000000000
--- a/board/raspberrypi/patches/linux-headers/linux-headers.hash
+++ /dev/null
@@ -1 +0,0 @@ 
-../linux/linux.hash
\ No newline at end of file
diff --git a/board/raspberrypi/patches/linux/linux.hash b/board/raspberrypi/patches/linux/linux.hash
index 8d43c25151..fc7338d0d0 100644
--- a/board/raspberrypi/patches/linux/linux.hash
+++ b/board/raspberrypi/patches/linux/linux.hash
@@ -1,2 +1,2 @@ 
 # Locally calculated
-sha256  dab3052783c68c46a5bc645b1c38d9705da995ab42823566518b62eb1fa1ef97  linux-576cc10e1ed50a9eacffc7a05c796051d7343ea4.tar.gz
+sha256  05ac851ea9b720ba44c66eb88cdcb7cbd280401b1dd1fab3391a3883e4719197  linux-stable_20240529.tar.gz
diff --git a/configs/raspberrypi5_defconfig b/configs/raspberrypi5_defconfig
index 3c88ce46cd..10cbe6fea3 100644
--- a/configs/raspberrypi5_defconfig
+++ b/configs/raspberrypi5_defconfig
@@ -1,8 +1,9 @@ 
 BR2_aarch64=y
-BR2_cortex_a76_a55=y
-BR2_ARM_FPU_VFPV4=y
+BR2_cortex_a76=y
 
-BR2_TOOLCHAIN_BUILDROOT_CXX=y
+# patches
+BR2_GLOBAL_PATCH_DIR="board/raspberrypi/patches"
+BR2_DOWNLOAD_FORCE_CHECK_HASHES=y
 
 BR2_SYSTEM_DHCP="eth0"
 
@@ -10,9 +11,8 @@  BR2_SYSTEM_DHCP="eth0"
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y
 
 BR2_LINUX_KERNEL=y
-BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/raspberrypi/linux-4k-page-size.fragment"
 BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
-BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,576cc10e1ed50a9eacffc7a05c796051d7343ea4)/linux-576cc10e1ed50a9eacffc7a05c796051d7343ea4.tar.gz"
+BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,stable_20240529)/linux-stable_20240529.tar.gz"
 BR2_LINUX_KERNEL_DEFCONFIG="bcm2712"
 
 # Build the DTB from the kernel sources
@@ -23,8 +23,6 @@  BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi5/config_5.txt"
-BR2_PACKAGE_RPI_FIRMWARE_CMDLINE_FILE="board/raspberrypi5/cmdline_5.txt"
-# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
@@ -34,8 +32,8 @@  BR2_PACKAGE_HOST_MTOOLS=y
 # Filesystem / image
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
-BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
-# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_ROOTFS_EXT2_SIZE="256M"
+BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS="-O 64bit"
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi5/post-build.sh"
 BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi5/post-image.sh"
 
@@ -45,6 +43,3 @@  BR2_PACKAGE_KMOD_TOOLS=y
 BR2_PACKAGE_XZ=y
 BR2_PACKAGE_KMOD=y
 BR2_PACKAGE_HOST_KMOD_XZ=y
-
-BR2_DOWNLOAD_FORCE_CHECK_HASHES=y
-BR2_GLOBAL_PATCH_DIR="board/raspberrypi5/patches"