aboutsummaryrefslogtreecommitdiffstats
path: root/main/u-boot/APKBUILD
blob: 15281c99c7c947538996c5b2b599f90a8a4fda8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Contributor: He Yangxuan <yangxuan8282@gmail.com>
# Contributor: Timo Teras <timo.teras@iki.fi>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=u-boot
pkgver=2022.01
pkgrel=1
pkgdesc="u-boot bootloader common files"
url="https://www.denx.de/wiki/U-Boot/"
arch="all !s390x !ppc64le"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
	ISC LGPL-2.0-only LGPL-2.1-only X11"
makedepends="$depends_dev
	bc
	bison
	dtc
	flex
	linux-headers
	openssl-dev
	py3-setuptools
	python3-dev
	swig
	"
if [ "$CARCH" = "aarch64" ]; then
	makedepends="$makedepends arm-trusted-firmware"
fi
source="https://ftp.denx.de/pub/u-boot/u-boot-${pkgver//_/-}.tar.bz2
	README.txt
	update-u-boot
	hifive-unmatched-ramdisk.patch
	fix-tools-build.patch
	mkimage-struc-tstat.st_size-may-not-be-long.patch
	"
builddir="$srcdir"/u-boot-${pkgver//_/-}

if [ "$CARCH" = "riscv64" ]; then
	makedepends="$makedepends opensbi"
	export OPENSBI=/usr/share/opensbi/generic/firmware/fw_dynamic.bin
fi

# secfixes:
#   2021.04-r0:
#     - CVE-2021-27097
#     - CVE-2021-27138

case "$CARCH" in
arm*) board_configs="
	beagleboard:am335x_boneblack_vboot
	linksprite:Linksprite_pcDuino3_Nano
	cuboxi:mx6cuboxi
	raspberrypi:rpi_0_w,rpi,rpi_2,rpi_3_32b
	wandboard:wandboard
	qemu:qemu_arm
	odroid:odroid-xu3
	sunxi:LicheePi_Zero,Bananapi,Lamobo_R1,Cubieboard,Cubieboard2
	";;
aarch64) board_configs="
	thunderx:thunderx_88xx
	raspberrypi:rpi_3
	odroid:odroid-c2,odroid-n2
	libretech:libretech-cc
	rockchip:rockpro64-rk3399
	qemu:qemu_arm64
	sunxi:pine64-lts,pinebook,orangepi_3,teres_i,a64-olinuxino,a64-olinuxino-emmc,nanopi_neo2
	";;
riscv64) board_configs="
	qemu:qemu-riscv64
	unleashed:sifive_unleashed
	unmatched:sifive_unmatched
";;
esac

for board_config in $board_configs; do
	_allboards="$_allboards $pkgname-${board_config%%:*}"
done

subpackages="$_allboards $pkgname-tools"
case "$CARCH" in
	arm*|aarch64|riscv64) subpackages="$pkgname-all:_all $_allboards $pkgname-tools";;
esac

build() {
	cd "$builddir"
	touch include/config.h
	LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
	LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h

	local board_config board
	for board_config in $board_configs; do
		local configs="${board_config#*:}"
		for board in ${configs//,/ }; do
			msg "Building u-boot for $board"

			case "$board" in
				"pine64-lts"|"pinebook"|"teres_i"|"a64-olinuxino"|"a64-olinuxino-emmc")
					export BL31="/usr/share/arm-trusted-firmware/sun50i_a64/bl31.bin";;
				"orangepi_3")
					export BL31="/usr/share/arm-trusted-firmware/sun50i_h6/bl31.bin";;
			esac

			export BUILD_DIR="$builddir"/build/$board
			mkdir -p "$BUILD_DIR"
			make O="$BUILD_DIR" ${board}_config
			make O="$BUILD_DIR" all
		done
	done
	msg "Building u-boot-tools"
	make tools-only_defconfig
	make tools-all
}

package() {
	case "$CARCH" in
		mips64|x86*) return;;
	esac
	cd "$builddir"/build
	mkdir -p "$pkgdir"/usr/share/$pkgname "$pkgdir"/usr/sbin
	install "$srcdir"/README.txt "$pkgdir"/usr/share/$pkgname/README.txt
	install "$srcdir"/update-u-boot "$pkgdir"/usr/sbin
}

tools() {
	pkgdesc="u-boot bootloader utility tools"
	provides="uboot-tools"
	replaces="uboot-tools"
	mkdir -p $pkgdir
	mkdir $subpkgdir
	cd "$builddir"
	for tool in bmp_logo dumpimage env/fw_printenv \
		fit_check_sign fit_info gdb/gdbcont gdb/gdbsend gen_eth_addr img2srec \
		mkenvimage mkimage ncb proftool ubsha1 xway-swap-bytes; do
		install -D tools/$tool \
		$subpkgdir/usr/bin/$(basename $tool)
		done
	install -Dm644 tools/env/fw_env.config \
		"$subpkgdir/usr/share/doc/$pkgname/examples/fw_env.config"
	cd "$subpkgdir"/usr/bin
	ln -sf fw_printenv fw_setenv
}

_all() {
	pkgdesc="u-boot for all boards (meta package)"
	depends="$_allboards"

	mkdir -p "$subpkgdir"/
}

_split_boards() {
	cd "$builddir"/build
	pkgdesc="u-boot for $1"
	depends="u-boot"
	shift
	local board
	for board; do
		msg "Including board $board"
		mkdir -p "$subpkgdir"/usr/share/$pkgname/$board
		export BUILD_DIR="$builddir"/build/$board

		local board_images=""
		case "$board" in
			"sifive_unleashed") board_images="u-boot.itb spl/u-boot-spl.bin --" ;;
			"sifive_unmatched") board_images="u-boot.itb spl/u-boot-spl.bin --" ;;
		esac

		local ok=no
		for image in $board_images u-boot-sunxi-with-spl.bin -- MLO SPL u-boot.img -- u-boot.bin; do
			if [ "$image" = "--" ]; then
				[ "$ok" = yes ] && break
				continue
			fi
			if [ -e "$BUILD_DIR"/$image ]; then
				cp "$BUILD_DIR"/$image "$subpkgdir"/usr/share/$pkgname/$board
				ok=yes
			fi
		done
		[ "$ok" = yes ] || return 
	done
}

for board_config in $board_configs; do
	_board="${board_config%%:*}"
	_configs="${board_config#*:}"
	eval "$_board() { _split_boards $_board ${_configs//,/ }; }"
done

sha512sums="
d83c62bd8f0f51664d2aca329a3ce1379cfd1dfff439dccd6cfc2cb33cfef89a2b01855c97716f591b5550bfdf99e2f3aef7efa33f2e7834c820648f9eef3825  u-boot-2022.01.tar.bz2
f8c9bb6e84d6f0620c976ac7ad5dd7ec7ff9dfdd4b1d03d2bf6653e7beccf80bdf2debfc92fb1f696dba92fb40287d3c45897e0078951451d0835cb61a5f16d1  README.txt
b5b5960a70c0edab38c208e5a41f2130c673334e05ef77dd4c839d59365d4243590a79bf3865914397b600550f4d0f69f8145e51a7ef05aa0190420fcc7ff02d  update-u-boot
1e8c95a37e7efb74f6519f66da44a0050417066aa2bd6d38e8a7e7135f501a9578dcc3701f66a170bf4cbd5c17b87d69ff80760979b1aa31d26e75be7cf7b97f  hifive-unmatched-ramdisk.patch
3b900d833ee7d82ee3bca6e8f8cb8e297359bb65c3f095a0d22377779eb8a233c5e566e5db6ce79f3076fbe6413d002941eb9cc450e3462337f46c1805472ce0  fix-tools-build.patch
b1d8a0ecf66fa845d4b248a8928958def042f16b84b2467bfa2a838eedddeac33ff0c41aee9b932949f1bb673454f0124b1176c9839377f3e1bec8049bf6bcca  mkimage-struc-tstat.st_size-may-not-be-long.patch
"