aboutsummaryrefslogtreecommitdiff
path: root/util/spd_tools/ddr4/gen_spd.go
diff options
context:
space:
mode:
authorMichael Niewöhner <foss@mniewoehner.de>2020-08-28 00:59:19 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-09-08 05:46:41 +0000
commitf23794cf04030bb8d1d7ebe0a3634dffd092e2f7 (patch)
tree4108c93827195d8cc9e799c9c7c324cfd1679214 /util/spd_tools/ddr4/gen_spd.go
parente10efa3a037c78c831a2b94c75eb0ab862412acf (diff)
util/spd_tools: output binaries instead of hexdumps
Instead of generating hexdumps, output binary SPD files since we plan to convert all hex SPD files to binary. Also adjust the file extension where needed. Test: compared generated binaries with converted binaries from hex files Change-Id: Ie99d108ca90758d09dbefad20fe6c9f7fc263ef1 Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/44878 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'util/spd_tools/ddr4/gen_spd.go')
-rw-r--r--util/spd_tools/ddr4/gen_spd.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/util/spd_tools/ddr4/gen_spd.go b/util/spd_tools/ddr4/gen_spd.go
index 3c8f71a263..b60ab03d81 100644
--- a/util/spd_tools/ddr4/gen_spd.go
+++ b/util/spd_tools/ddr4/gen_spd.go
@@ -3,6 +3,7 @@
package main
import (
+ "bytes"
"encoding/json"
"fmt"
"io/ioutil"
@@ -968,8 +969,8 @@ func getSPDByte(index int, memAttribs *memAttributes) byte {
return e.constVal
}
-func createSPD(memAttribs *memAttributes) string {
- var s string
+func createSPD(memAttribs *memAttributes) bytes.Buffer {
+ var spd bytes.Buffer
for i := 0; i < 512; i++ {
var b byte = 0
@@ -977,14 +978,10 @@ func createSPD(memAttribs *memAttributes) string {
b = getSPDByte(i, memAttribs)
}
- if (i + 1) % 16 == 0 {
- s += fmt.Sprintf("%02X\n", b)
- } else {
- s += fmt.Sprintf("%02X ", b)
- }
+ spd.WriteByte(b)
}
- return s
+ return spd
}
func dedupeMemoryPart(dedupedParts []*memPart, memPart *memPart) bool {
@@ -999,16 +996,16 @@ func dedupeMemoryPart(dedupedParts []*memPart, memPart *memPart) bool {
}
func generateSPD(memPart *memPart, SPDId int, SPDDirName string) {
- s := createSPD(&memPart.Attribs)
- memPart.SPDFileName = fmt.Sprintf("ddr4-spd-%d.hex", SPDId)
- ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), []byte(s), 0644)
+ spd := createSPD(&memPart.Attribs)
+ memPart.SPDFileName = fmt.Sprintf("ddr4-spd-%d.bin", SPDId)
+ ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), spd.Bytes(), 0644)
}
func generateEmptySPD(SPDDirName string) {
- s := createSPD(nil)
- SPDFileName := "ddr4-spd-empty.hex"
- ioutil.WriteFile(filepath.Join(SPDDirName, SPDFileName), []byte(s), 0644)
+ spd := createSPD(nil)
+ SPDFileName := "ddr4-spd-empty.bin"
+ ioutil.WriteFile(filepath.Join(SPDDirName, SPDFileName), spd.Bytes(), 0644)
}
func readMemoryParts(memParts *memParts, memPartsFileName string) error {