Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Created March 1, 2018 17:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpavlik/a85b3580590702764d14cab3bdc44a98 to your computer and use it in GitHub Desktop.
Save rpavlik/a85b3580590702764d14cab3bdc44a98 to your computer and use it in GitHub Desktop.
Reading 24xx i2c eeprom using rpi or other linux board
# Make sure you have i2c-dev loaded and set up for whatever interface you're using
# This is the right one for the default rpi interface.
cd /sys/class/i2c-adapter/i2c-1/
# Instantiate a new device at runtime
# use the right generic chip name (24cSOMETHING) - don't screw this up! see
# table at https://elixir.bootlin.com/linux/v4.14.18/source/drivers/misc/eeprom/at24.c#L136
# description further up at https://elixir.bootlin.com/linux/v4.14.18/source/drivers/misc/eeprom/at24.c#L30
# and info about what this command actually does at
# https://elixir.bootlin.com/linux/v4.14.18/source/Documentation/i2c/instantiating-devices#L207
echo 24c16 0x50 | sudo tee new_device
# Do the actual reading - see https://elixir.bootlin.com/linux/v4.14.18/source/Documentation/nvmem/nvmem.txt
sudo cat /sys/bus/nvmem/devices/1-00500/nvmem > ~/whatever.bin
# Alternately to just look at it...
sudo hexdump /sys/bus/nvmem/devices/1-00500/nvmem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment