From 7c6c0d3b3c103417113a3e352a95167ca847c27f Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 12 Feb 2014 17:08:29 +0100 Subject: [PATCH] Add some contrib scripts to show different uses of eeprog --- contrib/dump_24LC08B.sh | 21 +++++++++++++++++++++ contrib/dump_24LC16.sh | 21 +++++++++++++++++++++ contrib/dump_24LC64.sh | 14 ++++++++++++++ contrib/write_24LC08B.sh | 21 +++++++++++++++++++++ contrib/write_24LC16.sh | 21 +++++++++++++++++++++ contrib/write_24LC64.sh | 12 ++++++++++++ 6 files changed, 110 insertions(+) create mode 100755 contrib/dump_24LC08B.sh create mode 100755 contrib/dump_24LC16.sh create mode 100755 contrib/dump_24LC64.sh create mode 100755 contrib/write_24LC08B.sh create mode 100755 contrib/write_24LC16.sh create mode 100755 contrib/write_24LC64.sh diff --git a/contrib/dump_24LC08B.sh b/contrib/dump_24LC08B.sh new file mode 100755 index 0000000..0374d14 --- /dev/null +++ b/contrib/dump_24LC08B.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +I2C_DEVICE=/dev/i2c-1 + +START_ADDRESS=0x50 +PAGE_SIZE=256 +NUM_PAGES=4 + +OUTPUT_FILE=OUTPUT_24C08B.bin + +PAGES=$(seq 0 $((NUM_PAGES - 1))) + +rm -rf "$OUTPUT_FILE" + +for i in $PAGES; +do + ADDRESS=$(($START_ADDRESS + $i)) + sudo eeprog -f -r 0:$PAGE_SIZE $I2C_DEVICE $ADDRESS >> $OUTPUT_FILE +done diff --git a/contrib/dump_24LC16.sh b/contrib/dump_24LC16.sh new file mode 100755 index 0000000..bb3aa80 --- /dev/null +++ b/contrib/dump_24LC16.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +I2C_DEVICE=/dev/i2c-1 + +START_ADDRESS=0x50 +PAGE_SIZE=256 +NUM_PAGES=8 + +OUTPUT_FILE=OUTPUT_24C16.bin + +PAGES=$(seq 0 $((NUM_PAGES - 1))) + +rm -rf "$OUTPUT_FILE" + +for i in $PAGES; +do + ADDRESS=$(($START_ADDRESS + $i)) + sudo eeprog -f -r 0:$PAGE_SIZE $I2C_DEVICE $ADDRESS >> $OUTPUT_FILE +done diff --git a/contrib/dump_24LC64.sh b/contrib/dump_24LC64.sh new file mode 100755 index 0000000..cf5b36b --- /dev/null +++ b/contrib/dump_24LC64.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +I2C_DEVICE=/dev/i2c-1 + +START_ADDRESS=0x50 +BYTES=8192 + +OUTPUT_FILE=OUTPUT_24C64.bin + +rm -rf "$OUTPUT_FILE" + +sudo eeprog -f -16 -r 0:$BYTES $I2C_DEVICE $ADDRESS >> $OUTPUT_FILE diff --git a/contrib/write_24LC08B.sh b/contrib/write_24LC08B.sh new file mode 100755 index 0000000..31fd1e5 --- /dev/null +++ b/contrib/write_24LC08B.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +I2C_DEVICE=/dev/i2c-1 + +START_ADDRESS=0x50 +PAGE_SIZE=256 +NUM_PAGES=4 + +INPUT_FILE=INPUT_24C08B.bin + +PAGES=$(seq 0 $((NUM_PAGES - 1))) + +for i in $PAGES; +do + ADDRESS=$(($START_ADDRESS + $i)) + OFFSET=$(($PAGE_SIZE * $i)) + dd if=$INPUT_FILE bs=1 skip=$OFFSET count=$PAGE_SIZE | \ + sudo eeprog -f -w 0 $I2C_DEVICE $ADDRESS +done diff --git a/contrib/write_24LC16.sh b/contrib/write_24LC16.sh new file mode 100755 index 0000000..fe59c2e --- /dev/null +++ b/contrib/write_24LC16.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +I2C_DEVICE=/dev/i2c-1 + +START_ADDRESS=0x50 +PAGE_SIZE=256 +NUM_PAGES=8 + +INPUT_FILE=INPUT_24C16.bin + +PAGES=$(seq 0 $((NUM_PAGES - 1))) + +for i in $PAGES; +do + ADDRESS=$(($START_ADDRESS + $i)) + OFFSET=$(($PAGE_SIZE * $i)) + dd if=$INPUT_FILE bs=1 skip=$OFFSET count=$PAGE_SIZE | \ + sudo eeprog -f -w 0 $I2C_DEVICE $ADDRESS +done diff --git a/contrib/write_24LC64.sh b/contrib/write_24LC64.sh new file mode 100755 index 0000000..315da54 --- /dev/null +++ b/contrib/write_24LC64.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +I2C_DEVICE=/dev/i2c-1 + +START_ADDRESS=0x50 +BYTES=8192 + +INPUT_FILE=INPUT_24C16.bin + +cat "$INPUT_FILE" | sudo eeprog -f -16 -w 0 $I2C_DEVICE $ADDRESS