chip_specific_config.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Apache-2.0
  3. #
  4. # This file contains values (e.g. delay time, ...) that are different for each chip for a particular action.
  5. # If adding a new device, set only values that are different from the default, e.g.:
  6. # 'esp32s2': {
  7. # 0: {
  8. # 'reset': 0.35,
  9. # }
  10. # },
  11. #
  12. # for more information see the method "handle_commands" in idf_monitor.py
  13. conf = {
  14. # the default values were previously hardcoded in idf_monitor.py (taken from esptool.py)
  15. 'default': {
  16. 0: {
  17. 'reset': 0.2,
  18. 'enter_boot_set': 0.1,
  19. 'enter_boot_unset': 0.05,
  20. }
  21. },
  22. 'esp32': {
  23. 0: {
  24. 'reset': 0.2,
  25. 'enter_boot_set': 1.3,
  26. 'enter_boot_unset': 0.45,
  27. },
  28. 1: {
  29. 'reset': 0.2,
  30. 'enter_boot_set': 0.1,
  31. 'enter_boot_unset': 0.05,
  32. }
  33. },
  34. }
  35. def get_chip_config(chip, revision=0):
  36. # type: (str, int) -> dict
  37. # If the config is not set in the `conf` dict for a specific chip, the `default` will be used.
  38. # In case if only some values are specified, others are used from the `default`.
  39. # If chip is set in `conf` but the specific revision R is missing,
  40. # the values from highest revision lower than R are used.
  41. # If some fields are missing, they will be taken from next lower revision or from the `default`.
  42. default = dict(conf['default'][0])
  43. rev_number = int(revision)
  44. if chip not in conf.keys():
  45. return default
  46. chip_revisions = sorted(list(conf[chip].keys()), key=int)
  47. for rev in chip_revisions:
  48. if int(rev) > rev_number:
  49. break
  50. for key in conf[chip][rev].keys():
  51. default[key] = conf[chip][rev][key]
  52. return default