[En-Nut-Discussion] NutLoadConfig, NutSaveConfig

Klaus Kloos klaus.kloos at gmx.de
Sat Nov 5 12:01:47 CET 2011


Hello

I stumbled over Loading/Saving the configuration.
On my system (sam7Xek, ethernut 4.10) the saved net-configuration was never used at startup because the magic was never written and so the configuration was reset every time.
If found the comment on NutSaveConfig()
* Since Nut/OS version 4.7.5, this routine is no longer called automatically 
 * during system initialization. Thus, if NutLoadConfig() fails, then the 
 * non-volatile memory remains invalid and NutLoadConfig() will again fail 
 * during the next system start.
But how to use it correctly?
For me, the result of NutLoadConfig() indicates that the config in flash is ok or not. After creating a new configuration, saving this to flash makes sense to me.
Something like
    if (NutLoadConfig()!=0){
    	NutSaveConfig();
    }
in NutIdle. This way magic is set correctly (and NutNetSaveConfig() will work).
But I guess this was the old version before 4.7.5.....

On the other hand, it has to be checked that magic is valid every time a part of the configuration is written to flash (as in NutNetSaveConfig()) to make sure this setting is used at startup.

Do I have missed something?
Thanks and greetings
Klaus








More information about the En-Nut-Discussion mailing list