summaryrefslogtreecommitdiff
path: root/tizen/bootscript/tizen-boot-rpi4.scr
blob: 6d0f6a4c3a7e148442e1ea3a1b6feb59fe46fce9 (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
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
# U-boot script for tizen RPI4

setenv legacy_ramdisk_part	0x7
setenv legacy_recovery_part	0x8

if test "${target}" = "mmc0"; then;
	setenv bootdev mmc
fi
if test "${target}" = "usb0"; then;
	setenv bootdev usb
	setenv opts "${opts} rootdelay=2"
fi

# find 'inform' partition or use ${mmcinformpart} fallback
part number $bootdev $mmcbootdev "inform" res
if test -n "${res}"; then;
	setenv mmcinformpart ${res}
fi

# set sane defaults
setenv partition_name "ramdisk"
setenv partition_ab "a"
setenv partition_fallback ${legacy_ramdisk_part}

if test -e $bootdev $mmcbootdev:$mmcinformpart $slotfile; then;
	ext4load $bootdev $mmcbootdev:$mmcinformpart $slot_addr $slotfile;
	if itest.b *${slot_addr} == 0x62; then;
		setenv partition_ab "b"
	fi
fi
echo "boot from slot_${partition_ab}"

if test -e $bootdev $mmcbootdev:$mmcinformpart $rebootparamfile; then;
	ext4load $bootdev $mmcbootdev:$mmcinformpart $rebootparam_addr $rebootparamfile;
	if itest.l *${rebootparam_addr} == ${upgrade_val}; then;
		setenv partition_name "ramdisk-recovery"
		setenv partition_fallback ${legacy_recovery_part}
		setenv bootmode "fota"
	elif itest.l *${rebootparam_addr} == ${recovery_val}; then;
		setenv partition_name "ramdisk-recovery"
		setenv partition_fallback ${legacy_recovery_part}
		setenv bootmode "recovery"
	elif itest.l *${rebootparam_addr} == ${download_val}; then;
		setenv partition_name "ramdisk-recovery"
		setenv partition_fallback ${legacy_recovery_part}
		setenv bootmode "flash"
	elif itest.l *${rebootparam_addr} == ${nodef_val}; then;
		echo "This reboot parameter is not supported...";
	fi
fi

# This is for jumping to flash mode on u-boot.
if test "${bootmode}" = "download"; then;
	setenv partition_name "ramdisk-recovery"
	setenv partition_fallback ${legacy_recovery_part}
	setenv bootmode "flash"
fi

if test "${bootmode}" = "flash"; then;
	if test -n "${ipaddr}"; then;
		ip_opt=\"ip=${ipaddr}::${gateway}:${netmask}\"
	fi
fi

# find the selected ramdisk variant partition
part number $bootdev $mmcbootdev "${partition_name}_${partition_ab}" res
if test -n "${res}"; then;
	setenv ramdiskpart ${res}
else
	setenv ramdiskpart ${partition_fallback}
fi

# setting console device if noting is set
if test -z "${console}"; then;
	if test "$board_name" = "5 Model B"; then;
		fdt addr $fdt_addr;
		fdt get value uart "/axi/pcie@120000/rp1/serial@30000" status;
		if test "$uart" = "okay"; then;
			setenv console "console=ttyAMA0,115200n8";
		else
			setenv console "console=ttyAMA10,115200n8 earlycon";
		fi
	else
		setenv console "console=ttyS0,115200n8 earlycon=uart8250,mmio32,0xfe215040";
	fi
fi
echo "console: ${console}"

# DT image by model
setenv boot_prefixes \"/\"

# Find the ramdisk offset and block count
part start $bootdev $mmcrootdev $ramdiskpart ramdisk_start
part size $bootdev $mmcrootdev $ramdiskpart ramdisk_size

# Set to ramdisksize with real partition size. (Need to multiply block-size 0x200)
setexpr ramdisksize $ramdisk_size * 200
setexpr tizen_kernel_addr_r $ramdisk_addr_r + $ramdisksize

# boot from ram0 if there is sbin or it is initramfs
if test -e $bootdev $mmcrootdev:$ramdiskpart sbin/init; then;
	setenv rootdev ram0
	echo "Loading Ramdisk from partition ${ramdiskpart}";
	$bootdev read $ramdisk_addr_r $ramdisk_start $ramdisk_size;
else
	# Check for gzip (initramfs) magic
	$bootdev read $ramdisk_addr_r $ramdisk_start 1;
	if itest.w *$ramdisk_addr_r == 0x8b1f; then;
		setenv rootdev ram0
		echo "Loading initramfs from partition ${ramdiskpart}";
		$bootdev read $ramdisk_addr_r $ramdisk_start $ramdisk_size;
	else
		if test "${bootdev}" = "mmc"; then;
			setenv rootdev mmcblk${mmcrootdev}p${mmcrootpart}
		fi
		if test "${bootdev}" = "usb"; then;
			setenv rootdev sda${mmcrootpart}
		fi
		setenv bootmode normal
	fi
fi

# To use cmdline for using serial console. /* Normal mode */
setenv bootargs \"${tizen_bootarg} cgroup_enable=memory root=/dev/${rootdev} rw bootmode=${bootmode} partition_ab=${partition_ab} rootwait ${console} ${opts} ${ip_opt}\"

echo "Searching for kernel in"; for prefix in $boot_prefixes; do
if load $bootdev $mmcbootdev:$mmcbootpart $tizen_kernel_addr_r $prefix$kernel; then;
	echo ${bootmode} "boot";

	# use fdt already preloaded by the firmware available at $fdt_addr
	if test "$kernel" = "zImage"; then;
		bootz $tizen_kernel_addr_r $ramdisk_addr_r:$ramdisksize $fdt_addr;
	else
		booti $tizen_kernel_addr_r $ramdisk_addr_r:$ramdisksize $fdt_addr;
	fi
fi
done