Skip to content

Add RaspberryPi 5 support#275

Merged
nisargjhaveri merged 1 commit intonisargjhaveri:mainfrom
manio:pi5
Jun 6, 2025
Merged

Add RaspberryPi 5 support#275
nisargjhaveri merged 1 commit intonisargjhaveri:mainfrom
manio:pi5

Conversation

@manio
Copy link
Contributor

@manio manio commented May 26, 2025

Adding initial work for Pi5 support. The work is still in progress, but creating PR so maybe something finally comes out of this...

@manio
Copy link
Contributor Author

manio commented May 26, 2025

It ended with:

>>> linux-headers custom Patching
for p in /app/aa_wireless_dongle/patches/linux ; do if test -d $p ; then PATH=/app/buildroot/output/raspberrypi5/host/bin:$PATH support/scripts/apply-patches.sh  /app/buildroot/output/raspberrypi5/build/linux-headers-custom $p \*.patch || exit 1 ; else PATH=/app/buildroot/output/raspberrypi5/host/bin:$PATH support/scripts/apply-patches.sh  /app/buildroot/output/raspberrypi5/build/linux-headers-custom `dirname $p` `basename $p` || exit 1; fi done

Applying 0001-Backport-and-apply-patches-for-Android-Accessory-mod.patch using patch: 
patching file drivers/usb/gadget/Kconfig
Hunk #1 succeeded at 223 (offset 7 lines).
Hunk #2 succeeded at 240 (offset 7 lines).
Hunk #3 succeeded at 389 (offset 7 lines).
patching file drivers/usb/gadget/configfs.c
Hunk #1 FAILED at 10.
Hunk #2 succeeded at 59 with fuzz 1 (offset 8 lines).
Hunk #3 succeeded at 292 (offset 13 lines).
Hunk #4 succeeded at 1828 (offset 398 lines).
Hunk #5 succeeded at 1906 (offset 398 lines).
Hunk #6 succeeded at 1975 (offset 398 lines).
Hunk #7 succeeded at 1987 (offset 398 lines).
Hunk #8 succeeded at 2003 (offset 398 lines).
Hunk #9 succeeded at 2081 (offset 398 lines).
Hunk #10 succeeded at 2099 (offset 398 lines).
Hunk #11 succeeded at 2244 (offset 402 lines).
Hunk #12 succeeded at 2259 (offset 402 lines).
Hunk #13 succeeded at 2303 (offset 402 lines).
Hunk #14 succeeded at 2317 (offset 402 lines).
1 out of 14 hunks FAILED -- saving rejects to file drivers/usb/gadget/configfs.c.rej
patching file drivers/usb/gadget/function/Makefile
Hunk #1 succeeded at 52 (offset 2 lines).
patching file drivers/usb/gadget/function/f_accessory.c
patching file include/linux/usb/composite.h
Hunk #1 succeeded at 583 (offset 5 lines).
patching file include/linux/usb/f_accessory.h
patching file include/uapi/linux/usb/f_accessory.h
make[1]: *** [package/pkg-generic.mk:242: /app/buildroot/output/raspberrypi5/build/linux-headers-custom/.stamp_patched] Error 1
make: *** [Makefile:23: _all] Error 2
ERROR: 2

The gadget patch has to be adjusted to this kernel first...

@nisargjhaveri
Copy link
Owner

We need to use same kernel version across different RPi to make it easy to manage. I have a change locally on top of the buildroot upgrade PR, I can push today so you don't have to redo the patch at least.

@manio
Copy link
Contributor Author

manio commented May 26, 2025

Great!

@nisargjhaveri
Copy link
Owner

@manio see recent commit in #270, if it helps.

@manio
Copy link
Contributor Author

manio commented May 26, 2025

Thanks... giving a try...

@sree3333
Copy link

@manio I will try to use the same branch "pi5", could you let me know how did you run the build, did you use raspberrypi5_defconfig directly?

@sree3333
Copy link

sree3333 commented May 26, 2025

Facing this issue on rpi5 branch. @manio
Screenshot 2025-05-27 004509

@manio
Copy link
Contributor Author

manio commented May 27, 2025

