
    :)did                        d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm	Z	 d dl
mZ d dlZd dlZd dlmZ d dlZd dlmZ ddlmZ dd	lmZ dd
lmZ  G d dej                  Z G d de          Z G d dej                  Z G d dej                  Z G d de          Z G d dej                   Z!defdZ"defdZ#defdZ$ G d d          Z%dS )    )abstractmethodN)AnyBinaryIOTextIO)Callable)	BitStream)log   )base_fields)util)EmulateEfuseControllerBasec                   :     e Zd Zddej        dz  def fdZ xZS )EfuseArgumentNctxreturnc                     	 t                                          |          S # t          $ r# t                                                      cY S w xY w)zICompatibility layer for Click 8.2.0+; which now requires a ctx parameter.)supermake_metavar	TypeErrorselfr   	__class__s     e/var/www/menimich/repos/protonApp/venv/lib/python3.11/site-packages/espefuse/efuse/base_operations.pyr   zEfuseArgument.make_metavar   sW    	*77'',,, 	* 	* 	*77'')))))	*s    $ *AAN)__name__
__module____qualname__clickContextstrr   __classcell__r   s   @r   r   r      sW        * * 4 * * * * * * * * * * *    r   c                   V     e Zd Z fdZddef fdZdej        dee         fdZ	 xZ
S )	EfuseValuePairArgc                 :     t                      j        |i | d S r   r   __init__r   argskwargsr   s      r   r(   zEfuseValuePairArg.__init__'   s%    $)&)))))r#   Nr   c                 N    dt                                          |           dS )N[] ...)r   r   r   s     r   r   zEfuseValuePairArg.make_metavar*   s&    3577'',,3333r#   r   valuec                 :    | j                             |d |          S r   typeconvert)r   r   r/   s      r   type_cast_valuez!EfuseValuePairArg.type_cast_value-   s    y  c222r#   r   )r   r   r   r(   r    r   r   r   listr4   r!   r"   s   @r   r%   r%   &   s        * * * * *4 4 4 4 4 4 4 435= 3c 3 3 3 3 3 3 3 3r#   r%   c                   F    e Zd ZdZd Zdedej        dz  dej        fdZ	dS )EfuseValuePairTypezefuse-value-pairc                 "    || _         || _        d S r   )efuse_choicesefuses)r   r9   r:   s      r   r(   zEfuseValuePairType.__init__4   s    *r#   r/   paramNr   c                 2    dt           f fd}i }t          |          dk    rt          j        d          t          |          dk    rt          |          dz  rt          j        d|           t	          dt          |          d          D ]H}||         }||dz            } ||          }t          j         j        |          }	 |	|          ||<   In;|d         } ||           t          j         j        |          }	 |	d           ||<   |S )N
efuse_namec                 X    | j         vrt          j        d|  dj                    | S )NzInvalid eFuse name 'z'. Available eFuse names: )r9   r   BadParameterr=   r   s    r   check_efuse_namez4EfuseValuePairType.convert.<locals>.check_efuse_name9   sT    !333(C: C C.2.@C C   r#   r   z"Missing eFuse name and value pair.r
      z1The list does not have a valid pair (name value) )r    lenr   r?   ranger   CheckArgValuer:   )
r   r/   r;   r   rA   efuse_value_pairsir=   	new_value	check_args
   `         r   r3   zEfuseValuePairType.convert8   sX   	 	 	 	 	 	 	 u::??$%IJJJZZ!^^5zzA~ (OOO   1c%jj!,, E E"'(
!&q1u	--j99
'5dk:NN	09	)0D0D!*--E qJZ(((#1$+zJJI,5IdOOj)  r#   )
r   r   r   namer(   r    r   	Parameterr   r3    r#   r   r7   r7   1   sZ        D  !!S !!4)? !!em !! !! !! !! !! !!r#   r7   c                   @    e Zd ZdZdedej        dz  dej        fdZdS )CustomMACType
custom_macr/   r;   Nr   c                 T     t          j        |j        d         d          |          S )Nr:   
CUSTOM_MAC)r   rE   obj)r   r/   r;   r   s       r   r3   zCustomMACType.convert_   s&    I{():LII%PPPr#   )	r   r   r   rJ   r    r   rK   r   r3   rL   r#   r   rN   rN   \   sT        DQS Q4)? Qem Q Q Q Q Q Qr#   rN   c                   j     e Zd Z fdZd	def fdZdej        dee         de	e
df         fdZ xZS )
TupleParameterc                 p    |                     dd           | _         t                      j        |i | d S )N	max_arity)poprV   r   r(   r)   s      r   r(   zTupleParameter.__init__d   s:    K66$)&)))))r#   Nr   c                    | j         dk    r!t                                          |          S | j        %dt                                          |           dS dt                                          |           d| j         dS )Nr
   r-   r.   z] ... (max z groups))nargsr   r   rV   r   s     r   r   zTupleParameter.make_metavarh   s~    :??77'',,,>!7uww++C007777Q577'',,QQQQQQr#   r   r/   .c                     t          fdD                       r:t          j                                                                                     j        bt                     j         j        j        z  k    r=t          j	        d j         d j        j         dt                     d d	          t                     j        j        z  dk    r5t          j	        d j        j         d	t                     d d           fd
t          dt                     j        j                  D             }t           fd|D                       S )Nc              3   *   K   | ]}|j         v V  d S r   )help_option_names).0vr   s     r   	<genexpr>z1TupleParameter.type_cast_value.<locals>.<genexpr>q   s+      99aqC))999999r#   zExpected at most z	 groups (z values each), got z
 (values: )r   zExpected multiple of z values, got c                 >    g | ]}||j         j        z            S rL   )r2   arity)r]   rG   r   r/   s     r   
<listcomp>z2TupleParameter.type_cast_value.<locals>.<listcomp>   s<     
 
 
 !a$)/))*
 
 
r#   c              3   P   K   | ] }j                             |d           V  !d S r   r1   )r]   groupr   r   s     r   r_   z1TupleParameter.type_cast_value.<locals>.<genexpr>   s7      MMUTY&&udC88MMMMMMr#   )anyr   echoget_helpexitrV   rC   r2   rb   r?   rD   tuple)r   r   r/   groupss   ``` r   r4   zTupleParameter.type_cast_valueo   s   9999599999 	Js||~~&&&HHJJJ >%#e**t~	7W*W*W$=DN = =TY_ = =!%jj= =49= = =   u::	'1,,$%	 % %c%jj % %!% % %  
 
 
 
 
1c%jj$)/::
 
 
 MMMMMfMMMMMMr#   r   )r   r   r   r(   r    r   r   r   r5   rj   r   r4   r!   r"   s   @r   rT   rT   c   s        * * * * *R R R R R R R RN5= Nc NuSRUX N N N N N N N Nr#   rT   c                   "     e Zd ZdZ fdZ xZS )NonCompositeTupleFc                 J    t                                          |           d S r   r'   )r   typesr   s     r   r(   zNonCompositeTuple.__init__   s!    r#   )r   r   r   is_compositer(   r!   r"   s   @r   rm   rm      s=        L                 r#   rm   functionc                     dt           j        dt           j        dt          fd} t          j        ddd|          |           S )	Nr   r;   r/   c                     |                      t                     | j                            dd           || j        d         j        _        d S d S )Ncommands)ensure_objectdictrR   getr:   force_write_alwaysr   r;   r/   s      r   callbackz(add_force_write_always.<locals>.callback   sL    $7;;z4((4<ACGJ&999 54r#   z--force-write-alwayszWrite the eFuse even if it looks like it's already been written, or is write protected. Note that this option can't disable write protection, or clear any bit which has already been set.T)helpis_flagrz   )r   r   rK   r    optionrq   rz   s     r   add_force_write_alwaysr      sr    Bem BEO BC B B B B
