
    :)diW                     &   d dl Z d dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZmZmZmZmZmZ d dlmZ g dZ ej        e
d	d	 ed
dgd          dej         d           ej        dd edg e ej                              z             ddd           ej        ddeej        j         dd           ej        ddd ej!                    d            ej        d! eg d"          d#d$%           ej        d&d'd	d()           ej        d*d	d+)           ej        d, ej!                    d-.           ej        d/d	d0)           ej        d1d	d2)           ej        d3 ej"        d4          d5.          ej#        d6                                                                                                                                                 Z$e$%                    d7d	8           ej&        d9d:ej'        ;           ej        d<ej'        =           ej        d>ej'        =          d?                                                 Z(dEd@ee)         dz  dAej        dz  fdBZ*dC Z+e,dDk    r e+             dS dS )F    N)ChipTypeResetModeType)log)Group)BaseCommands)DEPRECATED_COMMANDSget_espinit_commandsSUPPORTED_COMMANDSSUPPORTED_BURN_COMMANDSSUPPORTED_READ_COMMANDSSUPPORTED_CHIPS)check_deprecated_py_suffix)r	   r
   r   r   r   r   r   Tz-hz--helpx   )help_option_namesmax_content_width
espefuse vz5 - Utility for eFuse configuration in Espressif SoCs.)clschainno_args_is_helpcontext_settingshelpz--chipz-cauto)choicesESPTOOL_CHIPzTarget chip type.)typedefaultenvvarr   z--baudz-bESPTOOL_BAUDz1Serial port baud rate used when flashing/reading.--portz-pESPTOOL_PORTzSerial port device.)r   r   r   z--before)default-resetz	usb-resetzno-resetzno-reset-no-syncr"   z5Which reset to perform before connecting to the chip.)r   r   r   z--debugz-dz,Show debugging information (loglevel=DEBUG).)is_flagr   z--virtz:For host tests, work in virtual mode (no chip connection).z--path-efuse-filez*For host tests, save eFuse memory to file.)r   r   z--do-not-confirmzRDo not pause for confirmation before permanently writing eFuses. Use with caution!z
--postponez4Postpone burning some eFuses from BLOCK0 at the end.z--extend-efuse-tablerz3CSV file from ESP-IDF (esp_efuse_custom_table.csv).c           
         t          j        dt          j                    |                     t
                     | j                            dd           d u| j                            dd          }| j                            dg           }t          d |D                       rd S |ss|sst          j
        dd          sF	 t          |||||||          n.# t          j        $ r}t          j        | d	          d }~ww xY wfd
}|                     |           |dk    rH| j                            dd          rt          j        d           j                                        }t#          ||||
          |	j        _                            t*                     t-          d |D                       dk    r                                 || j        d<   | j        d<   j        | j        d<   || j        d<   t*                                          fd            }d S )Nr   espis_helpF	used_cmdsc              3   P   K   | ]!}|                     d d          t          v V  "dS _-N)replacer   .0cmds     X/var/www/menimich/repos/protonApp/venv/lib/python3.11/site-packages/espefuse/__init__.py	<genexpr>zcli.<locals>.<genexpr>   s6      
M
MC3;;sC  $77
M
M
M
M
M
M    r    z<Missing required argument. Please specify the --port option.z;
Please make sure you specified the right port with --port.c                  \    s$s$ j         r j                                          d S d S d S d S )N)_portclose)r&   external_espvirts   r1   
close_portzcli.<locals>.close_port   sQ     	D 	SY 	IOO	 	 	 	 	 	r3   r   zoChip not specified, showing commands for ESP32 by default. Specify the --chip option to get chip-specific help.)r&   skip_connectdebugdo_not_confirmextend_efuse_tablec              3   P   K   | ]!}|                     d d          t          v V  "dS r*   )r-   r   r.   s     r1   r2   zcli.<locals>.<genexpr>   s6      RRCKKS!!%<<RRRRRRr3      r;   commandsefusesr<   c                     r@                     d          st          j        d          t          j        d           d S d S )NT)check_batch_modezBURN was not done.zSuccessful.)burn_allesptool
FatalErrorr   print)resultargskwargsr@   multiple_burn_commandss      r1   process_resultzcli.<locals>.process_result   sV    ! 	%$$d$;; ?()=>>>Im$$$$$	% 	%r3   )r   rG   rE   __version__ensure_objectdictobjgetanyclickBadOptionUsager	   rF   call_on_closenote	CHIP_NAMElowerr
   rA   postponeadd_cli_commandsclisumuse_batch_moderesult_callback)ctxchipbaudportbeforer;   r8   path_efuse_filer<   rY   r=   r'   r(   er9   rL   r@   r&   r7   rK   s         `         @@@@r1   r[   r[   %   s   d I07.00111d