@sree3333 I have exactly same problem. It seems that zImage is not generated for some reason. I inspected the build process and the kernel is building correctly:

  CC [M]  fs/smb/common/cifs_md4.mod.o
  CC [M]  fs/smb/client/cifs.mod.o
  CC [M]  fs/smb/server/ksmbd.mod.o
  CC [M]  fs/ntfs/ntfs.mod.o
  CC [M]  fs/ntfs3/ntfs3.mod.o
  CC [M]  fs/jffs2/jffs2.mod.o
  NM      System.map
  CC [M]  fs/ubifs/ubifs.mod.o
  CC [M]  fs/fuse/fuse.mod.o
  CC [M]  fs/fuse/cuse.mod.o
  CC [M]  fs/overlayfs/overlay.mod.o
  SORTTAB vmlinux
  CC [M]  fs/udf/udf.mod.o
[...]
  CC [M]  crypto/blake2b_generic.mod.o
  OBJCOPY arch/arm64/boot/Image
  CC [M]  crypto/cbc.mod.o
  CC [M]  crypto/ctr.mod.o
  GZIP    arch/arm64/boot/Image.gz
  CC [M]  crypto/adiantum.mod.o
  CC [M]  crypto/nhpoly1305.mod.o
  CC [M]  crypto/gcm.mod.o

but /app/buildroot/output/raspberrypi5/images/zImage is not there, there's only Image .
Will now try with BR2_LINUX_KERNEL_ZIMAGE in config...

did you use raspberrypi5_defconfig directly?

I am not using it directly but I am building in Docker with docker-compose run --rm rpi5

Edit:
I found something similar here. The problem is described at the end of article (Abnormality 7), but the resolution is weird - some script modification...
This is also interesting.

@sree3333
Copy link

@manio are you making changes in post_build.sh? acc to
"However, it is possible to select a custom image name (BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM) and then set BR2_LINUX_KERNEL_IMAGE_TARGET_NAME to Image.gz. Alternatively, you can do the compression in a post-build script."

@manio
Copy link
Contributor Author

manio commented May 27, 2025

I just did this:

diff --git a/aa_wireless_dongle/configs/raspberrypi5_defconfig b/aa_wireless_dongle/configs/raspberrypi5_defconfig
index e0ee78c..7fe2286 100644
--- a/aa_wireless_dongle/configs/raspberrypi5_defconfig
+++ b/aa_wireless_dongle/configs/raspberrypi5_defconfig
@@ -15,6 +15,7 @@ BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,576cc1
 BR2_LINUX_KERNEL_DEFCONFIG="bcm2712"
 BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_AA_WIRELESS_DONGLE_PATH)/board/common/kernel.config"
 BR2_LINUX_KERNEL_LZ4=y
+BR2_LINUX_KERNEL_ZIMAGE=y
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
 # Build the DTB from the kernel sources

But doesn't work - same error :(

@sree3333
Copy link

@manio is buildroot different from before?

@manio
Copy link
Contributor Author

manio commented May 27, 2025

@manio is buildroot different from before?

What you mean?

@manio
Copy link
Contributor Author

manio commented May 27, 2025

Sorry... due to other important tasks I have to leave this as it is for now...

We are hopefully really close to the complete Pi5 Image (the problem is only with correct kernel zImage format).
If you know how to fix building the zImage, let me know so I'll push necessary changes.

@sree3333
Copy link

@manio @nisargjhaveri I resolved the issue and successfully built the sdimage, also I have flashed to the sdcard and it is running properly as I can connect the device's bluetooth to phone. But the problems lies in USB connection now as the main usb point that is connected with the headunit is not able to power up the rpi5 properly due to the power requirements. I powered up rpi5 with another usb power cable to type C and connected the headunit to rpi5 type A usb but it is not working with that. Any suggestions?

@manio
Copy link
Contributor Author

manio commented May 27, 2025

How you fixed this? Copying the image? :)
Give the logs so we could look what the problem may be?

@sree3333
Copy link

@manio In the Rpi5 branch of your's , you are using the raspberrypi5_defconfig but the config,cmdline, post-build and post-image as of raspberrypi. @nisargjhaveri released a buildroot supporting rpi5 config. I replaced existing configs with those and made neccessary changes in defconfig and it worked.

@manio
Copy link
Contributor Author

manio commented May 27, 2025

That easy... OK... checking that out...

@sree3333
Copy link

@manio @nisargjhaveri I have forked my changes https://github.com/sree3333/WirelessAndroidAutoDonglePi5 Please check this out if you are facing any issues.

@manio
Copy link
Contributor Author

manio commented May 27, 2025

@sree3333 Thanks, please look how to obtain logs... :)

