100200300400500600
  
 
 

Linux Phone

Aeons ago I've ordered a phone. A Librem Phone. Librem5 to be precise. It was all well forgotten history when all of a sudden last spring I got notification it has been delayed.

After that glorious event I've started monitoring the progress of the almost finishing development with greater interest which also led me to know there appered to be another project promising to deliver mainline linux phone in about half a year. The price tag was ridiculously low (comparing to L5) so I just gave it a shot - just in case.

Now last week you can imagine the degree of my bewilderment when I've received sealed envelop stating the customs office awaits for my decision on how to proceed with some electronic shipment to me, which clearly need tax clearance (if I want to proceed with the shipment).

So here we are, today they brought it to me, wrapped in a bubble plastic. Which I quickly removed and disposed without a trace. And here's the result:

Forgot to mention - the reason I gave PinePhone a try is because by November '19 I've realized I won't see the developer batches of the L5 (Amber, Birch, Chestnut, Dogwood) but I've itched to try PureOS on mobile, because I still believe it's a thing. The Right Thing.

PinePhone

The phone is big. Damn big. To put it in the right context I consider anything bigger than 5"2 a yuge, YUGE Phablet. This one is bigger. The L5 will be also bigger in the end so I have a time to get used to it now.

It came in ascetic box containing just the Phone and USB-C cable. Just what I needed! (it will be second USB-C cable in my inventory, will put in the car!) The battery is isolated with the sticker, so you need to pry the back cover open and remove the sticker. Maybe also to put sdcard - but we'll touch it later. The pre-installed image is also ascetic - PostmarketOS bootscreen ends up with some simple Testing shell which allows you to test some HW components - touch screen, rgb led, earpiece, speaker, motor, radio modules.

All tests passed but GSM for obvious reason (no sim card inserted). Yea that's pretty much all the capabilities of the pre-installed image. You may need to hold down power button for a bit to turn it off. Or just wait till shut itself down.

PureOS

As I have mentioned before the goal to get Pine was to use it as a devkit. Because L5 devkit is also not available for sale (same as the phone) and even if it were it costs some ridiculous amount of money (not much cheaper than the phone itself).

But Pure OS is pure. What it means is that it does not contain any closed source binary files, neither software nor firmware. It is designed for Pure hardware. The hardware which just works when you turn it on. It shouldn't require any obscure initialisation vector or blob upload to make it work - just pop on and on it goes. That's also the goal of the Librem hardware design. So in the end some hardware will likely won't work on pureOS without additional love. Or hate.

