Kampi
Posts: 66
Joined: Sun Oct 07, 2012 12:05 am
Location: Monheim, Germany
Contact: Website

HAT EEPROM

Tue Apr 07, 2015 8:17 am

Hello Guys,

I´m testing a little bit with a HAT EEPROM for my Raspberry Pi. In this case I have ordered some 24c32 EEPROMs and connect one of it with the EEDATA and EECLOCK Pins of my Raspberry Pi v2.
After that I build a small device tree (just for testing):

Code: Select all

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

    fragment@0 
   {
        target = <&i2c1>;
        __overlay__ 
      {
         rtc@68 
         {
            status = "RTC";
         };
        };
    };
};
Now I compile it:

Code: Select all

dtc -@ -I dts -O dtb -o /Programme/RTC_Hat/RTC.dtb /Programme/RTC_Hat/RTC.dts
After the compiling I have created a "RTC.txt" file:

Code: Select all

########################################################################
# EEPROM settings text file
#
# Edit this file for your particular board and run through eepmake tool,
# then use eepflash tool to write to attached HAT ID EEPROM 
#
# Tools available:
#  eepmake   Parses EEPROM text file and creates binary .eep file
#  eepdump   Dumps a binary .eep file as human readable text (for debug)
#  eepflash  Write or read .eep binary image to/from HAT EEPROM
#
########################################################################

########################################################################
# Vendor info

# 128 bit UUID. If left at zero eepmake tool will auto-generate
# RFC 4122 compliant UUID
product_uuid 00000000-0000-0000-0000-000000000000

# 16 bit product id
product_id 0x0000

# 16 bit product version
product_ver 0x0000

# ASCII vendor string  (max 255 characters)
vendor "kampis-elektroecke

# ASCII product string (max 255 characters)
product "RTC Hat"

########################################################################
# GPIO bank settings, set to nonzero to change from the default.
# NOTE these setting can only be set per BANK, uncommenting any of
# these will force the bank to use the custom setting.

# drive strength, 0=default, 1-8=2,4,6,8,10,12,14,16mA, 9-15=reserved
gpio_drive 0

# 0=default, 1=slew rate limiting, 2=no slew limiting, 3=reserved
gpio_slew 0

# 0=default, 1=hysteresis disabled, 2=hysteresis enabled, 3=reserved
gpio_hysteresis 0

# If board back-powers Pi via 5V GPIO header pins:
# 0 = board does not back-power
# 1 = board back-powers and can supply the Pi with a minimum of 1.3A
# 2 = board back-powers and can supply the Pi with a minimum of 2A
# 3 = reserved
# If back_power=2 then USB high current mode will be automatically 
# enabled on the Pi
back_power 0

########################################################################
# GPIO pins, uncomment for GPIOs used on board
# Options for FUNCTION: INPUT, OUTPUT, ALT0-ALT5
# Options for PULL: DEFAULT, UP, DOWN, NONE
# NB GPIO0 and GPIO1 are reserved for ID EEPROM so cannot be set

#         GPIO  FUNCTION  PULL
#         ----  --------  ----
#setgpio  2     INPUT     DEFAULT
#setgpio  3     INPUT     DEFAULT
#setgpio  4     INPUT     DEFAULT
#setgpio  5     INPUT     DEFAULT
#setgpio  6     INPUT     DEFAULT
#setgpio  7     INPUT     DEFAULT
#setgpio  8     INPUT     DEFAULT
#setgpio  9     INPUT     DEFAULT
#setgpio  10    INPUT     DEFAULT
#setgpio  11    INPUT     DEFAULT
#setgpio  12    INPUT     DEFAULT
#setgpio  13    INPUT     DEFAULT
#setgpio  14    INPUT     DEFAULT
#setgpio  15    INPUT     DEFAULT
#setgpio  16    INPUT     DEFAULT
#setgpio  17    INPUT     DEFAULT
#setgpio  18    INPUT     DEFAULT
#setgpio  19    INPUT     DEFAULT
#setgpio  20    INPUT     DEFAULT
#setgpio  21    INPUT     DEFAULT
#setgpio  22    INPUT     DEFAULT
#setgpio  23    INPUT     DEFAULT
#setgpio  24    INPUT     DEFAULT
#setgpio  25    INPUT     DEFAULT
#setgpio  26    INPUT     DEFAULT
#setgpio  27    INPUT     DEFAULT
Then I flashed both files into my EEPROM, using the official software from git:

Code: Select all

/Programme/eepmake /Programme/RTC_Hat/RTC.txt /Programme/RTC_Hat/RTC.dtb /Programme/RTC_Hat/RTC.eep
/Programme/eepflash.sh -w -f=/Programme/RTC_Hat/RTC.eep -t=24c32
After that I activate I²C in my /boot/config.txt

Code: Select all

dtparam=i2c_arm=on
dtparam=i2c_vc=on
In the last step I reboot my Raspberry Pi.
After that reboot I should found a "RTC" Device unter my I2C1 I think, but I don´t see anything when I use "ls /proc/device-tree/soc/i2c@7e804000/"
What is wrong and why he doesn´t load the Overlay from the EEPROM?

Thank you for help!
Meine Homepage:

www.Kampis-Elektroecke.de

martinlbb
Posts: 4
Joined: Thu Jun 20, 2013 3:32 pm

Re: HAT EEPROM

Fri Apr 10, 2015 4:40 pm

Mmmm, everyone is playing right now with hats :)

Just a dumb question: did you try you dtd file before?

You make a dtd overlay, and parse it to kernel, using dtoverlay=myname
At boot, kernel will look for a dtd file, under /boot/overlays/, called myname-overlay.dtb

Then you can check if it's a faulty DT overlay or not.

Hope it helps

martinlbb
Posts: 4
Joined: Thu Jun 20, 2013 3:32 pm

Re: HAT EEPROM

Fri Apr 10, 2015 4:54 pm

There is also an error in eepmake command line arguments.
You inversed two parameters.

Syntac usage of eepmake:
eepmake input_file output_file [dt_file] [-c custom_file_1 ... custom_file_n]

In your case, you have to type:

Code: Select all

/Programme/eepmake /Programme/RTC_Hat/RTC.txt /Programme/RTC_Hat/RTC.eep /Programme/RTC_Hat/RTC.dtd 
(notice, eep output file is before DT.

And you have a strange DT file, with a dtb extension. It should be dtd extension (or maybe you have dyslexia, then happy my friend, welcome to the club!) :)

gandolf
Posts: 1
Joined: Tue Nov 07, 2017 7:57 pm

Re: HAT EEPROM

Tue Nov 07, 2017 8:00 pm

I am trying to do the same thing but I am having difficulties to detect the i2c address of the EEPROM. The EEPROMs I found on mouser usually have 3 bits of adderss/chip sel/chip EN pins. I could not find any information regarding how does rpi address the EEPROM. Or it is smart enough to detect the address and read the EEPROM contents?

Return to “Advanced users”