'++eT
"
"Cd?Lgkk)U++GK,,I

M
M9
M
M
MMM  
 
W 
T 
"T
 
 	
  	dFD'4 CC ! 	 	 	$RRR  	
       j!!! v~~7;;y%(( 	HG   }""$$%-  H  (HOc""" 	RR	RRRRRUVV   "!!! CGG"CGJ CGH .CG% % % % % % % %s   C( (D7DDzexecute-scripts)hiddenscripts)nargsr   z--index)r   z--configfilesc                 V    t          j        d           t          j        d           dS )z:REMOVED: See Migration guide in documentation for details.zREMOVED: `execute_scripts` was replaced with the public API in v5. Please see Migration Guide in documentation for details: https://docs.espressif.com/projects/esptool/en/latest/migration-guide.html#espefuse-py-v5-migration-guide   N)r   errorsysexit)rg   indexconfigfiless      r1   execute_scripts_clirq      s1     I	t  
 HQKKKKKr3   argvr&   c                     t          j        | pt          j        dd                   }	 t	          ||           dS # t
          $ r}|j        dk    r Y d}~dS d}~ww xY w)a  
    Main function for espefuse

    argv - Optional override for default arguments parsing
    (that uses sys.argv), can be a list of custom arguments as strings.
    Arguments and their values need to be added as individual items to the list
    e.g. "--port /dev/ttyUSB1" thus becomes ['--port', '/dev/ttyUSB1'].

    esp - Optional override of the connected device previously
    returned by esptool.get_default_connected_device()
    r?   N)rI   r&   r   )rE   expand_file_argumentsrm   rr   r[   
SystemExitcode)rr   r&   rI   re   s       r1   mainrw      s}     ()=!"">>D3   6Q;; ;;;;;s   = 
AAAc                  D   t          t                     	 t                       d S # t          j        $ r6} t          j        d|             t          j        d           Y d } ~ d S d } ~ wt          $ r, t          j        d           t          j        d           Y d S w xY w)Nz
A fatal error occurred: rk   z)KeyboardInterrupt: Run cancelled by user.)
r   __name__rw   rE   rF   r   rl   rm   rn   KeyboardInterrupt)re   s    r1   _mainr{      s    x(((   	2q22333   	=>>>s   & B+A&&5BB__main__)NN)-rm   
rich_clickrS   rE   esptool.cli_utilr   r   esptool.loggerr   espefuse.cli_utilr   espefuse.efuse.base_operationsr   espefuse.efuse_interfacer   r	   r
   r   r   r   r   esptool.utilr   __all__grouprO   rM   optionlistkeysint	ESPLoaderESP_ROM_BAUDPathFilepass_contextr[   commandargumentUNPROCESSEDrq   strrw   r{   ry    r3   r1   <module>r      s  
 


      4 4 4 4 4 4 4 4       # # # # # # 7 7 7 7 7 7                  4 3 3 3 3 3   
TT8,<PSTTT
9g) 
9 
9 
9   	6(TT*>/*>*@*@%A%AA	B	B	B	   	*	<   		   	NNN
 
 
 	@   tT(V   	E  
 		5  
 
   	?  
 	C	>  
 Q% Q%            JQ%h t,,	%*;<<<ie/000oE$5666  76 10 =< -, tCy4 W->-E    (	 	 	 z	EGGGGG r3   