stockmind / gpd-pocket-ubuntu-respin

Collection of scripts and tweaks to adapt Ubuntu and Linux Mint ISO images to let them run smooth on GPD Pocket
350 stars 35 forks source link

Donate Donate Bitcoin [Docker Build Statu]() [Docker Automated buil]()

GPD Pocket Ubuntu

Unmaintained

Check out Ultra Mobile PC (UMPC) hardware configuration for Ubuntu, a similar project targeting multiple GPD devices to work with Ubuntu 20.04 and 22.04.

Update an installed system

You can update an installed system using the update commands here: Update steps

Warning: Ubuntu 17.10/18.04 Issues

Ubuntu 17.10/18.04 ships with GNOME 3 as default desktop environment. There are several issues and things that doesn't work as expected at the moment (Scaling, rotation after sleep/login, random missing characters, graphical glitches etc...). I suggest you to install Unity and use LightDM as login/display manager until GNOME gets updated with latest patches.

You can do that issuing:

sudo apt install unity lightdm

And select "LightDM" instead of "GDM" when prompted.

On first login after Unity and LightDM install, click on the big "circle" icon near your username and select "Unity" as Desktop Environment.

An experimental ISO of Ubuntu 17.10 with Unity preinstalled as default DE can be found in the downloads section (First mirror gpdpocket.cre.ovh)

Check kernel builds by Petr Matula

Petr Matula kernel repository

Petr Matula is kindly starting building kernels with greater frequency than my releases, if you need/want an updated kernel without have to wait try his builds! He have an easy script to download and install the packages.

Check new rotation script and tray icon!

GPD Pocket Screen rotation utility

https://github.com/stockmind/gpd-pocket-screen-indicator

Run update script to install it automatically.

Have an issue?

Check Troubleshooting section. Try to download this repository and run update.sh script and update-kernel.sh script to update system to latest working configuration. Check update section. If your problem persist or is not on the troubleshooting list check Problem reporting section before open an issue.

Scripts on this repository are not compatible with Ansible-playbook setup due to rotation and other scripts that may conflict. Clean your system before use this. You may try this clean script at your own risk: Clean Ansible Playbook script

How to Respin an ISO for GPD Pocket

Overview

This is a collection of scripts and tweaks to adapt Ubuntu and Linux Mint ISO images and let them run smoothly on GPD Pocket.

All informations, tips and tricks was gathered from:

What Works Out-of-the-Box

What Doesn't Work at the Moment

Overview for Building and Respinning an ISO

  1. Clone the repo and install necessary tools
  2. Download your ISO of choice
  3. Download or build the latest kernel
  4. Respin the ISO (it many take a about 30 minutes or even longer)
  5. Install OS and run post-install update

Download an Already Respun ISO

Click here for the downloads section

Updating the BIOS

At the moment no BIOS update is required to run Ubuntu respin iso. You can run any BIOS you want and you probably won't notice big differences. Different BIOS have however different features enabled. Check BIOS section here

NOTE: Based on my experience the best BIOS version is the latest 2017/08/07 BIOS. It doesn't turn on fan at max when device is off and charging. It also let you boot on zero battery charge (previous versions require at least 15-20% of battery charge to boot). It seems also to fix the odds system "freeze" that some users encounter on unlocked BIOS.

Respin iso and build kernels with Docker

Docker

Click here for the Docker building section

Build and respin without Docker

Step 1: Cloning the Repo and Installing Tools

To respin an existing Ubuntu ISO, you will need to use a Linux machine with squashfs-tools and xorriso installed (e.g. sudo apt install -y squashfs-tools xorriso) and a working internet connection and at least 10GB of free storage space.

The first step is to clone this repo:

git clone https://github.com/stockmind/gpd-pocket-ubuntu-respin/
cd gpd-pocket-ubuntu-respin/

Debian-based systems:

Install all the required packages:

sudo apt install -y git wget genisoimage bc squashfs-tools xorriso

Arch-Based Systems:

Install all the required packages:

sudo pacman -S git wget cdrkit bc libisoburn squashfs-tools dosfstools

Step 2: Download your ISO of Choice

Download your favourite distribution ISO and copy it in this repository cloned folder.

Step 3: Download or Build a Kernel for the Respin

Option 1: Download the Latest Kernel

  1. Running ./build.sh in the terminal will download the most recent kernel automatically.

Option 2: Build Your Own Kernel

