ts-7000
[Top] [All Lists]

[ts-7000] Using NVRAM on TS7250

To:
Subject: [ts-7000] Using NVRAM on TS7250
From: "naturalwatt" <>
Date: Fri, 22 Dec 2006 14:25:58 -0000
Hi.  Some time ago I asked if there was a way of writing to Flash when a system 
was being 
powered down.  The replies convinced me to not even thinking about this as it 
was likely 
to lead to filesystem corruption.  Someone suggested usng the TS- NVRAM board, 
but I 
only needed to store a single timestamp of 8 bytes.

In discussion with Eddie, it looks like the right thing to do is use the 114 
NVRAM bytes 
available in the RTC - assuming you have one.  It so happens I do.

In order to access the NVRAM, you need the NVRAM driver. You can either compile 
the full 
kernel with the CONFIG_NVRAM=y or create a loadable module.  To do this, 

make ts7520_config
make old_config

to get the basic config there.  Then edit .config (carefully reading all the 
instructions 
telling you not to do this) and change
# CONFIG_NVRAM not set
to
CONFIG_NVRAM=m

note the m, for module.

Then run "make modules".  You certainly don't need to build the whole kernel.  
Unless you 
want to.

This will have created drivers/char/nvram.o. Copy this to the 7250 into
/lib/modules/2.4.26-ts11/kernel/drivers/char/nvram.o
It's md5sum is 031a3c521b089919e5fd7ded72e8f7a1 and size is 9488.

I am more than happy to post this somewhere if there is a good place to do so.

To load it, simply run insmod nvram.  You will have to do something to make 
sure this 
module is loaded at evey power up; I put a script and link in /etc/init.d

This will create /dev/misc/nvram, a character file you can read and write. 
Except that you 
can't until the checksum is initialised!  Until you do this, any access will 
give error 5, 
Input/Out Error.

In order to initialise the checksum you need to use a special IOCTL on this 
device. It only 
ever has to be done once, as the entire point of this RAM is that it is 
non-volatile.

Here is a small program to do this.  I can also post the source and a compiled 
version, if 
people are interested.

nvraminit.c

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/nvram.h>

int main (int argc, const char * argv[]) {
        int fd;
        if (fd = open("/dev/misc/nvram", O_RDWR) < 0) {
                fprintf(stderr, "Open of /dev/misc/nvram failed %d %s\n", 
errno, strerror(errno));
                exit(errno);
        }
        
        if (ioctl(fd, NVRAM_INIT, 0) < 0) {
                fprintf(stderr, "Init ioctl failed %d %s\n", errno, 
strerror(errno));
                exit(errno);
        }
        close(fd);
    return 0;
}

Hope this helps.  I expect a similar approach will work on any TS system, not 
just a TS250.

Martin







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU