mkimg.arm.sh 2.97 KB
Newer Older
1
build_rpi_blobs() {
2
	apk fetch --quiet --stdout raspberrypi-bootloader | tar -C "${DESTDIR}" -zx --strip=1 boot/
3 4 5 6 7 8 9
}

rpi_gen_cmdline() {
	echo "modules=loop,squashfs,sd-mod,usb-storage quiet ${kernel_cmdline}"
}

rpi_gen_config() {
10 11 12 13 14
	cat <<-EOF
	# do not modify this file as it will be overwritten on upgrade.
	# create and/or modify usercfg.txt instead.
	# https://www.raspberrypi.org/documentation/configuration/config-txt
	EOF
15 16 17 18 19 20
	case "$ARCH" in
	armhf)
		cat <<-EOF
		[pi0]
		kernel=boot/vmlinuz-rpi
		initramfs boot/initramfs-rpi
21 22 23
		[pi0w]
		kernel=boot/vmlinuz-rpi
		initramfs boot/initramfs-rpi
24 25 26
		[pi1]
		kernel=boot/vmlinuz-rpi
		initramfs boot/initramfs-rpi
27 28 29 30 31 32 33 34 35
		[pi2]
		kernel=boot/vmlinuz-rpi2
		initramfs boot/initramfs-rpi2
		[pi3]
		kernel=boot/vmlinuz-rpi2
		initramfs boot/initramfs-rpi2
		[pi3+]
		kernel=boot/vmlinuz-rpi2
		initramfs boot/initramfs-rpi2
36 37 38 39 40 41
		[all]
		include usercfg.txt
		EOF
	;;
	armv7)
		cat <<-EOF
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
		[pi2]
		kernel=boot/vmlinuz-rpi2
		initramfs boot/initramfs-rpi2
		[pi3]
		kernel=boot/vmlinuz-rpi2
		initramfs boot/initramfs-rpi2
		[pi3+]
		kernel=boot/vmlinuz-rpi2
		initramfs boot/initramfs-rpi2
		[all]
		include usercfg.txt
		EOF
	;;
	aarch64)
		cat <<-EOF
		arm_control=0x200
		kernel=boot/vmlinuz-rpi
		initramfs boot/initramfs-rpi
60
		include usercfg.txt
61 62 63
		EOF
	;;
	esac
64 65 66 67 68 69 70 71
}

build_rpi_config() {
	rpi_gen_cmdline > "${DESTDIR}"/cmdline.txt
	rpi_gen_config > "${DESTDIR}"/config.txt
}

section_rpi_config() {
72
	[ "$hostname" = "rpi" ] || return 0
73
	build_section rpi_config $( (rpi_gen_cmdline ; rpi_gen_config) | checksum )
74
	build_section rpi_blobs
75 76 77 78
}

profile_rpi() {
	profile_base
79 80
	title="Raspberry Pi"
	desc="Includes Raspberry Pi kernel.
Sascha Paunovic's avatar
Sascha Paunovic committed
81
		Designed for RPI 1, 2 and 3.
82
		And much more..."
83
	image_ext="tar.gz"
84
	arch="aarch64 armhf armv7"
85 86
	kernel_flavors="rpi"
	case "$ARCH" in
87 88
		armhf) kernel_flavors="rpi rpi2";;
		armv7) kernel_flavors="rpi2";;
89
	esac
90 91
	kernel_cmdline="console=tty1"
	initfs_features="base squashfs mmc usb kms dhcp https"
92
	hostname="rpi"
93
	grub_mod=
94 95 96
}

build_uboot() {
97
	set -x
98
	# FIXME: Fix apk-tools to extract packages directly
99
	local pkg pkgs="$(apk fetch  --simulate --root "$APKROOT" --recursive u-boot-all | sed -ne "s/^Downloading \(.*\)\-[0-9].*$/\1/p")"
100
	for pkg in $pkgs; do
101
		[ "$pkg" = "u-boot-all" ] || apk fetch --root "$APKROOT" --stdout $pkg | tar -C "$DESTDIR" -xz usr
102 103 104 105 106 107 108 109 110 111 112 113 114
	done
	mkdir -p "$DESTDIR"/u-boot
	mv "$DESTDIR"/usr/sbin/update-u-boot "$DESTDIR"/usr/share/u-boot/* "$DESTDIR"/u-boot
	rm -rf "$DESTDIR"/usr
}

section_uboot() {
	[ -n "$uboot_install" ] || return 0
	build_section uboot $ARCH $(apk fetch --root "$APKROOT" --simulate --recursive u-boot-all | sort | checksum)
}

profile_uboot() {
	profile_base
115 116 117 118
	title="Generic ARM"
	desc="Has default ARM kernel.
		Includes the uboot bootloader.
		Supports armhf and aarch64."
119
	image_ext="tar.gz"
120
	arch="aarch64 armhf armv7"
121 122
	kernel_flavors="vanilla"
	kernel_addons="xtables-addons"
123
	initfs_features="base bootchart squashfs ext4 kms mmc raid scsi usb"
124 125 126 127
	apkovl="genapkovl-dhcp.sh"
	hostname="alpine"
	uboot_install="yes"
}