Installing Ubuntu 20.04 (Focal) with BSP uBoot with deep sleep and sound
#1
Or, "As close to a daily driver OS as I can get."  Which I have been attempting to daily drive.

Post 1 is getting it installed, working, and sleeping properly, with at least "mostly works" sound functionality.  Later parts will cover various other aspects, including abusing the environment into something that can play Spotify (armhf browser in a chroot).

You'll need a microSD card and some time, with the install ending up on the eMMC.

I'm also assuming some general familiarity with Linux - I've got all the steps, but there may be some assumptions missing between them, because I didn't record the exact keystrokes.

Get the initial image, flash it to SD.

Pull the image from ayufan's repo here:

https://github.com/ayufan-rock64/linux-b...ag/0.10.12

You want focal-gnome-pinebookpro-0.10.12-1184-arm64.img.xz - it's ARM64, and Ubuntu 20.04.  Unzip this and put it on an SD card with your preferred techniques (Etcher doesn't seem to like these images, so you may have to dd it directly over - I just dd'd the unzipped image onto the SD card and it was fine).

Toss a copy of this image onto a USB drive or local server as well - you'll need it for flashing onto the eMMC.

Put the SD card in, boot, and you should find yourself at something looking generally Ubuntu 20.04-ish.  rock64/rock64 will get you in, and it will make you change the password immediately.

Flash the image to the eMMC

Find the eMMC - I think it tends to be /dev/mmcblk0 when booted from the SD card.  The 'lsblk' command will show you what your block devices are, and the one that's not got something mounted as root is your eMMC.

Grab a copy of the image again from your preferred source, and we'll put it on the eMMC.  It's worth running lsblk and unmounting anything mounted from your eMMC before you start, though it probably won't matter.  It's just rude to blow away a filesystem without unmounting it, and in theory it could mess with the flash if something got written to a half intact filesystem.

