Close

CSV file / memory changes

A project log for Hardware 2FA TOTP authenticator

Small USB 2FA authenticator for up to 32 profiles

itzandroidtabitzandroidtab 03/24/2024 at 21:070 Comments

CSV file

When a error is detected in the CSV file there was no way for the user to see what was wrong in a specific profile. To make this clear I added messages that are displayed when parsing the CSV file. These are displayed in every path except for unchanged entries. Currently the following messages are displayed:

* Profile added

* Profile deleted

* Invalid profile name error

* Invalid interval input error (seperate error for out of range and for invalid characters)

* Invalid digits input error (seperate error for out of range and for invalid characters)

* Invalid profile key error

* Error to signal there is no more space for new profiles

All these messages are shown in the configuration screen and can be cleared by short pressing the enter button. To clear all messages and go back to the settings screen, long press the enter button.

Adding a profile
Removing a profile
Example of a error message

Memory

To make space for these new messages I reduced the stack size to 0x1000 (was 0x4000). I did a few tests to make sure the authenticator would not run out of memory. To detect if the authenticator ever runs out of memory I added a hardfault handler that will be called when a error is detected. This handler displays the error and a message where to report errors if they keep occuring (the hardfault handler reinitializes all the required hardware and directly writes the pixels to the display. This is done to ensure that we do not trigger DMA interrupts, it also reduces the amount of memory used in the hardfault handler).

Error screen of the hardfault handler (simulated by decreasing the stack size until a harrdfault occurred)

With all these new features the current usage the authenticator should be able to run on any LPC175x with more than 20.6k of ram and more than 103.5k of flash. 

Current usage on a release build with LTO enabled (LTO decreased flash usage by around 1.5k):
Build logs including these statistics can be found here

Discussions