Rasperry PI Device Configuration BALENA_HOST_CONFIG Bug?

Hi all, I am getting some odd behavior from the Balena Cloud Device Configuration page.

The document located at Advanced boot settings | balena indicates the following behavior:

BALENA_HOST_CONFIG_dtoverlay = i2c-rtc,ds1307 shall result in

dtoverlay=i2c-rtc,ds1307

in the /mnt/bott/config.txt file, and oddly enough, before I made a change in the Custom configuration section to try to set the above value to things did seem to work based on the original value which was set as “vc4-kms-v3d,cma-320” this resulted in properly in config.txt as dtoverlay=vc4-kms-v3d,cma-320.

After I made the addition under Custom Config to obtain the behavior of

dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch

first using

BALENA_HOST_CONFIG_dtoverlay = vc4-kms-dsi-waveshare-panel,4_0_inch

when that didn’t work using:
BALENA_HOST_CONFIG_dtoverlay = “vc4-kms-dsi-waveshare-panel,4_0_inch”

(notice the ““ because that syntax is also mentioned in the doc)

I am getting the following in the actual host

root@691f313:~# cat /mnt/boot/config.txt
avoid_warnings=1
disable_overscan=1
disable_splash=1
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
enable_uart=0
gpu_mem=16
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

And if I delete my custom config parameter to go back to the original, I now started getting:

root@691f313:~# cat /mnt/boot/config.txt
avoid_warnings=1
disable_overscan=1
disable_splash=1
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
enable_uart=0
gpu_mem=16
dtoverlay=vc4-kms-v3d
dtparam=cma-320

So please help me out here, how do i get balena to give me a properly edited config.txt file? One other clue here, until I edited the Custom Configs section it looked like balena was actually putting a default config.txt on the host device because it had a bunch of lines commented out in it after the change to Custom Configs section my config.txt only has the values set under the Device Congfiguration section, as shown in the cloud.

