summaryrefslogtreecommitdiff
path: root/alt-rootfs-installer/socs.d/AllWinner-riscv64.sh
blob: 1c2c828c266d8d4146a9718186659a6630578047 (plain)
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
#!/bin/bash
# vim:sw=8:noet

BBL=2E54B353-1271-4842-806F-E436D6AF6985
FSBL=5B193300-FC78-40CD-8002-E86C45580B47

MEDIATABLE=gpt
START_SECTOR=34 # MiB
ROOTPART_NUM=1
CONSOLE=1
[ -n "$SYSCON" ] || SYSCON=ttyS0,115200n8

soc_write_bootloader() {
	if [ "$MEDIATABLE" = gpt ]; then
		[ -n "$ROOTFS" ] || clear_riscv64_bootloader_partition

		# resize gpt table to 7 KiB (56 entries partition)
		sgdisk -S 56 "${MEDIA-}"
	fi

	[ -n "$TMPROOT" ] || mount_partition
	# Write U-Boot
	set_path_to_uboot
	print_message "Searching U-Boot files for ${TARGET-}..."
	[ -d "$UBOOT" ] ||
		fatal_error "U-Boot files for ${TARGET-} were not found"
	print_done
	if [ -f "$UBOOT/u-boot.itb" ]; then
		print_message "Writing sunxi-spl.bin for ${TARGET-}..."
		dd if="$UBOOT/sunxi-spl.bin" of="${MEDIA-}" bs=8k seek=1 ||
		  fatal_error "failed to write SPL"
		sync
		print_done

		print_message "Writing U-Boot image for ${TARGET-}..."
		dd if="$UBOOT/u-boot.itb" of="${MEDIA-}" bs=8k seek=5 ||
		  fatal_error "failed to write U-Boot"
		sync
		print_done
	else
		print_message "Writing u-boot-sunxi-with-spl.bin..."
		dd if="$UBOOT/u-boot-sunxi-with-spl.bin" of="${MEDIA-}" bs=1024 seek=8 ||
		  fatal_error "failed to write U-Boot"
		sync
		print_done
	fi
}