// 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 preboot_mode=0 systemsuspend_switch=1 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 ffv_wake=off powermode=on powermode_ini=0 suspend=off cpuid_env=0 vout_init=disabled vout2_init=disabled #ifdef CONFIG_NOVERBOSE_BUILD loglevel=2 #else #ifdef CONFIG_KNL_LOG_LEVEL loglevel=CONFIG_KNL_LOG_LEVEL #else loglevel=7 #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 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 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 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},${vout2_init} lcd0=${lcd0_attr} bl_level=${bl_level} lcd_debug=${lcd_debug} lcd1=${lcd1_attr} bl1_level=${bl1_level} eDPTX=${eDP_ctrl} hdmitx=${hdmimode},${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=${kvm_arm_mode} 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}; setenv bootconfig ${bootconfig} androidboot.chipid=${cpuid_env}; if test ${cc_enable} != 1; then else setenv bootconfig ${bootconfig} androidboot.cc_enable=${cc_enable}; fi; run cmdline_keys; # 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; 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; 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; get_rebootmode; echo reboot_mode : ${reboot_mode}; setenv bootargs ${bootargs} reboot_mode=${reboot_mode}; 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; 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 ${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; vout boot_display; #ifdef CONFIG_AML_DOLBY dovi set;dovi pkg; #endif vpp hdrpkt; run storeargs; fi;fi; upgrade_display_prepare= echo prepare display for upgrade multidisplay; 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 multidisplay; echo hdmitx hpd;hdmitx get_parse_edid;hdmitx hpd;hdmitx get_parse_edid; 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; fi; setenv bootconfig ${bootconfig} androidboot.wificountrycode=${region_code}; factory_provision init; 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;