// 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 silent_build=0 firstboot=1 ENABLE_SMP lock=10101000 preboot_mode=0 systemsuspend_switch=1 ir_preboot_key=0x0 disable_ir=0 upgrade_step=0 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 ffv_wake=off powermode=on suspend=off cpuid_env=0 factorytest=0 keymatch=false need_erase_key=0 rc_level=3 ini_update_flag=0 bootperf=0 userdata_size=0; provision_efuse_debug=1; arb_reboot_flag=0 cec_fun=0x2f logic_addr=0x0 cec_ac_wakeup=1 jpg_logo=false wk0_test=no #ifdef CONFIG_NOVERBOSE_BUILD loglevel=2 page_trace=off #else #ifdef CONFIG_KNL_LOG_LEVEL loglevel=CONFIG_KNL_LOG_LEVEL #else loglevel=7 #endif//ifdef CONFIG_KNL_LOG_LEVEL page_trace=on #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 preboot_condition= if test ${preboot_mode} = 1 && test ${disable_ir} = 1 && test ${reboot_mode} = cold_boot; then setenv enable_preboot_mode 1; else setenv enable_preboot_mode 0; fi; preboot_check_action= if test ${enable_preboot_mode} = 1; then setenv bootup_display preboot; irkey_wakeup 4; watchkey test 0; if test ${ir_preboot_key} != 0x0 || test ${wk0_test} = yes; then setenv bootup_display on; fi; fi; #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 #ifdef CONFIG_YOCTO check_factory_reset=if test -n ${factory-reset}; then if test ${factory-reset} != 0; then defenv_reserve factory-reset model_name panel_type ${factory-reset_extra_preserved_envs}; saveenv; fi; fi; init_ir_wakeup=irkey_wakeup 0 2 0x0 0xef10fe01 0xac53fe01 #endif 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; run preboot_condition; run preboot_check_action; initargs=init=/init ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 loop.max_part=4 console=ttyS0,115200 storeargs=get_bootloaderversion; run init_bootreason; if test ${reboot_mode} = factory_reboot; then setenv EnableSelinux permissive; fi; if test ${reboot_mode} = bist_reboot; then setenv EnableSelinux permissive; fi; setenv bootargs ${initargs} loglevel=${loglevel} console=${console} no_console_suspend earlycon=aml_uart,${uart_base} scramble_reg=${scramble_reg} page_trace=${page_trace} otg_device=${otg_device} disable_ir=${disable_ir} cpufreq.default_governor=${default_governor} logo=${display_layer},loaded,${fb_addr} vout=${outputmode},${vout_init} connector0_type=${connector0_type} lcd0=${lcd0_attr} lcd_debug=${lcd_debug} bl_level=${bl_level} display_bpp=${display_bpp} outputmode=${outputmode} dolby_vision_on=${dolby_vision_on} hdr_policy=${hdr_policy} hdr_priority=${hdr_priority} frac_rate_policy=${frac_rate_policy} osd_reverse=${osd_reverse} video_reverse=${video_reverse} aml_isolcpus=${aml_isolcpus} isolcpus_speedup_boot=${isolcpus_speedup_boot} apu_enable=${apu_enable}; setenv bootargs ${bootargs} ${emmc_quirks} kvm-arm.mode=none init_on_alloc=0 reboot_mode=${reboot_mode}; 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.production_mode=${production_mode}; setenv bootconfig ${bootconfig} androidboot.chipid=${cpuid_env}; setenv bootconfig ${bootconfig} androidboot.rc_level=${rc_level}; setenv bootconfig ${bootconfig} androidboot.bootperf=${bootperf}; setenv bootconfig ${bootconfig} androidboot.userdatasize=${userdata_size}; setenv bootconfig ${bootconfig} androidboot.arb_reboot_flag=${arb_reboot_flag}; setenv bootconfig ${bootconfig} androidboot.need_erase_key=${need_erase_key}; setenv bootconfig ${bootconfig} androidboot.ini_update_flag=${ini_update_flag}; setenv bootconfig ${bootconfig} androidboot.model_name=${model_name}; setenv bootconfig ${bootconfig} androidboot.dtbo_idx=${androidboot.dtbo_idx}; run cmdline_keys; run preboot_check_action # vad mode and powermode = last reset_suspend= if test ${ffv_freeze} != on ; then if test ${suspend} = on || test ${suspend} = shutdown; then echo reset_suspend off; setenv suspend off; saveenv; fi; fi; cec_init= echo cec_ac_wakeup=${cec_ac_wakeup}; if test ${cec_ac_wakeup} = 1; then cec ${logic_addr} ${cec_fun}; if test ${edid_select} = 1111; then hdmirx init ${port_map} ${edid_20_dir}; else hdmirx init ${port_map} ${edid_14_dir}; fi; fi; ffv_freeze_action= run cec_init; setenv ffv_freeze on; setenv bootargs ${bootargs} ffv_freeze=on cold_boot_normal_check= setenv bootargs ${bootargs} ffv_freeze=off; #ifdef CONFIG_YOCTO run init_ir_wakeup; #endif if test ${powermode} = on; then ; elif test ${powermode} = standby; then run cec_init; if test ${preboot_mode} = 0; then if test ${systemsuspend_switch} = 0; then irkey_wakeup 3 0; systemoff; else systemsuspend; fi; fi; elif test ${powermode} = last; then echo suspend=${suspend}; if test ${suspend} = off; then ; else run cec_init; if test ${preboot_mode} = 0; then if test ${systemsuspend_switch} = 0; then irkey_wakeup 3 0; systemoff; else systemsuspend; fi; fi; fi; fi; switch_bootmode= setenv ffv_freeze off; if test ${reboot_mode} = factory_reset; then run recovery_from_flash; elif test ${reboot_mode} = update; then run update; elif test ${reboot_mode} = quiescent; then setenv bootconfig ${bootconfig} androidboot.quiescent=1; elif test ${reboot_mode} = recovery_quiescent; then setenv bootconfig ${bootconfig} androidboot.quiescent=1; run recovery_from_flash; elif test ${reboot_mode} = cold_boot; then echo cold boot: ffv_wake=${ffv_wake} powermode=${powermode} suspend=${suspend}; if test ${ffv_wake} = on; then if test ${powermode} = on; then setenv bootargs ${bootargs} ffv_freeze=off; elif test ${powermode} = standby; then run ffv_freeze_action; elif test ${powermode} = last; then if test ${suspend} = off; then setenv bootargs ${bootargs} ffv_freeze=off; elif test ${suspend} = on; then run ffv_freeze_action; elif test ${suspend} = shutdown; then run ffv_freeze_action; fi; fi; else run cold_boot_normal_check; fi; elif test ${reboot_mode} = ffv_reboot; then if test ${ffv_wake} = on; then run ffv_freeze_action; fi; elif test ${reboot_mode} = fastboot; then fastboot 1; elif test ${reboot_mode} = factory_reboot; then bcb factory; elif test ${reboot_mode} = bist_reboot; then bcb bist; fi; enter_fastboot= fastboot 1; switch_usbmode= if env exists usb2t_mode; then setenv bootargs ${bootargs} usb2t_mode=1; 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}; elif 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 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; 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; else setenv bootargs ${bootargs} ${fs_type} aml_dt=${aml_dt}; setenv bootconfig ${bootconfig} androidboot.slot_suffix=${active_slot}; recovery_part=${recovery_part} recovery_offset=${recovery_offset}; if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then bootm ${loadaddr}; fi; fi; fi; bcb_cmd= get_avb_mode; get_valid_slot; 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; logo_read= if rdext4pic ${board_logo_part} $loadaddr ${logo_file_name}; then setenv ext4pic_load_success 1; else setenv ext4pic_load_success 0; imgread pic logo bootup $loadaddr; fi; if test ${jpg_logo} = true; then jpeg info $logoLoadAddr; else bmp info $logoLoadAddr; fi; load_bmp_logo= if test ${ext4pic_load_success} = 1; then bmp display $logoLoadAddr; else bmp display $bootup_offset; fi; load_jpg_logo= if test ${ext4pic_load_success} = 1; then jpeg display $logoLoadAddr $ext4LogoSz; else jpeg display $bootup_offset $bootup_size; fi; init_display= watermark_init; logo_display; run logo_read; osd open; osd clear; if test ${jpg_logo} = true; then run load_jpg_logo; else run load_bmp_logo; fi; bmp scale; vout boot_display; upgrade_display_prepare= echo prepare display for upgrade tv; setenv display_on_smp 0; setenv fb_for_4k2k 0; setenv jpg_logo false; setenv display_layer osd0; setenv display_bpp 16; setenv display_color_index 16; upgrade_display_init= echo prepare display for upgrade tv; echo osd open;osd open; echo osd clear;osd clear; echo vout output ${outputmode};vout output ${outputmode}; storage_param= setenv bootargs ${bootargs} ${emmc_quirks}; 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 odmsn ${loadaddr} str; then setenv bootargs ${bootargs} odmsn=${odmsn}; setenv bootconfig ${bootconfig} androidboot.odmsn=${odmsn}; fi; if keyman read deviceid ${loadaddr} str; then setenv bootconfig ${bootconfig} androidboot.deviceid=${deviceid}; fi; if oemkey_read; then setenv bootconfig ${bootconfig} androidboot.oem.key1=${oemkey_name}; else setenv bootconfig ${bootconfig} androidboot.oem.key1=ATV00105525; fi; fi; setenv bootconfig ${bootconfig} androidboot.wificountrycode=${region_code}; factory_provision init; check_connector_type= setenv bootconfig ${bootconfig} androidboot.connector0_type=${connector0_type}; check_display= ini_powermode; echo check_display reboot_mode: ${reboot_mode}, powermode: ${powermode}; setenv ddr_resume 0; setenv bootup_display on; if test ${reboot_mode} = ffv_reboot; then if test ${ffv_wake} = on; then echo ffv reboot need display; setenv bootup_display preboot; fi; elif test ${reboot_mode} = cold_boot; then if test ${ffv_wake} = on; then echo ffv_wake on, need display; setenv bootup_display preboot; elif test ${powermode} = standby; then if test ${preboot_mode} = 0; then setenv ddr_resume 1; fi; elif test ${powermode} = last; then if test ${suspend} != off; then if test ${preboot_mode} = 0; then echo suspend: ${suspend}; setenv ddr_resume 1; fi; fi; fi; elif test ${reboot_mode} = quiescent; then echo quiescent reboot no display; setenv bootup_display off; elif test ${reboot_mode} = recovery_quiescent; then echo quiescent reboot no display; setenv bootup_display off; fi; run preboot_check_action; if test ${write_boot} = 1; then setenv bootup_display off; fi; check_aocpu= if test ${reboot_mode} = aocpu_watchdog; then systemsuspend; fi; init_bootreason= get_rebootmode; echo reboot_mode:::: ${reboot_mode}; if test ${reboot_mode} = quiescent; then setenv reboot_mode_android "quiescent"; setenv initconfig "androidboot.quiescent=1 androidboot.bootreason=${reboot_mode}"; elif test ${reboot_mode} = recovery_quiescent; then setenv reboot_mode_android "quiescent"; setenv initconfig "androidboot.quiescent=1 androidboot.bootreason=recovery,quiescent"; else setenv reboot_mode_android "normal"; setenv initconfig "androidboot.bootreason=${reboot_mode}"; fi;