mirror of https://github.com/arendst/Tasmota.git
Merge pull request #15504 from s-hadinger/berry_flash_more2
Berry flash.factory()
This commit is contained in:
commit
b65cad3584
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
static be_define_const_map_slots(m_libflash_map) {
|
static be_define_const_map_slots(m_libflash_map) {
|
||||||
{ be_const_key(write, -1), be_const_func(p_flash_write) },
|
{ be_const_key(write, -1), be_const_func(p_flash_write) },
|
||||||
{ be_const_key(read, 2), be_const_func(p_flash_read) },
|
{ be_const_key(factory, 2), be_const_ctype_func(p_factory) },
|
||||||
{ be_const_key(erase, 3), be_const_func(p_flash_erase) },
|
{ be_const_key(erase, 3), be_const_func(p_flash_erase) },
|
||||||
{ be_const_key(rollback, -1), be_const_ctype_func(p_rollback) },
|
{ be_const_key(read, -1), be_const_func(p_flash_read) },
|
||||||
};
|
};
|
||||||
|
|
||||||
static be_define_const_map(
|
static be_define_const_map(
|
||||||
|
|
|
@ -8,12 +8,16 @@
|
||||||
#include "be_constobj.h"
|
#include "be_constobj.h"
|
||||||
#include "be_mapping.h"
|
#include "be_mapping.h"
|
||||||
|
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_partition.h"
|
||||||
|
|
||||||
void p_rollback(void) {
|
// Forces the next restart to use the `factory` partition if any is present
|
||||||
esp_ota_mark_app_invalid_rollback_and_reboot();
|
void p_factory(void) {
|
||||||
|
const esp_partition_t *otadata_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
|
||||||
|
if (otadata_partition) {
|
||||||
|
esp_partition_erase_range(otadata_partition, 0, SPI_FLASH_SEC_SIZE * 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BE_FUNC_CTYPE_DECLARE(p_rollback, "", "");
|
BE_FUNC_CTYPE_DECLARE(p_factory, "", "");
|
||||||
|
|
||||||
extern int p_flash_read(bvm *vm);
|
extern int p_flash_read(bvm *vm);
|
||||||
extern int p_flash_write(bvm *vm);
|
extern int p_flash_write(bvm *vm);
|
||||||
|
@ -25,7 +29,7 @@ module flash (scope: global) {
|
||||||
write, func(p_flash_write)
|
write, func(p_flash_write)
|
||||||
erase, func(p_flash_erase)
|
erase, func(p_flash_erase)
|
||||||
|
|
||||||
rollback, ctype_func(p_rollback)
|
factory, ctype_func(p_factory)
|
||||||
}
|
}
|
||||||
@const_object_info_end */
|
@const_object_info_end */
|
||||||
#include "be_fixed_flash.h"
|
#include "be_fixed_flash.h"
|
||||||
|
|
Loading…
Reference in New Issue