How to read newly added nvram variables once kernel is loaded ?

I need to add new variables to nvram in ‘Digi connect ME 9210’. I can add it but was unable to find a way to read it back once the kernel is loaded.

I believe that nvram utility is not built as part of the kernel. Also in general if we add new parameters to the nvram through the uboot bootloaded then is there any other way other than nvram utility as to how i can read them back once the kernel is loaded.

If nvram utility is the only way then where do I find the code for nvram utility. The current utility allows me to read only the predefined nvram variables so i will have to modify the nvram utility to read the new variables that i add?

Thanks
Sanju

use ubootenv command in linux kernel commandline for accessing nvram variables.

To read nvram from command line, check the examples in /etc/init.d/S40networking.sh /etc/init.d/S95runapp.sh /etc/network/if-up.d/ifup

If you want to read the from C source code, the API is documented only in source code:
DEL59-DVD/toolchain/del_toolchain/packages/ubootenv/
it uses
DEL59-DVD/toolchain/del_toolchain/nvram/
and
DEL59-DVD/toolchain/del_toolchain/libdigi/

How to compile the source code on your own (for modifications):

  • copy the toolchain from DVD to your local host:

    cp -r DEL59-DVD/toolchain .

    cd toolchain

    export TOOLCHAIN_DIR=/usr/local/DigiEL-5.9/x-tools/arm-unknown-linux-gnueabi

    export POOLWWW=file://pwd/packages

    cd del_toolchain/packages

    cd libdigi; make

    cd …/nvram; cp SOMEFOLDER/nvram-Makefile Makefile; make

    cd …/ubootenv

    cp SOMEFOLDER/ubootenv-Makefile.in Makefile.in

    cp SOMEFOLDER/cgi_env.c src

    where SOMEFOLDER is where you extraced this application example source code

    make

    copy target/ubootenv.cgi into your rootfs /usr/share/www/cgi-bin
    copy stylesheet.csss into your rootfs /usr/share/www
    Make NVRAM /dev/mdt1 read+writable for CGI script (see above)
    You might want to modify the source code src/cgi_env.c
    See src/.[ch] and …/nvram/src/.[ch] for example source code

here an example:

#include /* printf() getchar() EOS /
#include /
strncmp() */
#include // EXIT_FAILURE

#include /* uname(&struct utsname) */

#include “nvram.h” /* Nv* */

struct nv_critical *crit;
nv_param_ip_t *ip_params;
char ipaddr[IP_STRING_SIZE+1] = “192.168.42.30”;
char serverip[IP_STRING_SIZE+1] = “192.168.42.1”;

if (!NvInit(NVR_AUTO)) exit(-1);
if (!NvCriticalGet( &crit ) ) exit(-2);
ip_params = &crit->s.p.xIP;
strncpy(ipaddr, NvToStringIP(ip_params->axDevice[0].uiIP), sizeof(ipaddr));
strncpy(serverip, NvToStringIP(ip_params->uiIPServer), sizeof(serverip));