example_test.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from __future__ import print_function
  2. import os
  3. import sys
  4. try:
  5. import IDF
  6. from IDF.IDFDUT import ESP32DUT
  7. except ImportError:
  8. test_fw_path = os.getenv('TEST_FW_PATH')
  9. if test_fw_path and test_fw_path not in sys.path:
  10. sys.path.insert(0, test_fw_path)
  11. import IDF
  12. # To prepare a test runner for this example:
  13. # 1. Generate zero flash encryption key:
  14. # dd if=/dev/zero of=key.bin bs=1 count=32
  15. # 2.Burn Efuses:
  16. # espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CONFIG 0xf
  17. # espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CNT 0x1
  18. # espefuse.py --do-not-confirm -p $ESPPORT burn_key flash_encryption key.bin
  19. @IDF.idf_example_test(env_tag='Example_Flash_Encryption')
  20. def test_examples_security_flash_encryption(env, extra_data):
  21. dut = env.get_dut('flash_encryption', 'examples/security/flash_encryption', dut_class=ESP32DUT)
  22. # start test
  23. dut.start_app()
  24. lines = [
  25. 'FLASH_CRYPT_CNT eFuse value is 1',
  26. 'Flash encryption feature is enabled in DEVELOPMENT mode',
  27. 'with esp_partition_write',
  28. '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f',
  29. 'with esp_partition_read',
  30. '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f',
  31. 'with spi_flash_read',
  32. '29 68 2e 13 88 a0 5b 7f cc 6b 39 f9 d7 7b 32 2f'
  33. ]
  34. for line in lines:
  35. dut.expect(line, timeout=2)
  36. if __name__ == '__main__':
  37. test_examples_security_flash_encryption()