summaryrefslogtreecommitdiff
path: root/include/env/tq/ubi.env
blob: 01243d2eb53836459d759578ccc53528cf14255c (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
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright (c) 2024-2026 TQ-Systems GmbH <[email protected]>,
 * D-82229 Seefeld, Germany.
 * Author: Max Merchel
 *
 * shared ubi environment for TQ boards
 */

addubi=
	setenv bootargs "${bootargs}" rootfstype=ubifs ubi.mtd="${ubimtdname}"
        root=ubi0:"${ubirootfsvol}" "${rootfsmode}" rootwait;

load_spi=
	if sf probe; then
                if ubi part "${ubirootfspart}"; then
			if ubifsmount ubi0:"${ubirootfsvol}"; then
				ubifsload "${kernel_addr_r}" /boot/"${image}";
				ubifsload "${fdt_addr_r}" /boot/"${fdtfile}";
                                fdt address "${fdt_addr_r}";
				fdt resize 0x100000;
				for overlay in "${fdt_overlays}"; do
					ubifsload "${fdtoverlay_addr_r}"
					/boot/"${overlay}" &&
					fdt apply "${fdtoverlay_addr_r}";
				done;
				ubifsumount;
			fi;
			ubi detach;
		fi;
	fi

ubiargs=run addubi addtty

ubiboot=
	echo "Booting from UBI ...";
	setenv bootargs;
	run ubiargs;
	if run load_spi; then
		run boot_os;
	else
		echo "ERROR: loading kernel";
	fi;

ubimtdname=mtdname
ubirootfspart=ubi
ubirootfsvol=root