CROSS_FLAGS = ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- all: pine64-pinephone.img.xz pine64-pinetab.img.xz pine64-pinephone.img: fat-pine64-pinephone.img u-boot-sunxi-with-spl.bin rm -f $@ truncate --size 50M $@ parted -s $@ mktable msdos parted -s $@ mkpart primary fat32 2048s 100% parted -s $@ set 1 boot on dd if=u-boot-sunxi-with-spl.bin of=$@ bs=8k seek=1 dd if=fat-$@ of=$@ seek=1024 bs=1k fat-pine64-pinephone.img: initramfs-pine64-pinephone.gz kernel-sunxi.gz pine64-pinephone.scr dtbs/sunxi/sun50i-a64-pinephone.dtb @echo "MKFS $@" @rm -f $@ @truncate --size 40M $@ @mkfs.fat -F32 $@ @mcopy -i $@ kernel-sunxi.gz ::Image.gz @mcopy -i $@ dtbs/sunxi/sun50i-a64-pinephone.dtb ::sun50i-a64-pinephone.dtb @mcopy -i $@ initramfs-pine64-pinephone.gz ::initramfs.gz @mcopy -i $@ pine64-pinephone.scr ::boot.scr pine64-pinetab.img: fat-pine64-pinetab.img u-boot-sunxi-with-spl.bin rm -f $@ truncate --size 50M $@ parted -s $@ mktable msdos parted -s $@ mkpart primary fat32 2048s 100% parted -s $@ set 1 boot on dd if=u-boot-sunxi-with-spl.bin of=$@ bs=8k seek=1 dd if=fat-$@ of=$@ seek=1024 bs=1k fat-pine64-pinetab.img: initramfs-pine64-pinetab.gz kernel-sunxi.gz pine64-pinetab.scr dtbs/sunxi/sun50i-a64-pinetab.dtb @echo "MKFS $@" @rm -f $@ @truncate --size 40M $@ @mkfs.fat -F32 $@ @mcopy -i $@ kernel-sunxi.gz ::Image.gz @mcopy -i $@ dtbs/sunxi/sun50i-a64-pinetab.dtb ::sun50i-a64-pinetab.dtb @mcopy -i $@ initramfs-pine64-pinetab.gz ::initramfs.gz @mcopy -i $@ pine64-pinetab.scr ::boot.scr %.img.xz: %.img @echo "XZ $@" @xz -c $< > $@ initramfs/bin/busybox: src/busybox src/busybox_config @echo "MAKE $@" @mkdir -p build/busybox @cp src/busybox_config build/busybox/.config @$(MAKE) -C src/busybox O=../../build/busybox $(CROSS_FLAGS) @cp build/busybox/busybox initramfs/bin/busybox splash/%.ppm.gz: splash/%.ppm @echo "GZ $@" @gzip < $< > $@ initramfs-%.cpio: initramfs/bin/busybox initramfs/init initramfs/init_functions.sh splash/%.ppm.gz splash/%-error.ppm.gz @echo "CPIO $@" @rm -rf initramfs-$* @cp -r initramfs initramfs-$* @cp src/info-$*.sh initramfs-$*/info.sh @cp splash/$*.ppm.gz initramfs-$*/splash.ppm.gz @cp splash/$*-error.ppm.gz initramfs-$*/error.ppm.gz @cp src/info-$*.sh initramfs-$*/info.sh @cd initramfs-$*; find . | cpio -H newc -o > ../$@ initramfs-%.gz: initramfs-%.cpio @echo "GZ $@" @gzip < $< > $@ kernel-sunxi.gz: src/linux_config @echo "MAKE $@" @mkdir -p build/linux-sunxi @mkdir -p dtbs/sunxi @cp src/linux_config build/linux-sunxi/.config @$(MAKE) -C src/linux O=../../build/linux-sunxi $(CROSS_FLAGS) olddefconfig @$(MAKE) -C src/linux O=../../build/linux-sunxi $(CROSS_FLAGS) @cp build/linux-sunxi/arch/arm64/boot/Image.gz $@ @cp build/linux-sunxi/arch/arm64/boot/dts/allwinner/*.dtb dtbs/sunxi/ %.scr: src/%.txt @echo "MKIMG $@" @mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d $< $@ u-boot-sunxi-with-spl.bin: @echo "WGET $@" @wget http://dl-cdn.alpinelinux.org/alpine/edge/main/aarch64/u-boot-pine64-2020.01-r0.apk @tar -xvf u-boot-pine64-2020.01-r0.apk usr/share/u-boot/pine64-lts/u-boot-sunxi-with-spl.bin --strip-components 4 .PHONY: clean cleanfast cleanfast: @rm -rvf build @rm -rvf initramfs-*/ @rm -vf *.img @rm -vf *.img.xz @rm -vf *.apk @rm -vf *.bin @rm -vf *.cpio @rm -vf *.gz @rm -vf *.scr @rm -vf splash/*.gz clean: cleanfast @rm -vf kernel*.gz @rm -vf initramfs/bin/busybox @rm -vrf dtbs