mkimg.arm.sh 2.74 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 15 16 17 18 19 20 21 22
	case "$ARCH" in
	armhf)
		cat <<-EOF
		disable_splash=1
		boot_delay=0
		gpu_mem=256
		gpu_mem_256=64
		[pi0]
		kernel=boot/vmlinuz-rpi
		initramfs boot/initramfs-rpi
		[pi1]
		kernel=boot/vmlinuz-rpi
		initramfs boot/initramfs-rpi
23 24 25 26 27 28
		[all]
		include usercfg.txt
		EOF
	;;
	armv7)
		cat <<-EOF
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
		[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
		disable_splash=1
		boot_delay=0
		arm_control=0x200
		kernel=boot/vmlinuz-rpi
		initramfs boot/initramfs-rpi
		# uncomment line to enable serial on ttyS0 on rpi3
		# NOTE: This fixes the core_freq to 250Mhz
		# enable_uart=1
52
		include usercfg.txt
53 54 55
		EOF
	;;
	esac
56 57 58 59 60 61 62 63
}

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

section_rpi_config() {
64
	[ "$hostname" = "rpi" ] || return 0
65
	build_section rpi_config $( (rpi_gen_cmdline ; rpi_gen_config) | checksum )
66
	build_section rpi_blobs
67 68 69 70
}

profile_rpi() {
	profile_base
71 72
	title="Raspberry Pi"
	desc="Includes Raspberry Pi kernel.
Sascha Paunovic's avatar
Sascha Paunovic committed
73
		Designed for RPI 1, 2 and 3.
74
		And much more..."
75
	image_ext="tar.gz"
76
	arch="aarch64 armhf armv7"
Natanael Copa's avatar
Natanael Copa committed
77 78
	kernel_flavors="rpi"
	case "$ARCH" in
79
		armv7|armhf) kernel_flavors="rpi2";;
Natanael Copa's avatar
Natanael Copa committed
80
	esac
81
	kernel_cmdline="dwc_otg.lpm_enable=0 console=tty1"
Natanael Copa's avatar
Natanael Copa committed
82
	initfs_features="base bootchart squashfs ext4 f2fs kms mmc raid scsi usb"
83
	hostname="rpi"
84
	grub_mod=
85 86 87
}

build_uboot() {
Natanael Copa's avatar
Natanael Copa committed
88
	set -x
89
	# FIXME: Fix apk-tools to extract packages directly
Natanael Copa's avatar
Natanael Copa committed
90
	local pkg pkgs="$(apk fetch  --simulate --root "$APKROOT" --recursive u-boot-all | sed -ne "s/^Downloading \([^0-9.]*\)\-.*$/\1/p")"
91
	for pkg in $pkgs; do
Natanael Copa's avatar
Natanael Copa committed
92
		[ "$pkg" = "u-boot-all" ] || apk fetch --root "$APKROOT" --stdout $pkg | tar -C "$DESTDIR" -xz usr
93 94 95 96 97 98 99 100 101 102 103 104 105
	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
106 107 108 109
	title="Generic ARM"
	desc="Has default ARM kernel.
		Includes the uboot bootloader.
		Supports armhf and aarch64."
110
	image_ext="tar.gz"
111
	arch="aarch64 armhf armv7"
112 113
	kernel_flavors="vanilla"
	kernel_addons="xtables-addons"
114
	initfs_features="base bootchart squashfs ext4 kms mmc raid scsi usb"
115 116 117 118
	apkovl="genapkovl-dhcp.sh"
	hostname="alpine"
	uboot_install="yes"
}