5<7      r#   c                     dt           j        dt           j        dt          fd} t          j        ddd|d          |           S )	Nr   r;   r/   c                     |s5| j                             d          s| j                             dd          rd}|| j         d<   |S )Ndebugshow_sensitive_infoFT)rR   rw   ry   s      r   rz   z0add_show_sensitive_info_option.<locals>.callback   sN     	CGKK(( 	CGKK8Mu,U,U 	E).%&r#   z--show-sensitive-infozOShow data to be burned (may expose sensitive data). Enabled if --debug is used.T)r{   r|   rz   expose_value)r   r   rK   boolr}   r~   s     r   add_show_sensitive_info_optionr      sl    em EO D    5<&     r#   c                      t          j        ddd          |           }  t          j        ddd          |           } | S )Nz--no-write-protecta  Disable write-protecting of the key. The key remains writable. (The keys use the RS coding scheme that does not support post-write data changes. Forced write can damage RS encoding bits.) The write-protecting of keypurposes does not depend on the option, it will be set anyway.T)r{   r|   z--no-read-protectzFDisable read-protecting of the key. The key remains readable software.)r   r}   )rq   s    r   protect_optionsr      sq    u|!
     Hu|U   	 H
 Or#   c                   t   e Zd ZU dZdZeej                 dz  ed<   ej        ed<   e	j
        ez  ed<   dZeed<   	 	 	 	 d<dZd	 Zd
 Zdej        fdZd Zd=dZdej        dej        defdZdej        dee         dej        dz  fdZdee         dee         dee         deee         ee         ee         f         fdZdee         dee         dee         dedeee         ee         ee         f         f
