Change screen resolution permanently

So I have installed Ubuntu (exactly VIM2_Ubuntu-mate-16.04_Linux-4.9_V171028 from FirmwareResources page).

The problem is that normally I don’t have access to 1080p monitor and I got error message on monitor about unsupported resolution.

I plugged the Khadas to other monitor supporting 1080p, I tried to change resolution, but on the Display settings the only option is 1080p.

I have tried to change the resolution by modyfying /sys/class/display/mode to 720p60hz.
The screen resolution is changed to 720p, but after a reboot this changes back to 1080p.

Is there a way to add other resolutions to Display Settings (like 720p,480p and possibly others), because now I’m not able to use Khadas on my own monitor.

Thanks a lot.

Hi BonusBGC,

When you change the resolution to 720p60hz, dose it display OK ?

Try to add HDMI service to setup resolution via serial uart

Update khadas_init.sh

khadas@Khadas:~$ sudo tee /etc/initramfs-tools/scripts/local-top/khadas_init.sh <<-EOF
#!/bin/sh                                                                   

bpp=32

#mode=1080p60hz
mode=720p60hz

case \$mode in
       1080*)
       fbset -fb /dev/fb0 -g 1920 1080 1920 2160 \$bpp
       fbset -fb /dev/fb1 -g 32 32 32 32 32
       echo \$mode > /sys/class/display/mode
       echo 0 > /sys/class/graphics/fb0/free_scale
       echo 1 > /sys/class/graphics/fb0/freescale_mode
       echo 0 0 1919 1079 > /sys/class/graphics/fb0/free_scale_axis
       echo 0 0 1919 1079 > /sys/class/graphics/fb0/window_axis
       echo 0 > /sys/class/graphics/fb1/free_scale
       ;;
      *)
       fbset -fb /dev/fb0 -g 1280 720 1280 1440 \$bpp
       fbset -fb /dev/fb1 -g 32 32 32 32 32
       echo \$mode > /sys/class/display/mode
       echo 0 > /sys/class/graphics/fb0/free_scale
       echo 1 > /sys/class/graphics/fb0/freescale_mode
       echo 0 0 1279 719 > /sys/class/graphics/fb0/free_scale_axis
       echo 0 0 1279 719 > /sys/class/graphics/fb0/window_axis
       echo 0 > /sys/class/graphics/fb1/free_scale
       ;;
esac

# Enable framebuffer device
echo 0 > /sys/class/graphics/fb0/blank

# Blank fb1 to prevent static noise
echo 1 > /sys/class/graphics/fb1/blank

echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
EOF

Add executable permition to khadas_init.sh

khadas@Khadas:~$ sudo chmod +x /etc/initramfs-tools/scripts/local-top/khadas_init.sh

Recreate uInitrd

khadas@Khadas:~$ sudo mkinitramfs -o /boot/initrd.img 4.9.40
khadas@Khadas:~$ sudo mkimage -A arm64 -O linux -T ramdisk -a 0x0 -e 0x0 -n "initrd"  -d /boot/initrd.img  /boot/uInitrd
khadas@Khadas:~$ sudo sync

Add HDMI service

khadas@Khadas:~$ sudo tee /lib/systemd/system/0hdmi.service <<-EOF
[Unit]
Description=HDMI init
DefaultDependencies=no
Wants=rsyslog.service systemd-journald.service
Before=syslog.target sysinit.target
After=local-fs.target

[Service]
Type=oneshot
ExecStart=/boot/hdmi.sh
RemainAfterExit=no

[Install]
WantedBy=sysinit.target
EOF

Add HDMI service script

khadas@Khadas:~$ sudo tee /boot/hdmi.sh <<-EOF
#!/bin/sh

bpp=32

#mode=1080p60hz
mode=720p60hz

case \$mode in
       1080*)
       fbset -fb /dev/fb0 -g 1920 1080 1920 2160 \$bpp
       fbset -fb /dev/fb1 -g 32 32 32 32 32
       echo \$mode > /sys/class/display/mode
       echo 0 > /sys/class/graphics/fb0/free_scale
       echo 1 > /sys/class/graphics/fb0/freescale_mode
       echo 0 0 1919 1079 > /sys/class/graphics/fb0/free_scale_axis
       echo 0 0 1919 1079 > /sys/class/graphics/fb0/window_axis
       echo 0 > /sys/class/graphics/fb1/free_scale
       ;;
      *)
       fbset -fb /dev/fb0 -g 1280 720 1280 1440 \$bpp
       fbset -fb /dev/fb1 -g 32 32 32 32 32
       echo \$mode > /sys/class/display/mode
       echo 0 > /sys/class/graphics/fb0/free_scale
       echo 1 > /sys/class/graphics/fb0/freescale_mode
       echo 0 0 1279 719 > /sys/class/graphics/fb0/free_scale_axis
       echo 0 0 1279 719 > /sys/class/graphics/fb0/window_axis
       echo 0 > /sys/class/graphics/fb1/free_scale
       ;;
esac

# Enable framebuffer device
echo 0 > /sys/class/graphics/fb0/blank

# Blank fb1 to prevent static noise
echo 1 > /sys/class/graphics/fb1/blank

echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
EOF

Add executable permition to /boot/hdmi.sh

khadas@Khadas:~$ sudo chmod +x /boot/hdmi.sh
khadas@Khadas:~$ sudo systemctl enable 0hdmi
khadas@Khadas:~$ sudo sync
khadas@Khadas:~$ sudo reboot

You can modify mode in script /boot/hdmi.sh to change the resolution.

mode=720p60hz set resolution to 720P
mode=1080p60hz set resolution to 1080P

Thanks.

1 Like