mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 11:16:34 +00:00
Berry add flash.current_ota
(#21097)
This commit is contained in:
parent
ed7909f23f
commit
07a2df1b74
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
||||
### Added
|
||||
- Command ``PowerLock`` to disable power control of selected outputs (#21081)
|
||||
- Command ``Wifi 6`` to enable 11ax on ESP32 Core3
|
||||
- Berry add `flash.current_ota`
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
@ -15,6 +15,10 @@
|
||||
extern void p_factory(bbool force_ota);
|
||||
BE_FUNC_CTYPE_DECLARE(p_factory, "", "b");
|
||||
|
||||
// return current OTA partition
|
||||
extern int p_cur_ota();
|
||||
BE_FUNC_CTYPE_DECLARE(p_cur_ota, "i", "");
|
||||
|
||||
int32_t p_flashid(void) {
|
||||
uint32_t id = bootloader_read_flash_id();
|
||||
id = ((id & 0xff) << 16) | ((id >> 16) & 0xff) | (id & 0xff00);
|
||||
@ -42,6 +46,7 @@ module flash (scope: global) {
|
||||
|
||||
id, ctype_func(p_flashid)
|
||||
size, ctype_func(p_flashsize)
|
||||
current_ota, ctype_func(p_cur_ota)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "be_fixed_flash.h"
|
||||
|
@ -181,6 +181,18 @@ extern "C" {
|
||||
be_raise(vm, kTypeError, nullptr);
|
||||
}
|
||||
|
||||
// return current OTA partition
|
||||
// Typically `0` or `1`, or `-1` if safeboot
|
||||
int p_cur_ota() {
|
||||
uint32_t cur_part = ESP_PARTITION_SUBTYPE_APP_FACTORY; // 0
|
||||
const esp_partition_t *running_ota = esp_ota_get_running_partition();
|
||||
if (running_ota) { cur_part = running_ota->subtype; } // 16 - 32
|
||||
if (cur_part >= (uint32_t)ESP_PARTITION_SUBTYPE_APP_OTA_MIN /*16*/ && cur_part < (uint32_t)ESP_PARTITION_SUBTYPE_APP_OTA_MAX /*32*/) {
|
||||
return cur_part - (uint32_t)ESP_PARTITION_SUBTYPE_APP_OTA_MIN /*16*/;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Forces the next restart to use the `factory` partition if any is present
|
||||
void p_factory(bbool force_ota) {
|
||||
const esp_partition_t *otadata_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user