dZdeez  defdZ g de!j"        fdee         d ed!e#fd"Z$d>d ed$edz  fd%Z%d=d&e&eef         d'efd(Z'd)ee         fd*Z(d)ee         fd+Z)	 d?dee         dee         d-e*ddfd.Z+ded/ee*         fd0Z,d1 Z-d@d2ed3efd4Z.deez  fd5Z/d6 Z0d7efd8Z1d9 Z2e3d:             Z4e3d;             Z5dS )ABaseCommandsautoN	efuse_libr:   espFexternal_espc                 6   | j         t          j        d          | j        | j         j        k    r@| j        t          j        d          |                     | j         ||||          | _        d S t          j        d| j         d| j         j         d          )Nzget_efuses: esp is not setz get_efuses: efuse_lib is not setz get_efuses: Mismatch chip name (z != r`   )r   esptool
FatalError	CHIP_NAMEr   r:   )r   skip_connect
debug_modedo_not_confirmextend_efuse_tables        r   
get_efuseszBaseCommands.get_efuses   s     8$%ABBB>TX///~%()KLLL..,
NDV DKKK $>N> >(,(:> > >  r#   c                     | S r   rL   r   s    r   	__enter__zBaseCommands.__enter__   s    r#   c                     | j         F| j        sAt          | j         t          j                  r$| j         j                                         d S d S d S d S r   )r   r   
isinstancer   	ESPLoader_portclose)r   exc_type	exc_value	tracebacks       r   __exit__zBaseCommands.__exit__   s^    H % !48W%677 ! HN  """""	 !     r#   clic                 
     j         t          j        d          t           j         dg           }|                    ddd                    d |D                        d	          t          j        d
t          dddt          d |D             d |D             z    j                             t          j
        ddd          t          j         fd                                                }|                    ddd          t          j        ddd          t          j         fd                                    }|                    ddd          t          j        ddd           fd                        }|                    d d!d                     j         j                   d	          t          j        d"t          d#ddt           j         j                  t          t          j         j         j                  t          j        d$          g          %          t          j
        d&d't$          d(d)*          t&           fd+                                                }|                    d,          t          j        d-d.          t          j        d/dt$          d0          t&           fd1                                                }|                    d2          t          j
        d3t          j        g d4          d5d6*          t          j
        d7t          j        d8d9          dd:*           fd;                                    }|                    d<          t          j        d=dd8          t          j
        d3t          j        g d>          d<d?*          t          j
        d@t          j        dA          t*          j        dB*          g f fdC	                                                }	|                    dD          t          j
        dEddF          t          j         fdG                                    }
|                    dHdIdIJ           fdK            }|                    dLdMdN j         dO         j         dPJ          t          j        dQt1                      R          t&           fdS                                    }|                    dT           fdU            }dS )Vz-Add the CLI commands to the given click groupNzDTo initialize the CLI commands, you need to call get_efuses() first.r:   z
burn-efusezJBurn the eFuse with the specified name.

Allowed options for EFUSE_NAME: [, c                     g | ]	}|j         
S rL   rJ   r]   es     r   rc   z1BaseCommands.add_cli_commands.<locals>.<listcomp>   s    :R:R:Ra16:R:R:Rr#   z].)r{   name_value_pairsz<EFUSE_NAME> <VALUE>Tc                     g | ]	}|j         
S rL   r   r   s     r   rc   z1BaseCommands.add_cli_commands.<locals>.<listcomp>  s    (((A(((r#   c                 2    g | ]}|j         D ]
}|d k    |S ) )	alt_names)r]   r   rJ   s      r   rc   z1BaseCommands.add_cli_commands.<locals>.<listcomp>  s+    NNNAAKNND42::4::::r#   )clsmetavarrequiredrY   r2   z--forcez$Suppress errors when burning eFuses.)r|   r{   c                 4                         ||           d S r   )
burn_efuse)r   r   forcer   s      r   burn_efuse_cliz5BaseCommands.add_cli_commands.<locals>.burn_efuse_cli   s     , OO,e44444r#   zread-protect-efusez@Disable readback for the selected eFuse with the specified name.zDisable readback for the eFuse.)r{   
short_helpr=   )rY   r   c                 2                         |           d S r   )read_protect_efuse)r   r=   r   s     r   read_protect_efuse_cliz=BaseCommands.add_cli_commands.<locals>.read_protect_efuse_cli  s     ##J/////r#   zwrite-protect-efuse5Disable writing to the eFuse with the specified name.zDisable writing to the eFuse.c                 2                         |            dS )r   N)write_protect_efuser@   s    r   write_protect_efuse_cliz>BaseCommands.add_cli_commands.<locals>.write_protect_efuse_cli  s     $$Z00000r#   zburn-block-datazBurn non-key data to EFUSE blocks. (Don't use this command to burn key data for Flash Encryption or ESP32 Secure Boot V1, as the byte order of keys is swapped (use burn-key)).

Allowed options for BLOCK: [block_datafilez<BLOCK> <DATAFILE>rb)r   r   r   rY   rV   r2   z--offsetz-or   zByte offset in the eFuse block.)r2   defaultr{   c                 N    t          |  \  }}                    |||           d S r   )zipburn_block_data)r   offsetr+   blockdatafiler   s        r   burn_block_data_cliz:BaseCommands.add_cli_commands.<locals>.burn_block_data_cli&  s1    > ">2OE8  &99999r#   zburn-bitr   )r   
bit_number)rY   r2   r   c                 4                         | |           dS )zBurn bit in the eFuse block.N)burn_bit)r   r   r+   r   s      r   burn_bit_cliz3BaseCommands.add_cli_commands.<locals>.burn_bit_cliH  s     MM%,,,,,r#   dumpz--format)r   splitjointr   zSelect the dump format: default - usual console eFuse dump; joint - all eFuse blocks are stored in one file; split - each eFuse block is placed into its own file.z--file-nameF)dir_okaywritablezXThe path to the file in which to save the dump, if not specified, output to the console.c                 4                         | |           dS )z"Dump raw hex values of all eFuses.N)r   )format	file_namer   s     r   dump_cliz/BaseCommands.add_cli_commands.<locals>.dump_cliU  s    $ IIfi(((((r#   summaryefuses_to_show)r   json
value_onlyzSelect the summary format.z--filewz"File to save the eFuse summary to.c                 6                         || |           dS )z-Print human-readable summary of eFuse values.N)r   )r   filer   r   s      r   summary_cliz2BaseCommands.add_cli_commands.<locals>.summary_clii  s!      LL66666r#   zcheck-errorz
--recoveryz)Recovery of BLOCKs after encoding errors.c                 J                         || j        d                    dS )zChecks eFuse errors.r   N)check_errorrR   )r   recoveryr   s     r   check_error_cliz6BaseCommands.add_cli_commands.<locals>.check_error_cli{  s)     Xsw/?'@AAAAAr#   zadc-info?Display information about ADC calibration data stored in eFuse.)r   r{   c                  0                                       d S r   )adc_infor   s   r   adc_info_cliz3BaseCommands.add_cli_commands.<locals>.adc_info_cli  s     MMOOOOOr#   zburn-custom-macz!Burn a 48-bit Custom MAC address.z/Burn a 48-bit Custom MAC address to EFUSE,BLOCKrQ   zl. Mac address should be given in hexadecimal format with bytes separated by colons (e.g. AA:CD:EF:01:02:03).mac)r2   c                 2                         |            d S r   )burn_custom_mac)r   r+   r   s     r   burn_custom_mac_cliz:BaseCommands.add_cli_commands.<locals>.burn_custom_mac_cli  s       %%%%%r#   zget-custom-macc                  0                                       dS )z"Get the 48-bit Custom MAC Address.N)get_custom_macr   s   r   get_custom_mac_cliz9BaseCommands.add_cli_commands.<locals>.get_custom_mac_cli  s     !!!!!r#   )r:   r   r   getattrcommandjoinr   argumentr%   r7   r}   pass_contextBURN_BLOCK_DATA_NAMESrT   rC   rm   ChoiceFileintr   Pathsysstdoutr   rN   )r   r   r:   r   r   r   r   r   r   r   r   r   r   r   s   `             r   add_cli_commandszBaseCommands.add_cli_commands   s    ;$V   4;4;RT3U3U	X04		:R:R6:R:R:R0S0SX X X 
 

 


 
!*#(((((NNNNNO 

 

 

 
t*P

 

 

 
		5 	5 	5 	5 
	

 



 



 

*	5 
 S8 
 

 


 
B	>	>	>			0 	0 	0 	0 
	 
?	>

 

	0 
!H6 
 

 


 
B	>	>	>	1 	1 	1 	1 
?	>

 

	1 
A 		$+;<<	A A A 
 

 

 
($+;<<"L!BCCJt$$ 

 

 

 
2

 

 

 
 	: 	: 	: 	: 
 	

 



 



 

<	: 
Z	 	 	$	/	/	/		

 

 

 
 	- 	- 	- 	- 
 	

 

 
0	/ 
!	 	- 
V			;;;<<D	

 

 

 
UT:::%	

 

 

	) 	) 	) 	)

 



 

 
	 	) 
Y			(U	C	C	C	???@@-	

 

 

 
CJ5	

 

 

 68 	7 	7 	7 	7 	7

 



 

 
D	C 
 		7 
]	#	#	$-X

 

 

 
		B 	B 	B 	B 
	

 

 
$	#
	B 
R	 
 

 

	 	 	 	

 

	 
:2K-32 2 2 
 

 

 


 

 

 
 	& 	& 	& 	& 
 		

 



 

	& 
