[En-Nut-Discussion] NutNvMemSave overwrites other data
Stefan Profanter
enut at s.profanter.me
Tue Aug 2 02:51:12 CEST 2011
Hi,
i'm having problems with Nonvolatile memory.
The following situation:
I use http to change the ip address of the ethernut. If i press "send" on
the html form, a cgi function is called.
This cgi function parses the values an then calls:
saved = (NutNetSaveConfig()==0);
log_debug("------- After SaveConfig %d", saved);
NvMemDebugOutput(0,300); //Prints out a ,memory dump' from address 0 to
address 300
But it seems, that NutNetSaveConfig(); (which returns 0 for success)
overwrites the whole other stuff in the nonvolatile memory (eg. CONFBOOT).
Because the debug output is:
------------------------------------------------------
DEBUG: ------- After SaveConfig 1
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: 20 65 74 68 30 00 00 00 00 00 00 06 98 30 04 3E
DEBUG: C0 A8 01 0F FF FF FF 00 C0 A8 01 01 C0 A8 01 0F
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF -> BootConf is
missing which shoud begin here
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF
------------------------------------------------------
But if I make a debug output before writing, everything works fine:
log_debug("------- Before SaveConfig");
NvMemDebugOutput(0,300); //Prints out a ,memory dump' from address 0 to
address 300
saved = (NutNetSaveConfig()==0);
log_debug("------- After SaveConfig %d", saved);
NvMemDebugOutput(0,300); //Prints out a ,memory dump' from address 0 to
address 300
The Debug output is:
------------------------------------------------------
DEBUG: ------- Before SaveConfig
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: 20 65 74 68 30 00 00 00 00 00 00 06 98 30 04 3E
DEBUG: C0 A8 01 0F FF FF FF 00 C0 A8 01 01 C0 A8 01 0F
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: 40 00 C0 A8 01 1E 68 6F 6D 65 61 75 74 6F 2E 62 -> BootConf is
here before Saving
DEBUG: 69 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DEBUG: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DEBUG: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: 14 FF FF FF C0 A8 01 01 82 95 11 15 00 00 00 00 -> Adress 256:
Here are some other settings which are also overwritten
DEBUG: 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF
DEBUG: ------- After SaveConfig 1
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: 20 65 74 68 30 00 00 00 00 00 00 06 98 30 04 3E
DEBUG: C0 A8 01 0F FF FF FF 00 C0 A8 01 01 C0 A8 01 0F
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: 40 00 C0 A8 01 1E 68 6F 6D 65 61 75 74 6F 2E 62 -> BootConf is
here also after Saving
DEBUG: 69 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DEBUG: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DEBUG: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: 14 FF FF FF C0 A8 01 01 82 95 11 15 00 00 00 00 -> Adress 256:
These settings are also here
DEBUG: 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF
DEBUG: FF FF FF FF FF FF FF FF
------------------------------------------------------
Where may be the problem?? Is there a special timing for accessing
nonvolatile memory?
It seems that this problem only occurs if I call NutNetSaveConfig in the
httpd thread. Using the same code in the main loop without prior reading
works fine.
This problem occurs also with a custom Saving function which calls directly
NutNvMemSave (eg writing the settings at address 256).
Thanks for your help!!
Stefan
More information about the En-Nut-Discussion
mailing list