blob: 62657ee83d80be32d9d5e4207c58f3eacce85d8b [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*/
10firstboot=0
11lock=10101000
Sam Wu083c4852023-04-25 19:37:54 +080012upgrade_step=0
13jtag=disable
Sam Wuc7da1752023-07-28 12:05:06 +080014loadaddr=0x001080000
15dtb_mem_addr=0x001000000
Sam Wu083c4852023-04-25 19:37:54 +080016os_ident_addr=0x00500000
benlong.zhou7940f772023-07-21 09:21:09 +080017loadaddr_rtos=0x00080000
Bo Lv76f5c7d2023-07-27 15:16:40 +080018dtb_mem_addr=0x1000000
Sam Wu083c4852023-04-25 19:37:54 +080019loadaddr_kernel=0x03080000
Bo Lvda8d5b72023-07-31 14:58:21 +080020decaddr_kernel=0x01800000
Sam Wu083c4852023-04-25 19:37:54 +080021dv_fw_addr=0xa00000
22otg_device=1
23fdt_high=0x20000000
24EnableSelinux=enforcing
25recovery_offset=0
26osd_reverse=0
27video_reverse=0
28active_slot=normal
Sam Wu083c4852023-04-25 19:37:54 +080029boot_flag=0
30write_boot=0
Bo Lv119f5f32023-06-27 16:32:31 +080031fb_addr=0x00300000
32
Sam Wu083c4852023-04-25 19:37:54 +080033
34#ifdef CONFIG_KNL_LOG_LEVEL
35loglevel=CONFIG_KNL_LOG_LEVEL
36#else
37loglevel=8
38#endif//ifdef CONFIG_KNL_LOG_LEVEL
39
40#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
41common_dtb_load=imgread dtb ${boot_part} ${dtb_mem_addr}
42#else
43common_dtb_load=imgread dtb _aml_dtb ${dtb_mem_addr}
44#endif//#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
45
46get_os_type=if store read ${os_ident_addr} ${boot_part} 0 0x1000; then os_ident ${os_ident_addr}; fi
47fatload_dev=usb
48fs_type=rootfstype=ramfs
49upgrade_check=
50 echo recovery_status=${recovery_status};
51 if itest.s "${recovery_status}" == "in_progress"; then
52 run storeargs; run recovery_from_flash;
53 else fi;
54 echo upgrade_step=${upgrade_step};
55 if itest ${upgrade_step} == 3; then run storeargs; run update; fi;
56
57initargs=init=/init ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 loop.max_part=4
58
59storeargs=
60 get_bootloaderversion;
61 setenv bootargs ${initargs}
yao zhang15ef11eb2023-11-21 14:46:44 +080062 loglevel=${loglevel} async_long_initcall=1 console=ttyS0,${baudrate} no_console_suspend earlycon=aml_uart,${uart_base}
Sam Wu083c4852023-04-25 19:37:54 +080063 ${fs_type} otg_device=${otg_device}
64 logo=${display_layer},loaded,${fb_addr} vout=${outputmode},enable panel_type=${panel_type}
65 hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode}
66 hdmichecksum=${hdmichecksum} dolby_vision_on=${dolby_vision_on}
67 hdr_policy=${hdr_policy} hdr_priority=${hdr_priority}
68 frac_rate_policy=${frac_rate_policy} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode}
69 osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en}
70 jtag=${jtag};
71 run cmdline_keys;
72
73switch_bootmode=
74 get_rebootmode;
75 if test ${reboot_mode} = factory_reset; then run recovery_from_flash;
76 else if test ${reboot_mode} = update; then run update;
77 else if test ${reboot_mode} = quiescent; then
78 setenv bootargs ${bootargs} androidboot.quiescent=1;
79 else if test ${reboot_mode} = recovery_quiescent; then
80 setenv bootargs ${bootargs} androidboot.quiescent=1;
81 run recovery_from_flash;
82 else if test ${reboot_mode} = cold_boot; then
83 else if test ${reboot_mode} = fastboot; then fastboot 0; fi;
84 fi;fi;fi;fi;fi;
85
86storeboot=
87 run get_os_type;
88 run storage_param;
89 if test ${os_type} = rtos; then
90 setenv loadaddr ${loadaddr_rtos};
91 store read ${loadaddr} ${boot_part} 0 0x400000;
92 bootm ${loadaddr};
93 else if test ${os_type} = kernel; then
94 get_avb_mode;
95 if fdt addr ${dtb_mem_addr}; then else echo retry common dtb; run common_dtb_load; fi;
96 setenv loadaddr ${loadaddr_kernel};
97 if imgread kernel ${boot_part} ${loadaddr}; then bootm ${loadaddr}; fi;
98 else echo wrong OS format ${os_type}; fi;fi;
99 echo try upgrade as booting failure; run update;
100
101update=
102 /*first usb burning, second sdc_burn, third ext-sd autoscr/recovery, last udisk autoscr/recovery*/\
103 run usb_burning;
104 run recovery_from_sdcard;
105 run recovery_from_udisk;
106 run recovery_from_flash;
107
108recovery_from_fat_dev=
109 setenv loadaddr ${loadaddr_kernel};
110 if fatload ${fatload_dev} 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;
111 if fatload ${fatload_dev} 0 ${loadaddr} recovery.img; then
112 if fatload ${fatload_dev} 0 ${dtb_mem_addr} dtb.img; then echo ${fatload_dev} dtb.img loaded; fi;
113 setenv bootargs ${bootargs} ${fs_type};
114 bootm ${loadaddr};
115 fi;
116recovery_from_udisk=
117 setenv fatload_dev usb;
118 if usb start 0; then run recovery_from_fat_dev; fi;
119recovery_from_sdcard=
120 setenv fatload_dev mmc;
121 if mmcinfo; then run recovery_from_fat_dev; fi;
122
123recovery_from_flash=
124 echo active_slot: ${active_slot};
Bing Jiangee808882023-09-15 15:29:24 +0800125 run storage_param;
Sam Wu083c4852023-04-25 19:37:54 +0800126 setenv loadaddr ${loadaddr_kernel};
127 if test ${active_slot} = normal; then
128 setenv bootargs ${bootargs} ${fs_type} aml_dt=${aml_dt}
129 recovery_part=${recovery_part} recovery_offset=${recovery_offset};
130 if test ${upgrade_step} = 3; then
131 if ext4load mmc 1:2 ${dtb_mem_addr} /recovery/dtb.img; then echo cache dtb.img loaded; fi;
132 if test ${vendor_boot_mode} = true; then
133 if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then bootm ${loadaddr}; fi;
134 else
135 if ext4load mmc 1:2 ${loadaddr} /recovery/recovery.img; then
136 echo cache recovery.img loaded; bootm ${loadaddr};
137 fi;
138 fi;
139 else
140 if imgread dtb recovery ${dtb_mem_addr}; then
141 else echo restore dtb; run common_dtb_load;
142 fi;
143 fi;
144 if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then bootm ${loadaddr}; fi;
145 else
Sam Wu9db1ccc2023-05-09 18:31:35 +0800146 echo "active_slot ${active_slot} not supported";
Sam Wu083c4852023-04-25 19:37:54 +0800147 fi;
148
149bcb_cmd=
150 get_avb_mode;
151 get_valid_slot;
152 if test ${vendor_boot_mode} = true; then
Bo Lv119f5f32023-06-27 16:32:31 +0800153 setenv loadaddr_kernel 0x3000000;
Sam Wu083c4852023-04-25 19:37:54 +0800154 setenv dtb_mem_addr 0x1000000;
155 fi;
Bo Lv119f5f32023-06-27 16:32:31 +0800156 if test ${active_slot} != "normal"; then
Sam Wu083c4852023-04-25 19:37:54 +0800157 echo ab mode, read dtb from kernel;
158 setenv common_dtb_load imgread dtb ${boot_part} ${dtb_mem_addr};
159 fi;
160
161load_bmp_logo=
162 if imgread pic logo bootup $loadaddr; then bmp display $bootup_offset; fi;
163
164init_display=
165 get_rebootmode;
166 echo reboot_mode:::: ${reboot_mode};
167 if test ${reboot_mode} = quiescent; then
168 setenv reboot_mode_android "quiescent";
169 setenv dolby_status 0;
170 setenv dolby_vision_on 0;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800171 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800172 setenv bootargs ${bootargs} androidboot.quiescent=1;
173 osd open;osd clear;
174 else if test ${reboot_mode} = recovery_quiescent; then
175 setenv reboot_mode_android "quiescent";
176 setenv dolby_status 0;
177 setenv dolby_vision_on 0;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800178 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800179 setenv bootargs ${bootargs} androidboot.quiescent=1;
180 osd open;osd clear;
181 else
182 setenv reboot_mode_android "normal";
ruofei.zhao4a2ec0c2023-10-31 19:24:41 +0800183 hdmitx hpd;hdmitx get_parse_edid;
Bo Lvcb044df2023-08-07 10:55:30 +0800184 dovi process;watermark_init;osd open;osd clear;run load_bmp_logo;
185 bmp scale;vout output ${outputmode};dovi set;dovi pkg;vpp hdrpkt;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800186 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800187 fi;fi;
188
189storage_param=
190 setenv bootargs ${bootargs} ${emmc_quirks};
191 store param;
192 setenv bootargs ${bootargs} ${mtdbootparts};
193
194cmdline_keys=
195 setenv region_code US;
196 if keyman init 0x1234; then
197 if keyman read usid ${loadaddr} str; then
198 setenv bootargs ${bootargs} androidboot.serialno=${usid};
199 setenv serial ${usid}; setenv serial# ${usid};
200 else
201 setenv bootargs ${bootargs} androidboot.serialno=ap222${cpu_id};
202 setenv serial ap222${cpu_id}; setenv serial# ap222${cpu_id};
203 fi;
204 if keyman read region_code ${loadaddr} str; then fi;
205 if keyman read mac ${loadaddr} str; then
206 setenv bootargs ${bootargs} mac=${mac} androidboot.mac=${mac};
207 fi;
208 if keyman read deviceid ${loadaddr} str; then
209 setenv bootargs ${bootargs} androidboot.deviceid=${deviceid};
210 fi;
211 fi;
212 setenv bootargs ${bootargs} androidboot.wificountrycode=${region_code};
213 factory_provision init;
214
215upgrade_key=
216 if gpio input GPIOD_2; then
217 echo detect upgrade key; run update;
218 fi;
219