How to get board reset count

Hi,
I’m using LPC1768 board. I want to get board reset count (how many times board gets ON and OFF) and save it into EEPROM. Can someone tell me how to do that?

regards,
V.

Hello,

I do not know if Mbed provide something like that directly, I saw only a counter of system crashes - Error handling - API references and tutorials | Mbed OS 6 Documentation

However it can be done with KVStore - API references and tutorials | Mbed OS 6 Documentation.
You can read a stored value every start of the board, incremented it and store it again.

BR, Jan

1 Like

I have gone through with those documents. Still could not find how to get persistence count

What do you want to monitor? Reset due to errors, reset due to manual actions or both?

1 Like

I did not write that the KVStore do it, I wrote it is possible to achive it via the KVStore.
The KVStore let you store a value in the on-chip flashmemory and thank to this you will able to read the value in the next start up, after power down.

So it can works as…
Board start -> init KVS -> read KEY -> print the value -> increment the value -> re-write KEY -> rest of program

Simplest examples than official is

BR, Jan

2 Likes

No. I want to count board reset count. (How many times board is resetting)

Maybe you can use mbed_get_error_count. If you want to capture all the reboots, use @JohnnyK solution.

1 Like

@JohnnyK what does char kv_key[] = {"/kv/key"}; mean?

KVStore is a FileSystem so from my understanding it is like path in any other file system {"/FOLDER/FILENAME"}. Similar it is with FAT or Little FileSystem.

BR, Jan

1 Like

got it. So instead of saving persistence value into a file I can save value into eeprom. Am I correct?

Yes, it is like a virtual file in on-chip flash memory (a type of EEPROM).

BR, Jan

1 Like

Thank you for taking the time and sharing this tutorial. It was indeed very helpful and insightful.

1 Like