blob: 93876e741f98722d1d3ec07145b53421dc8a4b6d [file] [log] [blame]
Sam Wu083c4852023-04-25 19:37:54 +08001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
4*/
5/*
6* uboot text based env
7* more details: https://u-boot.readthedocs.io/en/latest/usage/environment.html
8* or: v2023 doc/usage/environment.rst
9*/
Tao Zeng4dd2adf2024-02-21 15:26:04 +080010#ifdef CONFIG_NOVERBOSE_BUILD
11silent=1
12#else
13silent=0
14#endif
Sam Wu083c4852023-04-25 19:37:54 +080015firstboot=0
16lock=10101000
Sam Wu083c4852023-04-25 19:37:54 +080017upgrade_step=0
18jtag=disable
Sam Wuc7da1752023-07-28 12:05:06 +080019loadaddr=0x001080000
20dtb_mem_addr=0x001000000
Sam Wu083c4852023-04-25 19:37:54 +080021os_ident_addr=0x00500000
benlong.zhou7940f772023-07-21 09:21:09 +080022loadaddr_rtos=0x00080000
Bo Lv76f5c7d2023-07-27 15:16:40 +080023dtb_mem_addr=0x1000000
Sam Wu083c4852023-04-25 19:37:54 +080024loadaddr_kernel=0x03080000
Bo Lvda8d5b72023-07-31 14:58:21 +080025decaddr_kernel=0x01800000
Sam Wu083c4852023-04-25 19:37:54 +080026dv_fw_addr=0xa00000
27otg_device=1
28fdt_high=0x20000000
29EnableSelinux=enforcing
30recovery_offset=0
31osd_reverse=0
32video_reverse=0
33active_slot=normal
Sam Wu083c4852023-04-25 19:37:54 +080034boot_flag=0
35write_boot=0
Bo Lv119f5f32023-06-27 16:32:31 +080036fb_addr=0x00300000
37
Tao Zeng4dd2adf2024-02-21 15:26:04 +080038#ifdef CONFIG_NOVERBOSE_BUILD
39loglevel=2
40#else
Sam Wu083c4852023-04-25 19:37:54 +080041#ifdef CONFIG_KNL_LOG_LEVEL
42loglevel=CONFIG_KNL_LOG_LEVEL
43#else
44loglevel=8
45#endif//ifdef CONFIG_KNL_LOG_LEVEL
Tao Zeng4dd2adf2024-02-21 15:26:04 +080046#endif
Sam Wu083c4852023-04-25 19:37:54 +080047
48#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
49common_dtb_load=imgread dtb ${boot_part} ${dtb_mem_addr}
50#else
51common_dtb_load=imgread dtb _aml_dtb ${dtb_mem_addr}
52#endif//#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
53
Mingyen Hung96effce2023-09-01 00:39:46 -070054get_os_type=if imgread part ${boot_part} ${os_ident_addr} 0 0x1000; then os_ident ${os_ident_addr}; fi
Sam Wu083c4852023-04-25 19:37:54 +080055fatload_dev=usb
56fs_type=rootfstype=ramfs
57upgrade_check=
58 echo recovery_status=${recovery_status};
59 if itest.s "${recovery_status}" == "in_progress"; then
60 run storeargs; run recovery_from_flash;
61 else fi;
62 echo upgrade_step=${upgrade_step};
63 if itest ${upgrade_step} == 3; then run storeargs; run update; fi;
64
65initargs=init=/init ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 loop.max_part=4
66
67storeargs=
68 get_bootloaderversion;
69 setenv bootargs ${initargs}
yao zhang15ef11eb2023-11-21 14:46:44 +080070 loglevel=${loglevel} async_long_initcall=1 console=ttyS0,${baudrate} no_console_suspend earlycon=aml_uart,${uart_base}
Sam Wu083c4852023-04-25 19:37:54 +080071 ${fs_type} otg_device=${otg_device}
72 logo=${display_layer},loaded,${fb_addr} vout=${outputmode},enable panel_type=${panel_type}
73 hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode}
74 hdmichecksum=${hdmichecksum} dolby_vision_on=${dolby_vision_on}
75 hdr_policy=${hdr_policy} hdr_priority=${hdr_priority}
76 frac_rate_policy=${frac_rate_policy} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode}
77 osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en}
78 jtag=${jtag};
79 run cmdline_keys;
80
81switch_bootmode=
82 get_rebootmode;
83 if test ${reboot_mode} = factory_reset; then run recovery_from_flash;
84 else if test ${reboot_mode} = update; then run update;
85 else if test ${reboot_mode} = quiescent; then
86 setenv bootargs ${bootargs} androidboot.quiescent=1;
87 else if test ${reboot_mode} = recovery_quiescent; then
88 setenv bootargs ${bootargs} androidboot.quiescent=1;
89 run recovery_from_flash;
90 else if test ${reboot_mode} = cold_boot; then
91 else if test ${reboot_mode} = fastboot; then fastboot 0; fi;
92 fi;fi;fi;fi;fi;
93
94storeboot=
95 run get_os_type;
96 run storage_param;
97 if test ${os_type} = rtos; then
98 setenv loadaddr ${loadaddr_rtos};
99 store read ${loadaddr} ${boot_part} 0 0x400000;
100 bootm ${loadaddr};
101 else if test ${os_type} = kernel; then
102 get_avb_mode;
103 if fdt addr ${dtb_mem_addr}; then else echo retry common dtb; run common_dtb_load; fi;
104 setenv loadaddr ${loadaddr_kernel};
Mingyen Hung96effce2023-09-01 00:39:46 -0700105 if imgread kernel ${boot_part} ${loadaddr}; then
106#if CONFIG_PARTITION_ENCRYPTION
107 partition_enc apply;
108#endif
109 bootm ${loadaddr};
110 fi;
Sam Wu083c4852023-04-25 19:37:54 +0800111 else echo wrong OS format ${os_type}; fi;fi;
112 echo try upgrade as booting failure; run update;
113
114update=
115 /*first usb burning, second sdc_burn, third ext-sd autoscr/recovery, last udisk autoscr/recovery*/\
116 run usb_burning;
117 run recovery_from_sdcard;
118 run recovery_from_udisk;
119 run recovery_from_flash;
120
121recovery_from_fat_dev=
122 setenv loadaddr ${loadaddr_kernel};
123 if fatload ${fatload_dev} 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;
124 if fatload ${fatload_dev} 0 ${loadaddr} recovery.img; then
125 if fatload ${fatload_dev} 0 ${dtb_mem_addr} dtb.img; then echo ${fatload_dev} dtb.img loaded; fi;
126 setenv bootargs ${bootargs} ${fs_type};
127 bootm ${loadaddr};
128 fi;
129recovery_from_udisk=
130 setenv fatload_dev usb;
131 if usb start 0; then run recovery_from_fat_dev; fi;
132recovery_from_sdcard=
133 setenv fatload_dev mmc;
134 if mmcinfo; then run recovery_from_fat_dev; fi;
135
136recovery_from_flash=
137 echo active_slot: ${active_slot};
Bing Jiangee808882023-09-15 15:29:24 +0800138 run storage_param;
Sam Wu083c4852023-04-25 19:37:54 +0800139 setenv loadaddr ${loadaddr_kernel};
140 if test ${active_slot} = normal; then
141 setenv bootargs ${bootargs} ${fs_type} aml_dt=${aml_dt}
142 recovery_part=${recovery_part} recovery_offset=${recovery_offset};
143 if test ${upgrade_step} = 3; then
144 if ext4load mmc 1:2 ${dtb_mem_addr} /recovery/dtb.img; then echo cache dtb.img loaded; fi;
145 if test ${vendor_boot_mode} = true; then
146 if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then bootm ${loadaddr}; fi;
147 else
148 if ext4load mmc 1:2 ${loadaddr} /recovery/recovery.img; then
149 echo cache recovery.img loaded; bootm ${loadaddr};
150 fi;
151 fi;
152 else
153 if imgread dtb recovery ${dtb_mem_addr}; then
154 else echo restore dtb; run common_dtb_load;
155 fi;
156 fi;
Mingyen Hung96effce2023-09-01 00:39:46 -0700157 if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then
158#if CONFIG_PARTITION_ENCRYPTION
159 partition_enc apply;
160#endif
161 bootm ${loadaddr};
162 fi;
Sam Wu083c4852023-04-25 19:37:54 +0800163 else
Sam Wu9db1ccc2023-05-09 18:31:35 +0800164 echo "active_slot ${active_slot} not supported";
Sam Wu083c4852023-04-25 19:37:54 +0800165 fi;
166
167bcb_cmd=
168 get_avb_mode;
169 get_valid_slot;
170 if test ${vendor_boot_mode} = true; then
Bo Lv119f5f32023-06-27 16:32:31 +0800171 setenv loadaddr_kernel 0x3000000;
Sam Wu083c4852023-04-25 19:37:54 +0800172 setenv dtb_mem_addr 0x1000000;
173 fi;
Bo Lv119f5f32023-06-27 16:32:31 +0800174 if test ${active_slot} != "normal"; then
Sam Wu083c4852023-04-25 19:37:54 +0800175 echo ab mode, read dtb from kernel;
176 setenv common_dtb_load imgread dtb ${boot_part} ${dtb_mem_addr};
177 fi;
178
179load_bmp_logo=
180 if imgread pic logo bootup $loadaddr; then bmp display $bootup_offset; fi;
181
182init_display=
183 get_rebootmode;
184 echo reboot_mode:::: ${reboot_mode};
185 if test ${reboot_mode} = quiescent; then
186 setenv reboot_mode_android "quiescent";
187 setenv dolby_status 0;
188 setenv dolby_vision_on 0;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800189 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800190 setenv bootargs ${bootargs} androidboot.quiescent=1;
191 osd open;osd clear;
192 else if test ${reboot_mode} = recovery_quiescent; then
193 setenv reboot_mode_android "quiescent";
194 setenv dolby_status 0;
195 setenv dolby_vision_on 0;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800196 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800197 setenv bootargs ${bootargs} androidboot.quiescent=1;
198 osd open;osd clear;
199 else
200 setenv reboot_mode_android "normal";
ruofei.zhao4a2ec0c2023-10-31 19:24:41 +0800201 hdmitx hpd;hdmitx get_parse_edid;
Bo Lvcb044df2023-08-07 10:55:30 +0800202 dovi process;watermark_init;osd open;osd clear;run load_bmp_logo;
203 bmp scale;vout output ${outputmode};dovi set;dovi pkg;vpp hdrpkt;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800204 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800205 fi;fi;
206
207storage_param=
208 setenv bootargs ${bootargs} ${emmc_quirks};
209 store param;
210 setenv bootargs ${bootargs} ${mtdbootparts};
211
212cmdline_keys=
213 setenv region_code US;
214 if keyman init 0x1234; then
215 if keyman read usid ${loadaddr} str; then
216 setenv bootargs ${bootargs} androidboot.serialno=${usid};
217 setenv serial ${usid}; setenv serial# ${usid};
218 else
219 setenv bootargs ${bootargs} androidboot.serialno=ap222${cpu_id};
220 setenv serial ap222${cpu_id}; setenv serial# ap222${cpu_id};
221 fi;
222 if keyman read region_code ${loadaddr} str; then fi;
223 if keyman read mac ${loadaddr} str; then
224 setenv bootargs ${bootargs} mac=${mac} androidboot.mac=${mac};
225 fi;
226 if keyman read deviceid ${loadaddr} str; then
227 setenv bootargs ${bootargs} androidboot.deviceid=${deviceid};
228 fi;
229 fi;
230 setenv bootargs ${bootargs} androidboot.wificountrycode=${region_code};
231 factory_provision init;
232
233upgrade_key=
234 if gpio input GPIOD_2; then
235 echo detect upgrade key; run update;
236 fi;
237