Kernel suggested is the one with patches from Hans De Goede. You can find his repository here: Hans De Goede Kernel Repository

Debian Based Systems:

sudo apt-get install build-essential git libncurses5-dev libssl-dev libelf-dev bison flex
git clone https://github.com/jwrdegoede/linux-sunxi.git

If you have already donwloaded the repository, you can update it with latest commits issuing:

git fetch origin
git reset --hard origin/master

If you want to use the custom kernel config provided by this repository copy and overwrite .config that you can find in this repository in kernel/.config with .config file of Hans kernel repository

Then proceed with building:

cd linux-sunxi/
make clean
make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-custom   

You can find the generated kernel .deb files in the parent folder where linux-sunxi repository have been cloned.

Compress all the .deb files generated into a zip named "gpdpocket-kernel-files.zip" and put it in the root folder of this repository.

Step 4: Build Your Respun ISO

Run ./build.sh script as specified for your desired distro. If you built your own kernel, the build script wiill extract the kernels you zipped and install during respin.

Build on Debian-based systems:

Build on Arch-based systems:

Gnome desktop environment and derivate (Pantheon of Elementary OS) use a different name convention for monitors. The default Xorg configuration won't work and a custom configuration must be used to get everything to work. That's the reason of the "gnome" argument for update and build script.

If you want to use lightDM as Display/Login manager (Suggested) and Unity as Desktop Environment (Suggested) you can use unity as flag instead of gnome when calling build.sh script. This is experimental and may not work as expected but is the suggested environment on GNOME based distros like 17.10 Ubuntu default ISO for the moment.

Build Ubuntu 18.04 ISO

Pass bionicbeaver parameter to respin script. This will select the correct packages to install on ISO.

./build.sh <iso filename> gnome bionicbeaver

Step 5: Install and Update

Boot ISO from USB device

I sugget Etcher to write ISO on usb flash drives. It's fast, reliable and multi-platform.

Boot system using one time boot menu: Press during GPD logo Fn + F7 keys.

Don't boot your USB from a USB Type C adapter or USB Type C drive as it wouldn't work until USB Type C data is supported by kernel.

Post-install

These commands should be run after the first boot. There is an update script that will do it automatically, or you can run the necessary commands manually.

Update script

You can run my update script to update your installation and grub options, and to setup everything after an install or after a Desktop Environment change.

sudo apt-get install -y git
git clone https://github.com/stockmind/gpd-pocket-ubuntu-respin.git
cd gpd-pocket-ubuntu-respin/
chmod +x update.sh
  1. Unity, KDE, XFCE as Desktop Environment:
    sudo ./update.sh
  2. GNOME, Pantheon (Elementary OS) as Desktop Environment:
    sudo ./update.sh gnome

Gnome desktop environment and derivate (Pantheon of Elementary OS) use a different name convention for monitors. The default Xorg configuration won't work and a custom configuration must be used to get everything to work. That's the reason of the "gnome" argument for update and build script.

KDE systems: There are reports that on KDE some flags that the script sets in /etc/environment may cause graphic glitches and issues. To prevent update.sh script from adding those lines, append kde flag to update.sh script call. Like:

sudo ./update.sh kde

Update kernel:

Update kernel to latest version issuing the following command:

sudo ./update-kernel.sh

A kernel update is always recommended.

Additional Notes

Downloading Existing ISO's

On the following urls you can find already respinned Ubuntu ISO for GPD Pocket

https://gpdpocket.cre.ovh/

Mirror: https://mega.nz/#F!8WpQRZrD!0XHgajeG-QVZTp1Jbjndgw

BIOS Updates and Original Firmwares

At the moment no BIOS update is required to run Ubuntu respin iso. You can run any BIOS you want and you probably won't notice big differences. Different BIOS have however different features enabled. Check changelogs below.

You can find BIOS updates for GPD Pocket and original firmware files on this page:

http://www.gpd.hk/news.asp?id=1519&selectclassid=002002

Useful informations:

http://tieba.baidu.com/p/5293185138

Official GPD Pocket Ubuntu ISO

Diffs of latest (0809_2) GPD Official Ubuntu image with files that GPD added to vanilla Ubuntu ISO:

https://www.reddit.com/r/GPDPocket/comments/70qdsp/diff_of_latest_gpd_official_ubuntu_firmware_iso/?st=j7pa5css&sh=02dc3f67

Files: Download Here

ISO:

Latest versions are available here: http://www.gpd.hk/news.asp?id=1519&selectclassid=002002

