]> cvs.zerfleddert.de Git - m1-debian/blame - m1n1_uboot_kernel.sh
bump versions, no sound on m1 air and dmesg full of i2c-apple 23501c000.i2c: Bus...
[m1-debian] / m1n1_uboot_kernel.sh
CommitLineData
9ac5deac
TG
1#!/usr/bin/env bash
2
3# SPDX-License-Identifier: MIT
4
5set -o errexit
6set -o nounset
7set -o pipefail
8set -o xtrace
9
10cd "$(dirname "$0")"
11
9eed8ca6
TG
12export CARGO_HOME="$(pwd)/build/cargo"
13export RUSTUP_HOME="$(pwd)/build/rust"
14source "$(pwd)/build/cargo/env"
15
9ac5deac
TG
16unset LC_CTYPE
17unset LANG
18
6a1d2ed2
TG
19handle_crosscompile()
20{
21 if [ "`uname -m`" != 'aarch64' ]; then
22 export ARCH=arm64
23 export CROSS_COMPILE=aarch64-linux-gnu-
24 sudo apt install -y libc6-dev-arm64-cross
25 fi
26}
27
9ac5deac
TG
28build_linux()
29{
30(
6a1d2ed2 31 handle_crosscompile
9ac5deac
TG
32 test -d linux || git clone https://github.com/AsahiLinux/linux
33 cd linux
34 git fetch -a -t
a6c1aa4d 35 git reset --hard asahi-6.2-rc3-5;
7dcd418b 36 cat ../../config.txt > .config
e7515ac0
TG
37 make LLVM=${CLANG_VERSION} rustavailable
38 make LLVM=${CLANG_VERSION} olddefconfig
39 make -j `nproc` LLVM=${CLANG_VERSION} V=0 bindeb-pkg > /dev/null
9ac5deac
TG
40)
41}
42
43build_m1n1()
44{
45(
46 test -d m1n1 || git clone --recursive https://github.com/AsahiLinux/m1n1
47 cd m1n1
48 git fetch -a -t
59b40e06 49 git reset --hard v1.2.3;
92b37325 50 curl -sL https://tg.st/u/272.patch | git am -
9ac5deac
TG
51 make -j `nproc`
52)
53}
54
55build_uboot()
56{
57(
6a1d2ed2 58 handle_crosscompile
9ac5deac
TG
59 test -d u-boot || git clone https://github.com/AsahiLinux/u-boot
60 cd u-boot
61 git fetch -a -t
62 git reset --hard asahi-v2022.10-1;
63
64 make apple_m1_defconfig
65 make -j `nproc`
66)
67 cat m1n1/build/m1n1.bin `find linux/arch/arm64/boot/dts/apple/ -name \*.dtb` <(gzip -c u-boot/u-boot-nodtb.bin) > u-boot.bin
9ac5deac
TG
68}
69
ce492006
TG
70package_boot_bin()
71{
72(
a6c1aa4d 73 export M1N1_VERSION=1.2.3-7
59b40e06
TG
74 rm -rf m1n1_${M1N1_VERSION}_arm64
75 mkdir -p m1n1_${M1N1_VERSION}_arm64/DEBIAN m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/
76 cp u-boot.bin m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/boot.bin
77 cat <<EOF > m1n1_${M1N1_VERSION}_arm64/DEBIAN/control
ce492006
TG
78Package: m1n1
79Version: $M1N1_VERSION
80Section: base
81Priority: optional
82Architecture: arm64
83Maintainer: Thomas Glanzmann <thomas@glanzmann.de>
84Description: Apple silicon boot loader
85 Next to m1n1 this also contains the device trees and u-boot.
86EOF
87
59b40e06 88 cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<EOF
ce492006
TG
89#!/bin/bash
90
91export PATH=/bin
b5a41dd1
TG
92if [ -f /boot/efi/m1n1/boot.bin ]; then
93 cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin
94fi
95mkdir -p /boot/efi/m1n1/
ce492006
TG
96cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/
97EOF
98
59b40e06
TG
99 chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst
100 dpkg-deb --build m1n1_${M1N1_VERSION}_arm64
cd6d1106 101)
ce492006
TG
102}
103
e7515ac0
TG
104if type clang-15; then
105 export CLANG_VERSION=-15
106elif type clang-11; then
107 export CLANG_VERSION=-11
108fi
109
9ac5deac
TG
110mkdir -p build
111cd build
112
5a6d8c66 113build_linux
029bb7dc
TG
114build_m1n1
115build_uboot
116package_boot_bin
Impressum, Datenschutz