Skip to content

Commit

Permalink
Update device tree and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
8BitJosh authored and WillB97 committed Jul 4, 2022
1 parent b5cc6b2 commit 9db7802
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 77 deletions.
80 changes: 39 additions & 41 deletions EEPROM/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
# Utilities to create, flash and dump HAT EEPROM images.

Original source of the scripts and templates:
https://github.com/raspberrypi/hats/tree/master/eepromutils

There is a complete, worked example at:
https://www.raspberrypi.org/forums/viewtopic.php?t=108134

## Usage

1. Create tools with `make && sudo make install`
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

2. Edit `eeprom_setting.txt` to suit your specific HAT.

3. Run `./eepmake eeprom_settings.txt eeprom.eep` to create the eep binary

#### On the Raspberry Pi
0. create tools with `make && sudo make install` (If you did the previous steps on your Pi, you don't need to do this).
1. Disable EEPROM write protection
* Sometimes this requires a jumper on the board
* Sometimes this is a GPIO
* Check your schematics
2. Make sure you can talk to the EEPROM
* In the HAT specification, the HAT EEPROM is connected to pins that can be driven by I2C0.
However, this is the same interface as used by the camera and displays, so use of it by the ARMs is discouraged.
The `eepflash.sh` script gets around this problem by instantiating a software driven I2C interface using those
pins as GPIOs, calling it `i2c-9`:
```
sudo dtoverlay i2c-gpio i2c_gpio_sda=0 i2c_gpio_scl=1 bus=9
```
* Install i2cdetect `sudo apt install i2c-tools`
* Check with `i2cdetect -y 9` (should be at address 0x50)
```bash
i2cdetect -y 9 0x50 0x50
0 1 2 3 4 5 6 7 8 9 a b c d e f
00:
10:
20:
30:
40:
50: 50
60:
70:
```
Normally, you can skip this step, and assume things are working.
3. Flash eep file `sudo ./eepflash.sh -w -t=24c32 -f=eeprom.eep`
4. Enable EEPROM write protection, by undoing step 1 (putting back jumper, or resetting GPIO)
1. Add the following line to the `/boot/config.txt` file
```
dtparam=i2c_vc=on
```

2. Create tools with
```
make
```

3. Disable EEPROM write protection by shorting the two pins on the board

4. Make the device tree file
```
sudo dtc -@ -I dts -O dtb -o heartbeat.dtb heartbeat.dts
sudo chown pi:pi heartbeat.dtb
```

5. Make a file called `serial.txt` that contains only the serial number (no newline at the end)

6. Make the binary blob to go in the EEPROM
```
./eepmake eeprom_settings.txt hat.eep heartbeat.dtb -c serial.txt
```

6. Flash the blob to the EERPOM
```
sudo ./eepflash.sh -y -w -f=hat.eep -t=24c32
```

## Clearing the EEPROM
If things go bad this can be used to clear the contents of the EEPROM.
Resize as appropriate.
```
dd if=/dev/zero ibs=1k count=4 of=blank.eep
sudo ./eepflash.sh -w -f=blank.eep -t=24c32
```
67 changes: 31 additions & 36 deletions EEPROM/eeprom_settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 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
# then use eepflash tool to write to attached HAT ID EEPROM
#
# Tools available:
# eepmake Parses EEPROM text file and creates binary .eep file
Expand All @@ -19,21 +19,16 @@
product_uuid 00000000-0000-0000-0000-000000000000

# 16 bit product id
product_id 0x0000
product_id 0x4B43

# 16 bit product version
product_ver 0x0000
product_ver 0x0001

# ASCII vendor string (max 255 characters)
vendor "ACME Technology Company"
vendor "Student Robotics"

# ASCII product string (max 255 characters)
product "Special Sensor Board"

# Custom binary data
custom_data
deadbeef c00 1c0d e
end
product "KCH V1 Rev A"

########################################################################
# GPIO bank settings, set to nonzero to change from the default.
Expand All @@ -54,9 +49,9 @@ gpio_hysteresis 0
# 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
# If back_power=2 then USB high current mode will be automatically
# enabled on the Pi
back_power 0
back_power 2

########################################################################
# GPIO pins, uncomment for GPIOs used on board
Expand All @@ -68,27 +63,27 @@ back_power 0
# ---- -------- ----
#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
setgpio 4 OUTPUT DEFAULT
setgpio 5 OUTPUT DEFAULT
setgpio 6 OUTPUT DEFAULT
setgpio 7 ALT0 DEFAULT
setgpio 8 OUTPUT DEFAULT
setgpio 9 OUTPUT DEFAULT
setgpio 10 OUTPUT DEFAULT
setgpio 11 OUTPUT DEFAULT
setgpio 12 OUTPUT DEFAULT
setgpio 13 OUTPUT DEFAULT
#setgpio 14 ALT0 DEFAULT
#setgpio 15 ALT0 DEFAULT
setgpio 16 OUTPUT DEFAULT
setgpio 17 OUTPUT DEFAULT
setgpio 18 OUTPUT DEFAULT
setgpio 19 OUTPUT DEFAULT
setgpio 20 OUTPUT DEFAULT
setgpio 21 OUTPUT DEFAULT
setgpio 22 OUTPUT DEFAULT
setgpio 23 OUTPUT DEFAULT
setgpio 24 OUTPUT DEFAULT
setgpio 25 OUTPUT DEFAULT
setgpio 26 OUTPUT DEFAULT
setgpio 27 OUTPUT DEFAULT
17 changes: 17 additions & 0 deletions EEPROM/heartbeat.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2708";

fragment@0 {
target = <&leds>;
__overlay__ {
hb_led: led {
label = "hb_led";
gpios = <&gpio 19 0>;
linux,default-trigger = "heartbeat";
};
};
};
};

0 comments on commit 9db7802

Please sign in to comment.