How to change the display resolution of the Ubuntu on VIM3

Dear technical supporter,

Now, I am using Ubuntu OS 18.04 after flashing Ubuntu image (VIM3_Ubuntu-xfce-bionic_Linux-4.9_arm64_SD-USB_V20190830.7z) into micro-SDcard on VIM3 Pro development board.

I want to use the 1024x768 resolution for my small monitor (11"). How can I change the display resoultion of the Ubuntu OS on VIM3 Pro board?

BRs,
Geunsik.

I have added HDMI resolution UI setting menu for next release in this month, please wait…

Thanks. BTW, can I change the resolution in the console manually before using the next version that will be released by @numbqq?

Yes, you can use this script to setup the resolution:

$ cat hdmi.sh
#!/bin/sh


hpd_state=`cat /sys/class/amhdmitx/amhdmitx0/hpd_state`
#bpp=24
bpp=32
mode=${1:-720p60hz}
#mode=2160p60hz
#mode=720p60hz

if [ $hpd_state -eq 0 ]; then
	# Exit if HDMI cable is not connected
	exit 0
fi

common_display_setup() {
	M="0 0 $(($X - 1)) $(($Y - 1))"
	Y_VIRT=$(($Y * 2))
	fbset -fb /dev/fb0 -g $X $Y $X $Y_VIRT $bpp
	echo null > /sys/class/display/mode
	echo $mode > /sys/class/display/mode
	echo $M > /sys/class/graphics/fb0/free_scale_axis
	echo $M > /sys/class/graphics/fb0/window_axis

	echo 0 > /sys/class/graphics/fb0/free_scale
	echo 1 > /sys/class/graphics/fb0/freescale_mode
}

case $mode in
	480*)
		export X=720
		export Y=480
		;;
	576*)
		export X=720
		export Y=576
		;;
	720p*)
		export X=1280
		export Y=720
		;;
	1080*)
		export X=1920
		export Y=1080
		;;
	2160p*)
		export X=3840
		export Y=2160
		;;
	smpte24hz*)
		export X=3840
		export Y=2160
		;;
	640x480p60hz*)
		export X=640
		export Y=480
		;;
	800x480p60hz*)
		export X=800
		export Y=480
		;;
	800x600p60hz*)
		export X=800
		export Y=600
		;;
	1024x600p60hz*)
		export X=1024
		export Y=600
		;;
	1024x768p60hz*)
		export X=1024
		export Y=768
		;;
	1280x800p60hz*)
		export X=1280
		export Y=800
		;;
	1280x960p60hz*)
		export X=1280
		export Y=960
		;;
	1280x1024p60hz*)
		export X=1280
		export Y=1024
		;;
	1360x768p60hz*)
		export X=1360
		export Y=768
		;;
	1400x1050p60hz*)
		export X=1400
		export Y=1050
		;;
	1440x900p60hz*)
		export X=1440
		export Y=900
		;;
	1600x900p60hz*)
		export X=1600
		export Y=900
		;;
	1680x1050p60hz*)
		export X=1680
		export Y=1050
		;;
	1600x1200p60hz*)
		export X=1600
		export Y=1200
		;;
	1920x1200p60hz*)
		export X=1920
		export Y=1200
		;;
	2560x1080p60hz*)
		export X=2560
		export Y=1080
		;;
	2560x1440p60hz*)
		export X=2560
		export Y=1440
		;;
	2560x1600p60hz*)
		export X=2560
		export Y=1600
		;;
	3440x1440p60hz*)
		export X=3440
		export Y=1440
		;;
esac

common_display_setup

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

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

echo 1 > /sys/devices/virtual/graphics/fbcon/cursor_blink

exit 0

################# manual ######################

# 480 Lines (720x480)
# "480i60hz" Interlaced 60Hz
# "480i_rpt" Interlaced for Rear Projection Televisions 60Hz
# "480p60hz" 480 Progressive 60Hz
# "480p_rpt" 480 Progressive for Rear Projection Televisions 60Hz

