example_test.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. import http.server
  2. import os
  3. import re
  4. import socket
  5. import ssl
  6. import sys
  7. from threading import Thread
  8. import ttfw_idf
  9. from tiny_test_fw import DUT, Utility
  10. server_cert = '-----BEGIN CERTIFICATE-----\n' \
  11. 'MIIDXTCCAkWgAwIBAgIJAP4LF7E72HakMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\n'\
  12. 'BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX\n'\
  13. 'aWRnaXRzIFB0eSBMdGQwHhcNMTkwNjA3MDk1OTE2WhcNMjAwNjA2MDk1OTE2WjBF\n'\
  14. 'MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50\n'\
  15. 'ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n'\
  16. 'CgKCAQEAlzfCyv3mIv7TlLkObxunKfCdrJ/zgdANrsx0RBtpEPhV560hWJ0fEin0\n'\
  17. 'nIOMpJSiF9E6QsPdr6Q+eogH4XnOMU9JE+iG743N1dPfGEzJvRlyct/Ck8SswKPC\n'\
  18. '9+VXsnOdZmUw9y/xtANbURA/TspvPzz3Avv382ffffrJGh7ooOmaZSCZFlSYHLZA\n'\
  19. 'w/XlRr0sSRbLpFGY0gXjaAV8iHHiPDYLy4kZOepjV9U51xi+IGsL4w75zuMgsHyF\n'\
  20. '3nJeGYHgtGVBrkL0ZKG5udY0wcBjysjubDJC4iSlNiq2HD3fhs7j6CZddV2v845M\n'\
  21. 'lVKNxP0kO4Uj4D8r+5USWC8JKfAwxQIDAQABo1AwTjAdBgNVHQ4EFgQU6OE7ssfY\n'\
  22. 'IIPTDThiUoofUpsD5NwwHwYDVR0jBBgwFoAU6OE7ssfYIIPTDThiUoofUpsD5Nww\n'\
  23. 'DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAXIlHS/FJWfmcinUAxyBd\n'\
  24. '/xd5Lu8ykeru6oaUCci+Vk9lyoMMES7lQ+b/00d5x7AcTawkTil9EWpBTPTOTraA\n'\
  25. 'lzJMQhNKmSLk0iIoTtAJtSZgUSpIIozqK6lenxQQDsHbXKU6h+u9H6KZE8YcjsFl\n'\
  26. '6vL7sw9BVotw/VxfgjQ5OSGLgoLrdVT0z5C2qOuwOgz1c7jNiJhtMdwN+cOtnJp2\n'\
  27. 'fuBgEYyE3eeuWogvkWoDcIA8r17Ixzkpq2oJsdvZcHZPIZShPKW2SHUsl98KDemu\n'\
  28. 'y0pQyExmQUbwKE4vbFb9XuWCcL9XaOHQytyszt2DeD67AipvoBwVU7/LBOvqnsmy\n'\
  29. 'hA==\n'\
  30. '-----END CERTIFICATE-----\n'
  31. server_key = '-----BEGIN PRIVATE KEY-----\n'\
  32. 'MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCXN8LK/eYi/tOU\n'\
  33. 'uQ5vG6cp8J2sn/OB0A2uzHREG2kQ+FXnrSFYnR8SKfScg4yklKIX0TpCw92vpD56\n'\
  34. 'iAfhec4xT0kT6Ibvjc3V098YTMm9GXJy38KTxKzAo8L35Veyc51mZTD3L/G0A1tR\n'\
  35. 'ED9Oym8/PPcC+/fzZ999+skaHuig6ZplIJkWVJgctkDD9eVGvSxJFsukUZjSBeNo\n'\
  36. 'BXyIceI8NgvLiRk56mNX1TnXGL4gawvjDvnO4yCwfIXecl4ZgeC0ZUGuQvRkobm5\n'\
  37. '1jTBwGPKyO5sMkLiJKU2KrYcPd+GzuPoJl11Xa/zjkyVUo3E/SQ7hSPgPyv7lRJY\n'\
  38. 'Lwkp8DDFAgMBAAECggEAfBhAfQE7mUByNbxgAgI5fot9eaqR1Nf+QpJ6X2H3KPwC\n'\
  39. '02sa0HOwieFwYfj6tB1doBoNq7i89mTc+QUlIn4pHgIowHO0OGawomeKz5BEhjCZ\n'\
  40. '4XeLYGSoODary2+kNkf2xY8JTfFEcyvGBpJEwc4S2VyYgRRx+IgnumTSH+N5mIKZ\n'\
  41. 'SXWNdZIuHEmkwod+rPRXs6/r+PH0eVW6WfpINEbr4zVAGXJx2zXQwd2cuV1GTJWh\n'\
  42. 'cPVOXLu+XJ9im9B370cYN6GqUnR3fui13urYbnWnEf3syvoH/zuZkyrVChauoFf8\n'\
  43. '8EGb74/HhXK7Q2s8NRakx2c7OxQifCbcy03liUMmyQKBgQDFAob5B/66N4Q2cq/N\n'\
  44. 'MWPf98kYBYoLaeEOhEJhLQlKk0pIFCTmtpmUbpoEes2kCUbH7RwczpYko8tlKyoB\n'\
  45. '6Fn6RY4zQQ64KZJI6kQVsjkYpcP/ihnOY6rbds+3yyv+4uPX7Eh9sYZwZMggE19M\n'\
  46. 'CkFHkwAjiwqhiiSlUxe20sWmowKBgQDEfx4lxuFzA1PBPeZKGVBTxYPQf+DSLCre\n'\
  47. 'ZFg3ZmrxbCjRq1O7Lra4FXWD3dmRq7NDk79JofoW50yD8wD7I0B7opdDfXD2idO8\n'\
  48. '0dBnWUKDr2CAXyoLEINce9kJPbx4kFBQRN9PiGF7VkDQxeQ3kfS8CvcErpTKCOdy\n'\
  49. '5wOwBTwJdwKBgDiTFTeGeDv5nVoVbS67tDao7XKchJvqd9q3WGiXikeELJyuTDqE\n'\
  50. 'zW22pTwMF+m3UEAxcxVCrhMvhkUzNAkANHaOatuFHzj7lyqhO5QPbh4J3FMR0X9X\n'\
  51. 'V8VWRSg+jA/SECP9koOl6zlzd5Tee0tW1pA7QpryXscs6IEhb3ns5R2JAoGAIkzO\n'\
  52. 'RmnhEOKTzDex611f2D+yMsMfy5BKK2f4vjLymBH5TiBKDXKqEpgsW0huoi8Gq9Uu\n'\
  53. 'nvvXXAgkIyRYF36f0vUe0nkjLuYAQAWgC2pZYgNLJR13iVbol0xHJoXQUHtgiaJ8\n'\
  54. 'GLYFzjHQPqFMpSalQe3oELko39uOC1CoJCHFySECgYBeycUnRBikCO2n8DNhY4Eg\n'\
  55. '9Y3oxcssRt6ea5BZwgW2eAYi7/XqKkmxoSoOykUt3MJx9+EkkrL17bxFSpkj1tvL\n'\
  56. 'qvxn7egtsKjjgGNAxwXC4MwCvhveyUQQxtQb8AqGrGqo4jEEN0L15cnP38i2x1Uo\n'\
  57. 'muhfskWf4MABV0yTUaKcGg==\n'\
  58. '-----END PRIVATE KEY-----\n'
  59. def get_my_ip():
  60. s1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  61. s1.connect(('8.8.8.8', 80))
  62. my_ip = s1.getsockname()[0]
  63. s1.close()
  64. return my_ip
  65. def start_https_server(ota_image_dir, server_ip, server_port, server_file=None, key_file=None):
  66. os.chdir(ota_image_dir)
  67. if server_file is None:
  68. server_file = os.path.join(ota_image_dir, 'server_cert.pem')
  69. cert_file_handle = open(server_file, 'w+')
  70. cert_file_handle.write(server_cert)
  71. cert_file_handle.close()
  72. if key_file is None:
  73. key_file = os.path.join(ota_image_dir, 'server_key.pem')
  74. key_file_handle = open('server_key.pem', 'w+')
  75. key_file_handle.write(server_key)
  76. key_file_handle.close()
  77. httpd = http.server.HTTPServer((server_ip, server_port), http.server.SimpleHTTPRequestHandler)
  78. httpd.socket = ssl.wrap_socket(httpd.socket,
  79. keyfile=key_file,
  80. certfile=server_file, server_side=True)
  81. httpd.serve_forever()
  82. def check_sha256(sha256_expected, sha256_reported):
  83. Utility.console_log('sha256_expected: %s' % (sha256_expected))
  84. Utility.console_log('sha256_reported: %s' % (sha256_reported))
  85. if sha256_reported not in sha256_expected:
  86. raise ValueError('SHA256 mismatch')
  87. else:
  88. Utility.console_log('SHA256 expected and reported are the same')
  89. def calc_all_sha256(dut):
  90. bootloader_path = os.path.join(dut.app.binary_path, 'bootloader', 'bootloader.bin')
  91. output = dut.image_info(bootloader_path)
  92. sha256_bootloader = re.search(r'Validation Hash:\s+([a-f0-9]+)', output).group(1)
  93. Utility.console_log('bootloader SHA256: %s' % sha256_bootloader)
  94. app_path = os.path.join(dut.app.binary_path, 'simple_ota.bin')
  95. output = dut.image_info(app_path)
  96. sha256_app = re.search(r'Validation Hash:\s+([a-f0-9]+)', output).group(1)
  97. Utility.console_log('app SHA256: %s' % sha256_app)
  98. return sha256_bootloader, sha256_app
  99. @ttfw_idf.idf_example_test(env_tag='Example_WIFI_OTA')
  100. def test_examples_protocol_simple_ota_example(env, extra_data):
  101. """
  102. steps: |
  103. 1. join AP
  104. 2. Fetch OTA image over HTTPS
  105. 3. Reboot with the new OTA image
  106. """
  107. dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', dut_class=ttfw_idf.ESP32DUT)
  108. # check and log bin size
  109. binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
  110. bin_size = os.path.getsize(binary_file)
  111. ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
  112. sha256_bootloader, sha256_app = calc_all_sha256(dut1)
  113. # start test
  114. host_ip = get_my_ip()
  115. thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
  116. thread1.daemon = True
  117. thread1.start()
  118. dut1.start_app()
  119. dut1.expect('Loaded app from partition at offset 0x10000', timeout=30)
  120. check_sha256(sha256_bootloader, dut1.expect(re.compile(r'SHA-256 for bootloader:\s+([a-f0-9]+)'))[0])
  121. check_sha256(sha256_app, dut1.expect(re.compile(r'SHA-256 for current firmware:\s+([a-f0-9]+)'))[0])
  122. try:
  123. ip_address = dut1.expect(re.compile(r' sta ip: ([^,]+),'), timeout=30)
  124. print('Connected to AP with IP: {}'.format(ip_address))
  125. except DUT.ExpectTimeout:
  126. raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP')
  127. dut1.expect('Starting OTA example', timeout=30)
  128. print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
  129. dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
  130. dut1.expect('Loaded app from partition at offset 0x110000', timeout=60)
  131. dut1.expect('Starting OTA example', timeout=30)
  132. @ttfw_idf.idf_example_test(env_tag='Example_EthKitV1')
  133. def test_examples_protocol_simple_ota_example_ethernet_with_spiram_config(env, extra_data):
  134. """
  135. steps: |
  136. 1. join AP
  137. 2. Fetch OTA image over HTTPS
  138. 3. Reboot with the new OTA image
  139. """
  140. dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', dut_class=ttfw_idf.ESP32DUT, app_config_name='spiram')
  141. # check and log bin size
  142. binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
  143. bin_size = os.path.getsize(binary_file)
  144. ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
  145. # start test
  146. host_ip = get_my_ip()
  147. thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
  148. thread1.daemon = True
  149. thread1.start()
  150. dut1.start_app()
  151. dut1.expect('Loaded app from partition at offset 0x10000', timeout=30)
  152. try:
  153. ip_address = dut1.expect(re.compile(r' eth ip: ([^,]+),'), timeout=30)
  154. print('Connected to AP with IP: {}'.format(ip_address))
  155. except DUT.ExpectTimeout:
  156. raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP')
  157. dut1.expect('Starting OTA example', timeout=30)
  158. print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
  159. dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
  160. dut1.expect('Loaded app from partition at offset 0x110000', timeout=60)
  161. dut1.expect('Starting OTA example', timeout=30)
  162. @ttfw_idf.idf_example_test(env_tag='Example_Flash_Encryption_OTA')
  163. def test_examples_protocol_simple_ota_example_with_flash_encryption(env, extra_data):
  164. """
  165. steps: |
  166. 1. join AP
  167. 2. Fetch OTA image over HTTPS
  168. 3. Reboot with the new OTA image
  169. """
  170. dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', dut_class=ttfw_idf.ESP32DUT, app_config_name='flash_enc')
  171. # check and log bin size
  172. binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
  173. bin_size = os.path.getsize(binary_file)
  174. ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
  175. # erase flash on the device
  176. print('Erasing the flash in order to have an empty NVS key partiton')
  177. dut1.erase_flash()
  178. # start test
  179. host_ip = get_my_ip()
  180. thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
  181. thread1.daemon = True
  182. thread1.start()
  183. dut1.start_app()
  184. dut1.expect('Loaded app from partition at offset 0x20000', timeout=30)
  185. dut1.expect('Flash encryption mode is DEVELOPMENT (not secure)', timeout=10)
  186. try:
  187. ip_address = dut1.expect(re.compile(r' eth ip: ([^,]+),'), timeout=30)
  188. print('Connected to AP with IP: {}'.format(ip_address))
  189. except DUT.ExpectTimeout:
  190. raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP')
  191. dut1.expect('Starting OTA example', timeout=30)
  192. print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
  193. dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
  194. dut1.expect('Loaded app from partition at offset 0x120000', timeout=60)
  195. dut1.expect('Flash encryption mode is DEVELOPMENT (not secure)', timeout=10)
  196. dut1.expect('Starting OTA example', timeout=30)
  197. @ttfw_idf.idf_example_test(env_tag='Example_Flash_Encryption_OTA_WiFi', target=['esp32c3'])
  198. def test_examples_protocol_simple_ota_example_with_flash_encryption_wifi(env, extra_data):
  199. """
  200. steps: |
  201. 1. join AP
  202. 2. Fetch OTA image over HTTPS
  203. 3. Reboot with the new OTA image
  204. """
  205. dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', app_config_name='flash_enc_wifi')
  206. # check and log bin size
  207. binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
  208. bin_size = os.path.getsize(binary_file)
  209. ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
  210. # erase flash on the device
  211. print('Erasing the flash in order to have an empty NVS key partiton')
  212. dut1.erase_flash()
  213. # start test
  214. host_ip = get_my_ip()
  215. thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
  216. thread1.daemon = True
  217. thread1.start()
  218. dut1.start_app()
  219. dut1.expect('Loaded app from partition at offset 0x20000', timeout=30)
  220. dut1.expect('Flash encryption mode is DEVELOPMENT (not secure)', timeout=10)
  221. try:
  222. ip_address = dut1.expect(re.compile(r' sta ip: ([^,]+),'), timeout=30)
  223. print('Connected to AP with IP: {}'.format(ip_address))
  224. except DUT.ExpectTimeout:
  225. raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP')
  226. dut1.expect('Starting OTA example', timeout=30)
  227. print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
  228. dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
  229. dut1.expect('Loaded app from partition at offset 0x120000', timeout=60)
  230. dut1.expect('Flash encryption mode is DEVELOPMENT (not secure)', timeout=10)
  231. dut1.expect('Starting OTA example', timeout=30)
  232. @ttfw_idf.idf_example_test(env_tag='Example_EthKitV1')
  233. def test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_ecdsa(env, extra_data):
  234. """
  235. steps: |
  236. 1. join AP
  237. 2. Fetch OTA image over HTTPS
  238. 3. Reboot with the new OTA image
  239. """
  240. dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', dut_class=ttfw_idf.ESP32DUT,
  241. app_config_name='on_update_no_sb_ecdsa')
  242. # check and log bin size
  243. binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
  244. bin_size = os.path.getsize(binary_file)
  245. ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
  246. sha256_bootloader, sha256_app = calc_all_sha256(dut1)
  247. # start test
  248. host_ip = get_my_ip()
  249. thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
  250. thread1.daemon = True
  251. thread1.start()
  252. dut1.start_app()
  253. dut1.expect('Loaded app from partition at offset 0x20000', timeout=30)
  254. check_sha256(sha256_bootloader, dut1.expect(re.compile(r'SHA-256 for bootloader:\s+([a-f0-9]+)'))[0])
  255. check_sha256(sha256_app, dut1.expect(re.compile(r'SHA-256 for current firmware:\s+([a-f0-9]+)'))[0])
  256. try:
  257. ip_address = dut1.expect(re.compile(r' eth ip: ([^,]+),'), timeout=30)
  258. print('Connected to AP with IP: {}'.format(ip_address))
  259. except DUT.ExpectTimeout:
  260. raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP')
  261. dut1.expect('Starting OTA example', timeout=30)
  262. print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
  263. dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
  264. dut1.expect('Writing to partition subtype 16 at offset 0x120000', timeout=20)
  265. dut1.expect('Verifying image signature...', timeout=60)
  266. dut1.expect('Loaded app from partition at offset 0x120000', timeout=20)
  267. dut1.expect('Starting OTA example', timeout=30)
  268. @ttfw_idf.idf_example_test(env_tag='Example_EthKitV12')
  269. def test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_rsa(env, extra_data):
  270. """
  271. steps: |
  272. 1. join AP
  273. 2. Fetch OTA image over HTTPS
  274. 3. Reboot with the new OTA image
  275. """
  276. dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', dut_class=ttfw_idf.ESP32DUT,
  277. app_config_name='on_update_no_sb_rsa')
  278. # check and log bin size
  279. binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
  280. bin_size = os.path.getsize(binary_file)
  281. ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
  282. sha256_bootloader, sha256_app = calc_all_sha256(dut1)
  283. # start test
  284. host_ip = get_my_ip()
  285. thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
  286. thread1.daemon = True
  287. thread1.start()
  288. dut1.start_app()
  289. dut1.expect('Loaded app from partition at offset 0x20000', timeout=30)
  290. check_sha256(sha256_bootloader, dut1.expect(re.compile(r'SHA-256 for bootloader:\s+([a-f0-9]+)'))[0])
  291. check_sha256(sha256_app, dut1.expect(re.compile(r'SHA-256 for current firmware:\s+([a-f0-9]+)'))[0])
  292. try:
  293. ip_address = dut1.expect(re.compile(r' eth ip: ([^,]+),'), timeout=30)
  294. print('Connected to AP with IP: {}'.format(ip_address))
  295. except DUT.ExpectTimeout:
  296. raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP')
  297. dut1.expect('Starting OTA example', timeout=30)
  298. print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
  299. dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
  300. dut1.expect('Writing to partition subtype 16 at offset 0x120000', timeout=20)
  301. dut1.expect('Verifying image signature...', timeout=60)
  302. dut1.expect('#0 app key digest == #0 trusted key digest', timeout=10)
  303. dut1.expect('Verifying with RSA-PSS...', timeout=10)
  304. dut1.expect('Signature verified successfully!', timeout=10)
  305. dut1.expect('Loaded app from partition at offset 0x120000', timeout=20)
  306. dut1.expect('Starting OTA example', timeout=30)
  307. if __name__ == '__main__':
  308. if sys.argv[2:]: # if two or more arguments provided:
  309. # Usage: example_test.py <image_dir> <server_port> [cert_di>]
  310. this_dir = os.path.dirname(os.path.realpath(__file__))
  311. bin_dir = os.path.join(this_dir, sys.argv[1])
  312. port = int(sys.argv[2])
  313. cert_dir = bin_dir if not sys.argv[3:] else os.path.join(this_dir, sys.argv[3]) # optional argument
  314. print('Starting HTTPS server at "https://:{}"'.format(port))
  315. start_https_server(bin_dir, '', port,
  316. server_file=os.path.join(cert_dir, 'ca_cert.pem'),
  317. key_file=os.path.join(cert_dir, 'ca_key.pem'))
  318. else:
  319. test_examples_protocol_simple_ota_example()
  320. test_examples_protocol_simple_ota_example_ethernet_with_spiram_config()
  321. test_examples_protocol_simple_ota_example_with_flash_encryption()
  322. test_examples_protocol_simple_ota_example_with_flash_encryption_wifi()
  323. test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_ecdsa()
  324. test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_rsa()