chip_specific_config.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright 2015-2021 Espressif Systems (Shanghai) CO LTD
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #
  15. # This file contains values (e.g. delay time, ...) that are different for each chip for a particular action.
  16. # If adding a new device, set only values that are different from the default, e.g.:
  17. # 'esp32s2': {
  18. # 0: {
  19. # 'reset': 0.35,
  20. # }
  21. # },
  22. #
  23. # for more information see the method "handle_commands" in idf_monitor.py
  24. conf = {
  25. # the default values were previously hardcoded in idf_monitor.py (taken from esptool.py)
  26. 'default': {
  27. 0: {
  28. 'reset': 0.2,
  29. 'enter_boot_set': 0.1,
  30. 'enter_boot_unset': 0.05,
  31. }
  32. },
  33. 'esp32': {
  34. 0: {
  35. 'reset': 0.2,
  36. 'enter_boot_set': 1.3,
  37. 'enter_boot_unset': 0.45,
  38. },
  39. 1: {
  40. 'reset': 0.2,
  41. 'enter_boot_set': 0.1,
  42. 'enter_boot_unset': 0.05,
  43. }
  44. },
  45. }
  46. def get_chip_config(chip, revision=0):
  47. # type: (str, int) -> dict
  48. # If the config is not set in the `conf` dict for a specific chip, the `default` will be used.
  49. # In case if only some values are specified, others are used from the `default`.
  50. # If chip is set in `conf` but the specific revision R is missing,
  51. # the values from highest revision lower than R are used.
  52. # If some fields are missing, they will be taken from next lower revision or from the `default`.
  53. default = dict(conf['default'][0])
  54. rev_number = int(revision)
  55. if chip not in conf.keys():
  56. return default
  57. chip_revisions = sorted(list(conf[chip].keys()), key=int)
  58. for rev in chip_revisions:
  59. if int(rev) > rev_number:
  60. break
  61. for key in conf[chip][rev].keys():
  62. default[key] = conf[chip][rev][key]
  63. return default