Added Function to Read App Image size from Partition
This commit is contained in:
parent
337976e637
commit
df35def702
3
Makefile
3
Makefile
@ -66,3 +66,6 @@ monitor1:
|
|||||||
|
|
||||||
monitor2:
|
monitor2:
|
||||||
idf.py monitor -p /dev/ttyUSB2
|
idf.py monitor -p /dev/ttyUSB2
|
||||||
|
|
||||||
|
flash_second_ota:
|
||||||
|
parttool.py --port /dev/ttyACM0 write_partition --partition-name="ota_1" --input build/espAlox.bin
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "ota_update.h"
|
#include "ota_update.h"
|
||||||
#include "communication_handler.h"
|
#include "communication_handler.h"
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
|
#include "esp_app_format.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
#include "esp_partition.h"
|
#include "esp_partition.h"
|
||||||
@ -26,6 +27,32 @@ static uint16_t current_block_id;
|
|||||||
static uint16_t update_buffer_write_index;
|
static uint16_t update_buffer_write_index;
|
||||||
static uint32_t update_size;
|
static uint32_t update_size;
|
||||||
static uint16_t sequenz_counter; // how often the update buffer gets written
|
static uint16_t sequenz_counter; // how often the update buffer gets written
|
||||||
|
|
||||||
|
u_int32_t get_app_size(const esp_partition_t *app_size_partition) {
|
||||||
|
esp_app_desc_t app_desc;
|
||||||
|
esp_ota_get_partition_description(app_size_partition, &app_desc);
|
||||||
|
|
||||||
|
esp_image_header_t header;
|
||||||
|
|
||||||
|
esp_partition_read(app_size_partition, 0, &header, sizeof(header));
|
||||||
|
if (header.magic != ESP_IMAGE_HEADER_MAGIC) {
|
||||||
|
ESP_LOGE(TAG, "KEIN VALIDER HEADER");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
u_int32_t data_len = sizeof(header);
|
||||||
|
|
||||||
|
for (int i = 0; i < header.segment_count; i++) {
|
||||||
|
esp_image_segment_header_t segment_header;
|
||||||
|
esp_partition_read(app_size_partition, data_len, &segment_header,
|
||||||
|
sizeof(segment_header));
|
||||||
|
ESP_LOGI(TAG, "SEGMENT %d Address %d, Segment DataLen %d", i,
|
||||||
|
segment_header.load_addr, segment_header.data_len);
|
||||||
|
data_len += segment_header.data_len + sizeof(segment_header);
|
||||||
|
}
|
||||||
|
return data_len;
|
||||||
|
}
|
||||||
|
|
||||||
void ota_task(void *pvParameter) {
|
void ota_task(void *pvParameter) {
|
||||||
ESP_LOGI(TAG, "ota_task started");
|
ESP_LOGI(TAG, "ota_task started");
|
||||||
ota_task_queue_message_t msg;
|
ota_task_queue_message_t msg;
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "esp_now.h"
|
#include "esp_now.h"
|
||||||
|
#include "esp_partition.h"
|
||||||
#include "message_structs.h"
|
#include "message_structs.h"
|
||||||
|
|
||||||
#define UPDATE_BUFFER_SIZE 4096
|
#define UPDATE_BUFFER_SIZE 4096
|
||||||
@ -44,6 +45,8 @@ enum OTA_UPDATE_STATES {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
u_int32_t get_app_size(const esp_partition_t *app_size_partition);
|
||||||
|
|
||||||
int prepare_ota_update();
|
int prepare_ota_update();
|
||||||
esp_err_t write_ota_update(uint32_t write_len, const uint8_t *payload);
|
esp_err_t write_ota_update(uint32_t write_len, const uint8_t *payload);
|
||||||
esp_err_t end_ota_update();
|
esp_err_t end_ota_update();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user