example_test.py 1.4 KB

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