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
Code:
sudo dpkg -i upstream/*.deb
Code:
./pbp-update-ap6256-firmware
Code:
./pbp-post-install
Code:
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
  How to rewrite uboot to emmc pineitup 5 8,812 12-27-2020, 10:35 AM
Last Post: nightranger73
  How to install Ubuntu to eMMC and to install KDE (Neon) Wizzard 66 98,694 12-22-2020, 03:05 PM
Last Post: Wizzard
  Installing WPS Office on Manjaro brent.thierens 5 9,702 07-13-2020, 03:13 AM
Last Post: brent.thierens
Exclamation Flash dhivael's SPI uboot (risky) clover 51 52,932 06-20-2020, 03:24 PM
Last Post: craftkiller
  How to boot Manjaro from NVME with uboot on eMMC as400 47 56,540 06-07-2020, 02:37 AM
Last Post: as400
  Instructions for Installing VS Code on Manjaro clover 6 14,324 06-04-2020, 09:37 PM
Last Post: pfeerick
  Installing Docker on Pinebook Pro - update 1/18/20 SuperXkoodA 4 7,556 03-24-2020, 03:19 PM
Last Post: chaoskampf
  (almost) upstream uboot/atf User 15997 27 30,967 02-08-2020, 10:18 PM
Last Post: Natrox
  Quick Guide to installing Ubuntu Unity on your Pinebook Pro andybleaden@gmail.com 19 23,369 02-03-2020, 11:17 AM
Last Post: MIchael
  Installing Wine i386 on Pinebook Pro wrzomar 0 3,246 01-31-2020, 03:52 PM
Last Post: wrzomar

Forum Jump:


Users browsing this thread: 1 Guest(s)