boot counter using existing nvm object
This commit is contained in:
parent
bc26194bd0
commit
aaf2c3752e
14
main.c
14
main.c
@ -109,6 +109,7 @@
|
||||
|
||||
#ifdef CIRCUITPY_BOOT_COUNTER
|
||||
#include "shared-bindings/nvm/ByteArray.h"
|
||||
uint8_t value_out = 0;
|
||||
#endif
|
||||
|
||||
#if MICROPY_ENABLE_PYSTACK
|
||||
@ -308,15 +309,6 @@ STATIC void print_code_py_status_message(safe_mode_t safe_mode) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CIRCUITPY_BOOT_COUNTER
|
||||
nvm_bytearray_obj_t bootcnt = {
|
||||
.base = {.type = &nvm_bytearray_type},
|
||||
.len = ( uint32_t) 1,
|
||||
.start_address = (uint8_t*) (0x00080000 - CIRCUITPY_INTERNAL_NVM_SIZE)
|
||||
};
|
||||
uint8_t value_out = 0;
|
||||
#endif
|
||||
|
||||
STATIC bool run_code_py(safe_mode_t safe_mode) {
|
||||
bool serial_connected_at_start = serial_connected();
|
||||
bool printed_safe_mode_message = false;
|
||||
@ -330,9 +322,9 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
|
||||
#endif
|
||||
|
||||
#ifdef CIRCUITPY_BOOT_COUNTER
|
||||
common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out);
|
||||
common_hal_nvm_bytearray_get_bytes(&common_hal_mcu_nvm_obj,0,1,&value_out);
|
||||
++value_out;
|
||||
common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1);
|
||||
common_hal_nvm_bytearray_set_bytes(&common_hal_mcu_nvm_obj,0,&value_out,1);
|
||||
#endif
|
||||
|
||||
pyexec_result_t result;
|
||||
|
@ -31,13 +31,13 @@
|
||||
|
||||
extern const mp_obj_type_t nvm_bytearray_type;
|
||||
|
||||
uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self);
|
||||
uint32_t common_hal_nvm_bytearray_get_length(const nvm_bytearray_obj_t *self);
|
||||
|
||||
bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
|
||||
bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self,
|
||||
uint32_t start_index, uint8_t *values, uint32_t len);
|
||||
// len and values are intentionally swapped to signify values is an output and
|
||||
// also leverage the compiler to validate uses are expected.
|
||||
void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self,
|
||||
void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self,
|
||||
uint32_t start_index, uint32_t len, uint8_t *values);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_NVM_BYTEARRAY_H
|
||||
|
Loading…
Reference in New Issue
Block a user