@manio
Copy link
Contributor Author

manio commented May 27, 2025

Ok... so the final conclusion seems to be that the problem was not a buildroot version, but a missing config files for Rpi5...

@nisargjhaveri
Copy link
Owner

#270 was merged to main. You can rebase on top.

@manio
Copy link
Contributor Author

manio commented Jun 2, 2025

Thank you!
rebased... will see if CI will pass...

@manio
Copy link
Contributor Author

manio commented Jun 2, 2025

@nisargjhaveri
Would you like to remove the:
BR2_LINUX_KERNEL_ZIMAGE=y
and add back:
BR2_DOWNLOAD_FORCE_CHECK_HASHES=y ?
It was changed during testing process but maybe we can revert those now...

@nisargjhaveri
Copy link
Owner

BR2_DOWNLOAD_FORCE_CHECK_HASHES=y sounds like a good idea, let's just keep that.

Does BR2_LINUX_KERNEL_ZIMAGE=y even work for RPi 5? If not, let's just remove. I see we anyway use the Image instead of zImage in the config_5.txt?

@manio
Copy link
Contributor Author

manio commented Jun 2, 2025

OK pushed the changes and can see the CI started over...
I'll squash to single commit if all will be fine...

@manio
Copy link
Contributor Author

manio commented Jun 2, 2025

Oh... I'll try to also use common config.txt... (wondering about Image name though...)

@manio
Copy link
Contributor Author

manio commented Jun 3, 2025

Ok... it seems that separate config is needed because it failed before (that Image line is needed for correct build)...
Is it OK to you?
Can I clean it up?

Edit: done :)

@manio manio marked this pull request as ready for review June 3, 2025 09:06
@manio manio changed the title [WiP] This is a PR for RaspberryPi 5 Add RaspberryPi 5 support Jun 3, 2025
@nisargjhaveri
Copy link
Owner

Ok... it seems that separate config is needed because it failed before (that Image line is needed for correct build)...

Yeah, this makes sense. We can try using conditionals in the common config.txt, if the majority of the rest of the config is still applicable. If not, separate config is fine.

@manio
Copy link
Contributor Author

manio commented Jun 4, 2025

Good idea, do you know how to condition this Image only?
I think the rest is fine from common...

@nisargjhaveri
Copy link
Owner

https://www.raspberrypi.com/documentation/computers/config_txt.html#conditional-filters should help.

I think something like this should work?

kernel=zImage

[pi5]
kernel=Image
[all]

...

@manio
Copy link
Contributor Author

manio commented Jun 5, 2025

Hmmm... is seems that post-image doesn't like this (or I did it wrong):

2025-06-04T20:49:09.4094820Z >>>   Executing post-image script /home/runner/work/WirelessAndroidAutoDongle/WirelessAndroidAutoDongle/aa_wireless_dongle/board/raspberrypi/post-image.sh
2025-06-04T20:49:09.4168757Z sed: -e expression #1, char 264: unterminated `s' command
2025-06-04T20:49:09.4172410Z make: *** [Makefile:829: target-post-image] Error 1
2025-06-04T20:49:09.4219073Z ##[error]Process completed with exit code 2.

@nisargjhaveri
Copy link
Owner

Hmmm... is seems that post-image doesn't like this (or I did it wrong):

Haha! This is going to be interesting.

post-image.sh seems to be doing this to figure out which kernel file to include in the image. Which seems to be failing now? :)

	KERNEL=$(sed -n 's/^kernel=//p' "${BINARIES_DIR}/rpi-firmware/config.txt")
	FILES+=( "${KERNEL}" )

Maybe let's just have separate file. We can try to keep them as close as possible so easier to maintain in future?

@manio
Copy link
Contributor Author

manio commented Jun 5, 2025

Sure, trying it now...

@manio
Copy link
Contributor Author

manio commented Jun 5, 2025

Seems it's fine :)

@nisargjhaveri nisargjhaveri merged commit 14cfa9c into nisargjhaveri:main Jun 6, 2025
6 checks passed
@nisargjhaveri
Copy link
Owner

Thanks! :)

manio added a commit to aa-proxy/buildroot that referenced this pull request Aug 1, 2025
This was separated initialy because of problems with pointing to correct
kernel image:
nisargjhaveri/WirelessAndroidAutoDongle#275 (comment)

it is not an issue anymore, so use a common config

Credits: @juggie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants