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

Add officially supported camera modules #1213

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

vivien
Copy link
Contributor

@vivien vivien commented Aug 15, 2023

This patchset adds support for the camera modules listed in the official documentation and simplify the configuration with a single RASPBERRYPI_CAMERA variable (and predefined aliases) to describe if and which camera model is used.

At the same time, add an empty config.txt template file to the rpi-config package, because relying on a commented out config file from a user github repository is error prone and only a few keys are added to the configuration anyway. Prefer to point the user to the official documentation instead.

@vivien
Copy link
Contributor Author

vivien commented Aug 21, 2023

This PR also fixes #1177 and #1197.

conf/machine/include/rpi-base.inc Show resolved Hide resolved
recipes-bsp/bootfiles/rpi-config_git.bb Show resolved Hide resolved
@@ -2,18 +2,16 @@ DESCRIPTION = "Commented config.txt file for the Raspberry Pi. \
The Raspberry Pi config.txt file is read by the GPU before \
the ARM core is initialised. It can be used to set various \
system configuration parameters."
HOMEPAGE = "https://www.raspberrypi.com/documentation/computers/config_txt.html"
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure what to say about this commit. I feel like users are used to the format and will end up with a pretty confusing change. @kraj what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really don't think that a commented out file was adding any value to the user. On the contrary, this was just cluttered and error prone. The only useful addition to the config file would be to echo the homepage URL as the first line so that the user knows where to look for documentation if they want to tweak the config, not scrolling a subjectively commented out file.

Copy link
Owner

@agherzan agherzan Aug 29, 2023

Choose a reason for hiding this comment

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

I see both sides - I'm unsure how to proceed.

Copy link
Owner

Choose a reason for hiding this comment

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

@kraj your thoughts on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

config.txt has detailed comments for an option, in-place sed keeps that intact. Non yocto users are familiar with this as well, since thats the first place people go to debug weird issues. So keeping the format has advantages. Sed is as reliable as echo, both are shell commands. They can fail in same ways. If sed can go wrong so can echo emit an older option and render system problems. So I am not buying echo is better than sed argument :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to clarify that there isn't an "original" config.txt file that we are overwriting with this PR. The initial recipe fetched an unofficial file from GitHub.

Different distributions come with their own config.txt files. For instance, RPI-Distro (formerly Raspbian) ships this one, while Arch Linux ARM ships this version. The choice of config.txt is determined by the distribution, not the recipe.

In fact, a minimal image can successfully boot with either no config.txt file or with the following content:

# Empty file
# Some settings may impact device functionality. Refer to the official documentation below for details.
# https://www.raspberrypi.com/documentation/computers/config_txt.html

As a BSP layer, our goal should be to provide a clean default configuration with minimal adjustments. Distributions have the flexibility to further customize the configuration using conditional filters, additional files like autoboot.txt, or any configuration fragments enabled with the include directive, as outlined in the documentation.

Following best practices, it would be advisable to list rpi-config in MACHINE_EXTRA_RDEPENDS to prevent core-image-minimal from installing the file by default, while allowing other core images to include it. In the meantime, I kindly request that @kraj and @agherzan carefully consider this comment and refrain from advocating for the use of an unofficial text file on the internet, as it may not align with established best practices.

Copy link
Owner

Choose a reason for hiding this comment

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

I would recommend this being split in another PR. It does not directly support the camera modules and we can have more public visibility on this in this way.

Choose a reason for hiding this comment

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

I would personally prefer a minimal config.txt that isn't filled with every option imaginable.

Copy link
Owner

Choose a reason for hiding this comment

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

@vivien I started to lean into that, too - with the reoccurrence of the config.txt size issues in RPI5. @kraj I think we should start considering this as a cleaner solution forward.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes documentation can be moved out of config file and perhaps not a bad idea, one problem I do see though is it may be out of sync with whats installed on the system and that could be confusing, so there is value in capturing the comments but I think we can make that compromize. We hardly edit this on device.

recipes-bsp/bootfiles/rpi-config.bb Show resolved Hide resolved
Sort kernel device tree overlays alphabetically.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Add the device tree overlays for the supported cameras as listed on
https://www.raspberrypi.com/documentation/computers/camera_software.html#if-you-do-need-to-alter-the-configuration

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
The rpi-config package uses a mixture of sed -i $CONFIG and echo >>
$CONFIG commands in order to customize the config.txt file.