Second version - Chinese Mirror - My mirror

First version (Working iso, GPD one uploaded on indiegogo was corrupt)

BIOS versions:

Updating the BIOS

  1. Download the latest BIOS
  2. Install the flashing utility
    sudo apt install flashrom
  3. Use cd to enter the directory where you downloaded the BIOS
  4. Backup the current BIOS
    sudo flashrom -p internal -r backup.bin
  5. Flash the new BIOS
    sudo flashrom -p internal -w Rom_8MB_Tablet.bin
  6. Reboot Your Computer

Notes: You may need to restore BIOS setting to their default in order to get everything running smoothly.

Charging info

To get charging working correctly a different Power Delivery 2.0 charger may be required, based on kernel used, otherwise charging will be slow and will just keep device charge stable when in use. i.e. it will not drain battery as it may happen on old or generic kernels, but won't charge device more than when connected to power.

Follow some data recorded with several chargers and systems regarding the charge delivered and perceived by the system:

Charger System Volts (Avg.) Ampere (Avg.)
Stock GPD charger 4.12-rc2+ kernel (GPD official firmware) 4.70v 2.5a
Aukey charger 4.12-rc2+ kernel (GPD official firmware) 4.70v 2.5a
Stock GPD charger 4.12-rc7 kernel (HansDeGoede kernel) 4.89v 0.5a *
Aukey charger 4.12-rc7 kernel (HansDeGoede kernel) 4.89v 2a
Stock GPD charger 4.13-rc3 kernel (HansDeGoede kernel) 11.8v 1.5a
Aukey charger 4.13-rc3 kernel (HansDeGoede kernel) 9.20v 0.5a **
Stock GPD charger 4.13-rc5 kernel (HansDeGoede kernel) 11.8v 1.3a
Aukey charger 4.13-rc5 kernel (HansDeGoede kernel) 9.0v 1.4a
Stock GPD charger Windows 10 11.70v 1.7a
Aukey charger Windows 10 8.90v 2a

* Charging will not drain battery but won't charge device more than when connected to power

** Charging will be slow

Any kernel after 4.13-rc5 (From Hans de Goede repository) should be fine for full-speed charging! Mainline kernel 4.14 or later should be fine.

Ampere delivered may vary depending on the remaining battery charge.

The tests have been performed using this Jokitech USB-C Power Meter Tester Multimeter

Follow link of Aukey charger used.

Amazon UK - AUKEY USB C 29W PD 2.0

Amazon IT - AUKEY USB C 29W PD 2.0

Multitouch

Monitor CPU frequencies

You can monitor frequencies of cpu issuing:

cat /sys/bus/cpu/devices/cpu*/cpufreq/scaling_cur_freq

Build with Docker

Docker

You can respin iso and build kernels on a Docker environment easily. This build system will likely work on any x86 Docker supported platform. Tested and working on Linux and MacOS, builds on Windows not tested yet.

You just need to build the Docker image, or download it from Docker Hub, and follow the steps below.

1a. Download image from Docker Hub

docker pull stockmind/gpd-pocket-ubuntu-respin

1b. Or build the Docker image locally

Clone repository and run the following script to build the docker image

./docker-build-image.sh

Once the image is ready you can choose from the following steps:

2a. Respin ISO

To respin an ISO you need to place desired ISO in origin/ folder of this repository then run:

a. Distro based on Unity, KDE, XFCE as Desktop Environment:

./docker-respin.sh <iso-file-name-without-path>

b. Distro based on GNOME, Pantheon (Elementary OS) as Desktop Environment:

./docker-respin.sh <iso-file-name-without-path> gnome

Example:

./docker-respin.sh ubuntu-17.04-desktop-amd64.iso

Or:

./docker-respin.sh ubuntu-GNOME-17.04-desktop-amd64.iso gnome

Let it run, it will take from 10 to 30 minutes based on your internet connection and system speed. Once done you will find output ISO in destination/ folder of this repository named as gpdpocket-<build-date>-<iso-file-name>.iso.

2b. Build latest kernel

To build latest kernel you just need to run the following script:

./docker-build-kernel.sh

Let it run, it will take a while. When it's done you can find the kernel zipped in destination/ folder of this repository.

If you want to customize the .config flags edit the file in kernel/.config of this repository and launch kernel build script. Configuration will be copied over the Hans one before building.

If you want to build kernel using the original .config file provided by Hans instead of the one provided in this repository run the script with keepconfig argument:

./docker-build-kernel.sh keepconfig

If you are using the Docker Hub image remember to always pull latest version before running any of those scripts!

docker pull stockmind/gpd-pocket-ubuntu-respin

Stop running containers

If you made a mistake and want to stop the running containers in background for respinning or building you can use the stop script:

./docker-stop.sh

Troubleshooting

Blank screen on Live USB boot and white power led on

Press the power button to let the desktop load and look at issues below.

Brightness management doesn't work

Brightness management is currently broken on a Live environment. You must install system on your drive to get it working.

Sleep when plugging in charger

Some sort of Unity daemon or watcher seems to read bad values from battery or charge and put system on sleep when charger is plugged in. This seems to happen also on boot of Live USB. Press any key or power button to wake. It only happens on Unity as far as i know.

Screen keeps spamming errors regarding squashfs after power button press or close/open lid

Try to burn the image on a smaller usb device or try another image.

I sugget Etcher to write ISO on usb flash drives. It's fast, reliable and multi-platform.

No sound / streaming video crashing/not playing

Check that the correct sound output device is selected in System Settings. It should be "Speakers: chtrt5645" for device speakers and "Headphones: chtrt5645" for the audio jack output.

Video glitches and overlapping desktops when HDMI connected

Check your system displays settings and move your displays until they are not overlapping each others.

System freeze or hangs on high temperatures, high load or randomly

Disable DPTF in BIOS (Unlocked BIOS might be required), that's what freezes the system before it reaches the hardcoded factory limit of 90 degree.

Audio crackling and noise through speakers and headphones

Update your system configuration with latest of this repository. You can encounter noises if you use a kernel 4.14-rc5 or below (Hans de Goede kernel) or if your kernel was compiled with CONFIG_INTEL_ATOMISP=y (If you are not using Hans de Goede kernel patches or a kernel compiled by his repository below 4.14-rc5). Set CONFIG_INTEL_ATOMISP=y to CONFIG_INTEL_ATOMISP=n and compile/install kernel. Noises should disappear. You may still encounter noises while on headphones, in this case check that your HiFi headphones volume configuration is not too high.

Open the following file:

/usr/share/alsa/ucm/chtrt5645/HiFi.conf

And check that cset "name='Headphone Playback Volume'" is not too high. A good value seems to range between 25 and 30.

Thanks to Petr Matula @petrmatula for discovering and tests!

Audio jack disconnected on volume over 70-80% (only Linux behaviour) with some headphones

Audio jack may get disconnected on some headsets when volume is set over 70-80%. Windows does't have this problem with official GPD audio drivers. Windows have the same problem only when you using unofficial audio drivers (only one accept way is update audio driver over device manager). This doesn't seems to happen on tiny headphones. When this happen audio start to have a crackling noise again. To fix this you should restart pulseaudio and audio player.

To restart pulseaudio issue the following command

pulseaudio --kill && pulseaudio --start

or

pulseaudio -k

Video of the problem by Petr Matula @petrmatula (enable subtitles!)

Google Chrome tearing, glitch or flickering while scrolling or browsing heavy web pages

Chrome doens't seems to behave great with the i915 intel driver, a workaround for the glitches or flickering while scrolling pages or seeing video is to set "GPU Rasterization" to "Force-Enabled for all layers". Quick link: chrome://flags/#enable-gpu-rasterization

Graphical glitches on KDE

Remove/comment those lines from /etc/environment and reboot.

LIBGL_DRI3_DISABLE=1
COGL_ATLAS_DEFAULT_BLIT_MODE=framebuffer

When you want to update your system in future launch update.sh with kde flag to prevent re-add of these lines.

Why is system UI so big?

The scaling ratio is set to 2 to be able to read on the screen but it sure takes of a lot of space out of the FullHD screen. Things will be more aliased and have better edge but take more space on screen. To restore to native pixel resolution you have to edit the scale configuration:

sudo nano /etc/X11/Xsession.d/90-scale

You have to edit all the values to their default like below:

# Unity
gsettings set com.ubuntu.user-interface scale-factor "{'DSI-1': 8, 'DSI1': 8}" 
# Gnome 3
gsettings set org.gnome.desktop.interface scaling-factor 1 
gsettings set org.gnome.desktop.interface text-scaling-factor 1
# Cinnamon
gsettings set org.cinnamon.desktop.interface scaling-factor 1 
gsettings set org.cinnamon.desktop.interface text-scaling-factor 1
# Mate
gsettings set org.mate.font-rendering dpi 96.0