%	&	&	" 	" 	" 	" 
'	&	" 	" 	"r#   c                 0    | j         xj        dz  c_        dS )a  Enable batch mode for eFuse operations.

        This method increments the batch mode counter, allowing multiple eFuse
        operations to be queued before burning. All queued operations will be
        executed together when :func:`burn_all` is called.

        This method can be called multiple times to nest batch operations.
        Each call should be paired with a corresponding call to :func:`burn_all`.
        r
   N)r:   batch_mode_cntr   s    r   use_batch_modezBaseCommands.use_batch_mode  s      	""a'""""r#   c                 `    | j         xj        dz  c_        | j                             |          S )a  Execute all queued eFuse operations and decrement batch mode counter.

        This method decrements the batch mode counter, then burns all eFuses
        that have been queued during batch mode. When the counter reaches zero,
        batch mode is fully exited.

        This method should be called after :func:`use_batch_mode` to execute
        the queued operations.

        Args:
            check_batch_mode: If True, only execute the burn operation if this is the
                final burn_all call (i.e., when batch_mode_cnt reaches zero in nested
                operations).

        Returns:
            bool: True if the burn operation was successful.
        r
   )r:   r   burn_all)r   check_batch_modes     r   r   zBaseCommands.burn_all  s1    $ 	""a'""{##$4555r#   r   key_purpose_blockr   c                    |                                 r|                                sdS |                                dk    s|                                sdS |                                                    d          sdS dS )z:Helper method to check if a key block is available for useFUSERT)is_readableis_writeablerw   get_bitstringall)r   r   r  s      r   _key_block_is_unusedz!BaseCommands._key_block_is_unused  s       "" 	%*<*<*>*> 	5  ""f,,4E4R4R4T4T,5""$$((// 	5tr#   current_key_blockblock_name_listc                    d | j         j        D             }|                    |          }||d         |d|         z   }fd|D             }|D ].}| j         |j                 }|                     ||          r|c S /dS )z1Helper method to get the next available key blockc                      g | ]}|j         	|S rL   )key_purpose_name)r]   bs     r   rc   z4BaseCommands._get_next_key_block.<locals>.<listcomp>  s     JJJAq7IJaJJJr#   Nr   c                 &    g | ]}|j         v|S rL   r   )r]   r  r
  s     r   rc   z4BaseCommands._get_next_key_block.<locals>.<listcomp>  s%    MMMAqv_/L/La/L/L/Lr#   )r:   blocksindexr  r  )r   r	  r
  