Code:
unxz focal-gnome-pinebookpro-0.10.12-1184-arm64.img.xz
sudo umount /media/rock64/*
sudo dd if=focal-gnome-pinebookpro-0.10.12-1184-arm64.img of=/dev/mmcblk0 bs=1M

I'm not going to say you should mount the new filesystem to do a bunch of 'sed -i -e' over in /etc and rename your home directory.  But if you want to, now is a really good time to do it.

Power down, pop out the SD card, and reboot.  You should boot into a clean image, same as you had on the SD card.

Initial System Setup and Updates

The terminal font is violently broken.  Menu -> Preferences -> Use Custom Font, and pick something sane.  Monospace is a decent one.

Connect to wireless, then we'll update the system and fix the timezone to be correct.

Code:
sudo dpkg-reconfigure tzdata
sudo apt update
sudo apt -y dist-upgrade -y
reboot

Congratulations!  You have an updated Ubuntu 20.04 - but it doesn't have the good stuff yet.  It won't deep sleep, sound probably doesn't work, and we can do better.

Build a 5.7 Kernel and Such

Next, we'll build a 5.7 kernel from the development tree.  Bleeding edge and all.  Do this first, because the 5.6 kernel with the BSP firmware we'll flash takes about 2 minutes to boot, with a black screen in the process.

Be sure your battery is charged!  This will drain your battery down, even if plugged in.  You'll probably want to leave the screen brightness dim, but even then, the board at full tilt draws more than the barrel plug adapter can source.  Beta hardware and all.

We'll be using the pbp-tools repository, which has several useful scripts (and several scripts that will render things non-booting on this install, because the partition layout is different).

You'll need to agree to the menuconfig options in the kernel build step about 5 minutes in - just tab over to exit and call it good unless you want to explore and change things.  If you've never poked around menuconfig, it's a fun place!

Code:
sudo apt -y install build-essential libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev \
libpci-dev libiberty-dev autoconf fakeroot meson
git clone https://github.com/xmixahlx/pbp-tools
cd pbp-tools
./pbp-build-linux-hwaccel
sudo dpkg -i upstream/*.deb
./pbp-update-ap6256-firmware
./pbp-post-install
reboot


After you've left menuconfig, go do something else, because this takes a long time.  It's a pretty complete kernel build on a little ARM box.  Think two hours, though it might be less - I've not timed it.

Ideally, you come back to the box rebooted, in Ubuntu, with a 5.7 kernel (uname -a will show you the kernel version).  If this doesn't work... well, you have a UART, right?  You should even have working sound!

Do NOT run the update system partitions script.  It will render this system non-booting because it puts things in the wrong places and nukes the boot partition in the deal.  It's built for a different partition layout.


Flash the BSP uboot

We will, however, be flashing the BSP uboot.  This is different from the "mainline" uboot, which is fully open source.  Some of the quirks of deep sleep aren't ported over yet.  We'll be using the patched one with NVMe support, but putting it on the eMMC instead of the SPI flash chip (the SPI chip is good to avoid unless you really need to boot from NVMe, because recovering from a bad flash is somewhat harder).

Your eMMC should be mmcblk2 - use lsblk to verify, and adjust if needed.

Code:
git clone https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-pinebookpro-bsp.git
cd uboot-pinebookpro-bsp
sudo dd if=idbloader.img of=/dev/mmcblk2 seek=64 conv=notrunc
sudo dd if=uboot.img of=/dev/mmcblk2 seek=16384 conv=notrunc
sudo dd if=trust.img of=/dev/mmcblk2 seek=24576 conv=notrunc

Yes, this is putting stuff in the middle of a mounted partition (/boot/efi).  It does seem to work, but we'll do some fixup to prevent that from being overwritten.

Reboot.  You should now have deep sleep capability.  Ensure that /sys/power/mem_state has "deep" selected, and you should be able to deep sleep with fn-esc, or closing the lid.  Done right, you'll lose 2-3% battery overnight.  However, it's not always the most reliable thing on the planet, so you might still shut the system down if you really need battery preserved.  Beta dev hardware and all that.  The system will wake if you plug it in, otherwise you should be able to wake it with the power switch.

Let's Tweak the Trackpad

None of this really helps the trackpad on this system.  If it doesn't bother you, well, don't bother changing anything.  But if you're constantly clicking stuff you don't intend to click, there are a few changes that might help.  It's apparently somewhat hardware specific, but you can make it less annoying.

In Mouse & Trackpad settings, disable tap to click.  This will require you to actually click, which seems to eliminate most of the annoyances.  I'll also suggest that you can improve things by changing how you type (hands floating), and by using one finger on the touchpad - don't use your thumb to click, use your pointer finger.  Yes, it's working around the hardware, but it makes it somewhat less frustrating to use.

You might install and enable the synaptics driver - it seems slightly better, though... YMMV.

Code:
sudo apt install xserver-xorg-input-synaptics


Then modify /etc/X11/xorg.conf.d/40-pinebookpro-touchpad.conf with the suggested settings from the PBP wiki:

Code:
Section "InputClass"
   Identifier "touchpad catchall"
   Driver "synaptics"
   MatchIsTouchpad "on"
   MatchDevicePath "/dev/input/event*"
   Option "MinSpeed" "0.25"
EndSection

Adjust other options if needed.

Sound after Sleep

One may, rapidly, discover that sound doesn't work after sleep.  Something isn't getting reset properly, and I don't quite know what yet (this is an issue after deep sleep, not the s2idle sleep that burns 7% battery an hour).

One might try this:

Code:
pulseaudio -k && sudo alsa force-reload

If this doesn't work, something probably has sound open - try killing off the browser.  Sorry, still working out the details on sound and sleep - something isn't getting reset properly after a deep sleep on the 5.7 kernel.

A Little CPU Toggler Script

Care to mess with your CPUs?  Perhaps disable the big CPUs for light use, or disable the little CPUs for hardware virtualization experiments?  This ought to help you (run with sudo):

Code:
#!/bin/bash

if [ $# -eq 0 ]; then
    echo "Usage: sudo pbp_cpu.sh [all, big, little, status]"
    exit
fi

if [ $1 = "all" ]; then
    echo "Enabling all cores."
    echo 1 > /sys/devices/system/cpu/cpu0/online
    echo 1 > /sys/devices/system/cpu/cpu1/online
    echo 1 > /sys/devices/system/cpu/cpu2/online
    echo 1 > /sys/devices/system/cpu/cpu3/online
    echo 1 > /sys/devices/system/cpu/cpu4/online
    echo 1 > /sys/devices/system/cpu/cpu5/online
fi

if [ $1 = "big" ]; then
    echo "Enabling only big cores."
    # Online the big cores first, then take the little ones offline.
        echo 1 > /sys/devices/system/cpu/cpu4/online
        echo 1 > /sys/devices/system/cpu/cpu5/online
        echo 0 > /sys/devices/system/cpu/cpu0/online
        echo 0 > /sys/devices/system/cpu/cpu1/online
        echo 0 > /sys/devices/system/cpu/cpu2/online
        echo 0 > /sys/devices/system/cpu/cpu3/online
fi

if [ $1 = "little" ]; then
    echo "Enabling only LITTLE cores."
        echo 1 > /sys/devices/system/cpu/cpu0/online
        echo 1 > /sys/devices/system/cpu/cpu1/online
        echo 1 > /sys/devices/system/cpu/cpu2/online
        echo 1 > /sys/devices/system/cpu/cpu3/online
        echo 0 > /sys/devices/system/cpu/cpu4/online
        echo 0 > /sys/devices/system/cpu/cpu5/online
fi

if [ $1 = "status" ]; then
    echo "Core status:";
    echo -n "cpu0 (LITTLE): "
    cat /sys/devices/system/cpu/cpu0/online
    echo -n "cpu1 (LITTLE): "
    cat /sys/devices/system/cpu/cpu1/online
    echo -n "cpu2 (LITTLE): "
    cat /sys/devices/system/cpu/cpu2/online
    echo -n "cpu3 (LITTLE): "
    cat /sys/devices/system/cpu/cpu3/online
    echo -n "cpu4 (big)   : "
    cat /sys/devices/system/cpu/cpu4/online
    echo -n "cpu5 (big)   : "
    cat /sys/devices/system/cpu/cpu5/online
fi



The Results

Do all this, and you should have something more or less daily driverable.  Install your desired software, and just go to town.  Please let me know what works and what doesn't!


Messages In This Thread
Installing Ubuntu 20.04 (Focal) with BSP uBoot with deep sleep and sound - by Syonyk - 06-15-2020, 07:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help installing Manjaro on eMMC of Pinebook Pro pine4546464 4 2,077 12-13-2023, 07:22 PM
Last Post: trillobite
  Sleep and external display - Are there any options? chris88233 7 1,664 09-04-2023, 09:03 PM
Last Post: wdt
  PineBook Pro seems to go to deep sleep, but doesn't wake up pogo 11 5,150 08-31-2023, 04:20 PM
Last Post: TRS-80
  Sound on Armbian Bram 1 875 04-01-2023, 03:16 PM
Last Post: TRS-80
  With the help of a friend, I installed a beautiful deep os distribution, but I won't wangyukunshan 0 591 03-03-2023, 10:56 PM
Last Post: wangyukunshan
  DiY - Installing Void Linux ARM On The Pinebook Pro vincele 1 1,176 11-28-2022, 05:03 PM
Last Post: tllim
  Hibernation and Speaker Sound Issues, First Month of PBP kebab 7 2,926 11-02-2022, 02:33 PM
Last Post: kebab
  Loud distorted speaker sound when connecting to power supply myself600 2 1,172 09-21-2022, 12:11 PM
Last Post: myself600
  How to make manjaro sleep or hibernate? KDE? regretfulpineuser 0 966 06-20-2022, 12:56 AM
Last Post: regretfulpineuser
  Problems installing/ booting a different Linux on PinebookPro v-man 3 3,046 03-22-2022, 06:37 PM
Last Post: pentamassiv

Forum Jump:


Users browsing this thread: 1 Guest(s)