From 34cf7ccebc858b7543856fb0d736ff7809ae9e6c Mon Sep 17 00:00:00 2001 From: Rob Barnes Date: Fri, 2 Oct 2020 14:51:46 +0000 Subject: Revert "util/spd_tools: output binaries instead of hexdumps" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: I5840a1b895dcbc8b91c76d8b60df2f95b93a4370 Reviewed-on: https://review.coreboot.org/c/coreboot/+/44999 Reviewed-by: Angel Pons Reviewed-by: Michael Niewöhner Tested-by: build bot (Jenkins) --- util/spd_tools/lp4x/gen_spd.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'util/spd_tools/lp4x/gen_spd.go') diff --git a/util/spd_tools/lp4x/gen_spd.go b/util/spd_tools/lp4x/gen_spd.go index 17388336d1..e63ca8df6f 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 { -- cgit v1.2.3