key_blocksstartr   r  s     `    r   _get_next_key_blockz BaseCommands._get_next_key_block  s     KJ!3JJJ
  !233  '*QuW*==
 NMMMMMM
 	 	E $E,B C((0ABB  tr#   block_names	datafileskeypurposesc           
      8   t          |          }t          |          }t          |          }d|v r|                     |||d          \  }}}d|v r|                     |||d          \  }}}d}|t          |          k     rd||         v r||         dvrt          j        ||                   }t          j        |          }d||         k    rTt          |          dk    s
J d            t          j        d	|z             ||<   |                     |||d          \  }}}nAt          |          d
k    rt          j        d|z             nt          j        |          ||<   |dz  }|t          |          k     t          j	        |           t          |          t          |          k    s t          |          t          |          k    rEt          j        dt          |           dt          |           dt          |           d          |||fS )aJ  Split a key that takes more than one efuse block into two blocks.
        It handles all key purposes that require splitting into two blocks.

        This method checks if key purposes require splitting into two blocks,
        such as "XTS_AES_256_KEY", "XTS_AES_256_PSRAM_KEY", and "ECDSA_KEY_P384".

        Args:
            block_names: List of block names.
            datafiles: List of BinaryIO objects containing key data.
            keypurposes: List of key purposes.

        Returns:
            A tuple containing updated block names, datafiles, and keypurposes.
        XTS_AES_256_KEYXTS_AES_256_PSRAM_KEYr   	ECDSA_KEY)ECDSA_KEY_P384_LECDSA_KEY_P384_HECDSA_KEY_P3840   z,NIST384p private key should be 48 bytes longs                      s           r
   zThe number of blocks (z), datafile (z) and keypurpose () should be the same.)r5   _split_multiblock_keyrC   	espsecureload_ecdsa_signing_keyget_ecdsa_signing_key_raw_bytesioBytesIOr   check_duplicate_name_in_listr   r   )r   r  r  r  rG   skdatas          r   _adjust_key_data_for_blocksz(BaseCommands._adjust_key_data_for_blocks  st   ( ;''OO	;''++ 372L2L!	3 3/KK #k11262L2L'	3 3/KK #k""""k!n,,q>)QQQ"9)A,GGB$DRHHD';q>99"4yyBJ  / (*z,2E'F'F	! !66 + ) + 0	  <Y  #4yyB J{T'9:::!#D!1!1 "! FA9 #k""""> 	)+666 {s9~~--[1A1ASEUEU1U1U$&[)9)9 & & ^^& &?B;?O?O& & &   I{22r#   base_keypurposec                    t          |          }t          |          }t          |          }|                    |          }||         }	| j                            |	          }
| j        j        |
         }||                                         }t          |          dk    r(t          j        dt          |           d| d          | 	                    ||          }|st          j        | d          |
                    d          rddgnd	d
g}| |d          ||<   t          j        |dd                   ||<   |	||<   |                    |dz   | |d                     |                    |dz   t          j        |dd                              |                    |dz   |j                   |||fS )z8Helper method to split 512-bit key into two 256-bit keys@   zIncorrect key file size r   z should be 64 bytesz requires two free keyblocksXTS_AES_256_1_2_H_Lr   N    r
   )r5   r  r:   get_index_block_by_namer  readrC   r   r   r  
startswithr&  r'  insertrJ   )r   r  r  r  r,  keypurpose_listdatafile_listr
  rG   
block_name	block_numr   r*  key_block_2postfixs                  r   r"  z"BaseCommands._split_multiblock_keyC  s    {++Y{++!!/22$Q'
K77
CC	"9-Q$$&&t99??$%3t99 % % % % %  
 ..uoFF 	W$%U%U%UVVV ,66}EEWT4LLDRV< 	 !0===:d3B3i00a'q1u&F'!*&F&FGGGQUBJtBCCy$9$9:::q1uk&6777>>r#   r   c                 v    t          |t                    r# t          j        | j        d          |          S |S )NrQ   )r   r    r   rE   r:   r   r   s     r   _convert_mac_to_bytesz"BaseCommands._convert_mac_to_bytesm  s9    c3 	MG;,T[,GGLLL
r#   r   r   r   r   c                 0
   d}|dv }|dk    }|r't          |          dk    rt          j        d          t          |          }i }g }	|t          j        k    rt          j        d|j        z              |rC|sA|		                    |
                    dd          d	z             |		                    d
           t          t          d | j        D                       d           D ]>|r,|s*|		                                                     d           fd| j        D             D ]}
|
j                            d          rd}n'd                    |
                                          }|
                                |
                                }}|r|rd}n|rd}n|rd}nd}|
                                }t-          |          }|s|
                                }|dk    r|dt          |          dz           |t          |          dz  d         g}t1          |          D ]7}|
                    |          s||         
                    dd          ||<   8d                    |          }n|
                    dd          }|r|r	|
j        |v r|s|		                    ||
                                |
j        dd         t          |          dk    rdnd|||fz             t          |
j        dd                   }|rE|dz  }t1          d|d          D ].}|		                    ddd |
j        |d|z            d           /.|r#|r!|
j        |v r|		                    |            S|d!k    rM|r	|
j        |v rB|
j        |r|n||||
j        |
j        |
j        |
j        |
j        |
j        |
j         d"||
j        <   |rP|sN|r7|	d#                                          dk    r|	!                                 )|		                    d           @|r^|s\|		                    | j        "                                           | j        #                                }|r|		                    d$           |rW|	D ]}t          j        ||%           |t          j        k    r*|$                                 t          j        d&           dS dS |d!k    r.tK          j&        ||d'd()           t          j        d           dS dS )*z
        Print a human-readable or json summary of eFuse contents.

        Args:
            efuses_to_show: List of eFuse names to show.
            format: Format to use for the summary.
            file: File to write the summary to.
        z%-50s %-50s%s = %s %s %s)r   r   r   r
   z:The 'value_only' format can be used exactly for one eFuse.zSaving eFuse values to z-50z-12)zEFUSE_NAME (Block)Descriptionr   z[Meaningful Value]z[Readable/Writeable]z(Hex Value)zX----------------------------------------------------------------------------------------c              3   $   K   | ]}|j         V  d S r   categoryr   s     r   r_   z'BaseCommands.summary.<locals>.<genexpr>  s$      00q
000000r#   c                 *    |                                  S r   )title)cs    r   <lambda>z&BaseCommands.summary.<locals>.<lambda>  s    		 r#   )keyz fuses:c              3   2   K   | ]}|j         k    |V  d S r   rE  )r]   r   rF  s     r   r_   z'BaseCommands.summary.<locals>.<genexpr>  s/      GGA
h0F0Fa0F0F0F0FGGr#   bytesr   z({})zR/WzR/-z-/Wz-/-rB   N)blk_part0?2      z
  z<50 r   )rJ   r/   readable	writeabledescriptionrF  r   wordpos
efuse_typebit_lenr   z6WARNING: Coding scheme has encoding bit error warnings)r   DoneT   )	sort_keysindent)'rC   r   r   r   r   r   r	   printrJ   appendreplacesortedsetr:   rH  rY  r7  r   r  r  r  get_meaningr    get_count_read_disable_bitsrD   r   get_inforV  rF  r   rW  rX  rZ  rW   r   get_coding_scheme_warningsr   r   r   )r   r   r   r   
ROW_FORMAThuman_outputr   do_filtering
json_efusesummary_efuser   rawrT  rU  perms
base_valuer/   count_read_disable_bitsr^   rG   desc_lenwarningslinerF  s                          @r   r   zBaseCommands.summaryt  s#    0
!::|+
 	#n--22$L   N++
3:I/$);<<< 	+
 	+  ""5%00
 
 
   ***00DK000006I6I
 
 
 O	- O	-H  CJ C$$(8(8%A%A%ABBBGGGGGGG D D<**733 ;CC --(9(9::C)*!..:J:J9 "	 "!EE "!EE "!EE!E]]__
J 8./.K.K.M.M+.!33 ##6c%jjAo#67E

a?R?R9ST!&'>!?!? > >A#$==!=#<#< >'(t||C'='=! "

 %c3 7 7 ()(-.V~-E-E& .F "(("JJLLM#2#.&)%jj2ooFF2!!
 
 
  #1=#566H  B!&r8R!8!8  A)00#% M M MAM!rAv,,G M M M    " j QV~5M5M!((E4444v%%$ &().(@(@ !"/7!BU$,%.'(}$%J!" ! u&'l#$9* *Jqv&  -J - -M"$5HNN<L<L9U9U9U$U$U!%%''''!((,,, 	
 	  !4!4!6!6777{==??H $$L    	% + +	$T*****sz!!

	&!!!!! "! vIj$$qAAAAIbMMMMM r#   r   r   c                    |du }t           j        }dt          j        dt          t
          z  dt          fd}|dk    r?|r;| j        j        D ],}|	                    |
                                dd	           -dS d
}|d
k    r| j        j        D ]}|s^t          j                            |          \  }}| |j         | }	t          j        d|j         d|	            t#          |	d          } ||||           |s|                                 dS |dk    r]|s't          j        d|            t#          |d          }| j        j        D ]} ||||           |s|                                 dS dS dS )a  
        Dump raw eFuse data registers.

        Args:
            format: Format to use for the dump. Available options are:
                - "default": Print the dump to the console.
                - "split": Dump each eFuse block to a separate file.
                - "joint": Dump all eFuse blocks to a single file.
            file_name: File to write the dump to. If not provided, the dump will
                be printed to the console.
        Nr   f
to_consolec                     t          |                                           }|                                 |r|                    |j        dz              d S |                    |           d S )N
)r   r  byteswapwritehextofile)r   ru  rv  
block_dumps       r   output_block_to_filez/BaseCommands.dump.<locals>.output_block_to_file  sp     #5#6#6#8#899J!!! %
-.....!!!$$$$$r#   r   r   Tr   r   zDump eFuse block -> wbr   zDump eFuse blocks -> )r   r   r   EfuseBlockBaser   r   r   r:   r  print_blockr  ospathsplitextidr	   r_  openr   )
r   r   r   rv  	dump_filer~  r   fname
fextensionfile_dump_names
             r   r   zBaseCommands.dump  s    $&
'*z		%-	%2:V2C	%QU	% 	% 	% 	% Y !![/ Q QE%%e&9&9&;&;V4%PPPP !W+ & &! ;(*(8(8(C(C%E:(-%Eux%E%E%ENIOOO~OOPPP $^T : :I$$UIzBBB! &OO%%%& & w 2	=)==>>> D11	+ C C$$UIzBBBB "!!!!! " "r#   r   r   c                 L    dt           t                   fd}d |                                D             } fd|D             } fd|D             }d |                                D             }t	          j        |           d}t          j        d            j        j	        D ]Ԋfd	|D             }	t          |	          rt          j        d
j                    |	D ]t          j        dj                     j        j	        j                                                  j        j        j        k    r/fd j        D             }
d |	D             fd|
D             }d}|r ||           t          j        d| d           t#          ||          D ]i\  }}t          j        d|j         d|j         d|                                 d|                    |                      |                    |           jt          j                     d|v r<t          j        d           t          j        d           t          j        d           d|v r(t          j        d           t          j        d            j        j        dk    rI j                                        dk    r,d|v r(t          j        d            t          j        d!            j                                        r+|rt          j        d"           nt5          j        d#           j                            d$%          sd&S t          j        d'           d(}t#          |||          D ]\  }}}|                                st          j        d)|j         d*           8|                    |          }|                                }||k    r"t          j        |d+|d)|j         d,           d$}|rt5          j        d-          t          j        d.           d&S )/z
        Burn eFuses.

        Args:
            name_value_pairs: Dictionary of eFuse names and values to burn.
            force: If True, the burn will be performed even if the eFuse settings
                are incompatible.
        blocked_efuses_after_burnc                    t          |           r{t          j        d           t          dt          |           d          D ]J}t          j        dd                    d                    | ||dz                                           Id S d S )Nzz    ATTENTION! This BLOCK uses NOT the NONE coding scheme and after 'BURN', these efuses can not be burned in the feature:r      z              r   z{})rC   r	   r_  rD   r   r   )r  rG   s     r   print_attentionz0BaseCommands.burn_efuse.<locals>.print_attention?  s    ,-- 		W   q#&?"@"@!DD  AI(,Ea!a%k,R S STT   	 	
 r#   c                     g | ]}|S rL   rL   r]   rJ   s     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>K  s    DDDD4DDDr#   c                 *    g | ]}j         |         S rL   )r:   r]   rJ   r   s     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>L  s     JJJ$DK-JJJr#   c                 N    g | ]!}j         |                                         "S rL   )r:   get_rawr  s     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>M  s,    RRR$$+d+3355RRRr#   c                     g | ]}|S rL   rL   )r]   r/   s     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>N  s    GGGE%GGGr#   r   zThe eFuses to burn:c                 4    g | ]}|j         j        k    |S rL   )r   r  )r]   r   r   s     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>T  s'     T T Tq58@S@S@S@S@Sr#   z  from BLOCKz     - c                 >    g | ]}|j         j         k    |j        S rL   )r   rJ   )r]   r   fields     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>]  s0     6 6 6'(17ek;Q;QAF;Q;Q;Qr#   c                     g | ]	}|j         
S rL   r   r   s     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>`  s    #F#F#FqAF#F#F#Fr#   c                     g | ]}|v|	S rL   rL   )r]   rJ   wr_namess     r   rc   z+BaseCommands.burn_efuse.<locals>.<listcomp>a  s.     5 5 5 $#833 !333r#   z (see 'ATTENTION!' above)z
Burning eFuses:z    - 'z' (z) r  ENABLE_SECURITY_DOWNLOADzENABLE_SECURITY_DOWNLOAD -> 1: eFuses will not be read back for confirmation because this mode disables any SRAM and register operations.z6                               espefuse will not work.zA                               esptool can read/write only flash.DIS_DOWNLOAD_MODEzDIS_DOWNLOAD_MODE -> 1: eFuses will not be read back for confirmation because this mode disables any communication with the chip.zl                        espefuse/esptool will not work because they will not be able to connect to the chip.ESP32,  UART_DOWNLOAD_DISz{UART_DOWNLOAD_DIS -> 1: eFuses will be read for confirmation, but after that connection to the chip will become impossible.z7                        espefuse/esptool will not work.z#Ignore incompatible eFuse settings.zKIncompatible eFuse settings detected, abort. (use --force flag to skip it).Tr   NChecking eFuses...FEfuse z= is read-protected. Read back the burn value is not possible.z->z failed to burn. Protected?The burn was not successful.Successful.)r5   r    keysvaluesr   r(  r	   r_  r:   r  rC   r  rJ   r   get_coding_schemeREGSCODING_SCHEME_NONEr   rV  r  convert_to_bitstringsaver   r   get_chip_revisionis_efuses_incompatible_for_burnr   r   r   r  )r   r   r   r  efuse_name_listburn_efuses_listold_value_listnew_value_list	attentionburn_list_a_blockusing_the_same_block_namesr  efuserH   raise_error	old_valueburned_valuer   r  r  s   `                @@@r   r   zBaseCommands.burn_efuse5  sW   
	tCy 
	 
	 
	 
	 ED,<,A,A,C,CDDDJJJJ/JJJRRRR/RRRGG-=-D-D-F-FGGG)/:::		'((([' 	? 	?E T T T T,< T T T$%% ?	333444. @ @EI4
