blob: 5fbd7293c83d5bbd0ca5e68c8623a6428be89740 [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#ifdef CONFIG_KNL_LOG_LEVEL
34loglevel=CONFIG_KNL_LOG_LEVEL
35#else
36loglevel=8
37#endif//ifdef CONFIG_KNL_LOG_LEVEL
38
39#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
40common_dtb_load=imgread dtb ${boot_part} ${dtb_mem_addr}
41#else
42common_dtb_load=imgread dtb _aml_dtb ${dtb_mem_addr}
43#endif//#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
44
Mingyen Hung96effce2023-09-01 00:39:46 -070045get_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 +080046fatload_dev=usb
47fs_type=rootfstype=ramfs
48upgrade_check=
49 echo recovery_status=${recovery_status};
50 if itest.s "${recovery_status}" == "in_progress"; then
51 run storeargs; run recovery_from_flash;
52 else fi;
53 echo upgrade_step=${upgrade_step};
54 if itest ${upgrade_step} == 3; then run storeargs; run update; fi;
55
56initargs=init=/init ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 loop.max_part=4
57
58storeargs=
59 get_bootloaderversion;
60 setenv bootargs ${initargs}
yao zhang15ef11eb2023-11-21 14:46:44 +080061 loglevel=${loglevel} async_long_initcall=1 console=ttyS0,${baudrate} no_console_suspend earlycon=aml_uart,${uart_base}
Sam Wu083c4852023-04-25 19:37:54 +080062 ${fs_type} otg_device=${otg_device}
63 logo=${display_layer},loaded,${fb_addr} vout=${outputmode},enable panel_type=${panel_type}
64 hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode}
65 hdmichecksum=${hdmichecksum} dolby_vision_on=${dolby_vision_on}
66 hdr_policy=${hdr_policy} hdr_priority=${hdr_priority}
67 frac_rate_policy=${frac_rate_policy} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode}
68 osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en}
69 jtag=${jtag};
70 run cmdline_keys;
71
72switch_bootmode=
73 get_rebootmode;
74 if test ${reboot_mode} = factory_reset; then run recovery_from_flash;
75 else if test ${reboot_mode} = update; then run update;
76 else if test ${reboot_mode} = quiescent; then
77 setenv bootargs ${bootargs} androidboot.quiescent=1;
78 else if test ${reboot_mode} = recovery_quiescent; then
79 setenv bootargs ${bootargs} androidboot.quiescent=1;
80 run recovery_from_flash;
81 else if test ${reboot_mode} = cold_boot; then
82 else if test ${reboot_mode} = fastboot; then fastboot 0; fi;
83 fi;fi;fi;fi;fi;
84
85storeboot=
86 run get_os_type;
87 run storage_param;
88 if test ${os_type} = rtos; then
89 setenv loadaddr ${loadaddr_rtos};
90 store read ${loadaddr} ${boot_part} 0 0x400000;
91 bootm ${loadaddr};
92 else if test ${os_type} = kernel; then
93 get_avb_mode;
94 if fdt addr ${dtb_mem_addr}; then else echo retry common dtb; run common_dtb_load; fi;
95 setenv loadaddr ${loadaddr_kernel};
Mingyen Hung96effce2023-09-01 00:39:46 -070096 if imgread kernel ${boot_part} ${loadaddr}; then
97#if CONFIG_PARTITION_ENCRYPTION
98 partition_enc apply;
99#endif
100 bootm ${loadaddr};
101 fi;
Sam Wu083c4852023-04-25 19:37:54 +0800102 else echo wrong OS format ${os_type}; fi;fi;
103 echo try upgrade as booting failure; run update;
104
105update=
106 /*first usb burning, second sdc_burn, third ext-sd autoscr/recovery, last udisk autoscr/recovery*/\
107 run usb_burning;
108 run recovery_from_sdcard;
109 run recovery_from_udisk;
110 run recovery_from_flash;
111
112recovery_from_fat_dev=
113 setenv loadaddr ${loadaddr_kernel};
114 if fatload ${fatload_dev} 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;
115 if fatload ${fatload_dev} 0 ${loadaddr} recovery.img; then
116 if fatload ${fatload_dev} 0 ${dtb_mem_addr} dtb.img; then echo ${fatload_dev} dtb.img loaded; fi;
117 setenv bootargs ${bootargs} ${fs_type};
118 bootm ${loadaddr};
119 fi;
120recovery_from_udisk=
121 setenv fatload_dev usb;
122 if usb start 0; then run recovery_from_fat_dev; fi;
123recovery_from_sdcard=
124 setenv fatload_dev mmc;
125 if mmcinfo; then run recovery_from_fat_dev; fi;
126
127recovery_from_flash=
128 echo active_slot: ${active_slot};
Bing Jiangee808882023-09-15 15:29:24 +0800129 run storage_param;
Sam Wu083c4852023-04-25 19:37:54 +0800130 setenv loadaddr ${loadaddr_kernel};
131 if test ${active_slot} = normal; then
132 setenv bootargs ${bootargs} ${fs_type} aml_dt=${aml_dt}
133 recovery_part=${recovery_part} recovery_offset=${recovery_offset};
134 if test ${upgrade_step} = 3; then
135 if ext4load mmc 1:2 ${dtb_mem_addr} /recovery/dtb.img; then echo cache dtb.img loaded; fi;
136 if test ${vendor_boot_mode} = true; then
137 if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then bootm ${loadaddr}; fi;
138 else
139 if ext4load mmc 1:2 ${loadaddr} /recovery/recovery.img; then
140 echo cache recovery.img loaded; bootm ${loadaddr};
141 fi;
142 fi;
143 else
144 if imgread dtb recovery ${dtb_mem_addr}; then
145 else echo restore dtb; run common_dtb_load;
146 fi;
147 fi;
Mingyen Hung96effce2023-09-01 00:39:46 -0700148 if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then
149#if CONFIG_PARTITION_ENCRYPTION
150 partition_enc apply;
151#endif
152 bootm ${loadaddr};
153 fi;
Sam Wu083c4852023-04-25 19:37:54 +0800154 else
Sam Wu9db1ccc2023-05-09 18:31:35 +0800155 echo "active_slot ${active_slot} not supported";
Sam Wu083c4852023-04-25 19:37:54 +0800156 fi;
157
158bcb_cmd=
159 get_avb_mode;
160 get_valid_slot;
161 if test ${vendor_boot_mode} = true; then
Bo Lv119f5f32023-06-27 16:32:31 +0800162 setenv loadaddr_kernel 0x3000000;
Sam Wu083c4852023-04-25 19:37:54 +0800163 setenv dtb_mem_addr 0x1000000;
164 fi;
Bo Lv119f5f32023-06-27 16:32:31 +0800165 if test ${active_slot} != "normal"; then
Sam Wu083c4852023-04-25 19:37:54 +0800166 echo ab mode, read dtb from kernel;
167 setenv common_dtb_load imgread dtb ${boot_part} ${dtb_mem_addr};
168 fi;
169
170load_bmp_logo=
171 if imgread pic logo bootup $loadaddr; then bmp display $bootup_offset; fi;
172
173init_display=
174 get_rebootmode;
175 echo reboot_mode:::: ${reboot_mode};
176 if test ${reboot_mode} = quiescent; then
177 setenv reboot_mode_android "quiescent";
178 setenv dolby_status 0;
179 setenv dolby_vision_on 0;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800180 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800181 setenv bootargs ${bootargs} androidboot.quiescent=1;
182 osd open;osd clear;
183 else if test ${reboot_mode} = recovery_quiescent; then
184 setenv reboot_mode_android "quiescent";
185 setenv dolby_status 0;
186 setenv dolby_vision_on 0;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800187 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800188 setenv bootargs ${bootargs} androidboot.quiescent=1;
189 osd open;osd clear;
190 else
191 setenv reboot_mode_android "normal";
ruofei.zhao4a2ec0c2023-10-31 19:24:41 +0800192 hdmitx hpd;hdmitx get_parse_edid;
Bo Lvcb044df2023-08-07 10:55:30 +0800193 dovi process;watermark_init;osd open;osd clear;run load_bmp_logo;
194 bmp scale;vout output ${outputmode};dovi set;dovi pkg;vpp hdrpkt;
Wenjie Qiao52d73732023-09-11 17:08:11 +0800195 run storeargs;
Sam Wu083c4852023-04-25 19:37:54 +0800196 fi;fi;
197
198storage_param=
199 setenv bootargs ${bootargs} ${emmc_quirks};
200 store param;
201 setenv bootargs ${bootargs} ${mtdbootparts};
202
203cmdline_keys=
204 setenv region_code US;
205 if keyman init 0x1234; then
206 if keyman read usid ${loadaddr} str; then
207 setenv bootargs ${bootargs} androidboot.serialno=${usid};
208 setenv serial ${usid}; setenv serial# ${usid};
209 else
210 setenv bootargs ${bootargs} androidboot.serialno=ap222${cpu_id};
211 setenv serial ap222${cpu_id}; setenv serial# ap222${cpu_id};
212 fi;
213 if keyman read region_code ${loadaddr} str; then fi;
214 if keyman read mac ${loadaddr} str; then
215 setenv bootargs ${bootargs} mac=${mac} androidboot.mac=${mac};
216 fi;
217 if keyman read deviceid ${loadaddr} str; then
218 setenv bootargs ${bootargs} androidboot.deviceid=${deviceid};
219 fi;
220 fi;
221 setenv bootargs ${bootargs} androidboot.wificountrycode=${region_code};
222 factory_provision init;
223
224upgrade_key=
225 if gpio input GPIOD_2; then
226 echo detect upgrade key; run update;
227 fi;
228