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!
#2
Thank you for the time you took to write this down! Smile
I just wanted to the same thing, though I saw that the image I would use to flash the eMMC has only 4 GBs of space. I resized the partition (the 4th) to take up the rest of te space left on the SD, but the SD never boot. What did you do to have the necessary space there to unzip the xz image?
#3
Boot the image as-is on the SD card, then either copy the xz over, or shut down and put it on from the remote system. I haven't found a clean way to do that all in one step.
#4
great op post. i will update the systempartitions script for the single partition variety.
#5
This is a great write up! If you don't mind @Syonyk I'm going to place a copy of the thread into the PBP Tutorials forum.
#6
dd can use a pipeline, so you don't need to extract,, as so "xzcat someImage.xz| dd .........."
(obviously this takes place of "if=......" ) (zcat for gz or zip)
OR
you have perfectly fine usb sockets, put on usb stick
#7
(06-16-2020, 10:39 AM)xmixahlx Wrote: great op post. i will update the systempartitions script for the single partition variety.

Thanks. So, in general, my approach should work regardless of the partition layout. The code doesn't care about partitions, it only looks at offsets on the storage media. It should be the responsibility of the distros to stay out of the way (or make partitions at the offsets for convenience). Given this, I think writing to the actual fixed offsets on the media is the correct and general solution.

(06-16-2020, 10:41 AM)tophneal Wrote: This is a great write up! If you don't mind @Syonyk I'm going to place a copy of the thread into the PBP Tutorials forum.

Go for it, I tweaked a few formatting things, so should be good to go. I'll update it with some other stuff eventually, but this is the core.
#8
I'm having trouble getting this to work from the emmc.  I can put the Ubuntu 20.04 image on to the SD card and boot that just fine assuming the emmc has the Manjaro image on it.  If I copy the ubuntu to the emmc whenever I power up I just get the amber power light forever, the only way out of that issue I've found is to pull the emmc and write majaro image back to it and boot again.

I have tried both writing the emmc from the active ubuntu SD boot and just writing it directlly from my desktop system using the usb->emmc adapter.  I get the same result both ways just the amber power led.

Is there a doc anywhere that really describes the details of the boot process?
#9
Toss a serial adapter on and see where it's failing?

There are several hard coded offsets where the boot firmware is loaded from, starting with 32kb. If they're not right, the system won't boot. Firmware comes from the eMMC first, then the SD card is checked.

However, if you're seeing the amber light, it means at least some of the firmware is loading.
#10
I HAVE SERIAL! The cable came yesterday. Here is the serial output after using Etcher (I know, it's not DD, but Etcher has never failed me) to write the Focal Gnome IMG to my EMMC:

Script started on 2020-07-08 09:52:48-0500
^[]0;me@me-desktop: ~^G^[[01;32me@me-desktop^[[00m:^[[01;34m~^[[00m$ exit^H^H^H^Hsudo screen /dev/ttyUSB0 1500000
[sudo] password for me: [redacted]^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H
^[[!p^[[?3;4l^[[4l^[>^[[?1049h^[[22;0;0t^[[4l^[[?1h^[=^[[0m^[(B^[[1;54r^[[H^[[2J^[[H^[[2J
U-Boot TPL 2020.01-ayufan-2013-gdb96b24f (Apr 13 2020 - 08:44:03)
Channel 0: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
256B stride
lpddr4_set_rate: change freq to 400000000 mhz 0, 1
lpddr4_set_rate: change freq to 800000000 mhz 1, 0
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.01-ayufan-2013-gdb96b24f (Apr 13 2020 - 08:44:03 +0000)
^[[?1l^[>^[[54;1H
^[[?1049l^[[23;0;0t[detached from 13560.pts-2.timothy-desktop]
^[]0;me@me-desktop: ~^G^[[01;32mme@me-desktop^[[00m:^[[01;34m~^[[00m$ exit
exit

Script done on 2020-07-08 09:55:21-0500

Does this help at all?
__________________________________________________________________________________________________________

EDIT: Interestingly, when I insert a MicroSD card and try to boot it fails as well Dodgy  . Here is the serial ouput:

U-Boot TPL 2020.01-ayufan-2013-gdb96b24f (Apr 13 2020 - 08:44:03)
Channel 0: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
256B stride
lpddr4_set_rate: change freq to 400000000 mhz 0, 1
lpddr4_set_rate: change freq to 800000000 mhz 1, 0
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.01-ayufan-2013-gdb96b24f (Apr 13 2020 - 08:44:03 +0000)
Trying to boot from MMC2
mmc_load_image_raw_sector: mmc block read error
Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
Trying to boot from MMC2
mmc_load_image_raw_sector: mmc block read error
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help installing Manjaro on eMMC of Pinebook Pro pine4546464 4 3,015 12-13-2023, 07:22 PM
Last Post: trillobite
  Sleep and external display - Are there any options? chris88233 7 2,829 09-04-2023, 09:03 PM
Last Post: wdt
  PineBook Pro seems to go to deep sleep, but doesn't wake up pogo 11 7,037 08-31-2023, 04:20 PM
Last Post: TRS-80
  Sound on Armbian Bram 1 1,284 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 776 03-03-2023, 10:56 PM
Last Post: wangyukunshan
  DiY - Installing Void Linux ARM On The Pinebook Pro vincele 1 1,516 11-28-2022, 05:03 PM
Last Post: tllim
  Hibernation and Speaker Sound Issues, First Month of PBP kebab 7 3,840 11-02-2022, 02:33 PM
Last Post: kebab
  Loud distorted speaker sound when connecting to power supply myself600 2 1,565 09-21-2022, 12:11 PM
Last Post: myself600
  How to make manjaro sleep or hibernate? KDE? regretfulpineuser 0 1,160 06-20-2022, 12:56 AM
Last Post: regretfulpineuser
  Problems installing/ booting a different Linux on PinebookPro v-man 3 3,582 03-22-2022, 06:37 PM
Last Post: pentamassiv

Forum Jump:


Users browsing this thread: 1 Guest(s)