44555*5;7IIKK;+>? ?6 6 6 6,0K6 6 62 $G#F4E#F#F#F5 5 5 5(B5 5 51
 %@	 ?#O$=>>>	1Y111222 #$4n E E 	" 	"E9IV%* V V): V V&&((V V.3.H.H.S.SV V   JJy!!!!	%88I4  
 INOOOIS   /11IN   I@   H'))**,,33#66IP   IOPPP;6688 	 	?@@@@(5  
 {##T#:: 	F	&'''+.nn,
 ,
 	' 	''E9i $$&& '	@UZ @ @ @   
 "66yAA	$22449,,I$!HHHH	   #'K 	%$%CDDDIm$$$$$r#   efuse_namesc                 V   t          j        |           |D ]m}| j        |                                         st	          j        dj         d           B| j        j        dk    r|dk    r| j        d         	                                sd| j        
                                dk    rG| j        d         	                                rt          j        d          t	          j        d	           n| j        j        d
k    rf| j        d         	                                 o|dk    }|| j        d         	                                o|dv z  }|rt          j        | d          n| j        j        j        D ]}| j        j        	                    |          }|j        |k    rg|j        `| j        |j                                     | j        |j                 	                                          st          j        | d           nfd| j        D             }d                    d |D                       }t	          j        dt%          |          dk    rdnd d|                                             o| j                            d          sdS t	          j        d           d}|D ]B}| j        |                                         rt	          j        dj         d           d}C|rt          j        d          t	          j        d           dS ) z
        Disable readback for the eFuse with the specified name.

        Args:
            efuse_names: List of eFuse names to read-protect.
        r  z is already read protectedr  BLOCK2
ABS_DONE_0r  
ABS_DONE_1zWSecure Boot V2 is on (ABS_DONE_1 = True), BLOCK2 must be readable, stop this operation!zOIf Secure Boot V2 is used, BLOCK2 must be readable, please stop this operation!zESP32-C2XTS_KEY_LENGTH_256
BLOCK_KEY0SECURE_BOOT_EN)r  BLOCK_KEY0_HI_128z' must be readable, stop this operation!Nc                 4    g | ]}|j         j         k    |S rL   )read_disable_bitr]   r   r  s     r   rc   z3BaseCommands.read_protect_efuse.<locals>.<listcomp>  s4     ! ! !)U-CCC CCCr#   r   c              3   $   K   | ]}|j         V  d S r   r   r   s     r   r_   z2BaseCommands.read_protect_efuse.<locals>.<genexpr>  $      !@!@Q!&!@!@!@!@!@!@r#   z Permanently read-disabling eFuser
   sr   rS  Tr  r  Fz is not read-protected.r  r  )r   r(  r:   r  r	   r_  rJ   r   r   rw   r  r   r   BlocksBLOCKSkey_purposeneed_rd_protectr   rC   disable_readr   )	r   r  r=   errorr   all_disablingnamesr  r  s	           @r   r   zBaseCommands.read_protect_efuse  s    	)+666% :	% :	%JK
+E$$&& 8%	I5:IIIJJJJ8%00"h.. $L 9 = = ? ? / H6688C??;|488:: 	")"4!P# # 
  I!>   X':55 K(<=AACCC 7&,6  T[)9:>>@@ Z T F E  %0)RRR  
 "&!3!: 
" 
" $ 2 6 6u = = :338I8U#';u/@#A#Q#Q $E,= > B B D D$ $ " '.&8'1 %< %< %<'" '" !" "E! ! ! !![! ! !
 		!@!@-!@!@!@@@	G!-00144ss"G G?DG G   ""$$$${##T#:: 	F	&'''% 	# 	#JK
+E  "" #	F5:FFFGGG" 	%$%CDDDIm$$$$$r#   c                    t          j        |           |D ]}| j        |                                         st	          j        dj         d           Afd| j        D             }d                    d |D                       }t	          j        dt          |          dk    rdnd	 d
|            	                                 | j        
                    d          sdS t	          j        d           d}|D ]B}| j        |                                         rt	          j        dj         d           d}C|rt          j        d          t	          j        d           dS )z
        Disable writing to the eFuse with the specified name.

        Args:
            efuse_names: List of eFuse names to write-protect.
        r  z is already write protected.c                 4    g | ]}|j         j         k    |S rL   )write_disable_bitr  s     r   rc   z4BaseCommands.write_protect_efuse.<locals>.<listcomp>  s4     ! ! !*e.EEE EEEr#   r   c              3   $   K   | ]}|j         V  d S r   r   r   s     r   r_   z3BaseCommands.write_protect_efuse.<locals>.<genexpr>!  r  r#   z!Permanently write-disabling eFuser
   r  r   rS  Tr  Nr  Fz is not write-protected.r  r  )r   r(  r:   r  r	   r_  rJ   r   rC   disable_writer   r   r   )r   r  r=   r  r  r  r  s         @r   r   z BaseCommands.write_protect_efuse  s    	)+666% 	& 	&JK
+E%%'' &	K5:KKKLLLL! ! ! !![! ! !
 		!@!@-!@!@!@@@	G!-00144ss"G G?DG G   ##%%%%{##T#:: 	F	&'''% 	# 	#JK
+E!!## #	G5:GGGHHH" 	%$%CDDDIm$$$$$r#   r   r   c                 p   |dt          d |D                                }|dt          d |D                                }t          j        |           |r't          |          dk    rt          j        d          |rl| j                            |d                   }| j        j        |         }|                                }||k    r t          j        d|j	         d| d          t          |          t          |          k    r5t          j        d	t          |           d
t          |           d          t          ||          D ]0\  }	}
| j                            |	          }| j        j        |         }|
                                }|                                }|dk    r d|z  |z   }|d|t          |          z
  z  z   }t          |          |k    r3t          j        d|j	         d| dt          |           d| d	          t          j        d                    |j	        |j        t          |          |t          j        |d                               |                    |           2| j                            d          sdS t          j        d           dS )a  
        Burn non-key data to EFUSE blocks.

        Don't use this command to burn key data for Flash Encryption or ESP32
        Secure Boot V1, as the byte order of keys is swapped (use burn-key).

        Args:
            block_names: List of eFuse block names to burn data to.
            datafiles: List of files to read data from.
            offset: Byte offset in the eFuse block to start writing data at.
        r   c                     g | ]}||S r   rL   r  s     r   rc   z0BaseCommands.burn_block_data.<locals>.<listcomp>I  s    FFFdT5ET5E5E5Er#   c                     g | ]}||S r   rL   r  s     r   rc   z0BaseCommands.burn_block_data.<locals>.<listcomp>L  s    DDDd43CT3C3C3Cr#   r
   zqThe 'offset' option is not applicable when a few blocks are passed. With 'offset', should only one block be used.zInvalid offset: the blockz only holds z bytes.zThe number of block_name (z) and datafile (r!      zData does not fit: the blockz	 size is z bytes, data file is z bytes, offset .z6[{:02}] {:20} size={:02} bytes, offset={:02} - > [{}].rS  Tr  Nr  )rC   r   r(  r   r   r:   r5  r  get_block_lenr  r   r6  r	   r_  r   rJ   hexifyr  r   )r   r  r  r   r
  r:  	num_blockr   	num_bytesr;  r   r*  s               r   r   zBaseCommands.burn_block_data7  s+   " &FFkFFFGGI
 "DDiDDDEEG
 	)/::: 	c/**Q..$@  
   K??PQ@RSS	48K4Fy4Q!//11	Y&&!,.EH . .$. . .   3}#5#555$GS-A-A G G //G G G  
 %($G$G 	 	 J;;JGGIK&y1E==??D++--I{{&(D0w)c$ii*?@A4yyI%%((58 ( ( ( (7:4yy( ($( ( (  
 IHOOHej#d))VT[s=S=S   
 JJt{##T#:: 	F	-     r#   r   c                    | j                             |          }| j         j        |         }t          |                                dz            }|                    d           	 |                    d|           n0# t          $ r# t          j        | d|j	        dz
   d          w xY w|
                                 t          j        d|j	        dz
  dd	           t          j        d
|j        dd|           |                    |dd           |                    |j        ddd                    | j                             d          sdS t          j        d           dS )z
        Burn a single bit to the eFuse with the specified name.

        Args:
            block: Name of the eFuse block to burn the bit to.
            bit_number: List of bit numbers to burn.
           r   Tz has bit_number in [0..r
   ]zbit_number:   [03dz<]........................................................[0]BLOCKz>2dz   :regs_to_writer  Nr   r  r  )r:   r5  r  r   r  rc  
IndexErrorr   r   rC   reverser	   r_  r  r  r  rM  r   )r   r   r   r  	block_obj
data_blocks         r   r   zBaseCommands.burn_bit~  s    K77>>	040B90M	y66881<==
q	NN4,,,, 	 	 	$FF!1CFFF  	 		Kjnq07 K K K	
 	
 	
 		0),0000*===j/FFFz'"-...{##T#:: 	F	-     s   'A> >-B+c                 P   | j                                          t          d | j         j        D                       }|sdS d}| j         j        D ]=}|j        s|j        r+|j        dk    r| j         D ]}|j        |j        k    rs|j        s|j        re|                                rdnd}||dk    z  }|j	        }|
                                }t          j        d|j        dd	|d
d|dd| d	           |                                rdnd}||dk    z  }|j	         d|j         dt          |j                   d}t          |                                          }t          j        d|j        dd	|d
d|dd| d	           ?|s|rt          j        d           dS )Nc              3   :   K   | ]}|j         p
|j        d k    V  dS )r   N)fail
num_errors)r]   blks     r   r_   z1BaseCommands.get_error_summary.<locals>.<genexpr>  sA       
 
03CH+!+
 
 
 
 
 
r#   FTr   r   znot writabler  z<2z: z<40z = z<8z (r`   z	 [ERRORS:z FAIL:r  zDNot all errors can be fixed because some fields are write-protected!)r:   rg  rf   r  r  r  r  r   r  rJ   rw   r	   r_  r   r    r  )r   error_in_blocksr   r  r  wrrJ   vals           r   get_error_summaryzBaseCommands.get_error_summary  s#   ..000 
 