To make this changes persistent to updates you should copy the current 90-scale and name it with a greather starting number like 91-scale:

cp /etc/X11/Xsession.d/90-scale /etc/X11/Xsession.d/91-scale

Then edit the required settings in /etc/X11/Xsession.d/91-scale. Future runs of update.sh script will not overwrite your custom settings.

The settings in scale file cover all the main desktop environments. Change on settings might require a log-out, log-in, or reboot to take effect. Restarting the display manager service will also work. This way you can still read fine (if you have good 👀 ) and have all your pixels back.

Touchscreen or display rotation is wrong after wake/sleep or screen lock

Sometimes it may happen that rotation of touch or display is wrong due to several factor, particularly on GNOME or derived Desktop Environments. You can fix this simply selecting with mouse the GPD Screen Rotation icon on the tray bar ( GPD Screen Rotation icon ) and clicking on the desired rotation on menu.

Ex. If your display is rotated in landscape correctly but touchscreen is not aligned, you can select "Rotate landscape" to fix this. The opposite is also valid. The script will do it's best to compensate the alignment problems that may happen.

Touchscreen stop to respond

You can try to use the "Reset touchscreen" option from the GPD Screen Rotation icon on your tray bar ( GPD Screen Rotation icon ). It will ask for your password. Wait for 5 seconds than retry to use touchscreen. If problem persist try to put system in sleep for a bit or reboot your device.

No GPD Screen Rotation icon on GNOME Shell

Check this

No GPD Screen Rotation icon shows at boot

In some system it may happen that tray icon won't show at boot. Try to run in a terminal

gpdscreen-indicator

If it works add "gpdscreen-indicator" command to your system "Startup Application" utility to run it at boot.

GPD Fan daemon fail to run

Hans de Goede pushed a proper fan driver for kernel: https://www.reddit.com/r/GPDPocket/comments/7jiv3g/linux_proper_fan_driver_submitted_for_mainline/

The gpdfand daemon fail when the module for GPD fan gets loaded from kernel. You can check this by issuing:

lsmod | grep gpd

On kernel like 4.14 the daemon will run without issues, but i keep the daemon just for the moment, to let fan work on kernels that doesn't ship with the Hans driver included, so it is possible to switch kernels and try different configs without tinker too much with basic things (same approach for bluetooth).

GPD Fan always spinning on AC

On latest kernels with Hans patches and proper fan driver enabled (gpd-pocket-fan kernel module), fan is set as always spinning at speed 2 (of 3) on AC. That's because when charging it may be desirable to have some extra cooling, as some BIOS versions also do. (Thanks Hans for explanations!)

You can disable this behaviour by setting the speed_on_ac parameter (must be between 0 and 3) for the gpd-pocket-fan module to 0 in GRUB (see setting below). Note the default is 2, which is medium speed, 1 is low speed and 3 is max speed. 0 will not turn on fan on AC when not required (So when temps are fine and below the fan trigger temperatures).

File to edit /etc/default/grub:

GRUB_CMDLINE_LINUX=" ... gpd-pocket-fan.speed_on_ac=0"

Save and run sudo update-grub to apply new settings.

This repository default has been set to gpd-pocket-fan.speed_on_ac=0 so you don't need to worry about this if you use scripts on this repository to setup your GPD Pocket.

USB Type-C to video output not working

Once you've a kernel build from latest Hans's git master branch (version 5.0.0-rc7+), plug in a Type-C to video dongle and then do:

cat /sys/class/typec/port0-partner/port0-partner.0/displayport/pin_assignment

This should give you something like this:

C [D]

Which means that the USB-PD stack / Type-C state-machine in the kernel has correctly negotiated DisplayPort altmode.

If the above cat command fails with a No such file or directory error, then your dongle is not compatible with the kernels USB-PD stack for now.

Check issue #98 https://github.com/stockmind/gpd-pocket-ubuntu-respin/issues/98 https://github.com/stockmind/gpd-pocket-ubuntu-respin/issues/98#issuecomment-467014805

Problem reporting

To report a problem clone the repo, run "problem-reporting.sh" script and attach the output to your github issue. This will help debugging.

sudo ./problem-reporting.sh

Donate

If my work helped you consider a little donation to buy me a coffe... or an energy drink! :smile:

Paypal

paypal

Bitcoin

Donate Bitcoin