15#if PC_ENABLE_PARTITION_MONITOR
23#include <esp_ota_ops.h>
24#include <esp_partition.h>
26const char *pc_partition_kind(uint8_t type, uint8_t subtype)
34 if (subtype >= 0x10 && subtype <= 0x1F)
68static const pc_field PART_ENTRY[] = {
89int32_t pc_partition_json(
const pc_partition_info *parts, uint8_t count,
char *out, uint32_t cap)
104 for (uint8_t i = 0; i < count; i++)
106 const pc_partition_info *p = &parts[i];
107 if (
pc_frame_append(out, cap, PART_ENTRY, i ?
"," :
"", p->label, pc_partition_kind(p->type, p->subtype),
108 (uint32_t)p->type, (uint32_t)p->subtype, (uint32_t)p->address, (uint32_t)p->size,
109 p->running ?
"true" :
"false") == 0)
119uint8_t pc_partition_collect(pc_partition_info *out, uint8_t max)
121 if (!out || max == 0)
125 const esp_partition_t *running = esp_ota_get_running_partition();
127 esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
128 for (; it != NULL && n < max; it = esp_partition_next(it))
130 const esp_partition_t *p = esp_partition_get(it);
131 pc_partition_info *d = &out[n++];
132 strncpy(d->label, p->label,
sizeof(d->label) - 1);
133 d->label[
sizeof(d->label) - 1] =
'\0';
134 d->type = (uint8_t)p->type;
135 d->subtype = (uint8_t)p->subtype;
136 d->address = p->address;
138 d->running = (running != NULL && p->address == running->address);
140 esp_partition_iterator_release(it);
146uint8_t pc_partition_collect(pc_partition_info *, uint8_t)
size_t pc_frame_append(char *out, size_t cap, const pc_field *spec,...)
Append spec to the NUL-terminated contents already in out.
Declarative frame builder: a frame is a static table of typed fields, built by one engine.
@ PC_FK_LIT
literal text from lit; takes no argument
Flash partition-map monitor (PC_ENABLE_PARTITION_MONITOR).
One field of a frame. Frames are static const pc_field[], so they live in rodata.