Let me also add that it looks like a previous response from the Balena team member ( Problems adding dtparam and dtoverlay variables in /boot/config.txt - #3 by shaunmulligan1 ) indicates that the dtparam=4_0_inch on a separate line should be equivalent to dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch, however this is not the case for the screen I am trying to get working which is documented here https://www.waveshare.com/wiki/4inch_DSI_LCD.

If i just use a vanilla install on raspberry pi (not using balena) and use dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch in config.txt the screen functions as it should.

Hello @efe

Which device type and balenaOS version are you using?

Let me also add that it looks like a previous response from the Balena team member ( Problems adding dtparam and dtoverlay variables in /boot/config.txt - #3 by shaunmulligan1 ) indicates that the dtparam=4_0_inch on a separate line should be equivalent to dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch, however this is not the case for the screen I am trying to get working which is documented here https://www.waveshare.com/wiki/4inch_DSI_LCD.

Yes,

dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

should be equivalent to dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch as per the official Raspberry Pi Foundation documentation: https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2

If i just use a vanilla install on raspberry pi (not using balena) and use dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch in config.txt the screen functions as it should.

As per the documentation you shared, it seems that you require both dtoverlay=vc4-kms-v3d and dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch, so the correct value for the config value should be:

BALENA_HOST_CONFIG_dtoverlay = "vc4-kms-v3d", “vc4-kms-dsi-waveshare-panel,4_0_inch” which should result in:

dtoverlay=vc4-kms-v3d
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

if you are using balena supervisor version 16+. This is highlighted in the docs.

Hope this helps. Let u know how it goes!

Rahul,

Thank you for your response. I agree with your recommendation and expectation of how balena should function in terms of creating the config.txt.

Let me start with providing a direct response regarding the OS level, i am currently using: balenaOS 6.5.50+rev3

As you suggested, I have the same expectations based on the documentation provided, I have set the values as you have also suggested (please see the attached images), but the output i am getting still looks like the following leading me to believe that there is a bug with the sub system parsing the strings from balena cloud UI and actually creating the config.txt files.

root@c5da87f:~# cat /mnt/boot/config.txt
avoid_warnings=1
disable_overscan=1
disable_splash=1
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
enable_uart=0
gpu_mem=16
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

@rahul to clarify my previous note the part of the documentation that doesn’t seem to be working is the section in the document you also referenced. Towards the end the document states:

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. For instance BALENA_HOST_CONFIG_dtoverlay = i2c-rtc,ds1307 will translate to: dtoverlay=i2c-rtc,ds1307

Even if i set my string without “ as vc4-kms-dsi-waveshare-panel,4_0_inch this does not translate into dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch which is the behavior I am explicitly seeking. And it looks like my device requires.

From the manufacturers doc, I need to be able to produce dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch in the actual config.txt, if i do this manually than the screen will work, how do I accomplish this using Balena cloud?

Hello @efe

Thanks for the additional context.

Just to confirm, I tried to reproduce this on a Raspberry Pi 4 running balenaOS 6.5.50+rev7 and supervisor version 17.0.3

When I use BALENA_HOST_CONFIG_dtoverlay = "vc4-kms-v3d", "vc4-kms-dsi-waveshare-panel,4_0_inch",

the following gets applied as expected:

root@4f9794b:~# cat /mnt/boot/config.txt 
avoid_warnings=1
disable_splash=1
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
enable_uart=0
gpu_mem=16
otg_mode=1
dtoverlay=vc4-kms-v3d
dtparam=cma-320
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

However, I did try to add BALENA_HOST_CONFIG_dtoverlay = vc4-kms-dsi-waveshare-panel,4_0_inch, no “quotes” and indeed, I’m still seeing

root@4f9794b:~# cat /mnt/boot/config.txt 
avoid_warnings=1
disable_splash=1
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
enable_uart=0
gpu_mem=16
otg_mode=1
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

which is a different behaviour from what’s described in the docs. I’m looking further into this and will get back.

Can you please confirm the following:

  • which device type are you using?
  • is only dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch required for the display to function? or do you also need vc4-kms-v3d? in your tests it seems you are only adding vc4-kms-dsi-waveshare-panel
  • have you tested with
dtoverlay=vc4-kms-v3d
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

on a vanilla Raspberry Pi OS setup and confirm that it does not work?

  • The reason I ask the above is because the documentation from the Raspberry Pi foundation mention that it should functionally be the same as dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch
  • did the manufacturer, waveshare, explicitly confirm that the dtoverlay definition should be on the same line? I’m not convinced of this because the raspberry pi firmware would interprete the separate dtparam line accordingly and setup the dtoverlay in the same way as dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch

Thanks

@rahul-thakoor Thank you again for the follow-up and validating the behavior on your end, let me respond to your questions in line:

Can you please confirm the following:

  • which device type are you using?
    [response] Raspberry Pi 3 (using 64bit OS) + waveshare 4inch DSI LCD. I do also have a Raspberry Pi 4 available but the behavior there doesn’t seem to be any different. I have reproduced the issue using Supervisor 17.2.0 and 17.0.3 on balenaOS 6.5.50+rev3. I also tried this on 2 instances spinning up a brand new device from scratch.

  • is only dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch required for the display to function? or do you also need vc4-kms-v3d? in your tests it seems you are only adding vc4-kms-dsi-waveshare-panel
    [response] only dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch is required. I do not need vc4-kms-v3d

  • have you tested with

dtoverlay=vc4-kms-v3d
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

on a vanilla Raspberry Pi OS setup and confirm that it does not work?

[response] yes i have tried both do not work on vanilla Raspberry Pi OS

dtoverlay=vc4-kms-v3d
dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch

and

dtoverlay=vc4-kms-dsi-waveshare-panel
dtparam=4_0_inch
  • The reason I ask the above is because the documentation from the Raspberry Pi foundation mention that it should functionally be the same as dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch
    [response] I agree in that I would have expected this to work but it seems like it does not

  • did the manufacturer, waveshare, explicitly confirm that the dtoverlay definition should be on the same line? I’m not convinced of this because the raspberry pi firmware would interprete the separate dtparam line accordingly and setup the dtoverlay in the same way as dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch
    [response I have reached out to Waveshare and have also created a ticket with them, and I am currently waiting for a response. I would again agree that if they are functionally equal (using dtparam vs ,) that it should be working. But this doesn’t seem to be the case. However, I again want to point out the Balena documentation explicitly states you should be able to make the config.txt contain dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inchby not using quotes “, but this doesn’t seem to be working. Thank you for your follow-up on this issue.

hello @efe

However, I again want to point out the Balena documentation explicitly states you should be able to make the config.txt contain dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inchby not using quotes “, but this doesn’t seem to be working. Thank you for your follow-up on this issue.

thanks for highlighting this issue. I have tested on my end and this behaviour is no longer applicable when using supervisor v16+. Even if you use a single overlay that has params, it will be added in the following format.

dtoverlay=
dtparam=

However, the above method is the recommended way of adding dtoverlays, and we have not seen any other reports as to this not working or causing compatibily issues.

Thanks for highlighting the errata in our docs, I will fix that.


So I want to circle back and confirm whether we are missing other things?

In particular you mention:

is only dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch required for the display to function? or do you also need vc4-kms-v3d? in your tests it seems you are only adding vc4-kms-dsi-waveshare-panel
[response] only dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch is required. I do not need vc4-kms-v3d

I checked the dtoverlay doc here: linux/arch/arm/boot/dts/overlays/README at 3829e1b98f3d2750b8b38abfdb4a142a0d8e4590 · raspberrypi/linux · GitHub

it mentions:
Requires vc4-kms-v3d to be loaded.

The docs from waveshare also include vc4-kms-v3d

So, can you please try again, but with the following
BALENA_HOST_CONFIG_dtoverlay = "vc4-kms-v3d", "vc4-kms-dsi-waveshare-panel,4_0_inch"

Also, please make sure you are using DSI1 interface.
Otherwise, you will have to adjust the dtoverlay to the following if you are using DSI0:

BALENA_HOST_CONFIG_dtoverlay = "vc4-kms-v3d", "dtoverlay=vc4-kms-dsi-waveshare-panel,4_0_inch,dsi0"

Hope this helps.
Rahul

Thank you for the response. Waveshare also responded. Using the string above, you suggested has resulted in my LCD screen functioning.

Thank you again