# 576 Lines (720x576)
# "576i50hz" Interlaced 50Hz
# "576i_rpt" Interlaced for Rear Projection Televisions 50Hz
# "576p50hz" Progressive 50Hz
# "576p_rpt" Progressive for Rear Projection Televisions 50Hz

# 720 Lines (1280x720)
# "720p50hz"  50Hz
# "720p60hz"  60Hz

# 1080 Lines (1920x1080)
# "1080i60hz" Interlaced 60Hz
# "1080p60hz" Progressive 60Hz
# "1080i50hz" Interlaced 50Hz
# "1080p50hz" Progressive 50Hz
# "1080p24hz" Progressive 24Hz

# 4K (3840x2160)
# "2160p30hz"    Progressive 30Hz
# "2160p25hz"    Progressive 25Hz
# "2160p24hz"    Progressive 24Hz
# "smpte24hz"    Progressive 24Hz SMPTE
# "2160p50hz"    Progressive 50Hz
# "2160p60hz"    Progressive 60Hz
# "2160p50hz420" Progressive 50Hz with YCbCr 4:2:0 (Requires TV/Monitor that supports it)
# "2160p60hz420" Progressive 60Hz with YCbCr 4:2:0 (Requires TV/Monitor that supports it)

### VESA modes ###
# "640x480p60hz"
# "800x480p60hz"
# "800x600p60hz"
# "1024x600p60hz"
# "1024x768p60hz"
# "1280x800p60hz"
# "1280x1024p60hz"
# "1360x768p60hz"
# "1440x900p60hz"
# "1600x900p60hz"
# "1680x1050p60hz"
# "1600x1200p60hz"
# "1920x1200p60hz"
# "2560x1080p60hz"
# "2560x1440p60hz"
# "2560x1600p60hz"
# "3440x1440p60hz"

# HDMI BPP Mode
# "32"
# "24"
# "16"

How to use?

Switch to root, and execute:

$ sudo -i
# ./hdmi.sh 1024x768p60hz

sudo -i
./hdmi.sh 1024x768p60hz
It’s strange. When I tried to run the “hdmi.sh” script file, the result is as follows.

I wrote a simple script to find out a reason why the script is failed.
Could you give me some hint from the below script?

$ sudo  hdmi-800x600.sh

#!/usr/bin/env bash

# Declare X, Y resolution
export X=800
export Y=600

# get bpp and  mode
hpd_state=`cat /sys/class/amhdmitx/amhdmitx0/hpd_state`
#bpp=24
bpp=32
mode=${1:-720p60hz}
#mode=2160p60hz
#mode=720p60hz

if [ $hpd_state -eq 0 ]; then
    # Exit if HDMI cable is not connected
    exit 0
fi

# Set-up a frame-buffer with sysfs to change a display resolution
M="0 0 $(($X - 1)) $(($Y - 1))"
Y_VIRT=$(($Y * 2))
fbset -fb /dev/fb0 -g $X $Y $X $Y_VIRT $bpp
echo null > /sys/class/display/mode
echo $mode > /sys/class/display/mode
echo $M > /sys/class/graphics/fb0/free_scale_axis
echo $M > /sys/class/graphics/fb0/window_axis
echo 0 > /sys/class/graphics/fb0/free_scale
echo 1 > /sys/class/graphics/fb0/freescale_mode

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

# Blank fb1 to prevent static noise
echo 1 > /sys/class/graphics/fb1/blank
echo 1 > /sys/devices/virtual/graphics/fbcon/cursor_blink

exit 0

It’s strange. I cannot still get the 800x600 (or 1024x768) resolution when I tried to run the “hdmi-800x600.sh” (simple script) on the terminal.
@numbqq , Could you give me a hint to fix this issue? Any comments will be helpful to me.

What about ./hdmi-800x600.sh 800x600p60hz ?

