
    :)di]                     2   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
Z
d dlmZ d dlmc mZ d dlmc mZ d dlmc mZ d dlmc mZ d dlmc mZ d dlmc mZ d dl mc m!Z" d dl#mc m$Z% d dl&mc m'Z( d dl)mc m*Z+ d dl,mc m-Z. d dl/mc m0Z1 e G d d	                      Z2g d
Z3g dZ4dgZ5e4e3z   e5z   Z6 e2ee
j7        j8                   e2ee
j7        j9                   e2ee
j7        j:                   e2ee
j7        j;                   e2ee
j7        j<                   e2ee
j7        j=                   e2e"e
j7        j>                   e2e%e
j7        j?                   e2e(e
j7        j@                   e2e+e
j7        jA                   e2e.e
j7        jB                   e2e1e
j7        jC                  dZDdeEdefdZF	 	 	 	 	 d!deEdz  deGdeEdeEde
jH        e	z  dz  dedefdZI	 	 	 	 	 	 	 	 d"deEdz  deGdeEdeEdeJdeJdeJdeEdz  de
jH        e	z  fd ZKdS )#    )	dataclass)StringIO)Any)BaseCommands)EmulateEfuseControllerBaseN)strip_chip_namec                   :    e Zd ZU eed<   eej                 ed<   dS )DefChip	efuse_lib
chip_classN)__name__
__module____qualname__r   __annotations__typeesptool	ESPLoader     _/var/www/menimich/repos/protonApp/venv/lib/python3.11/site-packages/espefuse/efuse_interface.pyr
   r
      s/         NNNW&''''''r   r
   )	zread-protect-efusezwrite-protect-efusez
burn-efusezburn-block-datazburn-bitzburn-keyzburn-key-digestzburn-custom-maczset-flash-voltage)summarydumpzget-custom-maczadc-infozcheck-errorzexecute-scripts)esp32esp32c2esp32c3esp32c6esp32c61esp32c5esp32h2esp32h21esp32h4esp32p4esp32s2esp32s3	chip_namereturnc                 J    t           |          j                                        S )N)SUPPORTED_CHIPSr   commands)r%   s    r   _get_command_classr*   L   s    9%/88:::r     default-resetautoportbaudbeforechipespkwargsc           
      .   |                     dd          }|                     dd          }|                     dd          }|                     dd          }	|                     dd          }
|                     dd          }|du}|                     d	d          }|t          | |||||||	          }t          t          |j                            }||_        ||_        |                    |||
|
           |r|                                 |S )a  Get the ESP eFuse commands class for the given chip
    This function will establish a connection to the chip and
    return the ESP eFuse commands class with initialized chip
    and eFuse values.

    Either esp or port should be provided. If both are provided, esp will be used.
    If neither is provided, the function will create a mock ESPLoader object for tests.

    Args:
        port: The port to connect to the chip
        baud: The baud rate to connect to the chip
        before: The reset mode to use before connecting to the chip
        chip: The chip to use.
        esp: Optional ESPLoader object to use. If provided, the port, baud, before, and
            chip arguments will be ignored. If provided, user has to take care of
            closing the port.

    Keyword Args:
        skip_connect (bool): Whether to skip connecting to the chip. Default is False.
        virt (bool): Whether to use virtual mode. Default is False.
        debug (bool): Whether to enable debug mode. Default is False.
        virt_efuse_file (str): The file to save the eFuse values to. Default is None.
        do_not_confirm (bool): Whether to skip confirmation before burning eFuse.
            Default is False.
        extend_efuse_table (str): The file to extend the eFuse table from.
            Default is None.
        batch_mode (bool): Whether to enable batch mode. Default is False.

    Returns:
        The ESP eFuse commands class
    skip_connectFvirtdebugvirt_efuse_fileNdo_not_confirmextend_efuse_table
