@@ -174,20 +174,12 @@ def test_examples_efuse_with_virt_flash_enc_pre_loaded(dut: Dut) -> None:
174174 dut .expect ('example: Done' )
175175
176176 if dut .app .target == 'esp32' :
177- print (' - Flash emul_efuse with pre-loaded efuses (FLASH_CRYPT_CNT 1 -> 0)' )
178- # offset of this eFuse is taken from components/efuse/esp32/esp_efuse_table.csv
179- FLASH_CRYPT_CNT = 20
180- # Resets eFuse, which enables Flash encryption feature
181- dut .serial .erase_field_on_emul_efuse ([FLASH_CRYPT_CNT ])
182- elif dut .app .target == 'esp32c2' :
183- FLASH_CRYPT_CNT = 39
184- dut .serial .erase_field_on_emul_efuse ([FLASH_CRYPT_CNT ])
177+ CRYPT_CNT_EFUSE_NAME = 'FLASH_CRYPT_CNT'
185178 else :
186- # offset of this eFuse is taken from components/efuse/{target}/esp_efuse_table.csv
187- print (' - Flash emul_efuse with pre-loaded efuses (SPI_BOOT_CRYPT_CNT 1 -> 0)' )
188- SPI_BOOT_CRYPT_CNT = 82
189- # Resets eFuse, which enables Flash encryption feature
190- dut .serial .erase_field_on_emul_efuse ([SPI_BOOT_CRYPT_CNT ])
179+ CRYPT_CNT_EFUSE_NAME = 'SPI_BOOT_CRYPT_CNT'
180+ print (f' - Flash emul_efuse with pre-loaded efuses ({ CRYPT_CNT_EFUSE_NAME } 1 -> 0)' )
181+ # Resets eFuse, which enables Flash encryption feature
182+ dut .serial .erase_field_on_emul_efuse_by_name ([CRYPT_CNT_EFUSE_NAME ])
191183
192184 print (' - Start app (flash partition_table and app)' )
193185 dut .serial .write_flash_no_enc ()
@@ -347,10 +339,8 @@ def test_examples_efuse_with_virt_secure_boot_v1_pre_loaded(dut: Dut) -> None:
347339 dut .expect ('example: Done' )
348340
349341 print (' - Flash emul_efuse with pre-loaded efuses (ABS_DONE_0 1 -> 0)' )
350- # offset of this eFuse is taken from components/efuse/esp32/esp_efuse_table.csv
351- ABS_DONE_0 = 196
352342 # Resets eFuse, which enables Secure boot (V1) feature
353- dut .serial .erase_field_on_emul_efuse ([ ABS_DONE_0 ])
343+ dut .serial .erase_field_on_emul_efuse_by_name ([ ' ABS_DONE_0' ])
354344
355345 print (' - Start app (flash partition_table and app)' )
356346 dut .serial .flash ()
@@ -453,10 +443,8 @@ def test_examples_efuse_with_virt_secure_boot_v2(dut: Dut) -> None:
453443 dut .expect ('example: Done' )
454444
455445 print (' - Flash emul_efuse with pre-loaded efuses (ABS_DONE_1 1 -> 0)' )
456- # offset of this eFuse is taken from components/efuse/esp32/esp_efuse_table.csv
457- ABS_DONE_1 = 197
458446 # Resets eFuse, which enables Secure boot (V2) feature
459- dut .serial .erase_field_on_emul_efuse ([ ABS_DONE_1 ])
447+ dut .serial .erase_field_on_emul_efuse_by_name ([ ' ABS_DONE_1' ])
460448
461449 print (' - Start app (flash partition_table and app)' )
462450 dut .serial .flash ()
@@ -518,10 +506,8 @@ def test_examples_efuse_with_virt_secure_boot_v2_pre_loaded(dut: Dut) -> None:
518506 dut .expect ('example: Done' )
519507
520508 print (' - Flash emul_efuse with pre-loaded efuses (ABS_DONE_1 1 -> 0)' )
521- # offset of this eFuse is taken from components/efuse/esp32/esp_efuse_table.csv
522- ABS_DONE_1 = 197
523509 # Resets eFuse, which enables Secure boot (V2) feature
524- dut .serial .erase_field_on_emul_efuse ([ ABS_DONE_1 ])
510+ dut .serial .erase_field_on_emul_efuse_by_name ([ ' ABS_DONE_1' ])
525511
526512 print (' - Start app (flash partition_table and app)' )
527513 dut .serial .flash ()
@@ -594,7 +580,7 @@ def test_examples_efuse_with_virt_secure_boot_v2_esp32xx(dut: Dut) -> None:
594580
595581 dut .expect ('Verifying image signature...' )
596582 dut .expect ('secure_boot_v2: Secure boot V2 is not enabled yet and eFuse digest keys are not set' )
597- if dut .app .target == 'esp32c2' :
583+ if dut .app .sdkconfig . get ( 'SECURE_SIGNED_APPS_ECDSA_V2_SCHEME' ) :
598584 signed_scheme = 'ECDSA'
599585 else :
600586 signed_scheme = 'RSA-PSS'
@@ -670,24 +656,19 @@ def test_example_efuse_with_virt_secure_boot_v2_esp32xx_pre_loaded(dut: Dut) ->
670656
671657 print (' - Flash emul_efuse with pre-loaded efuses (SECURE_BOOT_EN 1 -> 0, SECURE_BOOT_KEY_REVOKE[0..2] -> 0)' )
672658 # offsets of eFuses are taken from components/efuse/{target}/esp_efuse_table.csv
673- if dut .app .target == 'esp32c2' :
674- SECURE_BOOT_EN = 53
675- dut .serial .erase_field_on_emul_efuse ([SECURE_BOOT_EN ])
659+ # Resets eFuse, which enables Secure boot feature
660+ # Resets eFuses, which control digest slots
661+ if dut .app .sdkconfig .get ('SOC_EFUSE_REVOKE_BOOT_KEY_DIGESTS' ):
662+ dut .serial .erase_field_on_emul_efuse_by_name (['SECURE_BOOT_EN' , 'SECURE_BOOT_KEY_REVOKE0' , 'SECURE_BOOT_KEY_REVOKE1' , 'SECURE_BOOT_KEY_REVOKE2' ])
676663 else :
677- SECURE_BOOT_EN = 116
678- SECURE_BOOT_KEY_REVOKE0 = 85
679- SECURE_BOOT_KEY_REVOKE1 = 86
680- SECURE_BOOT_KEY_REVOKE2 = 87
681- # Resets eFuse, which enables Secure boot feature
682- # Resets eFuses, which control digest slots
683- dut .serial .erase_field_on_emul_efuse ([SECURE_BOOT_EN , SECURE_BOOT_KEY_REVOKE0 , SECURE_BOOT_KEY_REVOKE1 , SECURE_BOOT_KEY_REVOKE2 ])
664+ dut .serial .erase_field_on_emul_efuse_by_name (['SECURE_BOOT_EN' ])
684665
685666 print (' - Start app (flash partition_table and app)' )
686667 dut .serial .flash ()
687668 dut .expect ('Loading virtual efuse blocks from flash' )
688669
689670 dut .expect ('Verifying image signature...' )
690- if dut .app .target == 'esp32c2' :
671+ if dut .app .sdkconfig . get ( 'SECURE_SIGNED_APPS_ECDSA_V2_SCHEME' ) :
691672 signed_scheme = 'ECDSA'
692673 else :
693674 signed_scheme = 'RSA-PSS'
@@ -981,7 +962,10 @@ def test_examples_efuse_with_virt_sb_v2_and_fe_esp32xx(dut: Dut) -> None:
981962
982963 dut .expect ('Verifying image signature...' )
983964 dut .expect ('secure_boot_v2: Secure boot V2 is not enabled yet and eFuse digest keys are not set' )
984- signed_scheme = 'ECDSA' if dut .app .target == 'esp32c2' else 'RSA-PSS'
965+ if dut .app .sdkconfig .get ('SECURE_SIGNED_APPS_ECDSA_V2_SCHEME' ):
966+ signed_scheme = 'ECDSA'
967+ else :
968+ signed_scheme = 'RSA-PSS'
985969 dut .expect ('secure_boot_v2: Verifying with %s...' % signed_scheme )
986970 dut .expect ('secure_boot_v2: Signature verified successfully!' )
987971
0 commit comments