Supporting source code for HDMI Audio in the BCM2712 Raspi5 Hardware. Use the Linux source code as a help for missing Broadcom Documentation
Supporting source code for HDMI Audio in the BCM2712 Raspi5 Hardware. Use the Linux source code as a help for missing Broadcom Documentation.
Ronald Klop says in his wiki about running FreeBSD 15.0 CURRENT on his Raspberry pi 5 hardware:
https://wiki.freebsd.org/arm/Raspberry%20Pi%205 Setup of FreeBSD on Raspi 5 BCM2712 Hardware
Grok answer for Raspi5 HDMI Audio: https://x.com/i/grok/share/HrunSIXyDIFTsBnK5eRhb75Om
Text Copy of the Grok Answer:
As of March 22, 2025, FreeBSD support for the Raspberry Pi 5 (BCM2712) is still evolving, and full HDMI audio functionality is not yet natively available in the mainline FreeBSD source tree for this specific hardware. However, there are ongoing efforts within the FreeBSD community to improve support for the Raspberry Pi 5, including its HDMI audio hardware. Below, I’ll outline the current state, point you to relevant resources, and suggest how you might approach obtaining or developing a device driver for HDMI audio on this platform.
Current Status of FreeBSD on Raspberry Pi 5 (BCM2712)
The Raspberry Pi 5, powered by the Broadcom BCM2712 SoC, is a relatively new addition to the Raspberry Pi family (released in late 2023). FreeBSD has robust support for earlier Raspberry Pi models like the Pi 3 and 4 (BCM2711), including some audio functionality via patches, but the BCM2712 introduces new hardware features and changes that require updated drivers and device tree configurations. Notably:
- HDMI Audio on BCM2711: For the Raspberry Pi 4, HDMI audio support has been achieved through community patches leveraging the VCHIQ (VideoCore Host Interface Queue) driver. These patches, discussed in FreeBSD forums and review boards (e.g., D36431, D37878, D37879), enable audio output via HDMI by interfacing with the Broadcom VideoCore GPU.
- BCM2712 Differences: The BCM2712 on the Pi 5 has a revised architecture, including changes to the VideoCore VI GPU and a new RP1 southbridge chip handling I/O. These changes mean that existing BCM2711 VCHIQ patches may not directly apply, and new drivers or adaptations are needed.
As of now, FreeBSD 15.0-CURRENT and 14.0-RELEASE provide basic boot support for the Raspberry Pi 5 using updated U-Boot firmware and device tree files (e.g., bcm2712-rpi-5-b.dtb), but peripheral support, including HDMI audio, remains incomplete or untested in the mainline source.
Finding the Source Code
The FreeBSD source code for ARM64 (aarch64) device drivers, including those potentially applicable to the Raspberry Pi 5, is located in the FreeBSD source tree under sys/arm64/ and sys/dev/. For HDMI audio, the relevant components would likely involve:
- VCHIQ Driver: Located in sys/dev/vchiq/, this driver interfaces with the Broadcom VideoCore GPU, which handles HDMI audio on Raspberry Pi devices. The existing driver was developed for BCM283x/BCM2711 chips and may need updates for BCM2712.
- Device Tree Files: Found in sys/dts/arm64/, the bcm2712-rpi-5-b.dts file describes the hardware layout. Audio-related nodes (e.g., HDMI or I2S interfaces) would need to be defined or adjusted here.
- Sound Framework: The FreeBSD sound system (sys/dev/sound/) provides the infrastructure for audio output, which would connect to the VCHIQ driver for HDMI audio routing.
You can access the latest FreeBSD source code via:
- Git Repository: git clone https://git.freebsd.org/src.git
- Web Browser: Browse at https://cgit.freebsd.org/src/
Using Linux to Download and write .img file to USB Flash disk drive stick
Existing Efforts and Patches
Community discussions (e.g., FreeBSD Forums threads like "Raspberry Pi 5 status") and code reviews suggest that HDMI audio support for BCM2712 is not yet merged into the mainline but can be adapted from BCM2711 work:
- Patches for BCM2711: Reviews like https://reviews.freebsd.org/D36431, D37878, and D37879 add VCHIQ-based HDMI audio for the Pi 4. These modify sys/dev/vchiq/ and related files to enable audio output through the GPU.
- Testing on BCM2712: Forum posts indicate that applying these patches to a Pi 5 kernel build has not been fully successful due to hardware differences. Users have reported needing to update memory mappings (e.g., in bcm2835_vcbus.c) and device tree definitions to reflect BCM2712 specifics.
A notable patch snippet for BCM2712 memory mapping (from a forum post) adjusts sys/arm/broadcom/bcm2835/bcm2835_vcbus.c to recognize the new SoC:
diff
+static struct bcm283x_memory_mapping bcm2712_memmap[] = {
+ { .armc_start = 0x00000000, .armc_size = 0x3fc00000, .vcbus_start = BCM2836_VCBUS_IO_BASE },
+ { .armc_start = 0x1000000000, .armc_size = 0x0002000000, .vcbus_start = BCM2836_VCBUS_IO_BASE },
+ { .armc_start = 0x107c000000, .armc_size = 0x0004000000, .vcbus_start = BCM2836_VCBUS_IO_BASE },
+ { 0, 0, 0 }
+};
+static struct bcm283x_memory_soc_cfg {
+ .memmap = bcm2712_memmap,
+ .soc_compat = "brcm,bcm2712",
+ .busdma_lowaddr = BCM2838_PERIPH_MAXADDR,
+};
This suggests that BCM2712 support is being worked on, but audio-specific changes are less documented.
Steps to Develop or Adapt an HDMI Audio Driver
If you want to create or adapt a driver for BCM2712 HDMI audio on FreeBSD aarch64, here’s a suggested approach:
- Start with BCM2711 Patches:
- Build a kernel with KERNCONF=GENERIC-VCHIQ as suggested in forum posts.
- Compile source https://ghostbsd-arm64.blogspot.com/2025/02/moving-from-141-or-140-freebsd-kernel.html
- Patch sourcehttps://ghostbsd-arm64.blogspot.com/2024/01/hdmi-audio-sound-patches-into-ghostbsd.html
- Update Device Tree:
- Check bcm2712-rpi-5-b.dts (from the Raspberry Pi firmware repo or FreeBSD’s DTS directory) for HDMI audio nodes. Compare with bcm2711-rpi-4-b.dts to identify missing or changed definitions.
- Ensure the HDMI audio path (likely via the VideoCore GPU) is correctly mapped.
- Modify VCHIQ for BCM2712:
- Adjust sys/dev/vchiq/ to handle BCM2712’s GPU differences. This may require Broadcom documentation (unfortunately scarce) or reverse-engineering from Linux drivers (e.g., vc4_hdmi in the Linux kernel).
- Build and Test:
- Compile the kernel: make buildkernel TARGET=arm64 TARGET_ARCH=aarch64 KERNCONF=GENERIC-VCHIQ
- Install on a Pi 5 SD card image (e.g., FreeBSD-15.0-CURRENT-arm64-aarch64-RPI.img.xz) and boot.
- Test audio output with tools like speaker-test or cat /dev/sndstat to verify device recognition.
- Debugging:
- Use dmesg to check for VCHIQ or sound driver errors.
- If needed, adapt further based on hardware register differences (BCM2712 datasheets are not publicly available, but Linux source at github.com/raspberrypi/linux may help).
Challenges and Alternatives
- Lack of Documentation: Broadcom does not release full BCM2712 datasheets, complicating driver development. You might need to infer details from Raspberry Pi OS’s Linux kernel source.
- Community Support: Check FreeBSD mailing lists (e.g., freebsd-arm@) or forums for updates. Someone may have unpublished patches for BCM2712 audio.
- Alternative: If immediate HDMI audio is critical, consider using Raspberry Pi OS or another Linux distro temporarily, as they have mature BCM2712 support.
Conclusion
As of now, there’s no off-the-shelf FreeBSD aarch64 driver in the mainline source for BCM2712 HDMI audio. You can start with the BCM2711 VCHIQ patches, adjust for BCM2712, and contribute your findings back to the FreeBSD community via reviews.freebsd.org or the forums. For the latest progress, monitor FreeBSD’s ARM64 wiki (https://wiki.freebsd.org/arm64) and forum threads tagged with Raspberry Pi 5.
If you need specific code snippets or further guidance on building the kernel, let me know!
Comments
Post a Comment