Nice catch. BTW, I got the same result as follows when I ran “./hdmi-800x600.sh 800x600p60hz” command in the console.

Oh no, under desktop mode you can’t this, for framebuffer console it works well.

Can you try this ? ssh to the board and execute the following commands.

$ sudo -i
# systemctl stop lightdm
# ./hdmi-800x600.sh 800x600p60hz
# systemctl restart lightdm
3 Likes

I also fixed this issue thanks to your comments. The below script is the final version of the resolution conversion script. Now, I successfully get the 800x600 resolution with my 7" monitor.

$ vi hdmi-800x600.sh

#!/usr/bin/env bash

#  @titile The resoltuion convertor for lots of monitors
#  @brief  This file is a simple script to convert the current mode
#          to the different resoltuion for various monitors.
#  @author Khadas Team <numbqq@khadas.com>
#          Geunsik Lim <leemgs@gmail.com>
#  @note
#  $ sudo systemctl stop lightdm
#  $ sudo ./hdmi-800x600.sh
#  $ sudo systemctl restart lightdm
#
#  ### VESA modes ###
# "640x480p60hz"
# "800x480p60hz"
# "800x600p60hz"
# "1024x600p60hz"
# "1024x768p60hz"
# "1280x800p60hz"
# "1280x1024p60hz"
# "1360x768p60hz"
# "1440x900p60hz"
# "1600x900p60hz"
# "1680x1050p60hz"
# "1600x1200p60hz"
# "1920x1200p60hz"
# "2560x1080p60hz"
# "2560x1440p60hz"
# "2560x1600p60hz"
# "3440x1440p60hz"


# Declare X, Y, and mode
export X=800
export Y=600
export mode="${X}x${Y}p60hz"

#----------------- DO NOT MODIFY FROM THIS LINE ---------------------
# Turn-off display manager
sudo systemctl stop lightdm

# Define a HDMI bpp and a resolution mode
bpp=32
_mode=${mode:-720p60hz}

echo -e "The _mode will be set with '$_mode'."

hpd_state=`cat /sys/class/amhdmitx/amhdmitx0/hpd_state`
if [ $hpd_state -eq 0 ]; then
    # Exit if HDMI cable is not connected
    echo -e "Oooops. HDMI cable is not connected."
    exit 0
fi

# Set-up a frame-buffer with sysfs to change a display mode
M="0 0 $(($X - 1)) $(($Y - 1))" 
Y_VIRT=$(($Y * 2)) 
fbset -fb /dev/fb0 -g $X $Y $X $Y_VIRT $bpp 
echo null   > /sys/class/display/mode 
echo $_mode > /sys/class/display/mode 
echo $M     > /sys/class/graphics/fb0/free_scale_axis 
echo $M     > /sys/class/graphics/fb0/window_axis 
echo 0      > /sys/class/graphics/fb0/free_scale 
echo 1      > /sys/class/graphics/fb0/freescale_mode

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

# Blank fb1 to prevent static noise 
echo 1 > /sys/class/graphics/fb1/blank 
echo 1 > /sys/devices/virtual/graphics/fbcon/cursor_blink 

# Turn-on display manager
sudo systemctl restart lightdm

echo -e "Done."
2 Likes

I have added HDMI resolution UI menu in next release, it will be easier to change the resolutions.

1 Like

Thanks in advance. :slight_smile:

After reboot the preffered screen resolution is lost and returning to the old
At Settings “Display” the is only one resolution to choose 1920x1080.
How to save the resolution ,(ex at 1024x768? )

Edit /boot/env.txt to setup your resolution.

Hi @numbqq,

In the new release as well I can see only 1920x1080 resolution. Can you publish a guide so that we can do it on our own please. Thank you!

Regards,
Prateek

Please check: Applications->Settings->HDMI Resolution Setting

I need a screen resolution of 1280x480p60hz. What can I do to add support for it?

1 Like