Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Librem 5 support #24

Merged
merged 10 commits into from Feb 11, 2021
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -6,13 +6,18 @@
/dtbs
/src/linux-rockchip
/src/linux-sunxi
/src/linux-librem5
/src/busybox
/src/u-boot
/src/u-boot-librem5
/src/arm-trusted-firmware
/*.scr
/*.dtb
/*.img.xz
/*.gz
/*.bin
/*.tar.bz2
/*.tar.xz
/*.lst
/boot-purism-librem5.sh
/splash/*.gz
46 changes: 44 additions & 2 deletions Makefile
@@ -1,7 +1,7 @@
CROSS_FLAGS = ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_FLAGS_BOOT = CROSS_COMPILE=aarch64-linux-gnu-

all: pine64-pinephone.img.xz pine64-pinetab.img.xz
all: pine64-pinephone.img.xz pine64-pinetab.img.xz purism-librem5.tar.xz


pine64-pinephone.img: fat-pine64-pinephone.img u-boot-sunxi-with-spl.bin
Expand Down Expand Up @@ -120,6 +120,18 @@ kernel-rockchip.gz: src/linux_config_rockchip src/linux-rockchip
@cp build/linux-rockchip/arch/arm64/boot/Image.gz $@
@cp build/linux-rockchip/arch/arm64/boot/dts/rockchip/*.dtb dtbs/rockchip/

kernel-librem5.gz: src/linux_config_librem5 src/linux-librem5
@echo "MAKE $@"
@mkdir -p build/linux-librem5
@mkdir -p dtbs/librem5
@cp src/linux_config_librem5 build/linux-librem5/.config
@$(MAKE) -C src/linux-librem5 O=../../build/linux-librem5 $(CROSS_FLAGS) olddefconfig
@$(MAKE) -C src/linux-librem5 O=../../build/linux-librem5 $(CROSS_FLAGS)
@cp build/linux-librem5/arch/arm64/boot/Image.gz $@
@cp build/linux-librem5/arch/arm64/boot/dts/freescale/imx8mq-librem5*.dtb dtbs/librem5/

dtbs/librem5/imx8mq-librem5-r2.dtb: kernel-librem5.gz

%.scr: src/%.txt
@echo "MKIMG $@"
@mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d $< $@
Expand Down Expand Up @@ -150,6 +162,12 @@ u-boot-rk3399.bin: build/atf/rk3399/bl31.elf src/u-boot
@BL31=../../../build/atf/rk3399/bl31.elf $(MAKE) -C src/u-boot O=../../build/u-boot/rk3399 $(CROSS_FLAGS_BOOT) all
@cp build/u-boot/rk3399/u-boot "$@"

u-boot-librem5.bin: src/u-boot-librem5
@echo "MAKE $@"
@mkdir -p build/u-boot/librem5
@cd build/u-boot/librem5 && ../../../src/u-boot-librem5/build_uboot.sh -b librem5
@cp build/u-boot/librem5/output/uboot-librem5/u-boot-librem5.imx $@

src/linux-rockchip:
@echo "WGET linux-rockchip"
@mkdir src/linux-rockchip
Expand All @@ -162,6 +180,12 @@ src/linux-sunxi:
@wget https://github.com/megous/linux/archive/orange-pi-5.9-20201019-1553.tar.gz
@tar -xvf orange-pi-5.9-20201019-1553.tar.gz --strip-components 1 -C src/linux-sunxi

src/linux-librem5:
@echo "WGET linux-librem5"
@mkdir src/linux-librem5
@wget -c https://source.puri.sm/Librem5/linux-next/-/archive/pureos/5.9.16+librem5.2/linux-next-pureos-5.9.16+librem5.2.tar.gz
@tar -xvf linux-next-pureos-5.9.16+librem5.2.tar.gz --strip-components 1 -C src/linux-librem5

src/arm-trusted-firmware:
@echo "WGET arm-trusted-firmware"
@mkdir src/arm-trusted-firmware
Expand All @@ -175,25 +199,43 @@ src/u-boot:
@tar -xvf u-boot-2020.04.tar.bz2 --strip-components 1 -C src/u-boot
@cd src/u-boot && patch -p1 < ../u-boot-pinephone.patch

src/u-boot-librem5:
@echo "WGET u-boot-librem5"
@mkdir src/u-boot-librem5
@wget https://source.puri.sm/Librem5/u-boot-builder/-/archive/3b1c7d957f46c87c6cdd71cd8dab7c84aca26570/u-boot-builder-3b1c7d957f46c87c6cdd71cd8dab7c84aca26570.tar.gz
@tar -xvf u-boot-builder-3b1c7d957f46c87c6cdd71cd8dab7c84aca26570.tar.gz --strip-components 1 -C src/u-boot-librem5

src/busybox:
@echo "WGET busybox"
@mkdir src/busybox
@wget https://www.busybox.net/downloads/busybox-1.32.0.tar.bz2
@tar -xvf busybox-1.32.0.tar.bz2 --strip-components 1 -C src/busybox

.PHONY: clean cleanfast
.PHONY: clean cleanfast purism-librem5

purism-librem5: initramfs-purism-librem5.gz kernel-librem5.gz u-boot-librem5.bin src/purism-librem5.txt dtbs/librem5/imx8mq-librem5-r2.dtb
cp src/boot-purism-librem5.sh boot-purism-librem5.sh
cp src/purism-librem5.txt purism-librem5.lst
@echo 'All done! Switch your phone into flashing mode and run Jumpdrive with `./boot-purism-librem5.sh`'

purism-librem5.tar.xz: purism-librem5
@echo "XZ librem5 files"
@tar cJf $@ initramfs-purism-librem5.gz kernel-librem5.gz u-boot-librem5.bin purism-librem5.lst dtbs/librem5/imx8mq-librem5-r2.dtb boot-purism-librem5.sh

cleanfast:
@rm -rvf build
@rm -rvf initramfs-*/
@rm -vf *.img
@rm -vf *.img.xz
@rm -vf *.tar.xz
@rm -vf *.apk
@rm -vf *.bin
@rm -vf *.cpio
@rm -vf *.gz
@rm -vf *.scr
@rm -vf splash/*.gz
@rm -vf *.lst
@rm -vf boot-purism-librem5.sh

clean: cleanfast
@rm -vf kernel*.gz
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -29,6 +29,10 @@ The dependencies are:
- u-boot tools
- mtools

Additional dependencies for the Purism Librem 5:
- arm-none-eabi- toolchain
- uuu

```shell-session
$ git submodule update --init --recursive
Downloads the projects to build
Expand Down
5 changes: 5 additions & 0 deletions initramfs/init
Expand Up @@ -40,6 +40,11 @@ if [ -n "$LED" ]; then
echo $TRIGGER > /sys/class/leds/$LED/trigger
fi

if [ -n "$SLEEP" ]; then
echo "Waiting for hardware to initialize..."
sleep $SLEEP
fi

# Create device nodes
echo "Creating device nodes..."
mknod /dev/null c 1 3
Expand Down
4 changes: 2 additions & 2 deletions initramfs/init_functions.sh
Expand Up @@ -28,10 +28,10 @@ setup_usb_configfs() {
mkdir $CONFIGFS/g1/strings/0x409 || echo " Couldn't create $CONFIGFS/g1/strings/0x409"

# shellcheck disable=SC2154
echo "Pine64" > "$CONFIGFS/g1/strings/0x409/manufacturer"
echo "$MANUFACTURER" > "$CONFIGFS/g1/strings/0x409/manufacturer"
echo "$usb_serialnumber" > "$CONFIGFS/g1/strings/0x409/serialnumber"
# shellcheck disable=SC2154
echo "PinePhone" > "$CONFIGFS/g1/strings/0x409/product"
echo "$PRODUCT" > "$CONFIGFS/g1/strings/0x409/product"

# Create rndis/mass_storage function
mkdir $CONFIGFS/g1/functions/"$usb_rndis_function" \
Expand Down
Binary file added splash/purism-librem5-error.ppm
Binary file not shown.
Binary file added splash/purism-librem5.ppm
Binary file not shown.
3 changes: 3 additions & 0 deletions src/boot-purism-librem5.sh
@@ -0,0 +1,3 @@
#!/bin/sh

uuu purism-librem5.lst
2 changes: 2 additions & 0 deletions src/info-pine64-pinebookpro.sh
@@ -1,2 +1,4 @@
PLATFORM=pine64-pinebookpro
MANUFACTURER=Pine64
PRODUCT="Pinebook Pro"
EMMC=/dev/mmcblk2
2 changes: 2 additions & 0 deletions src/info-pine64-pinephone.sh
@@ -1,4 +1,6 @@
PLATFORM=pine64-pinephone
MANUFACTURER=Pine64
PRODUCT=PinePhone
EMMC=/dev/mmcblk2
SD=/dev/mmcblk0
LED=pinephone\:red\:user
Expand Down
2 changes: 2 additions & 0 deletions src/info-pine64-pinetab.sh
@@ -1,4 +1,6 @@
PLATFORM=pine64-pinetab
MANUFACTURER=Pine64
PRODUCT=PineTab
EMMC=/dev/mmcblk2
SD=/dev/mmcblk0
SERIAL_CON=ttyS0
Expand Down
11 changes: 11 additions & 0 deletions src/info-purism-librem5.sh
@@ -0,0 +1,11 @@
PLATFORM=purism-librem5
MANUFACTURER=Purism
PRODUCT="Librem 5"
EMMC=/dev/mmcblk0
SD=/dev/sda
LED=green:status
TRIGGER=mmc0
ERRORLINES=80
SERIAL_CON=ttymxc0
SERIAL_BAUD=115200
SLEEP=3