写入树莓派的HATS IDROM

/ 0评 / 0

总结起来就是需要先打开I2C设备,然后从禁止VideoCore访问,然后开始编程,最后就成功了,首先你lsmod一下,看I2C设备加载没有,没有的话,赶紧去加载.

如果你用树莓派B+就没有regmap_i2c,其他一样:

i2c_bcm2708
i2c-dev
regmap_i2c

如果你使用B+,就在cmdline上添加 bcm2708.vc_i2c_override=1,如果是Pi 2添加 bcm2709.vc_i2c_override=1,这样就可以顺利编程,看结果:

pi@raspberrypi ~/hats/eepromutils $ sudo ./eepflash.sh -w -f=eep.eep -t=24c256
This will disable the camera so you will need to REBOOT after this process completes.
This will attempt to write to i2c address 0x50. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Writing...
0+1 records in
0+1 records out
105 bytes (105 B) copied, 2.07791 s, 0.1 kB/s
Done.

其实这个和Beaglebone Black Cape EEPROM是一个道理的,至于eep.eep文件,是我用eepmake生成的,原始文件应该是这样的:

########################################################################
# 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 0x0055
# 16 bit product version
product_ver 0x0003
# ASCII vendor string  (max 255 characters)
vendor "TaterLi"
# ASCII product string (max 255 characters)
product "Special 595 LED Board"
########################################################################
# 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     ALT0     DEFAULT
setgpio  8     ALT0     DEFAULT
setgpio  9     ALT0     DEFAULT
setgpio  10    ALT0     DEFAULT
setgpio  11   ALT0     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    OUTPUT     DEFAULT
#setgpio  19    INPUT     DEFAULT
#setgpio  20    INPUT     DEFAULT
#setgpio  21    INPUT     DEFAULT
setgpio  22    INPUT     DEFAULT
setgpio  23    OUTPUT     DEFAULT
setgpio  24    OUTPUT     DEFAULT
#setgpio  25    INPUT     DEFAULT
#setgpio  26    INPUT     DEFAULT
#setgpio  27    INPUT     DEFAULT

上面是我自己做一个595扩展IO的板子,看到SPI是ALT0,其实是可以查得到的,详细还是http://elinux.org/RPi_BCM2835_GPIOs看看吧.这个EEPROM太小也不好,我选AT24C256主要是为了后期可能加一些其他,当然AT24C32就够了.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注