summaryrefslogtreecommitdiffstats
path: root/util/spd_tools/lp4x
diff options
context:
space:
mode:
authorRob Barnes <robbarnes@google.com>2020-10-02 14:51:46 +0000
committerMichael Niewöhner <foss@mniewoehner.de>2020-10-03 16:29:00 +0000
commit34cf7ccebc858b7543856fb0d736ff7809ae9e6c (patch)
treef10fe2d43a79993d125bdba2104c79c399002920 /util/spd_tools/lp4x
parent2871e0e78c309041a0f3d6e0d7dca99bcaf9f12a (diff)
downloadcoreboot-34cf7ccebc858b7543856fb0d736ff7809ae9e6c.tar.gz
coreboot-34cf7ccebc858b7543856fb0d736ff7809ae9e6c.tar.bz2
coreboot-34cf7ccebc858b7543856fb0d736ff7809ae9e6c.zip
Revert "util/spd_tools: output binaries instead of hexdumps"
This reverts commit f23794cf04030bb8d1d7ebe0a3634dffd092e2f7. Reason for revert: This change breaks compatibility if the changes in CB:44775 are not also included. CB:44775 is still under discussion, so revert this change to make spd_tools usable again. Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: I5840a1b895dcbc8b91c76d8b60df2f95b93a4370 Reviewed-on: https://review.coreboot.org/c/coreboot/+/44999 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Michael Niewöhner <foss@mniewoehner.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/spd_tools/lp4x')
-rw-r--r--util/spd_tools/lp4x/README.md18
-rw-r--r--util/spd_tools/lp4x/gen_spd.go21
2 files changed, 22 insertions, 17 deletions
diff --git a/util/spd_tools/lp4x/README.md b/util/spd_tools/lp4x/README.md
index 0c49dadc4f6f..e614f259cf4f 100644
--- a/util/spd_tools/lp4x/README.md
+++ b/util/spd_tools/lp4x/README.md
@@ -168,7 +168,7 @@ Input JSON file requires the following two fields for every memory part:
This tool generates the following files using the global list of
memory parts in JSON format as described above:
* De-duplicated SPDs required for the different memory parts. These
- SPD files are named (spd_1.bin, spd_2.bin, spd_3.bin and so on)
+ SPD files are named (spd_1.hex, spd_2.hex, spd_3.hex and so on)
and placed in the directory provided as an input to the tool.
* CSV file representing which of the deduplicated SPD files is used
by which memory part. This file is named as
@@ -176,11 +176,11 @@ memory parts in JSON format as described above:
as an input to the tool along with the generated SPD
files. Example CSV file:
```
- MEMORY_PART_A, spd_1.bin
- MEMORY_PART_B, spd_2.bin
- MEMORY_PART_C, spd_3.bin
- MEMORY_PART_D, spd_2.bin
- MEMORY_PART_E, spd_2.bin
+ MEMORY_PART_A, spd_1.hex
+ MEMORY_PART_B, spd_2.hex
+ MEMORY_PART_C, spd_3.hex
+ MEMORY_PART_D, spd_2.hex
+ MEMORY_PART_E, spd_2.hex
```
## Tool 2 - gen_part_id.go
@@ -222,9 +222,9 @@ Sample Makefile.inc:
## This is an auto-generated file. Do not edit!!
SPD_SOURCES =
-SPD_SOURCES += spd_1.bin # ID = 0(0b0000) Parts = MEMORY_PART_A
-SPD_SOURCES += spd_2.bin # ID = 1(0b0001) Parts = MEMORY_PART_B, MEMORY_PART_D
-SPD_SOURCES += spd_3.bin # ID = 2(0b0010) Parts = MEMORY_PART_C
+SPD_SOURCES += spd_1.hex # ID = 0(0b0000) Parts = MEMORY_PART_A
+SPD_SOURCES += spd_2.hex # ID = 1(0b0001) Parts = MEMORY_PART_B, MEMORY_PART_D
+SPD_SOURCES += spd_3.hex # ID = 2(0b0010) Parts = MEMORY_PART_C
```
### Note of caution
diff --git a/util/spd_tools/lp4x/gen_spd.go b/util/spd_tools/lp4x/gen_spd.go
index 17388336d170..e63ca8df6fc2 100644
--- a/util/spd_tools/lp4x/gen_spd.go
+++ b/util/spd_tools/lp4x/gen_spd.go
@@ -3,7 +3,6 @@
package main
import (
- "bytes"
"encoding/json"
"fmt"
"io/ioutil"
@@ -638,14 +637,20 @@ func getSPDByte(index int, memAttribs *memAttributes) byte {
return e.constVal
}
-func createSPD(memAttribs *memAttributes) bytes.Buffer {
- var spd bytes.Buffer
+func createSPD(memAttribs *memAttributes) string {
+ var s string
for i := 0; i < 512; i++ {
- spd.WriteByte(getSPDByte(i, memAttribs))
+ b := getSPDByte(i, memAttribs)
+
+ if (i + 1) % 16 == 0 {
+ s += fmt.Sprintf("%02X\n", b)
+ } else {
+ s += fmt.Sprintf("%02X ", b)
+ }
}
- return spd
+ return s
}
func dedupeMemoryPart(dedupedParts []*memPart, memPart *memPart) bool {
@@ -660,9 +665,9 @@ func dedupeMemoryPart(dedupedParts []*memPart, memPart *memPart) bool {
}
func generateSPD(memPart *memPart, SPDId int, SPDDirName string) {
- spd := createSPD(&memPart.Attribs)
- memPart.SPDFileName = fmt.Sprintf("lp4x-spd-%d.bin", SPDId)
- ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), spd.Bytes(), 0644)
+ s := createSPD(&memPart.Attribs)
+ memPart.SPDFileName = fmt.Sprintf("lp4x-spd-%d.hex", SPDId)
+ ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), []byte(s), 0644)
}
func readMemoryParts(memParts *memParts, memPartsFileName string) error {