Enable the shield

Hardkernel LCD shields are easily enabled by editing a config file. In your Odroid board, open the /media/boot/config.ini file with your favorite text editor.

$ sudo vi /media/boot/config.ini

Then you can see the DTBO part at the bottom of the file. That contents may look similar to the below.

; Device Tree Overlay
overlay_resize=16384
overlay_profile=
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_hktft_cs_ogst]
overlays="hktft-cs-ogst"

Edit a line corresponding to line #3 of the above code block. You can choose an overlay profile by editing this line.

In this case, since we want to use the 3.2 inch TFT LCD Shield, we will edit this line to point to the overlays_hktft32 profile by adding the word hktft32.

This works in the same way for the 3.5 inch TFT LCD Shield.

Then it should look like the below.

3.2 inch LCD Shield

; Device Tree Overlay
overlay_resize=16384
overlay_profile=hktft32
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_hktft_cs_ogst]
overlays="hktft-cs-ogst"

3.5 inch LCD Shield

; Device Tree Overlay
overlay_resize=16384
overlay_profile=hktft35
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_hktft_cs_ogst]
overlays="hktft-cs-ogst"

All set. Reboot to take effect. The new Device Tree Overlay setting is applied when the U-Boot time.

Find the framebuffer number

We need to map a console to a framebuffer to move the activated screen to the LCD shield.

Before that, we also need to find the proper framebuffer name. The framebuffer number may differ from each board or each condition around the board.

You can find out which number is the LCD shield by the following codes.

Odroid-XU4/N2/C4

$ grep -Hri "hktft" /sys/class/graphics/fb*/name
/sys/class/graphics/fb0/name:fb_hktft32

In this case, fb0 in the result string indicates the framebuffer for the installed 3.2 inch LCD shield.

  • If you enabled the other DTBO file for 3.5 inch LCD Shield, the only difference is the found name: fb_hktft35.

Odroid-C1/C2

$ grep -Hri "flexfb" /sys/class/graphics/fb*/name
/sys/class/graphics/fb2/name:flexfb

In this case, fb2 in the result string indicates the framebuffer for the installed LCD shield.

In general, each board will have the following numbers respectively. If the listed number is not working then you can find the framebuffer number on yourself with the above command.

Board Framebuffer number
Odroid-XU4 0
Odroid-C1/C2 2
Odroid-N2/C4 4

Then, we should install fbset tool to go to the next step.

$ sudo apt install fbset

Run Terminal

Map a console to a framebuffer using con2fbmap command. We will map console number 1 to the framebuffer number {FB_NUM}. You must replace this with yours.

$ sudo con2fbmap 1 {FB_NUM}

Then change the foreground virtual terminal to number 1 that is the console number we mapped.

$ sudo chvt 1

Now you can see the terminal screen on the LCD shield.

Run X-Window

Map a console to a framebuffer using con2fbmap command. We will map console number 7 to the framebuffer number {FB_NUM}. Because console number 7 is an X-Window (GUI) console in general.

You must replace {FB_NUM} to yours.

$ sudo con2fbmap 7 {FB_NUM}

Then change the foreground virtual terminal to number 7 that is the console number we mapped.

$ sudo chvt 7

Probably the LCD shield won't respond yet. We should edit the X-Window settings to show the screen to the specific framebuffer.

Odroid-C1/XU4

Make a back-up of /etc/X11/xorg.conf file and create a new one.

$ sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
$ sudo vi /etc/X11/xorg.conf

Odroid-C2/N2/C4

Make a back-up of /usr/share/X11/xorg.conf.d/99-odroidc2.conf file and create a new one.

$ sudo mv /usr/share/X11/xorg.conf.d/99-odroidc2.conf /usr/share/X11/xorg.conf.d/99-odroidc2.conf.bak
$ sudo vi /usr/share/X11/xorg.conf.d/99-odroidc2.conf

Put the below codes into that. Be aware of the given framebuffer number, {FB_NUM}, that is you should change to the number you found in the previous step.

Odroid-XU4

Section "Device"
    Identifier    "fbdev"
    Driver        "fbdev"
    Option        "fbdev" "/dev/fb{FB_NUM}"
EndSection

Odroid-C1

Section "Device"
    Identifier      "Mali-Fbdev"
    Driver          "mali"
    Option          "fbdev"         "/dev/fb{FB_NUM}"
    Option          "DRI2"            "true"
    Option          "DRI2_PAGE_FLIP"  "false"
    Option          "DRI2_WAIT_VSYNC" "false"
    Option          "UMP_CACHED"      "true"
    Option          "UMP_LOCK"        "false"
    Option          "SWCursor"        "true"
    Option          "HWCursor"        "false"
EndSection

Section "ServerFlags"
    Option          "NoTrapSignals" "true"
    Option          "DontZap"       "false"
    Option          "BlankTime"     "0"
    Option          "StandbyTime"   "0"
    Option          "SuspendTime"   "0"
    Option          "OffTime"       "0"
EndSection

Section "DRI"
        Mode            0666
