Browse Source

Initial commit

Oz N Tiram 4 years ago
commit
7be721b5d2
3 changed files with 125 additions and 0 deletions
  1. 93 0
      pureos-pinephone-build-instructions.txt
  2. BIN
      pureos-pp-helpers.tar.gz
  3. 32 0
      pureos-uboot-script.cmd

+ 93 - 0
pureos-pinephone-build-instructions.txt

@@ -0,0 +1,93 @@
+# Instructions for creating a PureOS Image for PinePhone by mozzwald
+########################################################################
+# You will need u-boot-tools package for your distro and it helps
+# to have binfmt and qemu packages for chrooting to the image.
+# Paths and devices may be different on your system. Always verify
+# before blindly copying and pasting commands.
+
+# Make a new working directory
+mkdir ~/purepp
+cd ~/purepp
+
+# Download and extract PinePhone phosh image (check for newer releases if you like)
+wget https://images.postmarketos.org/pinephone/pine-pinephone-20200218-phosh.img.xz
+unxz -d pine-pinephone-20200218-phosh.img.xz
+
+# Download and extract PureOS Librem 5 image (check for newer releases if you like)
+wget http://downloads.pureos.net/amber/phone/gnome/librem5/2020-02-25/librem5.img.xz
+unxz -d librem5.img.xz
+
+# Make temporary dirs for mounting images
+mkdir pmos-boot pmos-root pureos-boot pureos-root
+
+# List used loop devices
+losetup -a
+# List all loop devices
+ls /dev/loop*
+
+# The remaining commands should be run with sudo or as root user (sudo su)
+
+# Pick an unused loop device (5 in my case) and mount pmOS image with partitions
+losetup -P /dev/loop5 pine-pinephone-20200218-phosh.img
+
+# Pick an unused loop device (6 in my case) and mount PureOS image with partitions
+losetup -P /dev/loop6 librem5.img
+
+# Get pmOS PinePhone bootloader
+dd if=/dev/loop5 of=uboot-pmos.bin count=2048
+
+# Put pmOS PinePhone bootloader on PureOS image
+dd if=uboot-pmos.bin of=/dev/loop6 bs=1024 skip=8 seek=8
+
+# Mount partitions
+mount /dev/loop5p1 pmos-boot
+mount /dev/loop5p2 pmos-root
+mount /dev/loop6p1 pureos-boot
+mount /dev/loop6p2 pureos-root
+
+# Copy PinePhone kernel & dtb to PureOS image
+cp pmos-boot/vmlinuz-postmarketos-allwinner pureos-boot/
+cp pmos-boot/sun50i-a64-pinephone.dtb pureos-boot/
+
+# Copy PinePhone modules to PureOS image
+cp -pRv pmos-root/lib/modules/5.5.0 pureos-root/lib/modules/
+
+# Copy PinePhone firmware to PureOS image
+cp -pRv pmos-root/lib/firmware pureos-root/lib/
+
+# Make u-boot initramfs from PureOS initramfs
+mkimage -A arm -O linux -T ramdisk -C gzip -d pureos-boot/initrd.img pureos-boot/uInitrd.img
+
+# Get uboot-script
+wget https://mozzwald.com/pp/pureos-uboot-script.cmd -O pureos-boot/boot.cmd
+
+# Compile uboot script
+mkimage -A arm64 -T script -C none -d pureos-boot/boot.cmd pureos-boot/boot.scr
+
+# Put helper files into rootfs
+wget https://mozzwald.com/pp/pureos-pp-helpers.tar.gz
+cd pureos-root
+tar -pxvf ../pureos-pp-helpers.tar.gz
+
+# If you have binfmt setup for arm64/aarch64 then you can chroot and enable modem service
+# and do whatever else you want. Otherwise this needs done after bootup
+cp /usr/bin/qemu-aarch64-static usr/bin/
+chroot ./
+systemctl enable pinephone.service # enable modem service
+exit
+cd ..
+
+# Unmount disk images
+umount pmos-boot pmos-root pureos-boot pureos-root
+losetup -d /dev/loop5
+losetup -d /dev/loop6
+
+# Copy the new image to SD card
+dd if=librem5.img of=/dev/your-sd-card-device bs=1M
+
+# Optionally resize PureOS Root partition on SD card
+
+# Put in PinePhone and boot. WIN!
+Default username: purism
+Default password: 123456
+

BIN
pureos-pp-helpers.tar.gz


+ 32 - 0
pureos-uboot-script.cmd

@@ -0,0 +1,32 @@
+gpio set 114
+
+if test ${mmc_bootdev} -eq 0 ; then
+	echo "Booting from SD";
+	setenv bootdev 0;
+else
+	echo "Booting from eMMC";
+	setenv bootdev 2;
+fi;
+
+setenv bootargs init=/sbin/init rw console=tty0 console=ttyS0,115200 no_console_suspend earlycon=uart,mmio32,0x01c28000 panic=10 consoleblank=0 loglevel=1 cma=256M root=/dev/mmcblk${bootdev}p2
+
+printenv
+
+echo Loading DTB
+load mmc ${mmc_bootdev}:1 ${fdt_addr_r} sun50i-a64-pinephone.dtb
+
+echo Loading Initramfs
+load mmc ${mmc_bootdev}:1 ${ramdisk_addr_r} uInitrd.img
+
+echo Loading Kernel
+load mmc ${mmc_bootdev}:1 ${kernel_addr_r} vmlinuz-postmarketos-allwinner
+
+gpio set 115
+
+echo Resizing FDT
+fdt addr ${fdt_addr_r}
+fdt resize
+
+echo Booting kernel
+gpio set 116
+booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}