7;{7I
 
 
 
 
  	5;% 	Q 	QCx Q3> Q6Q;;!%   ;#&00ej0EDT0/4/A/A/C/C!WB$j(88H#(:D"'))++CI V V V V$ V V Vs V V VQS V V V   (+'7'7'9'9M~Bj 00H!hWWWWs38}}WWWDc//1122CIOcfOOO4OOOOOO"OOOPPP 	O 	IV   tr#   r   r   c                 f   |                                  }|r|rd}t          | j        j                  D ]}|j        s|j        dk    r|                                                    d          sh|                    |                                j	        ddd                    |sd}| j        
                    d|           |                                 |r| j                                         |                                  }|rt          j        d          t          j        d           dS )	z
        Check for errors in the eFuse blocks.

        Args:
            recovery: Recovery of BLOCKs after encoding errors.
            do_not_confirm: If True, the confirmation will be skipped.
        Fr   Nr   TzRecovery of block coding errorsz!Error(s) were detected in eFuses.zNo errors detected.)r  reversedr:   r  r  r  r  r  r  rM  confirmburnupdate_efusesr   r   r	   r_  )r   r   r   r  	confirmedr   s         r   r   zBaseCommands.check_error  sE    0022 	7 	7I!$+"455 	% 	%: %!1A!5!5 ..0044U;; %