batch_mode)r5   
debug_moder9   r:   )	getget_espr*   r   	CHIP_NAMEr2   external_esp
get_efusesuse_batch_mode)r.   r/   r0   r1   r2   r3   r5   r6   r7   r8   r9   r:   r@   r;   r)   s                  r   init_commandsrC   P   s.   N ::ne44L::fe$$DJJw&&Ejj!2D99OZZ 0%88N$8$??d?LL%00J
{$lD%
 
 "/#-"@"@AAHHL(H!%-	      "!!!Or   Fr5   r6   r7   r8   c                 v   |dgt          t                                                    z   vrt          j        d| d          |rAt                              |t          d                   j        }|                    ||          S |dk    r.|s,| t          j        d          t          j        | ||          S t                              |t          d                   	                    |s| nt                      |          }	|s1|	                    |           |	j        r|	                    |	          }	|	S )a  Get the ESPLoader object for the given chip.
    Uses :func:`esptool.cmds.detect_chip` function.

    Args:
        port: The port to connect to the chip
        baud: The baud rate to connect to the chip
        before: The reset mode to use before connecting to the chip
            Supported values are: "default-reset", "usb-reset", "no-reset",
            "no-reset-no-sync"
        chip: The chip to use
        skip_connect: Whether to skip connecting to the chip
        virt: Whether to use virtual mode
        debug: Whether to enable debug mode
        virt_efuse_file: The file to save the eFuse values to

    Returns:
        The ESPLoader object or EmulateEfuseController object
    r-   zget_esp: Unsupported chip ()r   Nz@get_esp: Port is required when chip is 'auto' to detect the chip)listr(   keysr   
FatalErrorr=   r   EmulateEfuseControllerdetect_chipr   r   connectsync_stub_detected
STUB_CLASS)
r.   r/   r0   r1   r5   r6   r7   r8   efuser2   s
             r   r>   r>      s>   8 F8d?#7#7#9#9::::: !Ft!F!F!FGGG D##D/'*BCCM++OUCCCv~~l~<$R   "4v666


dOG$<
=
=
H
H 0hjj C  &F! 	&..%%CJr   )Nr+   r,   r-   N)Nr+   r,   r-   FFFN)Ldataclassesr   ior   typingr   espefuse.efuse.base_operationsr   ,espefuse.efuse.emulate_efuse_controller_baser   r   esptool.utilr   espefuse.efuse.esp32rN   r   esp32_efuseespefuse.efuse.esp32c2r   esp32c2_efuseespefuse.efuse.esp32c3r   esp32c3_efuseespefuse.efuse.esp32c5r   esp32c5_efuseespefuse.efuse.esp32c6r   esp32c6_efuseespefuse.efuse.esp32c61r   esp32c61_efuseespefuse.efuse.esp32h2r   esp32h2_efuseespefuse.efuse.esp32h21r    esp32h21_efuseespefuse.efuse.esp32h4r!   esp32h4_efuseespefuse.efuse.esp32p4r"   esp32p4_efuseespefuse.efuse.esp32s2r#   esp32s2_efuseespefuse.efuse.esp32s3r$   esp32s3_efuser
   SUPPORTED_BURN_COMMANDSSUPPORTED_READ_COMMANDSDEPRECATED_COMMANDSSUPPORTED_COMMANDStargetsESP32ROM
ESP32C2ROM
ESP32C3ROM
ESP32C6ROMESP32C61ROM
ESP32C5ROM
ESP32H2ROMESP32H21ROM
ESP32H4ROM
ESP32P4ROM
ESP32S2ROM
ESP32S3ROMr(   strr*   intr   rC   boolr>   r   r   r   <module>r      s  
 " ! ! ! ! !             7 7 7 7 7 7 S S S S S S  ( ( ( ( ( ( * * * * * * * * * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0 0 0 0 0 0 0 0 0 . . . . . . . . . 0 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ( ( ( ( ( ( ( (

 
 
     ))  558KK 
 W['/":;;w}go&@AAw}go&@AAw}go&@AA(CDDw}go&@AAw}go&@AA(CDDw}go&@AAw}go&@AAw}go&@AAw}go&@AA  ;# ;, ; ; ; ;
 !AE@ @
*@
@ @ 	@
 
	7	7$	>@ @ @ @ @ @H !"&2 2
*2
2 2 	2
 2 2 2 4Z2 332 2 2 2 2 2r   