bootloader_common.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE 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. #pragma once
  15. #include "esp_flash_data_types.h"
  16. /// Type of hold a GPIO in low state
  17. typedef enum {
  18. GPIO_LONG_HOLD = 1, /*!< The long hold GPIO */
  19. GPIO_SHORT_HOLD = -1, /*!< The short hold GPIO */
  20. GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
  21. } esp_comm_gpio_hold_t;
  22. /**
  23. * @brief Calculate crc for the OTA data partition.
  24. *
  25. * @param[in] ota_data The OTA data partition.
  26. * @return Returns crc value.
  27. */
  28. uint32_t bootloader_common_ota_select_crc(const esp_ota_select_entry_t *s);
  29. /**
  30. * @brief Verifies the validity of the OTA data partition
  31. *
  32. * @param[in] ota_data The OTA data partition.
  33. * @return Returns true on valid, false otherwise.
  34. */
  35. bool bootloader_common_ota_select_valid(const esp_ota_select_entry_t *s);
  36. /**
  37. * @brief Check if the GPIO input is a long hold or a short hold.
  38. *
  39. * Number of the GPIO input will be configured as an input with internal pull-up enabled.
  40. * If the GPIO input is held low continuously for delay_sec period then it is a long hold.
  41. * If the GPIO input is held low for less period then it is a short hold.
  42. *
  43. * @param[in] num_pin Number of the GPIO input.
  44. * @param[in] delay_sec Input must be driven low for at least this long, continuously.
  45. * @return esp_comm_gpio_hold_t Defines type of hold a GPIO in low state.
  46. */
  47. esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec);
  48. /**
  49. * @brief Erase the partition data that is specified in the transferred list.
  50. *
  51. * @param[in] list_erase String containing a list of cleared partitions. Like this "nvs, phy". The string must be null-terminal.
  52. * @param[in] ota_data_erase If true then the OTA data partition will be cleared (if there is it in partition table).
  53. * @return Returns true on success, false otherwise.
  54. */
  55. bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_data_erase);
  56. /**
  57. * @brief Determines if the list contains the label
  58. *
  59. * @param[in] list A string of names delimited by commas or spaces. Like this "nvs, phy, data". The string must be null-terminated.
  60. * @param[in] label The substring that will be searched in the list.
  61. * @return Returns true if the list contains the label, false otherwise.
  62. */
  63. bool bootloader_common_label_search(const char *list, char *label);