blob: 3a5f45aff12a263b8788de7ed941f61bfc3824f0 [file] [log] [blame]
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Copyright (c) 2019 Amlogic, Inc. All rights reserved.
*/
/*
* uboot text based env
* more details: https://u-boot.readthedocs.io/en/latest/usage/environment.html
* or: v2023 doc/usage/environment.rst
*/
#ifdef CONFIG_NOVERBOSE_BUILD
silent=1
#else
silent=0
#endif
firstboot=0
lock=10101000
upgrade_step=0
jtag=disable
loadaddr=0x001080000
dtb_mem_addr=0x01000000
os_ident_addr=0x00500000
loadaddr_rtos=0x00080000
dtb_mem_addr=0x1000000
loadaddr_kernel=0x03080000
decaddr_kernel=0x01800000
dv_fw_addr=0xa00000
otg_device=1
fdt_high=0x20000000
EnableSelinux=enforcing
recovery_offset=0
osd_reverse=0
video_reverse=0
active_slot=normal
boot_flag=0
write_boot=0
fb_addr=0x00300000
fastboot_step=0
default_governor=performance
#ifdef CONFIG_NOVERBOSE_BUILD
loglevel=2
#else
#ifdef CONFIG_KNL_LOG_LEVEL
loglevel=CONFIG_KNL_LOG_LEVEL
#else
loglevel=8
#endif//ifdef CONFIG_KNL_LOG_LEVEL
#endif
#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
common_dtb_load=imgread dtb ${boot_part} ${dtb_mem_addr}
#else
common_dtb_load=imgread dtb _aml_dtb ${dtb_mem_addr}
#endif//#ifdef CONFIG_DTB_BIND_KERNEL //load dtb from kernel, such as boot partition
get_os_type=if imgread part ${boot_part} ${os_ident_addr} 0 0x1000; then os_ident ${os_ident_addr}; fi
fatload_dev=usb
fs_type=rootfstype=ramfs
upgrade_check=
echo recovery_status=${recovery_status};
if itest.s "${recovery_status}" == "in_progress"; then
run init_display; run storeargs; run recovery_from_flash;
else fi;
echo upgrade_step=${upgrade_step};
if itest ${upgrade_step} == 3; then run storeargs; run update; fi;
initargs=init=/init ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 loop.max_part=4
storeargs=
get_bootloaderversion;
setenv bootargs ${initargs}
loglevel=${loglevel} async_long_initcall=1 console=ttyS0,${baudrate} no_console_suspend earlycon=aml_uart,${uart_base}
${fs_type} otg_device=${otg_device}
logo=${display_layer},loaded,${fb_addr} vout=${outputmode},enable
connector0_type=${connector0_type} connector1_type=${connector1_type}
connector2_type=${connector2_type} cpufreq.default_governor=${default_governor}
lcd0=${lcd0_attr} lcd_debug=${lcd_debug}
hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode}
hdmichecksum=${hdmichecksum} dolby_vision_on=${dolby_vision_on}
hdr_policy=${hdr_policy} hdr_priority=${hdr_priority}
frac_rate_policy=${actual_frac_rate} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode}
osd_reverse=${osd_reverse} video_reverse=${video_reverse} irq_check_en=${Irq_check_en}
jtag=${jtag} config_csc_en=${config_csc_en};
setenv bootargs ${bootargs} production_mode=${production_mode};
run cmdline_keys;
switch_bootmode=
get_rebootmode;
if test ${reboot_mode} = factory_reset; then run recovery_from_flash;
else if test ${reboot_mode} = update; then run update;
else if test ${reboot_mode} = quiescent; then
setenv bootargs ${bootargs} androidboot.quiescent=1;
else if test ${reboot_mode} = recovery_quiescent; then
setenv bootargs ${bootargs} androidboot.quiescent=1;
run recovery_from_flash;
else if test ${reboot_mode} = cold_boot; then
else if test ${reboot_mode} = fastboot; then fastboot 0; fi;
fi;fi;fi;fi;fi;
storeboot=
run get_os_type;
run storage_param;
if test ${os_type} = rtos; then
setenv loadaddr ${loadaddr_rtos};
store read ${loadaddr} ${boot_part} 0 0x400000;
bootm ${loadaddr};
else if test ${os_type} = kernel; then
get_avb_mode;
if fdt addr ${dtb_mem_addr}; then else echo retry common dtb; run common_dtb_load; fi;
setenv loadaddr ${loadaddr_kernel};
if imgread kernel ${boot_part} ${loadaddr}; then
#if CONFIG_PARTITION_ENCRYPTION
partition_enc apply;
#endif
bootm ${loadaddr};
fi;
else echo wrong OS format ${os_type}; fi;fi;
echo try upgrade as booting failure; run update;
update=
/*first usb burning, second sdc_burn, third ext-sd autoscr/recovery, last udisk autoscr/recovery*/\
run usb_burning;
run recovery_from_sdcard;
run recovery_from_udisk;
run recovery_from_flash;
recovery_from_fat_dev=
setenv loadaddr ${loadaddr_kernel};
if fatload ${fatload_dev} 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;
if fatload ${fatload_dev} 0 ${loadaddr} recovery.img; then
if fatload ${fatload_dev} 0 ${dtb_mem_addr} dtb.img; then echo ${fatload_dev} dtb.img loaded; fi;
setenv bootargs ${bootargs} ${fs_type};
bootm ${loadaddr};
fi;
recovery_from_udisk=
setenv fatload_dev usb;
if usb start 0; then run recovery_from_fat_dev; fi;
recovery_from_sdcard=
setenv fatload_dev mmc;
if mmcinfo; then run recovery_from_fat_dev; fi;
recovery_from_flash=
echo active_slot: ${active_slot};
run storage_param;
setenv loadaddr ${loadaddr_kernel};
if test ${active_slot} = normal; then
setenv bootargs ${bootargs} ${fs_type} aml_dt=${aml_dt}
recovery_part=${recovery_part} recovery_offset=${recovery_offset};
avb recovery 1;
if test ${upgrade_step} = 3; then
if ext4load mmc 1:2 ${dtb_mem_addr} /recovery/dtb.img; then echo cache dtb.img loaded; fi;
if test ${vendor_boot_mode} = true; then
if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then bootm ${loadaddr}; fi;
else
if ext4load mmc 1:2 ${loadaddr} /recovery/recovery.img; then
echo cache recovery.img loaded; bootm ${loadaddr};
fi;
fi;
else
if imgread dtb recovery ${dtb_mem_addr}; then
else echo restore dtb; run common_dtb_load;
fi;
fi;
if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then
#if CONFIG_PARTITION_ENCRYPTION
partition_enc apply;
#endif
bootm ${loadaddr};
fi;
else
echo "active_slot ${active_slot} not supported";
fi;
bcb_cmd=
get_avb_mode;
get_valid_slot;
if test ${vendor_boot_mode} = true; then
setenv loadaddr_kernel 0x3000000;
setenv dtb_mem_addr 0x1000000;
fi;
if test ${active_slot} != "normal"; then
echo ab mode, read dtb from kernel;
setenv common_dtb_load imgread dtb ${boot_part} ${dtb_mem_addr};
fi;
load_bmp_logo=
if imgread pic logo bootup $loadaddr; then bmp display $bootup_offset; fi;
init_display=
get_rebootmode;
echo reboot_mode:::: ${reboot_mode};
if test ${reboot_mode} = quiescent; then
setenv reboot_mode_android "quiescent";
setenv dolby_status 0;
setenv dolby_vision_on 0;
run storeargs;
setenv bootargs ${bootargs} androidboot.quiescent=1;
osd open;osd clear;
else if test ${reboot_mode} = recovery_quiescent; then
setenv reboot_mode_android "quiescent";
setenv dolby_status 0;
setenv dolby_vision_on 0;
run storeargs;
setenv bootargs ${bootargs} androidboot.quiescent=1;
osd open;osd clear;
else
setenv reboot_mode_android "normal";
hdmitx hpd;hdmitx get_parse_edid;
#ifdef CONFIG_AML_DOLBY
dovi process;
#endif
watermark_init;osd open;osd clear;run load_bmp_logo;
bmp scale;vout output ${outputmode};
#ifdef CONFIG_AML_DOLBY
dovi set;dovi pkg;
#endif
vpp hdrpkt;
run storeargs;
fi;fi;
storage_param=
setenv bootargs ${bootargs} ${emmc_quirks};
store param;
setenv bootargs ${bootargs} ${mtdbootparts};
cmdline_keys=
setenv region_code US;
if keyman init 0x1234; then
if keyman read usid ${loadaddr} str; then
setenv bootargs ${bootargs} androidboot.serialno=${usid};
setenv serial ${usid}; setenv serial# ${usid};
else
setenv bootargs ${bootargs} androidboot.serialno=ap222${cpu_id};
setenv serial ap222${cpu_id}; setenv serial# ap222${cpu_id};
fi;
if keyman read region_code ${loadaddr} str; then fi;
if keyman read mac ${loadaddr} str; then
setenv bootargs ${bootargs} mac=${mac} androidboot.mac=${mac};
fi;
if keyman read deviceid ${loadaddr} str; then
setenv bootargs ${bootargs} androidboot.deviceid=${deviceid};
fi;
fi;
setenv bootargs ${bootargs} androidboot.wificountrycode=${region_code};
factory_provision init;
upgrade_key=
if gpio input GPIOD_2; then
echo detect upgrade key; run update;
fi;