summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfram Sang <wsa@kernel.org>2021-03-07 06:31:07 +0100
committerWolfram Sang <wsa@kernel.org>2021-03-07 06:31:07 +0100
commit37f5ab8d4e334d89559594ab68f162e5ab3a3bc2 (patch)
tree81293367b7f44a94af37f3e3c15184a4c497c303
parent202054c8bc23492dcec50c30f3d981c584ddaa91 (diff)
downloadi2c-tools-git-37f5ab8d4e334d89559594ab68f162e5ab3a3bc2.tar.gz
eeprom, eepromer: remove the tools
These tools are deprecated for 6 years now because we have better alternatives. They are not built by default. I think it is time we can remove them. Signed-off-by: Wolfram Sang <wsa@kernel.org>
-rw-r--r--CHANGES3
-rw-r--r--README2
-rw-r--r--eepromer/.gitignore2
-rw-r--r--eepromer/Makefile12
-rw-r--r--eepromer/README34
-rw-r--r--eepromer/README.eeprom87
-rw-r--r--eepromer/README.eepromer29
-rw-r--r--eepromer/eeprom.864
-rw-r--r--eepromer/eeprom.c299
-rw-r--r--eepromer/eepromer.861
-rw-r--r--eepromer/eepromer.c723
11 files changed, 4 insertions, 1312 deletions
diff --git a/CHANGES b/CHANGES
index 1809cea..9e8dd02 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
i2c-tools CHANGES
-----------------
+master
+ eeprom, eepromer: removed the tools in favor of eeprog
+
4.2 (2020-09-22)
manpages: Add BUGS section to let people know how to contact us
Makefile: Allow to preset all CFLAGS and LDFLAGS variables
diff --git a/README b/README
index bd96d16..fb7bd03 100644
--- a/README
+++ b/README
@@ -23,7 +23,7 @@ category has its own sub-directory:
scripts rely on the eeprom kernel drivers ("at24" and "ee1004", "eeprom" on
older kernels). They are installed by default.
-* eeprog, eepromer
+* eeprog
Tools for writing to EEPROMs. These tools rely on the "i2c-dev" kernel
driver. They are not installed by default.
diff --git a/eepromer/.gitignore b/eepromer/.gitignore
deleted file mode 100644
index 5f76592..0000000
--- a/eepromer/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/eeprom
-/eepromer
diff --git a/eepromer/Makefile b/eepromer/Makefile
deleted file mode 100644
index b7d38f4..0000000
--- a/eepromer/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-#eepromer Makefile
-
-CFLAGS = -O2 -I../include -Wall
-
-all: eepromer eeprom
-
-eepromer: eepromer.o
-
-eeprom: eeprom.o
-
-clean:
- rm -rf *~ *.o eepromer eeprom
diff --git a/eepromer/README b/eepromer/README
deleted file mode 100644
index 392c266..0000000
--- a/eepromer/README
+++ /dev/null
@@ -1,34 +0,0 @@
-These programs are used to read and write eeproms.
-
-Use eeprom for small eeproms with one-byte addresses:
- 24C01, 24C01A, 24C02, 24C04, 24C08, and 24C16
- It works only on true i2c bus adapters.
- See README.eeprom for details.
- This program is deprecated, please use eeprog instead.
-
-Use eepromer for large eeproms with two-byte addresses:
- 24C32, 24C64, 24C128, 24C256, and 24C512
- It works only on true i2c bus adapters.
- See README.eepromer for details.
- This program is deprecated, please use eeprog instead.
-
-Use eeprog for either small or large eeproms.
- This program was moved to a separate subdirectory.
- Use the -16 switch for large eeproms.
- It works on both i2c and smbus bus adapters.
- See README.eeprog for details.
-
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!!! !
-!!! These programs should only be used on external busses such as i2c-pport !
-!!! unless you REALLY know what you are doing. !
-!!! !
-!!! Your computer probably contains eeproms for saving data vital to its !
-!!! operation. If you are not careful you might overwrite this data with !
-!!! this program and your computer may no longer boot! !
-!!! !
-!!! An example are the EEPROMS on your SDRAM DIMMs, your computer may no !
-!!! longer detect the RAM module rendering it essentially USELESS! !
-!!! !
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
diff --git a/eepromer/README.eeprom b/eepromer/README.eeprom
deleted file mode 100644
index b465d07..0000000
--- a/eepromer/README.eeprom
+++ /dev/null
@@ -1,87 +0,0 @@
-You can use this program to read/write to i2c-eeproms
-like the popular 24C16, 24C08, 24C04,.. In contrast to eeprommer
-which supports 24C256-type eeproms 24C16ss use 1-byte addresses!
-
-This program is deprecated, please use eeprog instead.
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!!! !
-!!! This program should only be used on external busses such as i2c-pport. !
-!!! !
-!!! Your computer may contain i2c-eeproms for saving data vital to its !
-!!! operation. If you are not careful you might overwrite this data with !
-!!! this program and your computer may no longer boot! !
-!!! !
-!!! An example are the EEPROMS on your SDRAM DIMMs, your computer may no !
-!!! longer detect the RAM module rendering it essentially USELESS! !
-!!! !
-!!! IBM Thinkpads are said to store their configuration data in a eeprom, !
-!!! if you manage to overwrite this eeprom you will have to send your !
-!!! computer to the manufacturer for a costly repair! !
-!!! !
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-It has several options:
-
- -d devicenode
-
- set this to the device-node of the i2c-bus
- you want to use like /dev/i2c-0.
- Use /dev/i2c-1 for the second bus, i2c-2 for the third...
-
- The default /dev/i2c-0 should work most of the time.
-
- -a address
-
- set this to the device-address of your
- eeprom. For a 24C16 the address is hardcoded to
- 0x50, which is -you guessed it- the default.
-
- For a 24C08 and smaller types you can choose which
- addresses they occupy by forcing the address-pins
- of the chip to High or Low so here the address may differ.
-
- -p number_of_pages
-
- set this to the number of pages you want to read
- from or write to the eeprom. The 24C16 maps it's
- pages to consecutive addresses on the i2c-bus so
- we will try to read 256 bytes from every i2c
- address between 'address' (inclusive) and
- 'address + number_of_pages' (exclusive)...
-
- A 24C16 has 8 pages so that's the default for this
- parameter.
-
- -f filename
-
- read data from this file (when writing to eeprom) or
- write data to this file (when reading from eeprom).
-
- When reading a file that's smaller than the
- eeprom's storage size we will pad the eeprom
- with zeroes.
-
- If no file is given we will just read the
- eeprom (while in read-mode) and test it's presence
- this way. In write-mode we will just write zeroes
- to the eeprom.
-
- -w When '-w' is present we will *write* to the eeprom.
- If you do not specify '-w' we will read the contents
- of the eeprom.
-
- -y This flag will suppress the warning when you write to the
- eeprom. You will not be required to enter 'yes' so be careful
- when using this switch!
-
-
-I wrote that program to clear a 24C16 eeprom that sit's in my crappy
-satellite receiver because sometimes its Z80 processor likes to
-write garbage to it and then crash....
-
-No further testing besides writing a long series of "The quick brown
-fox jumps over the lazy dog!" and reading it back has been done so
-of course this comes without any warranty.
-
- Chris <chris@hedonism.cx>
diff --git a/eepromer/README.eepromer b/eepromer/README.eepromer
deleted file mode 100644
index 4f0648c..0000000
--- a/eepromer/README.eepromer
+++ /dev/null
@@ -1,29 +0,0 @@
-Simple program for storing data to I2C EEPROM.
-
-This program is deprecated, please use eeprog instead.
-
-!!!!!!!!!!!!!!!!!!!!!!!!Warning!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-The EEPROM must be a large EEPROM which uses a 2-byte address
-field (24C32 or larger). It will NOT WORK on small EEPROMs
-(24C01 - 24C16) such as those used on SDRAM DIMMs.
-
-Tested only on 24C256.
-
-!!!!!!!!!!!!!!!!!!!!!!!!Warning!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-This program is intended for use on eeproms using external busses such as
-i2c-pport.
-Do not use this on your SDRAM DIMM EEPROMS, it won't work!!!!!!!!!
-Doing so will render your SDRAM USELESS and leave your system UNBOOTABLE!!!
-
-!!!!!!!!!!!!!!!!!!!!!!!!Warning!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-Options:
- -r read
- -w write
- -e erase
- -p print "super block of EEPROM" (date and size stored data)
-
-Daniel Smolik
-marvin@sitour.cz
diff --git a/eepromer/eeprom.8 b/eepromer/eeprom.8
deleted file mode 100644
index 0489590..0000000
--- a/eepromer/eeprom.8
+++ /dev/null
@@ -1,64 +0,0 @@
-.\"
-.\" eeprom.8 - manpage for the i2c-tools/eeprom utility
-.\" Copyright (C) 2013 Jaromir Capik
-.\"
-.\" This program is free software; you can redistribute it and/or modify
-.\" it under the terms of the GNU General Public License as published by
-.\" the Free Software Foundation; either version 2 of the License, or
-.\" (at your option) any later version.
-.\"
-.\" This program is distributed in the hope that it will be useful,
-.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
-.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-.\" GNU General Public License for more details.
-.\"
-.\" You should have received a copy of the GNU General Public License along
-.\" with this program; if not, write to the Free Software Foundation, Inc.,
-.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-.\"
-.TH eeprom "8" "Jul 2013" "i2c-tools" "System Administration"
-.SH NAME
-eeprom \- reads and writes 24Cxx EEPROMs connected to I2C serial bus
-.SH SYNOPSIS
-.B eeprom
-[-d dev] [-a addr] [-p pgs] [-w] [-y] [-f file]
-.SH DESCRIPTION
-.B eeprom
-can be used for reading from / writing to I2C EEPROMs like the popular
-24C16, 24C08, 24C04, etc.
-In contrast to
-.B eeprommer
-which supports 24C256-type EEPROMs,
-this tool works with 1-byte addresses!
-.SH NOTES
-Don't forget to load your i2c chipset and the i2c-dev drivers.
-.P
-Pages/addresses:
- EEPROMs with more than 256 bytes appear as if they
- were several EEPROMs with consecutive addresses on the bus
- so we might as well address several separate EEPROMs with
- increasing addresses
-.SH PARAMETERS
-.TP
-.B dev
-device (default /dev/i2c-0)
-.TP
-.B addr
-base address of EEPROM (default 0xA0)
-.TP
-.B pgs
-number of pages to read (default 8)
-.TP
-.B \-w
-write to EEPROM (default is reading!)
-.TP
-.B \-y
-suppress warning when writing (default is to warn!)
-.TP
-.B \-f file
-copy EEPROM contents to/from file (default for read is test only; for write is all zeros)
-.SH SEE ALSO
-.BR eeprog (8),
-.BR eepromer (8)
-.SH AUTHOR
-Christian Vogel
diff --git a/eepromer/eeprom.c b/eepromer/eeprom.c
deleted file mode 100644
index 78f5481..0000000
--- a/eepromer/eeprom.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-This program is hereby placed into the public domain.
-Of course the program is provided without warranty of any kind.
-*/
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <time.h>
-#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
-
-/*
- this program can read 24C16 (and probably smaller ones, too)
- I wrote it as a quick and dirty hack because my satellite receiver
- hung again... so I had to reprogram the eeprom where is stores it's
- settings.
- */
-
-#define DEFAULT_I2C_BUS "/dev/i2c-0"
-#define DEFAULT_EEPROM_ADDR 0x50 /* the 24C16 sits on i2c address 0x50 */
-#define DEFAULT_NUM_PAGES 8 /* we default to a 24C16 eeprom which has 8 pages */
-#define BYTES_PER_PAGE 256 /* one eeprom page is 256 byte */
-#define MAX_BYTES 8 /* max number of bytes to write in one chunk */
- /* ... note: 24C02 and 24C01 only allow 8 bytes to be written in one chunk. *
- * if you are going to write 24C04,8,16 you can change this to 16 */
-
-/* write len bytes (stored in buf) to eeprom at address addr, page-offset offset */
-/* if len=0 (buf may be NULL in this case) you can reposition the eeprom's read-pointer */
-/* return 0 on success, -1 on failure */
-int eeprom_write(int fd,
- unsigned int addr,
- unsigned int offset,
- unsigned char *buf,
- unsigned char len
-){
- struct i2c_rdwr_ioctl_data msg_rdwr;
- struct i2c_msg i2cmsg;
- int i;
- char _buf[MAX_BYTES + 1];
-
- if(len>MAX_BYTES){
- fprintf(stderr,"I can only write MAX_BYTES bytes at a time!\n");
- return -1;
- }
-
- if(len+offset >256){
- fprintf(stderr,"Sorry, len(%d)+offset(%d) > 256 (page boundary)\n",
- len,offset);
- return -1;
- }
-
- _buf[0]=offset; /* _buf[0] is the offset into the eeprom page! */
- for(i=0;i<len;i++) /* copy buf[0..n] -> _buf[1..n+1] */
- _buf[1+i]=buf[i];
-
- msg_rdwr.msgs = &i2cmsg;
- msg_rdwr.nmsgs = 1;
-
- i2cmsg.addr = addr;
- i2cmsg.flags = 0;
- i2cmsg.len = 1+len;
- i2cmsg.buf = _buf;
-
- if((i=ioctl(fd,I2C_RDWR,&msg_rdwr))<0){
- perror("ioctl()");
- fprintf(stderr,"ioctl returned %d\n",i);
- return -1;
- }
-
- if(len>0)
- fprintf(stderr,"Wrote %d bytes to eeprom at 0x%02x, offset %08x\n",
- len,addr,offset);
- else
- fprintf(stderr,"Positioned pointer in eeprom at 0x%02x to offset %08x\n",
- addr,offset);
-
- return 0;
-}
-
-/* read len bytes stored in eeprom at address addr, offset offset in array buf */
-/* return -1 on error, 0 on success */
-int eeprom_read(int fd,
- unsigned int addr,
- unsigned int offset,
- unsigned char *buf,
- unsigned char len
-){
- struct i2c_rdwr_ioctl_data msg_rdwr;
- struct i2c_msg i2cmsg;
- int i;
-
- if(len>MAX_BYTES){
- fprintf(stderr,"I can only write MAX_BYTES bytes at a time!\n");
- return -1;
- }
-
- if(eeprom_write(fd,addr,offset,NULL,0)<0)
- return -1;
-
- msg_rdwr.msgs = &i2cmsg;
- msg_rdwr.nmsgs = 1;
-
- i2cmsg.addr = addr;
- i2cmsg.flags = I2C_M_RD;
- i2cmsg.len = len;
- i2cmsg.buf = buf;
-
- if((i=ioctl(fd,I2C_RDWR,&msg_rdwr))<0){
- perror("ioctl()");
- fprintf(stderr,"ioctl returned %d\n",i);
- return -1;
- }
-
- fprintf(stderr,"Read %d bytes from eeprom at 0x%02x, offset %08x\n",
- len,addr,offset);
-
- return 0;
-}
-
-
-
-int main(int argc, char **argv){
- int i,j;
-
- /* filedescriptor and name of device */
- int d;
- char *dn=DEFAULT_I2C_BUS;
-
- /* filedescriptor and name of data file */
- int f=-1;
- char *fn=NULL;
-
- unsigned int addr=DEFAULT_EEPROM_ADDR;
- int rwmode=0;
- int pages=DEFAULT_NUM_PAGES;
-
- int force=0; /* suppress warning on write! */
-
- while((i=getopt(argc,argv,"d:a:p:wyf:h"))>=0){
- switch(i){
- case 'h':
- fprintf(stderr,"%s [-d dev] [-a adr] [-p pgs] [-w] [-y] [-f file]\n",argv[0]);
- fprintf(stderr,"\tdev: device, e.g. /dev/i2c-0 (def)\n");
- fprintf(stderr,"\tadr: base address of eeprom, eg 0xA0 (def)\n");
- fprintf(stderr,"\tpgs: number of pages to read, eg 8 (def)\n");
- fprintf(stderr,"\t-w : write to eeprom (default is reading!)\n");
- fprintf(stderr,"\t-y : suppress warning when writing (default is to warn!)\n");
- fprintf(stderr,"\t-f file: copy eeprom contents to/from file\n");
- fprintf(stderr,"\t (default for read is test only; for write is all zeros)\n");
- fprintf(stderr,"Note on pages/addresses:\n");
- fprintf(stderr,"\teeproms with more than 256 byte appear as if they\n");
- fprintf(stderr,"\twere several eeproms with consecutive addresses on the bus\n");
- fprintf(stderr,"\tso we might as well address several separate eeproms with\n");
- fprintf(stderr,"\tincreasing addresses....\n\n");
- exit(1);
- break;
- case 'd':
- dn=optarg;
- break;
- case 'a':
- if(sscanf(optarg,"0x%x",&addr)!=1){
- fprintf(stderr,"Cannot parse '%s' as addrs., example: 0xa0\n",
- optarg);
- exit(1);
- }
- break;
- case 'p':
- if(sscanf(optarg,"%d",&pages)!=1){
- fprintf(stderr,"Cannot parse '%s' as number of pages, example: 8\n",
- optarg);
- exit(1);
- }
- break;
- case 'w':
- rwmode++;
- break;
- case 'f':
- fn=optarg;
- break;
- case 'y':
- force++;
- break;
- }
-
- }
-
- fprintf(stderr,"base-address of eeproms : 0x%02x\n",addr);
- fprintf(stderr,"number of pages to read : %d (0x%02x .. 0x%02x)\n",
- pages,addr,addr+pages-1);
-
- if(fn){
- if(!rwmode) /* if we are reading, *WRITE* to file */
- f=open(fn,O_WRONLY|O_CREAT,0666);
- else /* if we are writing to eeprom, *READ* from file */
- f=open(fn,O_RDONLY);
- if(f<0){
- fprintf(stderr,"Could not open data-file %s for reading or writing\n",fn);
- perror(fn);
- exit(1);
- }
- fprintf(stderr,"file opened for %7s : %s\n",rwmode?"reading":"writing",fn);
- fprintf(stderr," on filedescriptor : %d\n",f);
- }
-
- if((d=open(dn,O_RDWR))<0){
- fprintf(stderr,"Could not open i2c at %s\n",dn);
- perror(dn);
- exit(1);
- }
-
- fprintf(stderr,"i2c-devicenode is : %s\n",dn);
- fprintf(stderr," on filedescriptor : %d\n\n",d);
-
- /***
- *** I'm not the one to blame of you screw your computer!
- ***/
- if(rwmode && ! force){
- unsigned char warnbuf[4];
- fprintf(stderr,"**WARNING**\n");
- fprintf(stderr," - \tYou have chosen to WRITE to this eeprom.\n");
- fprintf(stderr,"\tMake sure that this tiny chip is *NOT* vital to the\n");
- fprintf(stderr,"\toperation of your computer as you can easily corrupt\n");
- fprintf(stderr,"\tthe configuration memory of your SDRAM-memory-module,\n");
- fprintf(stderr,"\tyour IBM ThinkPad or whatnot...! Fixing these errors can be\n");
- fprintf(stderr,"\ta time-consuming and very costly process!\n\n");
- fprintf(stderr,"Things to consider:\n");
- fprintf(stderr," - \tYou can have more than one i2c-bus, check in /proc/bus/i2c\n");
- fprintf(stderr,"\tand specify the correct one with -d\n");
- fprintf(stderr,"\tright now you have chosen to use '%s'\n",dn);
- fprintf(stderr," - \tA eeprom can occupy several i2c-addresses (one per page)\n");
- fprintf(stderr,"\tso please make sure that there is no vital eeprom in your computer\n");
- fprintf(stderr,"\tsitting at addresses between 0x%02x and 0x%02x\n",addr,addr+pages-1);
-
- fprintf(stderr,"Enter 'yes' to continue:");
- fflush(stderr);
- if(!fgets(warnbuf,sizeof(warnbuf),stdin)){
- fprintf(stderr,"\nCould not read confirmation from stdin!\n");
- exit(1);
- }
- if(strncmp(warnbuf,"yes",3)){
- fprintf(stderr,"\n** ABORTING WRITE! **, you did not answer 'yes'\n");
- exit(1);
- }
- }
-
- for(i=0;i<pages;i++){
- unsigned char buf[BYTES_PER_PAGE];
-
- if(rwmode){
-
- if(f>=0){
- j=read(f,buf,sizeof(buf));
- if(j<0){
- fprintf(stderr,"Cannot read from file '%s'\n",fn);
- perror(fn);
- exit(1);
- }
- if(j!=sizeof(buf)){
- fprintf(stderr,"File '%s' is too small, padding eeprom with zeroes\n",fn);
- while(j<sizeof(buf))
- buf[j++]=0;
- }
- } else {
- for(j=0;j<sizeof(buf);j++)
- buf[j]=0;
- }
- for(j=0;j<(BYTES_PER_PAGE/MAX_BYTES);j++)
- if(eeprom_write(d,addr+i,j*MAX_BYTES,buf+(j*MAX_BYTES),MAX_BYTES)<0)
- exit(1);
- } else {
- for(j=0;j<(BYTES_PER_PAGE/MAX_BYTES);j++)
- if(eeprom_read(d,addr+i,j*MAX_BYTES,buf+(j*MAX_BYTES),MAX_BYTES)<0)
- exit(1);
- }
-
-
- if(!rwmode && f>=0){
- j=write(f,buf,sizeof(buf));
- if(j!=sizeof(buf)){
- fprintf(stderr,"Cannot write to file '%s'\n",fn);
- perror(fn);
- exit(1);
- }
- }
-
- }
-
- if(f>=0)
- close(f);
-
- close(d);
-
- exit(0);
-
-}
diff --git a/eepromer/eepromer.8 b/eepromer/eepromer.8
deleted file mode 100644
index c3f3239..0000000
--- a/eepromer/eepromer.8
+++ /dev/null
@@ -1,61 +0,0 @@
-.\"
-.\" eeprom.8 - manpage for the i2c-tools/eeprom utility
-.\" Copyright (C) 2013 Jaromir Capik
-.\"
-.\" This program is free software; you can redistribute it and/or modify
-.\" it under the terms of the GNU General Public License as published by
-.\" the Free Software Foundation; either version 2 of the License, or
-.\" (at your option) any later version.
-.\"
-.\" This program is distributed in the hope that it will be useful,
-.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
-.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-.\" GNU General Public License for more details.
-.\"
-.\" You should have received a copy of the GNU General Public License along
-.\" with this program; if not, write to the Free Software Foundation, Inc.,
-.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-.\"
-.TH eepromer "8" "Jul 2013" "i2c-tools" "System Administration"
-.SH NAME
-eepromer \- reads and writes 24Cxx EEPROMs connected to I2C serial bus
-.SH SYNOPSIS
-.B eepromer
-[-r|-w|-e|-p] -f <device> <i2c-addr>
-.SH DESCRIPTION
-The EEPROM must be a large EEPROM which uses a 2-byte address
-field (24C32 or larger). It will NOT WORK on small EEPROMs
-(24C01 - 24C16) such as those used on SDRAM DIMMs.
-.SH NOTES
-Don't forget to load your i2c chipset and the i2c-dev drivers.
-.P
-Tested only on 24C256.
-.P
-.SH PARAMETERS
-.TP
-.I Actions
-.TP
-.B \-r
-Read
-.TP
-.B \-w
-Write
-.TP
-.B \-e
-Erase
-.TP
-.B \-p
-Print header
-.TP
-.I Bus
-.TP
-.B \-f device
-Device file representing the I2C bus (eg. /dev/i2c-0)
-.TP
-.B i2c-addr
-I2C bus address of the EEPROM (eg. 0x3A)
-.SH SEE ALSO
-.BR eeprog (8),
-.BR eeprom (8)
-.SH AUTHOR
-Daniel Smolik
diff --git a/eepromer/eepromer.c b/eepromer/eepromer.c
deleted file mode 100644
index 1536b15..0000000
--- a/eepromer/eepromer.c
+++ /dev/null
@@ -1,723 +0,0 @@
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
-
-
-#define MAX_BLK_SIZE 64
-#define EEPROM_SIZE 32768
-#define READ 1
-#define WRITE 0
-#define ERASE 2
-#define PHEADER 3
-#define VER "eepromer v 0.4 (c) Daniel Smolik 2001\n"
-#define HEAD_SIZE sizeof(struct mini_inode)
-#define START_ADDR 0
-#define FORCE 1
-/*
-To disable startup warning #undef WARNINC
-
-
-*/
-
-#define WARNINC
-
-
-int block_write(int file,int dev_addr,int eeprom_addr,unsigned char *buf,int lenght);int block_write(int file,int dev_addr,int eeprom_addr,unsigned char *buf,int lenght);
-int block_read(int file,int dev_addr,int eeprom_addr,unsigned char *buf);
-
-/* block_read read block 64 bytes length and returns actual length of data*/
-void help(void);
-int init(char *device,int addr);
-int content_write(int file, int addr);
-int content_read(int file, int addr);
-int inode_write(int file, int dev_addr, int lenght);
-int inode_read(int file, int dev_addr, void *p_inode);
-void pheader(int file, int addr);
-void erase(int file,int addr,int eeprom_size);
-void made_address(int addr,unsigned char *buf);
-void warn(void);
-void bar(void);
-
-
-static int stav=0;
-
-
-
-static struct mini_inode {
-
- time_t timestamp;
- int data_len;
- char data[56];
-
- } m_ind,*p_ind;
-
-
-
-void help(void)
-{
- FILE *fptr;
- char s[100];
-
- fprintf(stderr,"Syntax: eepromer [-r|-w|-e|-p] -f /dev/i2c-X ADDRESS \n\n");
- fprintf(stderr," ADDRESS is address of i2c device eg. 0x51\n");
-
- if((fptr = fopen("/proc/bus/i2c", "r"))) {
- fprintf(stderr," Installed I2C busses:\n");
- while(fgets(s, 100, fptr))
- fprintf(stderr, " %s", s);
- fclose(fptr);
- }
-}
-
-
-
-
-
-int main(int argc, char *argv[]){
-
- int i, file, addr;
- int action; //in this variable will be (-r,-w,-e)
- char device[45];
- int force;
-
- p_ind=&m_ind;
- force=0;
-
-
-
-
- for(i=1; i < argc;i++){
-
-
- if(!strcmp("-r",argv[i])) {
- action=READ;
- break;
- }
- if(!strcmp("-e",argv[i])) {
- action=ERASE;
- break;
- }
- if(!strcmp("-w",argv[i])) {
- action=WRITE;
- break;
- }
- if(!strcmp("-p",argv[i])) {
- action=PHEADER;
- break;
- }
- if(!strcmp("-force",argv[i])) {
- force=FORCE;
- break;
- }
- if(!strcmp("-v",argv[i])) {
- fprintf(stderr,VER);
- exit(0);
- break;
- }
- else {
-
- fprintf(stderr,"Error: No action specified !\n");
- help();
- exit(1);
- }
-
- }
-
-
-#ifdef WARNINC
-
- if(force!=FORCE) warn();
-
-#endif
-
-
- if(argc < 5) {
- fprintf(stderr,"Error: No i2c address specified !\n");
- help();
- exit(1);
-
- }
-
-
- for(i=1; i < argc;i++){
-
-
- if(!strcmp("-f",argv[i])) {
- strcpy(device,argv[i+1]);
- break;
- }
-
- }
-
- if(!strlen(device)) {
-
- fprintf(stderr,"Error: No device specified !\n");
- help();
- exit(1);
- }
-
-
- if(! (addr=strtol(argv[4],NULL,16))) {
-
- fprintf(stderr,"Error: Bad device address !\n");
- help();
- exit(1);
- }
-
- if(! (file=init(device,addr))){
-
- fprintf(stderr,"Error: Init failed !\n");
- exit(1);
- }
-
-
- switch(action){
-
- case READ:
- content_read(file,addr);
- break;
-
- case WRITE:
- content_write(file,addr);
- break;
-
- case ERASE: erase(file,addr,EEPROM_SIZE);
- break;
- case PHEADER: pheader(file,addr);
- break;
-
- default:
- fprintf(stderr,"Internal error!\n");
- exit(1); break;
-
- }
-
-
- close(file);
- exit(0);
-
-}
-
-
-
-/****************************************************************************/
-/* Low level function */
-/* */
-/****************************************************************************/
-
-
-
-
-
-int block_write(int file,int dev_addr,int eeprom_addr,unsigned char *buf,int lenght){
-
- unsigned char buff[2];
- struct i2c_msg msg[2];
-
- struct i2c_ioctl_rdwr_data {
-
- struct i2c_msg *msgs; /* ptr to array of simple messages */
- int nmsgs; /* number of messages to exchange */
- } msgst;
-
-
-
- if ( lenght > (MAX_BLK_SIZE) ) {
-
- fprintf(stderr,
- "Error: Block too large:\n");
-
- }
-
-
- //bar();
-
- made_address(eeprom_addr,buff);
-
-
- msg[0].addr = dev_addr;
- msg[0].flags = 0;
- msg[0].len = 2;
- msg[0].buf = buff;
-
-
- msg[1].addr = dev_addr;
- msg[1].flags = I2C_M_NOSTART;
- msg[1].len = lenght;
- msg[1].buf = buf;
-
-
- msgst.msgs = msg;
- msgst.nmsgs = 2;
-
-
- if (ioctl(file,I2C_RDWR,&msgst) < 0){
-
- fprintf(stderr,
- "Error: Transaction failed: %s\n",
- strerror(errno));
-
- return 1;
-
- }
-
- return 0;
-
-}
-
-
-
-
-int block_read(int file,int dev_addr,int eeprom_addr,unsigned char *buf){
-
- int ln;
- char buff[2]; //={0x0,0x0};
-
- struct i2c_msg msg[2];
-
- struct i2c_ioctl_rdwr_data {
-
- struct i2c_msg *msgs; /* ptr to array of simple messages */
- int nmsgs; /* number of messages to exchange */
- } msgst;
-
-
-
- made_address(eeprom_addr,buff);
- ln=0;
- //bar();
-
- msg[0].addr = dev_addr;
- msg[0].flags = 0;
- msg[0].len = 2;
- msg[0].buf = buff;
-
-
- msg[1].addr = dev_addr;
- msg[1].flags = I2C_M_RD;
- msg[1].len = MAX_BLK_SIZE;
- msg[1].buf = buf;
-
-
-
-
- msgst.msgs = msg;
- msgst.nmsgs = 2;
-
-
-
-
- if ((ln = ioctl(file, I2C_RDWR, &msgst)) < 0) {
-
- fprintf(stderr,
- "Error: Read error:%d\n",ln);
- return ln;
- }
-
- return ln;
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-void made_address(int addr,unsigned char *buf){
-
- int k;
-
- //addr = addr & 0xFFFF; /*odstranim nepoterbne bity*/
-
- k=addr;
- buf[1]=(unsigned char) (k & 0xFF); //vyrobim druhy byte adresy
- k=addr & 0xFF00 ;
- buf[0]= ((unsigned char) (k >> 8)) & 0x7F;
-
-
- return;
-}
-
-
-int init(char *device,int addr) {
-
- int file;
- unsigned long funcs;
-
- if ((file = open(device,O_RDWR)) < 0) {
-
- fprintf(stderr,"Error: Could not open file %s\n",
- device);
-
- return 0;
- }
-
-
- /* check adapter functionality */
- if (ioctl(file,I2C_FUNCS,&funcs) < 0) {
- fprintf(stderr,
- "Error: Could not get the adapter functionality matrix: %s\n",
- strerror(errno));
- close(file);
- return 0;
- }
-
- /* The I2C address */
- if (ioctl(file,I2C_SLAVE,addr) < 0) {
- /* ERROR HANDLING; you can check errno to see what went wrong */
- fprintf(stderr,
- "Error: Cannot communicate with slave: %s\n",
- strerror(errno));
-
- close(file);
- return 0;
- }
-
- return file;
-}
-
-
-int content_write(int file, int addr){
-
- unsigned char buf[MAX_BLK_SIZE];
- unsigned char pom;
- int i, j, k, delka, addr_cnt;
-
- delka=0;
- addr_cnt=HEAD_SIZE;
- k=0;
-
- for(j=0;j<MAX_BLK_SIZE;j++)
- buf[j]=0;
-
-
-
- i=0;
-
- for(;;) {
-
- delka=fread(&pom,1,1,stdin);
-
- if( delka > 0 ){
- buf[i]=pom;
- }
-
- if(i==(MAX_BLK_SIZE-1) || (delka < 1)) {
-
-
-
- if(block_write(file,addr,addr_cnt,buf,delka<1?i:(i+1)) !=0) {
-
- fprintf(stderr,"Block write failed\n");
- return 1;
-
- }
- //printf("i:%d\n",i);
- addr_cnt=addr_cnt + i + (delka==1?1:0); //+i
-
- for(j=0;j<MAX_BLK_SIZE;j++)
- buf[j]=0;
-
- i=0;
- if(delka<1) {
-
- //pisu EOF
-
-
- if(inode_write(file,addr,(addr_cnt-HEAD_SIZE)) !=0) {
-
- fprintf(stderr,"Inode write failed\n");
- return 1;
-
- }
- break;
- }
-
-
- } else i++;
-
- }
-
- return 0;
-
-}
-
-
-int content_read(int file, int addr){
-
- unsigned char buf[MAX_BLK_SIZE];
- int i, j, k, delka;
-
- delka=0;
- k=0;
-
-
- inode_read(file,addr,p_ind );
-
-
- for(i=HEAD_SIZE;i<= (HEAD_SIZE + p_ind->data_len);i=i+MAX_BLK_SIZE ) {
-
-
- if(block_read(file,addr,i,buf) !=0) {
-
- fprintf(stderr,"Block read failed\n");
- return 1;
-
- }
-
- if( (HEAD_SIZE + p_ind->data_len - i) < MAX_BLK_SIZE ) {
- k= HEAD_SIZE + p_ind->data_len - i;
- }else {
- k=MAX_BLK_SIZE;
- }
-
-
- for(j=0;j<k ;j++){
-
- putc(buf[j],stdout);
-
- }
-
-
- }
-
- return 0;
-
-}
-
-
-
-void erase(int file, int addr,int eeprom_size){
-
- unsigned char buf[MAX_BLK_SIZE];
- int i, j, k, delka;
-
- delka=0;
- k=0;
-
- for(j=0;j<MAX_BLK_SIZE;j++)
- buf[j]=0;
-
-
-
-
-
- for(i=0;i<eeprom_size;i=i+MAX_BLK_SIZE) {
-
-
- if(block_write(file,addr,i,buf,MAX_BLK_SIZE) !=0) {
-
- fprintf(stderr,"Block write failed\n");
- return;
-
- }
-
- }
-
- return;
-
-}
-
-
-
-void bar(void){
-
-
- if( stav > 70 ) stav=0;
-
-
- switch(stav) {
-
-
- case 10: fwrite("\\",1,1,stderr);
- fflush(stderr);
- rewind(stderr);
- break;
- case 20: fwrite("|",1,1,stderr);
- fflush(stderr);
- rewind(stderr);
- break;
- case 30: fwrite("/",1,1,stderr);
- fflush(stderr);
- rewind(stderr);
- break;
- case 40: fwrite("-",1,1,stderr);
- fflush(stderr);
- rewind(stderr);
- break;
- case 50: fwrite("\\",1,1,stderr);
- fflush(stderr);
- rewind(stderr);
- break;
- case 60: fwrite("|",1,1,stderr);
- fflush(stderr);
- rewind(stderr);
- break;
- case 70: fwrite("/",1,1,stderr);
- fflush(stderr);
- rewind(stderr);
- break;
- }
- stav++;
-
-}
-
-
-
-
-
-int inode_write(int file,int dev_addr,int lenght){
-
- unsigned char buff[2];
- struct i2c_msg msg[2];
-
- struct i2c_ioctl_rdwr_data {
-
- struct i2c_msg *msgs; /* ptr to array of simple messages */
- int nmsgs; /* number of messages to exchange */
- } msgst;
-
-
- m_ind.timestamp=time(NULL);
- m_ind.data_len=lenght;
-
-
-
-
-
- //bar();
-
- made_address(START_ADDR,buff);
-
-
- msg[0].addr = dev_addr;
- msg[0].flags = 0;
- msg[0].len = 2;
- msg[0].buf = buff;
-
-
- msg[1].addr = dev_addr;
- msg[1].flags = I2C_M_NOSTART;
- msg[1].len = sizeof(struct mini_inode);
- msg[1].buf = (char *) &m_ind;
-
-
-
- msgst.msgs = msg;
- msgst.nmsgs = 2;
-
-
- if (ioctl(file,I2C_RDWR,&msgst) < 0){
-
- fprintf(stderr,
- "Error: Transaction failed: %s\n",
- strerror(errno));
-
- return 1;
-
- }
-
- return 0;
-
-}
-
-
-
-int inode_read(int file,int dev_addr,void *p_inode ){
-
-
- #define POK 32
- int ln;
- char buff[2]; //={0x0,0x0};
-
- struct i2c_msg msg[2];
-
- struct i2c_ioctl_rdwr_data {
-
- struct i2c_msg *msgs; /* ptr to array of simple messages */
- int nmsgs; /* number of messages to exchange */
- } msgst;
-
- made_address(START_ADDR,buff);
-
- ln=0;
- //bar();
-
- msg[0].addr = dev_addr;
- msg[0].flags = 0;
- msg[0].len = 2;
- msg[0].buf = buff;
-
-
- msg[1].addr = dev_addr;
- msg[1].flags = I2C_M_RD;
- msg[1].len = sizeof(struct mini_inode);
- msg[1].buf = p_inode;
-
-
-
-
- msgst.msgs = msg;
- msgst.nmsgs = 2;
-
-
- if ((ln = ioctl(file, I2C_RDWR, &msgst)) < 0) {
-
- fprintf(stderr,
- "Error: Read error:%d\n",ln);
- return ln;
- }
-
-
-
- return ln;
-
-}
-
-
-void pheader(int file,int dev_addr){
-
- struct tm *p_tm;
- char time_buf[15],*p_buf;
-
- p_buf=time_buf;
- inode_read(file,dev_addr,p_ind );
- p_tm=localtime(&p_ind->timestamp);
- strftime(p_buf,sizeof(time_buf),"%Y%m%d%H%M%S",p_tm);
- printf("LEN=%d,TIME=%s\n",p_ind->data_len,p_buf);
- return;
-}
-
-
-
-
-#ifdef WARNINC
-void warn(void)
-{
-
- fprintf(stderr,"\n\n!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!\n");
- fprintf(stderr,"This program is intended for use on eeproms\nusing external busses such as i2c-pport.\n");
- fprintf(stderr,"Do not use this on your SDRAM DIMM EEPROMS\nunless you REALLY REALLY know what you are\ndoing!!! Doing so will render your SDRAM\nUSELESS and leave your system UNBOOTABLE!!!\n");
- fprintf(stderr,"To disable this warning use -force\n");
- fprintf(stderr,"\n\nPress ENTER to continue or hit Control-C NOW !!!!\n\n\n");
-
- getchar();
-}
-#endif