Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel build re-architecture + Pi 0 2w support + Pi 0 Universal build #173

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

htruong
Copy link
Contributor

@htruong htruong commented Nov 14, 2021

This is gonna be a heavyweight one. While trying to support Pi 0 2w support, I realized we have been maintaining our kernel configs in a way that is not easy to keep track of: We have been hand-crafting kernel configs. This makes it hard to port support to new boards, because we have to figure out (manually) the diff from Pi0 which is the base kernel config and add stuff on top of that. This isn't something our small team could realistically support in the long run: Hand maintaining those configs and how they change is time consuming -- even when we just want to uprev the kernel.

The more sensible way to do it would be to respect the in-tree defconfig (which is maintained by the Raspberry Foundation) and tell it to "add more modules" (or remove them) on top of their work to support our embedded configuration. This simplifies the kernel config maintenance by a lot: No longer we have to maintain thousands of lines of kernel configs we don't understand, just maintain stuff that we care about and we do understand.

I also add a (poor man's) way to overlay/override vanilla buildroot packages -- in this case, we want to use a custom rpi-firmware package in order to support the pi0_2w.

@htruong htruong marked this pull request as draft November 14, 2021 08:18
echo "usage: BUILDROOT_DIR=buildroot $0 (boardname)"
echo "boardname: raspberrypi0, raspberrypi0w, raspberrypi4"
echo "usage: BUILDROOT_DIR=buildroot $0 (boardname) [component]"
echo "boardname: raspberrypi0, raspberry0_2, raspberrypi4"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, should be raspberrypi0_2

@@ -20,12 +20,12 @@ jobs:
build:
runs-on: ubuntu-20.04
env:
BUILDROOT_VERSION: '2021.02.4'
BUILDROOT_VERSION: '2021.08.2'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the buildroot people are still working on the Pi2 support, shall we wait for their stable release?

BUILDROOT_DIR: 'buildroot'

strategy:
matrix:
raspberry: ['raspberrypi0', 'raspberrypi0w', 'raspberrypi4']
raspberry: ['raspberrypi0', 'raspberrypi0_2', 'raspberrypi4']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to rework the naming to keep them consistent. Buildroot uses raspberrypizero2w, so we might use zero too instead of 0?

Or else raspberrypi0, raspberrypi0v2, raspberrypi4 etc.

@@ -129,8 +129,7 @@ jobs:
name: release

- name: Create checksums file
run: |
sha256sum "sdcard*" > CHECKSUMS.sha256
run: sha256sum sdcard* > CHECKSUMS.sha256
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a separate PR

@@ -0,0 +1,29 @@
# Please note that this is only a sample, we recommend you to change it to fit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really need this file, it's basically one from buildroot/board/raspberrypi/, so we might just copy it from there.

@@ -0,0 +1,29 @@
# Please note that this is only a sample, we recommend you to change it to fit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above

if [ $# -ge 1 ] ; then
make -C "output/$BOARDNAME" "$@"
else
make -C "output/$BOARDNAME" all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one

@@ -1,6 +1,6 @@
BR2_arm=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_KERNEL_HEADERS_5_10=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_10=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between those two?

BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_PICAM_PATH)/board/linux.config"
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,2a297702b85d53863458d698b60af4d8c3fc853f)/linux-2a297702b85d53863458d698b60af4d8c3fc853f.tar.gz"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_PICAM_PATH)/board/linux-additional-modules.config"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is nice, might even be easier to use our existing config overrides.

BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI_X=y
BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="$(BR2_EXTERNAL_PICAM_PATH)/board/config_0.txt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these are currently not existing in our setup, can you explain the changes?

@@ -0,0 +1,109 @@
config BR2_PACKAGE_RPI_FIRMWARE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above about package overrides

This kernel is needed for Raspberry Zero 2/2w support,
yet doesn't break traditional camera module.

It includes the device tree files for this board.
This change adds the following functionalities:

- Add Raspberry Pi Zero 2W support
- Consolidate Raspberry Zero support to one image
- Add the ability to override buildroot packages (in this case,
we override rpi-firmware package due to buildroot upstream hasn't
added support for Raspberry Pi Zero 2W)
- Allow build-showmewebcam.sh to take optional parameters

The build-showmewebcam.sh can now be called with a optional buildroot
package like so:

./build-showmewebcam.sh raspberrypi0 rpi-firmware
./build-showmewebcam.sh raspberrypi0 menuconfig

And so on. This simplifies manually calling those commands when we
just try to build a single package.

Fixes showmewebcam#168
It turns out that maintaining our linux configs is not a good idea.
This makes adding new board supports very hard, while we can mirror
what is buildroot does for the pis: Just use the foundation's
defconfig.

So this change deletes all of our linux defconfigs and just add
the modules that we want for showmewebcam to function, namely
board/linux-additional-modules.config.

This also add the post-image changes that is needed for this
almost-stock kernel to boot quickly and with the modules we desire.
The double quote doesn't allow the wildcard expansion, causing
the release to fail, so remove the double quotes.

Fixes showmewebcam#170
@dgsiegel
Copy link
Contributor

dgsiegel commented May 9, 2022

I am currently reworking this patch and preparing our setup to allow adding new boards (like the Pi0 2w) more easily in this new PR #197.

With the switch to libcamera, this is unfortunately harder than anticipated, so any help is highly appreciated!

@kbingham
Copy link

I've now discovered that there /is/ a hardware JPEG encoder on the new stack - I'm not sure how we missed it last time - so if anyone wants to try to resume this work - let me know and we can figure out how we make use of the hardware encoders on the Zero/Zero2.

@dgsiegel
Copy link
Contributor

I've now discovered that there /is/ a hardware JPEG encoder on the new stack - I'm not sure how we missed it last time - so if anyone wants to try to resume this work - let me know and we can figure out how we make use of the hardware encoders on the Zero/Zero2.

libcamera support is here: #197
How can one access the hardware encoders? Feel free to comment in the other PR.

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.

Support Raspberry Pi Zero 2 W
4 participants