So let's think, we have two SoCs which are mostly mainlined, so one would think - just take the image, put there bootloader - and the job is done. Ok, let's just try that! First - download latest build from the Puri.sm CI: click on the latest successfull build and then on librem5.img.xz build artifact. Next we need to download latest bootloader (if we don't want to build it ourselves) - for that we can use Pine64 u-boot CI. Click at Download build artifacts at latest successfull job. Finally put everything together: unpack xz image and copy u-bbot there:

# dd if=u-boot-sunxi-with-spl-pinephone.bin of=librem5.img bs=1k seek=8
613+1 Datensätze ein
613+1 Datensätze aus
627800 bytes (628 kB, 613 KiB) copied, 0,00306281 s, 205 MB/s
#

The 8k offset is what A64 is looking for to boot. If you don't trust all those pre-built images - you can always git clone and build it yourself, u-boot is pretty much upstreamed. On my dev laptop I only needed to install aarch64-linux-gnu-gcc, swig and dtc. And then - follow official guidelines

Now copy resulting image to uSD card (dd if=librem5.img of=/dev/sdb bs=4m) and insert the card into the phone. The moment of truth... Still boots into testing image :( *sigh*

Not what we expected. Let's connect serial console and see what is going on. Serial console is provided via audio jack (3.5mm) when killswitch 6 is off. So here's what we get:

U-Boot SPL 2019.04-01015-g8dacfcdc32 (Dec 19 2019 - 11:58:05 +0000)
DRAM: 2048 MiB
Trying to boot from MMC1
NOTICE:  BL31: v2.2(debug):v2.2-221-g0d35873c
NOTICE:  BL31: Built : 11:55:04, Dec 19 2019
NOTICE:  BL31: Detected Allwinner A64/H64/R18 SoC (1689)
NOTICE:  BL31: Found U-Boot DTB at 0x4080ea8, model: PinePhone
INFO:    ARM GICv2 driver initialized
INFO:    Configuring SPC Controller
INFO:    PMIC: Probing AXP803 on RSB
INFO:    PMIC: dcdc1 voltage: 3.300V
INFO:    PMIC: dcdc5 voltage: 1.200V
INFO:    PMIC: dcdc6 voltage: 1.100V
INFO:    PMIC: dldo1 voltage: 3.300V
INFO:    PMIC: dldo2 voltage: 3.300V
INFO:    PMIC: dldo4 voltage: 3.300V
INFO:    PMIC: Enabling DC SW
INFO:    BL31: Platform setup done
INFO:    BL31: Initializing runtime services
INFO:    BL31: cortex_a53: CPU workaround for 843419 was applied
INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x4a000000
INFO:    SPSR = 0x3c9


U-Boot 2019.04-01015-g8dacfcdc32 (Dec 19 2019 - 11:58:05 +0000) Pine64

CPU:   Allwinner A64 (SUN50I)
Model: PinePhone
DRAM:  2 GiB
MMC:   Device 'mmc@1c11000': seq 1 is in use by 'mmc@1c10000'
mmc@1c0f000: 0, mmc@1c10000: 2, mmc@1c11000: 1
Loading Environment from FAT... Unable to use mmc 1:1... In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
starting USB...
No working controllers found
Hit any key to stop autoboot:  0
=> ls mmc 0:1
<DIR>       1024 .
<DIR>       1024 ..
<DIR>      12288 lost+found
          169720 config-5.6.0-rc2-g21f52c5a2
         7612896 vmlinuz-5.6.0-rc2-g21f52c5a2
<DIR>       1024 dtbs
<SYM>         46 dtb-5.6.0-rc2-g21f52c5a2
<SYM>         46 dtb
         4493710 System.map-5.6.0-rc2-g21f52c5a2
         9916139 initrd.img-5.6.0-rc2-g21f52c5a2
        17902080 vmlinuz
        17902080 Image
         9916139 initrd.img
            2382 boot.scr
        17902080 vmlinuz.bak
        10434711 initrd.img.bak
            2382 boot.scr.bak
=>

Are we really booting from uSD? I mean is MMC1 SD or on-board eMMC? Let's try to remove uSD and boot again:

U-Boot SPL 2020.01 (Jan 09 2020 - 12:17:54 +0000)
DRAM: 2048 MiB
Trying to boot from MMC2
NOTICE:  BL31: v2.1(release):v3.10.0_rc3-151-ga4b61dc7d9
NOTICE:  BL31: Built : 16:21:59, Jun 12 2019
NOTICE:  BL31: Detected Allwinner A64/H64/R18 SoC (1689)
NOTICE:  BL31: Found U-Boot DTB at 0x408e1a8, model: Pine64 LTS
NOTICE:  BL31: PMIC: Detected AXP803 on RSB.


U-Boot 2020.01 (Jan 09 2020 - 12:17:54 +0000) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: Pine64 LTS
DRAM:  2 GiB
MMC:   mmc@1c0f000: 0, mmc@1c11000: 1
Loading Environment from FAT... Unable to use mmc 1:1... In:    serial
Out:   serial
Err:   serial
Net:   phy interface7
Could not get PHY for ethernet@1c30000: addr 1
No ethernet found.

starting USB...
Bus usb@1c1a000: USB EHCI 1.00
Bus usb@1c1a400: USB OHCI 1.0
Bus usb@1c1b000: USB EHCI 1.00
Bus usb@1c1b400: USB OHCI 1.0
scanning bus usb@1c1a000 for devices... 1 USB Device(s) found
scanning bus usb@1c1a400 for devices... 1 USB Device(s) found
scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
scanning bus usb@1c1b400 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
=>

Yea, ok, convinced. Apparently it cannot intialize the platform from uSD because it expects different image. Not sure whether it is hardcoded into the u-boot (you can pre-configure boot params while building it) but one thing is clear - we need to adjust boot and initialisation process.

Right, so what might we be missing? Flat Device Table file first - doesn't seem right as it clearly says imx8. There's patch submitted to include it into mainline, however it's not there yet. Let's take it from origins: curl https://gitlab.com/pine64-org/linux/-/raw/pine64-kernel-5.5.y/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dts -O and copy to the image. The boot.scr file - the one in the image looks way more complicated than the one suggested at pine64 wiki - but that's what we can try manually from the shell.

Hit any key to stop autoboot:  0
=> ls mmc 0:1
<DIR>       1024 .
<DIR>       1024 ..
<DIR>      12288 lost+found
          169720 config-5.6.0-rc2-g21f52c5a2
         7612896 vmlinuz-5.6.0-rc2-g21f52c5a2
<DIR>       1024 dtbs
<SYM>         46 dtb-5.6.0-rc2-g21f52c5a2
<SYM>         46 dtb
         4493710 System.map-5.6.0-rc2-g21f52c5a2
         9916139 initrd.img-5.6.0-rc2-g21f52c5a2
        17902080 vmlinuz
        17902080 Image
         9916139 initrd.img
            2382 boot.scr
           29746 sun50i-a64-pinephone.dtb
        17902080 vmlinuz.bak
        10434711 initrd.img.bak
            2382 boot.scr.bak
=> load mmc 0:1 ${fdt_addr_r} sun50i-a64-pinephone.dtb
29746 bytes read in 5 ms (5.7 MiB/s)
> load mmc 0:1 ${kernel_addr_r} Image
17902080 bytes read in 928 ms (18.4 MiB/s)
=> load mmc 0:1 ${ramdisk_addr_r} initrd.img
9916139 bytes read in 521 ms (18.2 MiB/s)
=> booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
=>

Oops, something is not right. Well while we are here we can try to load initrd from onboard flash (understanding how stupid it is) but still let's try. Oh and we forgot to set bootparams!

=> ls mmc 1:1
<DIR>       1024 .
<DIR>       1024 ..
<DIR>      12288 lost+found
        15091720 vmlinuz-postmarketos-allwinner
         4580494 uInitrd-postmarketos-allwinner
         4580430 initramfs-postmarketos-allwinner
         6751937 initramfs-postmarketos-allwinner-extra
             919 boot.scr
        15091784 uImage-postmarketos-allwinner
           29575 sun50i-a64-pinephone.dtb
=> load mmc 1:1 ${ramdisk_addr_r} uInitrd-postmarketos-allwinner
4580494 bytes read in 210 ms (20.8 MiB/s)
=> setenv bootargs console=ttyS0,115200 consoleblank=0 panic=10 root=/dev/mmcblk0p2 rw
=>booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
## Loading init Ramdisk from Legacy Image at 4fe00000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
   Data Size:    4580430 Bytes = 4.4 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
ERROR: Did not find a cmdline Flattened Device Tree
   Loading Ramdisk to 49ba1000, end 49fff44e ... OK

Starting kernel ...

... And nothing. Kind of expected but still sad there's no miracle. The FDT error though indicates the downloaded fdt file is wrong. If we retry and load dtb from flash - it loads ok

=> booti ${kernel_addr_r} ${ramdisk_addr_r} ${ftd_addr_r}
## Loading init Ramdisk from Legacy Image at 4fe00000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
   Data Size:    4580430 Bytes = 4.4 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
   Loading Ramdisk to 49ba1000, end 49fff44e ... OK

Starting kernel ...

Which doesn't help still. Also the L5 ramdisk is still not accepted by the boot loader - the above attempt is still using inird from flash (postmarketOS). Next attempt we can try is to boot full postmarketOS stack but point to l5 image by bootargs

=> load mmc 1:1 $fdt_addr_r sun50i-a64-pinephone.dtb
29575 bytes read in 6 ms (4.7 MiB/s)
=> load mmc 1:1 $ramdisk_addr_r initramfs-postmarketos-allwinner
4580430 bytes read in 210 ms (20.8 MiB/s)
=> load mmc 1:1 $kernel_addr_r vmlinuz-postmarketos-allwinner
15091720 bytes read in 679 ms (21.2 MiB/s)
=> booti $kernel_addr_r $ramdisk_addr_r $fdt_addr_r
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
=> load mmc 1:1 $ramdisk_addr_r uInitrd-postmarketos-allwinner
4580494 bytes read in 207 ms (21.1 MiB/s)
=> booti $kernel_addr_r $ramdisk_addr_r $fdt_addr_r
## Loading init Ramdisk from Legacy Image at 4fe00000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
   Data Size:    4580430 Bytes = 4.4 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
   Loading Ramdisk to 49ba1000, end 49fff44e ... OK
   Loading Device Tree to 0000000049b96000, end 0000000049ba0386 ... OK

Starting kernel ...


Welcome to postmarketOS
Kernel 5.4.0 on an aarch64 (/dev/ttyS0)
pine64-pinephone login:

Ok, we know now the u-boot is good, let's try again this time really setting the bootargs though:

=> setenv bootargs root=/dev/mmcblk0p2 rootwait console=ttyS0,115200 loglevel=7 \
		   panic=10 rw
=> load mmc 1:1 $fdt_addr_r sun50i-a64-pinephone.dtb
29575 bytes read in 6 ms (4.7 MiB/s)
=> load mmc 1:1 $ramdisk_addr_r initramfs-postmarketos-allwinner
4580430 bytes read in 210 ms (20.8 MiB/s)
=> load mmc 1:1 $kernel_addr_r vmlinuz-postmarketos-allwinner
15091720 bytes read in 679 ms (21.2 MiB/s)
=> booti $kernel_addr_r $ramdisk_addr_r $fdt_addr_r
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
=> load mmc 1:1 $ramdisk_addr_r uInitrd-postmarketos-allwinner
4580494 bytes read in 207 ms (21.1 MiB/s)
=> booti $kernel_addr_r $ramdisk_addr_r $fdt_addr_r

... whoops, lot of kernel messages went beyond scrollbuffer ...

[    3.006133] mmc0: new high speed SDHC card at address b368
[    3.012483] mmcblk0: mmc0:b368       29.8 GiB
[    3.019243]  mmcblk0: p1 p2
[    3.023161] sunxi-mmc 1c11000.mmc: initialized, max. request size: 2048 KB, uses new >
	       timings mode
[    3.037888] sun6i-rtc 1f00000.rtc: setting system clock to 2019-08-23T08:56:03 UTC >
	       (1566550563)
[    3.049819] Freeing unused kernel memory: 768K
[    3.052687] mmc1: new high speed SDIO card at address 0001
[    3.082804] Run /init as init process
### postmarketOS initramfs ###
NOTE: All output from the initramfs gets redirected to:
/pmOS_init.log
If you want to disable this behavior (e.g. because you're
debugging over serial), please add this to your kernel
command line: PMOS_NO_OUTPUT_REDIRECT
[    3.154993] mmc2: new DDR MMC card at address 0001
[    3.160714] mmcblk2: mmc2:0001  14.7 GiB
[    3.165163] mmcblk2boot0: mmc2:0001  partition 1 4.00 MiB
[    3.171049] mmcblk2boot1: mmc2:0001  partition 2 4.00 MiB
[    3.181253]  mmcblk2: p1 p2
[    3.618056] using random self ethernet address
[    3.622532] using random host ethernet address
[    3.636393] usb0: HOST MAC 32:67:d9:0c:10:16
[    3.640764] usb0: MAC ca:9b:fa:65:73:81
[    3.771983] EXT4-fs (mmcblk2p1): mounted filesystem without journal. Opts: (null)
[    3.971546] configfs-gadget gadget: high-speed config #1: c
[    6.874165] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: >
	       (null)

Welcome to postmarketOS
Kernel 5.4.0 on an aarch64 (/dev/ttyS0)
pine64-pinephone login:

Right, ok, two outcomes. First - seems L5 mainline kernel doesn't boot here regardless of the ramfs (50 shades of mainlineness). And it seems ramfs unconditionaly loaded builtin image so we need to find a way to use l5 initrd.

Note though - L5 kernel didn't even try to load FDT (no lines starting ## Flattened Device Tree blob at 4fa00000) - which may explain why it failed to boot.

Chapter 2: Let's take it serious

Let's take step back and rethink it. First of all - there's absolutely no problem to rebuild the u-boot and be sure it is fit for our purpose (rather than somene's else purpose). Second - L5 uboot seems to be way further from mainline than A64 - perhaps it is even capable loading native linux initrd. So two tasks first - build u-boot and ubootify initrd (using mkimage).

There's mainline u-boot repo and Pine64 u-boot repo. Pine version is not far from mainline and consists of few more commits (specific to pinephone nevertheless). So we will clone main repo and rebase Pine64 on it:

$ git clone https://github.com/ARM-software/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_a64 DEBUG=1 bl31
$ cd ..
$ git clone https://gitlab.denx.de/u-boot/u-boot.git
$ cd u-boot
$ git remote add pine64 https://gitlab.com/pine64-org/u-boot.git
$ git pull -r pine64 master
$ make CROSS_COMPILE=aarch64-linux-gnu- \
BL31=../arm-trusted-firmware/build/sun50i_a64/debug/bl31.bin pine64-lts_defconfig
$ make CROSS_COMPILE=aarch64-linux-gnu- \
BL31=../arm-trusted-firmware/build/sun50i_a64/debug/bl31.bin menuconfig
$ make CROSS_COMPILE=aarch64-linux-gnu- \
BL31=../arm-trusted-firmware/build/sun50i_a64/debug/bl31.bin

So - first we build el3 secure loader, then merge tips of mainline and pine branches of u-boot, then configuring it for Pin64-LTS and adjusting it a bit. The adjustment is mainly to make pinephone dtb default one and also enable ext4 fs for environment. But it can live without as far as I understand (we're loading dtd explicitly anyway). After build we have built binaries of dtb (arch/arm/dts/sun50i-a64-pinephone.dtb) and uboot-with-spl (u-boot-sunxi-with-spl.bin).

Next step is quite simple - mount uSD card and convert initrd umage into u-boot format. Also we can prepare boot.scr script:

# dd if=/home/ruff/co/u-boot/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=8k seek=1
88+1 Datensätze ein
88+1 Datensätze aus
725544 bytes (726 kB, 709 KiB) copied, 0,935345 s, 776 kB/s
# mount /dev/sdb1 /mnt/sd1/
# cd /mnt/sd1/
# mkimage -A arm64 -T ramdisk -n pinephone -d initrd.img initrd.uimg
Image Name:   pinephone
Created:      Sat Feb 29 17:26:24 2020
Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
Data Size:    9916139 Bytes = 9683.73 KiB = 9.46 MiB
Load Address: 00000000
Entry Point:  00000000
# echo "setenv bootargs root=/dev/mmcblk0p2 rootwait console=ttyS0,115200 loglevel=7 panic=10
load mmc 0:1 \$kernel_addr_r Image
load mmc 0:1 \$ramdisk_addr_r initrd.uimg
load mmc 0:1 \$fdt_addr_r sun50i-a64-pinephone.dtb
booti \$kernel_addr_r \$ramdisk_addr_r \$fdt_addr_r" > boot.txt
# mv boot.scr boot.scr.orig
# mkimage -A arm64 -T script -n pinephone -d boot.txt boot.scr
Image Name:   pinephone
Created:      Sat Feb 29 17:32:08 2020
Image Type:   AArch64 Linux Script (gzip compressed)
Data Size:    268 Bytes = 0.26 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 260 Bytes = 0.25 KiB = 0.00 MiB
# cp /home/ruff/co/u-boot/arch/arm/dts/sun50i-a64-pinephone.dtb ./
# cd
# umount /mnt/sd1
# screen /dev/ttyUSB0 115200 8n1
U-Boot SPL 2020.04-rc3-00013-g024b0654fc (Feb 29 2020 - 15:28:43 +0100)
DRAM: 2048 MiB
Trying to boot from MMC1
NOTICE:  BL31: v2.2(debug):v2.2-784-g896d684de
NOTICE:  BL31: Built : 23:32:10, Feb 26 2020
NOTICE:  BL31: Detected Allwinner A64/H64/R18 SoC (1689)
NOTICE:  BL31: Found U-Boot DTB at 0x4094540, model: Pine64 LTS
INFO:    ARM GICv2 driver initialized
INFO:    Configuring SPC Controller
INFO:    PMIC: Probing AXP803 on RSB
INFO:    PMIC: dcdc1 voltage: 3.300V
INFO:    PMIC: dcdc5 voltage: 1.200V
INFO:    PMIC: dcdc6 voltage: 1.100V
INFO:    PMIC: dldo1 voltage: 3.300V
INFO:    PMIC: Enabling DC SW
INFO:    BL31: Platform setup done
INFO:    BL31: Initializing runtime services
INFO:    BL31: cortex_a53: CPU workaround for 843419 was applied
INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x4a000000
INFO:    SPSR = 0x3c9


U-Boot 2020.04-rc3-00013-g024b0654fc (Feb 29 2020 - 15:28:43 +0100) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: Pine64 LTS
DRAM:  2 GiB
MMC:   mmc@1c0f000: 0, mmc@1c11000: 1
Loading Environment from EXT4... ** File not found uboot.env **

** Unable to read "uboot.env" from mmc1:1 **
Loading Environment from FAT... Unable to use mmc 1:1... In:    serial
Out:   serial
Err:   serial
Net:   phy interface7
Could not get PHY for ethernet@1c30000: addr 1
No ethernet found.

starting USB...
Bus usb@1c1a000: USB EHCI 1.00
Bus usb@1c1a400: USB OHCI 1.0
Bus usb@1c1b000: USB EHCI 1.00
Bus usb@1c1b400: USB OHCI 1.0
scanning bus usb@1c1a000 for devices... 1 USB Device(s) found
scanning bus usb@1c1a400 for devices... 1 USB Device(s) found
scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
scanning bus usb@1c1b400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
332 bytes read in 3 ms (107.4 KiB/s)
## Executing script at 4fc00000
17902080 bytes read in 937 ms (18.2 MiB/s)
9916203 bytes read in 592 ms (16 MiB/s)
20627 bytes read in 6 ms (3.3 MiB/s)
## Loading init Ramdisk from Legacy Image at 4fe00000 ...
   Image Name:   pinephone
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    9916139 Bytes = 9.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
EHCI failed to shut down host controller.
   Loading Ramdisk to 4968b000, end 49fffeeb ... OK
   Loading Device Tree to 0000000049682000, end 000000004968a092 ... OK

Starting kernel ...

Ok, so here we reached almost the same result :( But now we know that uboot has loaded, ramdisk has loaded, fdt has loaded, but kernel is still not booting. However we may try to use new ramfs and working (postmarketos) kernel:

=> load mmc 0:1 $ramdisk_addr_r initrd.uimg
9916203 bytes read in 602 ms (15.7 MiB/s)
> load mmc 1:1 $kernel_addr_r vmlinuz-postmarketos-allwinner
15091720 bytes read in 658 ms (21.9 MiB/s)
=> load mmc 0:1 $fdt_addr_r sun50i-a64-pinephone.dtb
20627 bytes read in 6 ms (3.3 MiB/s)
=> setenv bootargs root=/dev/mmcblk0p2 console=tyyS0,115200 loglevel=7 panic=10 rw
=> booti $kernel_addr_r $ramdisk_addr_r $fdt_addr_r
## Loading init Ramdisk from Legacy Image at 4fe00000 ...
   Image Name:   pinephone
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    9916139 Bytes = 9.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
EHCI failed to shut down host controller.
   Loading Ramdisk to 4968b000, end 49fffeeb ... OK
   Loading Device Tree to 0000000049682000, end 000000004968a092 ... OK

Starting kernel ...


U-Boot SPL 2020.04-rc3-00013-g024b0654fc (Feb 29 2020 - 15:28:43 +0100)
DRAM: 2048 MiB
...

Comparing to L5 kernel the screen backlight turned on as if it tried to boot and then it went into boot loop. So again miracle didn't happen. Modules between different kernel versions do not work - proven above :) It seems then the image needs to be rebuilt as well. Or - we need to return to the first part of the story where we've mentioned Pine64 CI/CD artifacts (latest one) which is again an alternative to building it yourself. This time we just need to use linux repo instead of u-boot. The artifacts archive contains debian packages which we can install strait to the image - however we need qemu-arm64 for that. Easier approach is just ro unpack manually and force-overwrite later:

# curl -L https://gitlab.com/pine64-org/linux/-/jobs/artifacts/pine64-kernel-5.5.y/\
download?job=build > /tmp/p64l.zip
# unzip -d /tmp/p64l /tmp/p64l.zip
# cd /tmp/p64l
# ar x $(ls -1 linux-image-*_arm64.deb|grep -v dbg) data.tar.xz
# mount /dev/sdb2 /mnt/sd1/
# mount /dev/sdb1 /mnt/sd1/boot/
# cd /mnt/sd1/
# tar xf /tmp/p64l/data.tar.xz
# cp $(ls -1 /tmp/p64l/linux-image-*_arm64.deb|grep -v dbg) var/cache/apt/archives/
# zcat /boot/Image.gz-*-pine64 > /boot/Image
# cd
# umount /mnt/sd1/boot /mnt/sd1
# eject /dev/sdb
$ screen /dev/ttyUSB0 115200 8n1
... sorry I didn't manage to capture it ...
[  OK  ] Started Modem Manager.
[  OK  ] Stopped Power key hack.
[  OK  ] Started Power key hack.
[   15.058916] systemd-journald[1438]: File /var/log/journal/265b31e1705240c58257aa>
476a3b381b/user-1000.journal corrupted or uncleanly shut down, renaming and replacing.
[  OK  ] Stopped Power key hack.
[  OK  ] Started Power key hack.
[  OK  ] Started User Manager for UID 1000.
[  OK  ] Started Session 1 of user purism.
[  OK  ] Stopped Power key hack.
[  OK  ] Started Power key hack.
[  OK  ] Stopped Power key hack.
[  OK  ] Started Power key hack.

Debian GNU/Linux 10 pureos ttyS0


pureos login: root
Password:

Login incorrect
pureos login: purism
Password:
Last login: Thu Feb 14 10:15:22 UTC 2019 on tty7
Linux pureos 5.5.0-pine64 #1 SMP Sun Mar 1 01:15:34 UTC 2020 aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
purism@pureos:~$

The kernel yet was unable to initialize graphics - the backlight is on however posh is unable to start due to missing EGL. But now that we have linux booted we can fix that remotely - just need to connect to wifi (use nmtui) and install tinysshd to get rid of dodgy serial cable.

$ ssh purism@pine
purism@pureos:~$ uptime
 21:46:26 up  1:23,  2 users,  load average: 0.00, 0.02, 0.18
purism@pureos:~$ free
              total        used        free      shared  buff/cache   available
Mem:        1973820       99432     1447364         788      427024     1728284
Swap:             0           0           0
purism@pureos:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            831M     0  831M   0% /dev
tmpfs           193M  716K  193M   1% /run
/dev/mmcblk0p2   30G  2.0G   26G   7% /
tmpfs           964M     0  964M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           964M     0  964M   0% /sys/fs/cgroup
/dev/mmcblk0p1  176M  115M   52M  70% /boot
tmpfs           193M  8.0K  193M   1% /run/user/1000
purism@pureos:~$

Digging deeper revealed following: lima driver is built-in into kernel, pureOS mesa is recent enough to have mali utgart implementation (19.2, utgart included into 19.1). EGL cannot run because of missing /dev/dri/renderD128 node, which might be missing due to missing graphics definition in the DTB file we've put into boot partition or due to wrong initrd (which we still used from purism kernel). When we force-owerwrite kernel deb package that also executes initramfs hook which builds now kernel specific one - so we can replace it. Either way after refreshing initrd and replacing dtb file (and rebooting) - the graphics is working - starting from tux boot logo and down to functional phosh:

purism@pureos:~$ LIBGL_DEBUG=verbose eglinfo
EGL client extensions string:
    EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query
    EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses
    EGL_EXT_client_extensions EGL_KHR_debug EGL_EXT_platform_wayland
    EGL_EXT_platform_x11 EGL_MESA_platform_gbm
    EGL_MESA_platform_surfaceless EGL_EXT_platform_device

GBM platform:
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/purism/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/purism/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/purism/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/purism/.drirc: No such file or directory.
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 5, (OK)
drmOpenDevice: node name is /dev/dri/renderD128
... skip spamming multiple render node retries ...
MESA-LOADER: failed to open kms_swrast (search paths /usr/lib/aarch64-linux-gnu/dri:\
	\$${ORIGIN}/dri:/usr/lib/dri)
failed to load driver: kms_swrast
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/purism/.drirc: No such file or directory.
libEGL warning: did not find extension DRI2_Flush version 1
libEGL warning: did not find extension DRI_IMAGE version 1
eglinfo: eglInitialize failed
...
root@pureos:~# cp /usr/lib/linux-image-5.5.0-pine64/allwinner/sun50i-a64-pinephone.dtb\
 /boot/
root@pureos:~# mkimage -A arm64 -T ramdisk -n pinephone -d \
/boot/initrd.img-5.5.0-pine64 /boot/initrd.uimg
root@pureos:~# reboot

Sat Feb 29 13:01:44 2020 Upd.: Wed Mar 4 17:23:48 2020
 
 
© ruff 2011