System-boot/config.txt from RPI 3 on ubuntu core 18 gets overwritten

I try to set custom HDMI resolution for my RPI3 in system-boot/config.txt like so:

# uncomment to force a specific HDMI mode (here we are forcing 800x480!)
hdmi_cvt=800 480 60 6 0 0 0

But after a reboot i find them like this:

# uncomment to force a specific HDMI mode (here we are forcing 800x480!)
hdmi_cvt=800 480 60 6 0 0 0

First the system loads the new config, the HDMI has the new 800x480 resolution, but after a later reboot, the config.txt auto comments those lines.
Any ideea why?

i would not expect snapd (or any other part of a core18 install) to touch config.txt unless you are using any of the system config option defaults in your gadget.yaml like:

do you happen to use any of there ?
(beyond this, you perhaps should use them and ask for additional integration of hdmi_cvt)

I have set the hdmi-* options as you said with

snap set system ...

The hdmi_cvt remained uncommented in config.txt.

It seems it worked.

1 Like

Here’s a PR to snapd which will let you do snap set system pi-config.hdmi_cvt="...":


I’m trying to configure the HDMI mode as well. I am running core20 on a RPI4.
I made sure to include @ijohnson 's PR (snap refresh snapd --edge), and I’m now running snapd 2.49.2+git1051.ge408012.
What worked was using the dash hdmi-cvt and not the underscore hdmi_cvt
snap set system pi-config.hdmi-cvt="1024 600 60 6 0 0 0"

However, I haven’t had success in confirming if any of these HDMI changes are being applied (the screen looks the same with and without). I can confirm my values are being set by seeing them listed with snap get system pi-config.

The obvious visual confirmation if the modes are being applied is a 90 Deg rotation (pi-config.display-rotate=1), which I do not see.

Furthermore, I don’t know where to find the config.txt file, can someone let me know the full path to the file? By looking around I found /writable/system-data/var/lib/snapd/seed/config.txt, but from what I understand I should not make changes in this file in Core20 (as it gets re-created at boot?).

in UC20 it moved to /run/mnt/ubuntu-seed/

Ah if you are running on UC20, you are running into, which will be fixed with

Thanks for the fast response. I’ll keep an eye out for when that PR gets merged. In the meantime I’m trying out the manual editing of /run/mnt/ubuntu-seed/config.txt, I think I’m seeing some screen changes (the resolution seems different), but the rotation is not happening—It’s staying in portrait.

Just to make sure here, I’m looking at the UbuntuCore welcome text “The host key fingerprints are… To login ssh …” to confirm if the rotation’s being applied. I am assuming this text will be rotated.

Are there logs I can look for to see if the options from config.txt are being ignored/ if the options are failing and it’s rolling back?

the rotation might not work if the fkms overlay is active …
(just guessing though)

1 Like

That was spot-on, thanks!
In case someone else encounters this, comment-out vc4-fkms-v3d and replace with vc4-kms-v3d (I also removed the cma-128) from /run/mnt/ubuntu-seed/config.txt:


If the pi-gadget updates itself, will the update overwrite config.txt? I am asking because it looks like the fkms fix only works by editing config.txt since it affects the dtparam/ dtoverlay parameters, and I can’t find any integration of pi-config system options for these options (besides maybe making my own gadget, I wouldn’t know how to reliably change them).

Would it be considered bad practice to directly edit the config.txt file as I see fit (and just skip using the snap set system ... method)?

If you edit values in config.txt which are simultaneously set with snap set system, then upon the next snap refresh or the next snap set (even for an unrelated system config, not necessarily something pi related), you could have you manual changes undone or overwritten by the ones that are saved in snapd. You are best off having no config set for pi-config on the system if you wish to manually control config.txt entirely.

Regarding if a gadget asset update would overwrite the config.txt, it is technically possible via gadget asset updates, but these must be manually opted into by the gadget snap maintainer when they update the gadget by adding specific values to the gadget.yaml referencing which files should be updated. By default just changing the assets themselves (like the DTBs, overlays, config.txt etc.) and rebuilding and uploading a new revision of the gadget snap will not update the files on existing installations.

Additionally, it is highly unlikely that Canonical’s gadget snap maintainers would ever actually deliver a gadget asset update to the config.txt even if technically possible, specifically because of the issue with it being modifiable via snap config settings, and so it would have to be done very carefully and probably require changes in snapd so that if the config.txt was updated by a gadget asset update, then snapd would automatically re-apply the config on top of the config.txt before rebooting to apply the effects of the gadget asset update. The complexity here means we are extremely unlikely to do this except perhaps in the most dire of cases like where not doing so means bricked devices or critical security vulnerabilities which would be very surprising to see happen at the level of config.txt.

I hate to revive an old thread, but now that a lot of the discussed changes are released on the edge channel, I am retrying some stuff. This pertains to UC20 on a RPi4, so perhaps it’s now off-topic (if so, I can make a new post)?

I’m no longer able to get 90 degree screen rotation using the methods described here: i) editing directly /run/mnt/ubuntu-seed/config.txt ii) on a custom gadget, which already have those values in its config.txt or iii) using snap set system pi-config.display-rotate.
HOWEVER, by looking around for logs dmesg | grep hdmi, I stumbled across the kernel command line:
... video=HDMI-A-1:1024x600M@60,margin_left=0,margin_right=24,margin_top=0,margin_bottom=0 ...
and realized the rotation isn’t making its way to the kernel command. I decided to try copy pasting it as cmdline.txt after adding rotate=90 and the screen is now rotated the way I want it (actually, rotate=270).

my complete cmdline.txt

coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 video=HDMI-A-1:1024x600M@60,margin_left=0,margin_right=24,margin_top=0,margin_bottom=0 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=0 video=HDMI-A-1:1024x600M@60,margin_left=0,margin_right=24,margin_top=0,margin_bottom=0,rotate=270 smsc95xx.macaddr=DC:A6:32:6D:44:AC vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 elevator=deadline rng_core.default_quality=700 vt.handoff=2 splash quiet splash snapd_recovery_mode=run snapd_recovery_system=20210507 panic=-1 systemd.gpt_auto=0 quiet splash snapd_recovery_mode=run snapd_recovery_system=20210507 panic=-1 systemd.gpt_auto=0

I feel this method of writing directly to cmdline.txt is a bit of a hack and not “proper”. Did anything happen to the rotation directives from config.txt for them to no longer propagate to cmdline.txt?

they have always only applied to the proprietary driver … as soon as you use kms/fkms overlays you wont be able to use them … and our kernels nowdays always use fkms … (you can drop the overlay in config.txt and the old rotation directives will work again (but Mir wont for example))

I finally have it working the way I want (using the legacy drivers) and the following in config.txt:

hdmi_cvt=1024 600 60 6 0 0 0

I did that by writing them in pi-gadget/configs/core)/config.txt.arm64 and rebuilding the gadget.

The first boot seems to work nicely, I see the snaps are started and the display is OK. If I perform a single reboot however, I see that the lines have been commented-out (just like in the original post) and the display is back to landscape.

I want this to be a production device gadget, and so I don’t want to ssh in every devices and have to execute the list of snap set system pi-config.bleh... configs. Is there a place where I can set them (perhaps on the pi-gadget?) ahead of time?

OK, added some stuff to gadget.yaml which should work,

      display-rotate: 1
      hdmi-cvt: "1024 600 60 6 0 0 0"
      hdmi-group: 2
      hdmi-mode: 87
      hdmi-drive: 1
      overscan-right: 24
      framebuffer-depth: 32

I’m not sure about wrapping the hdmi-cvt value as a string, but it feels right.