pureos-pinephone-build-instructions.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Instructions for creating a PureOS Image for PinePhone by mozzwald
  2. ########################################################################
  3. # You will need u-boot-tools package for your distro and it helps
  4. # to have binfmt and qemu packages for chrooting to the image.
  5. # Paths and devices may be different on your system. Always verify
  6. # before blindly copying and pasting commands.
  7. # Make a new working directory
  8. mkdir ~/purepp
  9. cd ~/purepp
  10. # Download and extract PinePhone phosh image (check for newer releases if you like)
  11. wget https://images.postmarketos.org/pinephone/pine-pinephone-20200218-phosh.img.xz
  12. unxz -d pine-pinephone-20200218-phosh.img.xz
  13. # Download and extract PureOS Librem 5 image (check for newer releases if you like)
  14. wget http://downloads.pureos.net/amber/phone/gnome/librem5/2020-02-25/librem5.img.xz
  15. unxz -d librem5.img.xz
  16. # Make temporary dirs for mounting images
  17. mkdir pmos-boot pmos-root pureos-boot pureos-root
  18. # List used loop devices
  19. losetup -a
  20. # List all loop devices
  21. ls /dev/loop*
  22. # The remaining commands should be run with sudo or as root user (sudo su)
  23. # Pick an unused loop device (5 in my case) and mount pmOS image with partitions
  24. losetup -P /dev/loop5 pine-pinephone-20200218-phosh.img
  25. # Pick an unused loop device (6 in my case) and mount PureOS image with partitions
  26. losetup -P /dev/loop6 librem5.img
  27. # Get pmOS PinePhone bootloader
  28. dd if=/dev/loop5 of=uboot-pmos.bin count=2048
  29. # Put pmOS PinePhone bootloader on PureOS image
  30. dd if=uboot-pmos.bin of=/dev/loop6 bs=1024 skip=8 seek=8
  31. # Mount partitions
  32. mount /dev/loop5p1 pmos-boot
  33. mount /dev/loop5p2 pmos-root
  34. mount /dev/loop6p1 pureos-boot
  35. mount /dev/loop6p2 pureos-root
  36. # Copy PinePhone kernel & dtb to PureOS image
  37. cp pmos-boot/vmlinuz-postmarketos-allwinner pureos-boot/
  38. cp pmos-boot/sun50i-a64-pinephone.dtb pureos-boot/
  39. # Copy PinePhone modules to PureOS image
  40. cp -pRv pmos-root/lib/modules/5.5.0 pureos-root/lib/modules/
  41. # Copy PinePhone firmware to PureOS image
  42. cp -pRv pmos-root/lib/firmware pureos-root/lib/
  43. # Make u-boot initramfs from PureOS initramfs
  44. mkimage -A arm -O linux -T ramdisk -C gzip -d pureos-boot/initrd.img pureos-boot/uInitrd.img
  45. # Get uboot-script
  46. wget https://mozzwald.com/pp/pureos-uboot-script.cmd -O pureos-boot/boot.cmd
  47. # Compile uboot script
  48. mkimage -A arm64 -T script -C none -d pureos-boot/boot.cmd pureos-boot/boot.scr
  49. # Put helper files into rootfs
  50. wget https://mozzwald.com/pp/pureos-pp-helpers.tar.gz
  51. cd pureos-root
  52. tar -pxvf ../pureos-pp-helpers.tar.gz
  53. # If you have binfmt setup for arm64/aarch64 then you can chroot and enable modem service
  54. # and do whatever else you want. Otherwise this needs done after bootup
  55. cp /usr/bin/qemu-aarch64-static usr/bin/
  56. chroot ./
  57. systemctl enable pinephone.service # enable modem service
  58. exit
  59. cd ..
  60. # Unmount disk images
  61. umount pmos-boot pmos-root pureos-boot pureos-root
  62. losetup -d /dev/loop5
  63. losetup -d /dev/loop6
  64. # Copy the new image to SD card
  65. dd if=librem5.img of=/dev/your-sd-card-device bs=1M
  66. # Optionally resize PureOS Root partition on SD card
  67. # Put in PinePhone and boot. WIN!
  68. Default username: purism
  69. Default password: 123456