Updating password stored on MCU flash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-10 01:15 AM
Hi All,
​
I have a situation where I would like to allow STM32H7 based embedded web server users to update the password which is originally hardcoded in the code using const keyword. Which effectively means password is placed in internal flash memory of the microcontroller.
I can remove const but question is that:
​
Is there any way to update password run time which is available on next power cycle without using anything external to STM32H7 microcontroller?
​
I​ am using STM32H747 MCU and IAR embedded workbench environment for development. Currently using the Nucleo board.
The application is a embedded web server while browser is the client where user logs in to the device to change settings etc. ​.
​
I did come across some articles which did say it is possible to update password stored on flash of MCU’S but didn't give much detail about how to do it in a way once device switched off and back ON the updated password is still available or next login will require new password.
Thanks in advance
Regards
A Maq​
Solved! Go to Solution.
- Labels:
-
Flash
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-10 03:06 AM
> Is there any way to update password run time which is available on next power cycle without using anything external to STM32H7 microcontroller?
​You'd need to program it into FLASH, read the FLASH chapter in RM. As long as the number of password reprogramming can be limited, you can simply reserve some space for them in FLASH (taking into account the programming granularity); otherwise you would need also to erase a sector, with all its problems (it takes relatively long time, sectors are large).
If you have a backup battery connected to VBAT, you can conveniently store the password in the backup SRAM.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-10 03:06 AM
> Is there any way to update password run time which is available on next power cycle without using anything external to STM32H7 microcontroller?
​You'd need to program it into FLASH, read the FLASH chapter in RM. As long as the number of password reprogramming can be limited, you can simply reserve some space for them in FLASH (taking into account the programming granularity); otherwise you would need also to erase a sector, with all its problems (it takes relatively long time, sectors are large).
If you have a backup battery connected to VBAT, you can conveniently store the password in the backup SRAM.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-10 03:15 AM
There is a HAL flash API for accessing the flash. Note that writing a new value implies an erase plus a program operation which work on larger chunks of flash memory, not individual variables. Typically, one sets aside few pages of flash memory for such a purpose and works with raw memory adresses, compiler/linker pragmas etc.. There is also an EEPROM emulation library which might be helpful.
hth
KnarfB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-10 12:21 PM
Thanks for response. Can you please share any example code which describes how to do it?​