blob: ba3c4d9d4d26dbaeb83456ad2a4eac2d99153bc4 [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=1
lock=10101000
upgrade_step=0
jtag=disable
loadaddr=0x1080000
dtb_mem_addr=0x01000000
os_ident_addr=0x00500000
loadaddr_rtos=0x00080000
loadaddr_kernel=0x03000000
decaddr_kernel=0x01800000
fb_addr=0x00300000
dolby_status=0
dolby_vision_on=0
dv_fw_dir_odm_ext=/odm_ext/firmware/dovi_fw.bin
dv_fw_dir_vendor=/vendor/firmware/dovi_fw.bin
dv_fw_dir=/oem/firmware/dovi_fw.bin
dv_fw_addr=0xa00000
otg_device=1
fdt_high=0x20000000
EnableSelinux=enforcing
recovery_offset=0
osd_reverse=0
video_reverse=0
active_slot=normal
vendor_boot_part=vendor_boot
board_logo_part=odm_ext
rollback_flag=0
boot_flag=0
write_boot=0
recovery_mode=false
retry_recovery_times=7
androidboot.dtbo_idx=0
fatload_dev=usb
disable_ir=0
default_governor=performance
sdcburncfg=aml_sdc_burn.ini
recovery_part=recovery
ddr_size=0
fs_type=rootfstype=ramfs
fastboot_step=0
usb_status=detach
#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_ENABLE_AML_GPIO_UPGRADE
upgrade_key_base=
if gpio input CONFIG_AML_GPIO_UPGRADE_KEY; then
echo detect upgrade key;
if test ${upgrade_key_flag} = 0; then
echo enter recovery; setenv upgrade_key_flag 1; saveenv;
run recovery_from_flash;
else if test ${upgrade_key_flag} = 1; then
echo enter update; setenv upgrade_key_flag 2; saveenv; run update;
else
echo enter fastboot; setenv upgrade_key_flag 0; saveenv; fastboot 0;
fi;fi;
fi;
#else
upgrade_key_base=
echo base env no upgrade key;
#endif //#ifdef CONFIG_ENABLE_AML_GPIO_UPGRADE
#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 store read ${os_ident_addr} ${boot_part} 0 0x1000; then os_ident ${os_ident_addr}; fi
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} console=ttyS0,${baudrate} no_console_suspend earlycon=aml_uart,${uart_base}
scramble_reg=${scramble_reg} cma_first_wm_low=on
otg_device=${otg_device} disable_ir=${disable_ir} cpufreq.default_governor=${default_governor}
logo=${display_layer},loaded,${fb_addr} vout=${outputmode},${vout_init} vout2=${outputmode2},enable
lcd0=${lcd0_attr} lcd_debug=${lcd_debug}
hdmitx=${cecconfig},${colorattribute} hdmimode=${hdmimode}
hdmichecksum=${hdmichecksum} dolby_vision_on=${dolby_vision_on}
connector0_type=${connector0_type} connector1_type=${connector1_type}
connector2_type=${connector2_type} outputmode=${outputmode} outputmode2=${outputmode2}
hdr_policy=${hdr_policy} hdr_priority=${hdr_priority} config_csc_en=${config_csc_en}
hdr_force_mode=${hdr_force_mode} dolby_status=${dolby_status}
frac_rate_policy=${actual_frac_rate} hdmi_read_edid=${hdmi_read_edid} cvbsmode=${cvbsmode}
osd_reverse=${osd_reverse} video_reverse=${video_reverse} jtag=${jtag};
setenv bootargs ${bootargs} ${emmc_quirks} kvm-arm.mode=none init_on_alloc=0;
storeargs+= setenv bootconfig ${initconfig} androidboot.selinux=${EnableSelinux};
setenv bootconfig ${bootconfig} androidboot.bootloader=${bootloader_version} androidboot.hardware=amlogic;
setenv bootconfig ${bootconfig} androidboot.firstboot=${firstboot} androidboot.ddr_size=${ddr_size};
setenv bootconfig ${bootconfig} androidboot.cc.status=${usb_status};
setenv bootconfig ${bootconfig} androidboot.production_mode=${production_mode};
if test ${cc_enable} != 1; then
else
setenv bootconfig ${bootconfig} androidboot.cc_enable=${cc_enable};
fi;
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;
echo active_slot in storeboot: ${active_slot};
if fdt addr ${dtb_mem_addr}; then else echo retry common dtb; run common_dtb_load; fi;
setenv bootconfig ${bootconfig} androidboot.force_normal_boot=1;
if test ${active_slot} != normal; then
setenv bootconfig ${bootconfig} androidboot.slot_suffix=${active_slot};
fi;
setenv bootconfig ${bootconfig} androidboot.rollback=${rollback_flag};
setenv loadaddr ${loadaddr_kernel};
if imgread kernel ${boot_part} ${loadaddr}; then bootm ${loadaddr}; fi;
else echo wrong OS format ${os_type}; fi;fi;
echo try upgrade as booting failure; check_ab; 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};
setenv loadaddr ${loadaddr_kernel};
setenv recovery_mode true;
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 bootm ${loadaddr}; fi;
else
if fdt addr ${dtb_mem_addr}; then else echo retry common dtb; run common_dtb_load; fi;
if test ${vendor_boot_mode} = true; then
setenv bootargs ${bootargs} ${fs_type} aml_dt=${aml_dt};
setenv bootconfig ${bootconfig} androidboot.slot_suffix=${active_slot};
if imgread kernel ${boot_part} ${loadaddr}; then bootm ${loadaddr}; fi;
fi;
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 rdext4pic ${board_logo_part} $loadaddr; then bmp display $logoLoadAddr;
else if imgread pic logo bootup $loadaddr; then bmp display $bootup_offset; fi; 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;
setenv initconfig androidboot.quiescent=1
androidboot.bootreason=${reboot_mode};
run storeargs;
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;
setenv initconfig androidboot.quiescent=1
androidboot.bootreason=recovery,quiescent;
run storeargs;
osd open;osd clear;
else
setenv reboot_mode_android "normal";
setenv initconfig androidboot.bootreason=${reboot_mode};
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};vout2 output ${outputmode2};
#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 bootconfig ${bootconfig} androidboot.serialno=${usid};
setenv serial ${usid}; setenv serial# ${usid};
else
setenv bootconfig ${bootconfig} androidboot.serialno=${product}${cpu_id};
setenv serial ${product}${cpu_id}; setenv serial# ${product}${cpu_id};
fi;
if keyman read region_code ${loadaddr} str; then fi;
if keyman read mac ${loadaddr} str; then
setenv bootargs ${bootargs} mac=${mac};
setenv bootconfig ${bootconfig} androidboot.mac=${mac};
fi;
if keyman read deviceid ${loadaddr} str; then
setenv bootconfig ${bootconfig} androidboot.deviceid=${deviceid};
fi;
fi;
setenv bootconfig ${bootconfig} androidboot.wificountrycode=${region_code};
factory_provision init;