Because relying on commented out option is error prone, replace all
sed -i occurrences with the echo alternative.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Relying on a commented out config file fetched from a user Github
repository is likely error prone and misleading. The best practice
is to direct the user to the official documentation describing the
complete list of supported configuration keys.

Only a few keys are added to the config.txt file anyway, so start
from an empty file that the user may override if necessary.

Move the config.txt tweak code into do_compile for clarity and to
ensure that the 80 character wide check is done once the file is
modified, not in between appended modifications.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
recipes-bsp/bootfiles/rpi-config.bb Show resolved Hide resolved
RASPBERRYPI_CAMERA ??= "auto"
RASPBERRYPI_CAMERA_V1 = "ov5647"
RASPBERRYPI_CAMERA_V2 ?= "imx219"
RASPBERRYPI_CAMERA_HQ = "imx477"
Copy link
Owner

Choose a reason for hiding this comment

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

What uses some of these variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These variables describe the common values and are optionally used by the user to assign RASPBERRYPI_CAMERA if they wish not to explicit the actual model name.

Copy link
Owner

Choose a reason for hiding this comment

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

Can you give me an example?

Copy link
Contributor Author

@vivien vivien Sep 21, 2023

Choose a reason for hiding this comment

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

RASPBERRYPI_CAMERA = "${RASPBERRYPI_CAMERA_V2}", it's optional, but convenient in order to avoid case sensitive errors or other typos. I'll update the doc to reflect that as well. One may even append overlay parameters if they wish to, e.g. RASPBERRYPI_CAMERA = "imx219,rotation=0".

Copy link
Owner

Choose a reason for hiding this comment

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

I propose keeping this simple with only RASPBERRYPI_CAMERA and giving documentation examples of its values. Having indirect definitions and keeping them updated with new variables is a situation that might cause more confusion.

Instead of using many inconsistent variable flags like
VIDEO_CAMERA, RASPBERRYPI_CAMERA_V2, RASPBERRYPI_CAMERA_V3 or
RASPBERRYPI_HD_CAMERA, use a single RASPBERRYPI_CAMERA variable,
defaulting to "auto" for automatic camera detection, which can
be set to a specific camera module name or alias as described in
https://www.raspberrypi.com/documentation/computers/camera_software.html#if-you-do-need-to-alter-the-configuration

For convenience, provide variables for predefined values describing the
officially supported camera devices listed in the above documentation.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Reword the camera module section to describe the usage of the new
RASPBERRYPI_CAMERA variable.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
@vivien
Copy link
Contributor Author

vivien commented Sep 26, 2023

See this comment for explanation behind the motivation for a clean config file.

@vivien vivien requested a review from agherzan October 6, 2023 16:31
conf/machine/include/rpi-base.inc Show resolved Hide resolved
recipes-bsp/bootfiles/rpi-config_git.bb Show resolved Hide resolved
@@ -2,18 +2,16 @@ DESCRIPTION = "Commented config.txt file for the Raspberry Pi. \
The Raspberry Pi config.txt file is read by the GPU before \
the ARM core is initialised. It can be used to set various \
system configuration parameters."
HOMEPAGE = "https://www.raspberrypi.com/documentation/computers/config_txt.html"
Copy link
Owner

Choose a reason for hiding this comment

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

I would recommend this being split in another PR. It does not directly support the camera modules and we can have more public visibility on this in this way.

RASPBERRYPI_CAMERA ??= "auto"
RASPBERRYPI_CAMERA_V1 = "ov5647"
RASPBERRYPI_CAMERA_V2 ?= "imx219"
RASPBERRYPI_CAMERA_HQ = "imx477"
Copy link
Owner

Choose a reason for hiding this comment

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

I propose keeping this simple with only RASPBERRYPI_CAMERA and giving documentation examples of its values. Having indirect definitions and keeping them updated with new variables is a situation that might cause more confusion.


Similarly, the Raspberry Pi Camera Module v3 also has to be explicitly enabled in local.conf.
RASPBERRYPI_CAMERA = "${RASPBERRYPI_CAMERA_V3}"
Copy link
Owner

Choose a reason for hiding this comment

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

There are more values possible here. I would only keep RASPBERRYPI_CAMERA and have examples of direct assignments instead of having to document indirect variables.

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.

4 participants