forked from srobo/kch-hw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; | ||
}; | ||
}; | ||
}; |