Problems adding dtparam and dtoverlay variables in /boot/config.txt

hi

I have a complete python program running and working correctly on RPI4 CM using IO Board. My boot/config.txt file have the following configurations for the two MIPI-CSI Cameras which I want to add to my Balena Image in order to have the program working with Balena OS.

# One ov5647 camera in MIPI-CSI0 interface
# One ov5647 camera in MIPI-CSI1 interface
#camera_auto_detect=1
dtoverlay=ov5647,cam0
dtoverlay=ov5647,cam1

# For sd card
dtoverlay=sd0,overclock_50=50

In my fleet configurations RESIN_HOST_CONFIG_dtoverlay I added the following configurations:
"vc4-kms-v3d", "spi01cs", "ov5647,cam0", "ov5647,cam1", "max98357a", "sd0,overclock_50=50"

Then when I run balena ssh to get access to it and run the command:

cat /mnt/boot/config.txt

I got the result:

dtoverlay=ov5647
dtparam=cam0
dtoverlay=ov5647
dtparam=cam1
dtoverlay=sd0
dtparam=overclock_50=50

How to ensure that cam0, cam1 and overclock_50=50 values are not parsed as different parameters?

As the documentation says here, the Supervisor v16+ modifies each parameter to be on its own line in order to avoid the 80 character line limit imposed by config.txt. It is the recommended method of setting one or more overlays with their own parameters. This parsing will only be done if the value is a valid string, so if it doesn’t begin with a quote ", the value will be parsed as a single string and not split into several lines.

So I change this:
"vc4-kms-v3d", "spi0-1cs", "ov5647,cam0", "ov5647,cam1", "max98357a", "sd0,overclock_50=50"

To this:
`“vc4-kms-v3d”, “spi0-1cs”, ov5647,cam0, “max98357a”, ov5647,cam1, “sd0,overclock_50=50”

However still don’t work. Still get:

dtoverlay=ov5647
dtparam=cam0
dtoverlay=ov5647
dtparam=cam1
dtoverlay=sd0
dtparam=overclock_50=50

Hi @embedded what is the failure mode that you are seeing when the dtparams are set on individual lines? Do you find that cam1 is not activating? As far as I understand the config.txt you posted above should be valid and work on raspberry pi OS, is that not the case for you?

The reason I ask what error you are seeing and how this is failing for you is that because according to https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2 of the bootloader documentation the config.txt you want and the one balenaOS creates for you are functionally equivalent since the Overlay parameters are only in scope until the next overlay is loaded. So the first dtparam=cam0 will only apply to first dtoverlay=ov5647 and dtparam=cam1 will only apply to the second dtoverlay=ov5647. So the result is the same. If the cameras are not enumerating correctly on balenaOS it could be that the problem is elsewhere.

2 Likes

Hi

Indeed. The problem is no longer due to wrong settings in the /boot/config.txt file, but rather to the lack of libcamera in the balena image (which usually is a default in rpi images I guess).

I’m trying to install libcamera from docker with the following configuration:

FROM balenalib/raspberrypicm4-ioboard-python:3.11-bullseye-run

# Update and install dependencies including git
RUN apt-get update && apt-get install -y \
    build-essential \
    cmake \
    meson \
    ninja-build \
    python3-dev \
    python3-pip \
    git \
    libboost-dev \
    libgnutls28-dev \
    libjpeg-dev \
    libpng-dev \
    libtiff-dev \
    libevent-dev \
    libunwind-dev \
    libdrm-dev \
    libexif-dev \
    libxkbcommon-dev \
    qtbase5-dev \
    qtchooser \
    qt5-qmake \
    qtbase5-dev-tools && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Clone the libcamera repository
RUN git clone https://git.libcamera.org/libcamera/libcamera.git /usr/local/src/libcamera

# Change directory to libcamera source
WORKDIR /usr/local/src/libcamera

# List the contents to verify the clone
RUN ls -la

# Setup the meson build system
RUN meson setup build

# Build and install libcamera
RUN ninja -C build
RUN ninja -C build install

However the build is always failing:

[Error]        Some services failed to build:
[Error]        Service: my-service
[Error]        Error: The command '/bin/sh -c meson setup build' returned a non-zero code: 1
[Info]          Built on c617b98
[Error]        Not deploying release.

I also tried with the RPI fork of libcamera, but without success. There is some problem with the meson package.

Hey there, I just tried this from my CM4 which is running FROM balenalib/raspberrypi3-debian:build and then just did an apt install libcamera-apps which appears to work. It does need to install about 231MB of packages but it works :smiley:

It could be that for some reason the raspberrypicm4-ioboard-python base image doesn’t include the correct set of available source lists. So one way forward is to just switch your base image to the one above and install python, etc as you need. It should give you the same performance and functionality as the CM4 base image.