[En-Nut-Discussion] NutLoadConfig, NutSaveConfig

Ulrich Prinz ulrich.prinz at googlemail.com
Sun Nov 6 00:43:02 CET 2011

Hi Klaus,

For most applications the NuConfig is not needed. It is more an example
of how you could save your configuration.

The problem is, that the place, where to save the configuuration,
depends highly on the board you're using. Some provide internal FLASH of
the CPU,  others have serial FLASH or EEPROM on SPI or I2C.

Second problem I see with this NutConfig thing is that it is provided in
NutOS itself. So if you need to save your own data, you need to modify
the system itself. That will make troubles if you the like to provide
patches and fixes as you need to filter out these special things only
valid for your board.

A third thing is, that I myself don't like to use a simple token to show
if a configuration is valid or not. I prefer at least a simple CRC to be
build of the config section and written at it's end.

On the other hand, I like the easy way of configuring the config section...
In a project I simply appended my config to the Nut/OS config, by taking
the tokens address plus the size of the config struct as my address. But
you need to know, that the network setup is appended after the config too.

I already thought about modifying the driver to provide a void* and a
size, so you can just link in your own configuration in an easy way.

> 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.....

For the reasons told above this is not a good idea. It will work on all
the boards supported by Nut/OS out of the box but will fail if you try
to match the things to a foreign board.
And I learned that it could give you a headache if you port a new CPU
family where FLASH, I2C or SPI drivers are still unstable.

Ah, don't forget, that writing your own config struct to a NVmem is
still easy in NutOS. Just init one of the busses, a memory and write
that struct. Ready you are.

Best regards

More information about the En-Nut-Discussion mailing list