mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 06:11:06 +00:00 
			
		
		
		
	bootloader: fix analog reset on C6 and H2
This commit is contained in:
		
				
					committed by
					
						
						Xiao Xufeng
					
				
			
			
				
	
			
			
			
						parent
						
							aeabe8d742
						
					
				
				
					commit
					80315b77a0
				
			@@ -93,33 +93,10 @@ static inline void bootloader_hardware_init(void)
 | 
			
		||||
 | 
			
		||||
static inline void bootloader_ana_reset_config(void)
 | 
			
		||||
{
 | 
			
		||||
    // TODO: IDF-5990 copied from C6, need update
 | 
			
		||||
    // Have removed bootloader_ana_super_wdt_reset_config for now; can be evaluated later to see whether needs to add it back
 | 
			
		||||
    /*
 | 
			
		||||
      For origin chip & ECO1: only support swt reset;
 | 
			
		||||
      For ECO2: fix brownout reset bug, support swt & brownout reset;
 | 
			
		||||
      For ECO3: fix clock glitch reset bug, support all reset, include: swt & brownout & clock glitch reset.
 | 
			
		||||
    */
 | 
			
		||||
    uint8_t chip_version = efuse_hal_get_minor_chip_version();
 | 
			
		||||
    switch (chip_version) {
 | 
			
		||||
        case 0:
 | 
			
		||||
        case 1:
 | 
			
		||||
            //Disable BOR and GLITCH reset
 | 
			
		||||
            bootloader_ana_bod_reset_config(false);
 | 
			
		||||
            bootloader_ana_clock_glitch_reset_config(false);
 | 
			
		||||
            break;
 | 
			
		||||
        case 2:
 | 
			
		||||
            //Enable BOR reset. Disable GLITCH reset
 | 
			
		||||
            bootloader_ana_bod_reset_config(true);
 | 
			
		||||
            bootloader_ana_clock_glitch_reset_config(false);
 | 
			
		||||
            break;
 | 
			
		||||
        case 3:
 | 
			
		||||
        default:
 | 
			
		||||
            //Enable BOR, and GLITCH reset
 | 
			
		||||
            bootloader_ana_bod_reset_config(true);
 | 
			
		||||
            bootloader_ana_clock_glitch_reset_config(true);
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
    //Enable super WDT reset.
 | 
			
		||||
    bootloader_ana_super_wdt_reset_config(true);
 | 
			
		||||
    //Enable BOD reset
 | 
			
		||||
    bootloader_ana_bod_reset_config(true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
esp_err_t bootloader_init(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,20 +1,22 @@
 | 
			
		||||
/*
 | 
			
		||||
 * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
 | 
			
		||||
 * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 */
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include "soc/soc.h"
 | 
			
		||||
#include "soc/lp_analog_peri_reg.h"
 | 
			
		||||
 | 
			
		||||
void bootloader_ana_super_wdt_reset_config(bool enable)
 | 
			
		||||
{
 | 
			
		||||
    // ESP32H2 has removed the super wdt
 | 
			
		||||
    //H2 doesn't support bypass super WDT reset
 | 
			
		||||
    assert(enable);
 | 
			
		||||
    REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_SUPER_WDT_RST);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void bootloader_ana_bod_reset_config(bool enable)
 | 
			
		||||
{
 | 
			
		||||
    REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_BOR_RST);
 | 
			
		||||
    REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_BOD_RST);
 | 
			
		||||
 | 
			
		||||
    if (enable) {
 | 
			
		||||
        REG_SET_BIT(LP_ANALOG_PERI_LP_ANA_BOD_MODE1_CNTL_REG, LP_ANALOG_PERI_LP_ANA_BOD_MODE1_RESET_ENA);
 | 
			
		||||
    } else {
 | 
			
		||||
@@ -22,12 +24,8 @@ void bootloader_ana_bod_reset_config(bool enable)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Not supported but common bootloader calls the function. Do nothing
 | 
			
		||||
void bootloader_ana_clock_glitch_reset_config(bool enable)
 | 
			
		||||
{
 | 
			
		||||
    REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_FIB_ENABLE_REG, LP_ANALOG_PERI_LP_ANA_FIB_GLITCH_RST);
 | 
			
		||||
    if (enable) {
 | 
			
		||||
        REG_SET_BIT(LP_ANALOG_PERI_LP_ANA_CK_GLITCH_CNTL_REG, LP_ANALOG_PERI_LP_ANA_CK_GLITCH_RESET_ENA);
 | 
			
		||||
    } else {
 | 
			
		||||
        REG_CLR_BIT(LP_ANALOG_PERI_LP_ANA_CK_GLITCH_CNTL_REG, LP_ANALOG_PERI_LP_ANA_CK_GLITCH_RESET_ENA);
 | 
			
		||||
    }
 | 
			
		||||
    (void)enable;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user