5#6#6#8#8#>ttt#DEEE( (,I K// A>   

 ,))+++"4466O 	J$%HIII	'(((((r#   c                     |                      |          }| j        d                             |           | j                            d          sdS |                                  t          j        d           dS )u   
        Burn a 48-bit Custom MAC Address.

        Args:
            mac (str | bytes): Custom MAC Address to burn. e.g. "aa:cd:ef:11:22:33" or
                b'ªÍï"3'
        rQ   Tr  Nr  )rA  r:   r  r   r   r	   r_  r@  s     r   r   zBaseCommands.burn_custom_mac  sz     ((--L!&&s+++{##T#:: 	F	-     r#   c                 n    t          j        d| j        d                                                     dS )zGet the Custom MAC Address.zCustom MAC Address: rQ   N)r	   r_  r:   rw   r   s    r   r   zBaseCommands.get_custom_mac  s4    	J\)B)F)F)H)HJJKKKKKr#   voltagec                 *    t          j        d          )z
        Set the Flash Voltage. Available only for selected chips.

        Args:
            voltage: Voltage to set. Available options are: "1.8V", "3.3V", "OFF"
        z0set_flash_voltage is not supported for this chip)r   r   )r   r  s     r   set_flash_voltagezBaseCommands.set_flash_voltage  s      !STTTr#   c                      t          d          )r   z)adc-info is not implemented for this chip)NotImplementedErrorr   s    r   r   zBaseCommands.adc_info  s    !"MNNNr#   c                     dS )z?Burn a key to the eFuse. Exact implementation is chip-specific.NrL   r   r*   r+   s      r   burn_keyzBaseCommands.burn_key  	     	r#   c                     dS )zFBurn a key digest to the eFuse. Exact implementation is chip-specific.NrL   r  s      r   burn_key_digestzBaseCommands.burn_key_digest  r  r#   )FFFN)F)r   N)r   )FF)6r   r   r   r   r   r2   r   EspEfusesBase__annotations__r   r   r   r   r   r   r   r   r   Groupr   r   r   r  r  r5   r    r  r   rj   r+  r"  rM  rA  r   r   r   r   r   rv   r   r   r   r   r   r   r  r   r   r   r   r   r   r  r  rL   r#   r   r   r      s        I8<ItK-.5<<<%%%%		7	7777L$    *  # # #q"EK q" q" q" q"j
( 
( 
(6 6 6 6*) '5 
	   "!,!;NRSVi		#d	*   *V3#YV3 >V3 #Y	V3
 
tCy$x.$s)3	4V3 V3 V3 V3p(?#Y(? >(? #Y	(?
 (? 
tCy$x.$s)3	4(? (? (? (?Tu      %'z	F FS	F F 	F F F FP7" 7"3 7"sTz 7" 7" 7" 7"rB% B%4S> B%$ B% B% B% B%HR%d3i R% R% R% R%h(%tCy (% (% (% (%\ 	E! E!#YE! >E! 	E!
 
E! E! E! E!N!c !tCy ! ! ! !>  @) )D )$ ) ) ) )8!3; ! ! ! ! L L LU U U U UO O O   ^   ^  r#   r   )&abcr   r&  r  r   r   typingr   r   r   collections.abcr   r#  
rich_clickr   	bitstringr   r   esptool.loggerr	   r   r   r   emulate_efuse_controller_baser   Argumentr   r%   	ParamTyper7   rN   rT   Tuplerm   r   r   r   r   rL   r#   r   <module>r     s         				 				  



 ( ( ( ( ( ( ( ( ( ( $ $ $ $ $ $                                  E E E E E E* * * * *EN * * *3 3 3 3 3 3 3 3(! (! (! (! (! (! (! (!VQ Q Q Q QEO Q Q Q&N &N &N &N &N] &N &N &NR               X     X    "h    $| | | | | | | | | |r#   