EndSection

Odroid-C2/N2/C4

Section "Device"
    Identifier      "FBTURBO"
    Driver          "fbturbo"
    Option          "fbdev" "/dev/fb{FB_NUM}"

    Option          "SwapbuffersWait" "true"
    Option          "alpha_swap" "true"
EndSection
  • Basically, the configuration contents for each board are from the original xorg.conf (99-odroidc2.conf) file. If this cannot work, try to copy the original configuration file and edit the only framebuffer number.

Restart the display manager to take effect. In the Odroid official Ubuntu Mate images, we will restart LightDM service.

$ sudo service lightdm restart

Now you can see the graphical interface display on the LCD shield.

Touchscreen

Enable unless it is working

  • This isn't relevant to the 3.5 inch LCD shield. If you use 3.5 inch LCD shield, you can skip this step.

After enabling the X-Window environment on the top of the LCD Shield, you may use its touchscreen as well out of the box.

But someone maybe not. For those who get suffering that, there's one thing you should check out.

Some Odroid images set the ads7846 module, which is for the touchscreen of the 3.2 inch LCD shield, as one of the blacklists. This means the specified modules including ads7846 will not be loaded at the boot time. So, if you want to use the module normally, you can remove the corresponding line in the blacklist file.

Fortunately, the blacklist modules for the Odroid boards are grouped as one file. Edit the file named /etc/modprobe.d/blacklist-odroid.conf.

$ sudo vi /etc/modprobe.d/blacklist-odroid.conf

Find ads7846 line and comment out this by adding a “#” character into the beginning of the sentence. Then it will be like this.

#blacklist ads7846

Reboot and check the loaded module list to check the touchscreen module is loaded or not.

$ lsmod | grep ads7846
ads7846                20480  0

If the result is like the above code block, the touchscreen module is loaded successfully. Then you can use the touchscreen of the LCD shield.

Calibrate touchscreen

If the pointer is not working as you intended, you may calibrate the touchscreen works.

Install the calibrator utilities.

$ sudo apt install xserver-xorg-input-evdev xinput-calibrator

And there are some things you have to prepare.

Odroid-C1/XU4

Create a X11 configuration file under the /etc/X11/xorg.conf.d directory like the below.

$ sudo vi /etc/X11/xorg.conf.d/99-calibration.conf
Odroid-C2/N2/C4

Create a X11 configuration file under the /usr/share/X11/xorg.conf.d directory like the below.

$ sudo vi /usr/share/X11/xorg.conf.d/99-calibration.conf

Put the following contents into that new file.

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Driver "evdev"
EndSection

Restart the lightdm service.

sudo service lightdm restart

Now enter the following command to start calibration.

$ xinput_calibrator

Follow the calibration steps. Then you can see the results from the terminal like this.

Calibrating standard Xorg driver "SX865X Touchscreen"
        current calibration values: min_x=0, max_x=65535 and min_y=0, max_y=65535
        If these values are estimated wrong, either supply it manually with the --precalib option, or run the 'get_precalib.sh' script to automatically get it (through HAL).
        --> Making the calibration permanent <--
  copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "SX865X Touchscreen"
        Option  "Calibration"   "3748 165 133 3867"
        Option  "SwapAxes"      "0"
EndSection

Copy that Option properties of the Section block into the 99-calibration.conf file you have created.

So that completed 99-calibration.conf file looks like this.

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "3748 165 133 3867"
        Option  "SwapAxes"      "0"
        Driver "evdev"
EndSection
  • If your board uses /usr/share/X11/xorg.conf.d directory, then you have to remove all the /etc/X11/xorg.conf.d directory and the containing files.
  • If your board uses /etc/X11/xorg.conf.d directory but it is absent, create one and put the file into that new directory.
  • Copying the calibration values may slightly hard due to the small size of the LCD shield. If so, try saving the results as a file and copying the values via SSH or with something big screen.
$ xinput_calibrator > calibration_results.txt

Restart X-Window to take effect. In the official Ubuntu Mate images, we will restart LightDM service.

$ sudo service lightdm restart

Login automatically

Console

First, you have to set the front virtual terminal by editing /etc/rc.local file.

$ sudo vi /etc/rc.local

Put this line into the file.

chvt 1

Then, edit the getty service to log in automatically.

$ sudo systemctl edit getty@tty1.service

After the screen changes put these lines into that.

[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin odroid %I $TERM
Type=idle
  • The default editor for editing systemctl services is Joe's Own Editor. To save with this editor, type Ctrl + K and S. To quit, type Ctrl + K and Q.

If you want to set the account to be signed in, replace odroid with the other user name you want.

X-Window

After setting up with the Run X-Window part above, edit the /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf file to bypass the login prompt.

$ sudo vi /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf

Put this contents into that file.

autologin-user=odroid

So that the file contents will be like the below.

[Seat:*]
greeter-wrapper=/usr/lib/lightdm/lightdm-greeter-session
autologin-user=odroid

If you want to set the account to be signed in, replace odroid with the other user name you want.