check_firmware.h 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include "options.h"
  3. #include <stdint.h>
  4. #include <esp_ota_ops.h>
  5. // reversed app descriptor. Reversed used to prevent it appearing in flash
  6. #define APP_DESCRIPTOR_REV { 0x19, 0x75, 0xe2, 0x46, 0x37, 0xf1, 0x2a, 0x43 }
  7. class CheckFirmware {
  8. public:
  9. typedef struct {
  10. uint8_t sig[8];
  11. uint32_t board_id;
  12. uint32_t image_size;
  13. uint8_t sign_signature[64];
  14. } app_descriptor_t;
  15. // check the firmware on the partition which will be updated by OTA
  16. static bool check_OTA_next(const esp_partition_t *part, const uint8_t *lead_bytes, uint32_t lead_length);
  17. static bool check_OTA_running(void);
  18. private:
  19. static bool check_OTA_partition(const esp_partition_t *part, const uint8_t *lead_bytes, uint32_t lead_length, uint32_t &board_id);
  20. static bool check_partition(const uint8_t *flash, uint32_t flash_len,
  21. const uint8_t *lead_bytes, uint32_t lead_length,
  22. const app_descriptor_t *ad, const uint8_t public_key[32]);
  23. };