Revert "util/spd_tools: output binaries instead of hexdumps"

This reverts commit f23794cf04.

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>
This commit is contained in:
Rob Barnes
2020-10-02 14:51:46 +00:00
committed by Michael Niewöhner
parent 2871e0e78c
commit 34cf7ccebc
5 changed files with 47 additions and 39 deletions

View File

@ -3,7 +3,6 @@
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
@ -969,8 +968,8 @@ 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++ {
var b byte = 0
@ -978,10 +977,14 @@ func createSPD(memAttribs *memAttributes) bytes.Buffer {
b = getSPDByte(i, memAttribs)
}
spd.WriteByte(b)
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 {
@ -996,16 +999,16 @@ func dedupeMemoryPart(dedupedParts []*memPart, memPart *memPart) bool {
}
func generateSPD(memPart *memPart, SPDId int, SPDDirName string) {
spd := createSPD(&memPart.Attribs)
memPart.SPDFileName = fmt.Sprintf("ddr4-spd-%d.bin", SPDId)
ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), spd.Bytes(), 0644)
s := createSPD(&memPart.Attribs)
memPart.SPDFileName = fmt.Sprintf("ddr4-spd-%d.hex", SPDId)
ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), []byte(s), 0644)
}
func generateEmptySPD(SPDDirName string) {
spd := createSPD(nil)
SPDFileName := "ddr4-spd-empty.bin"
ioutil.WriteFile(filepath.Join(SPDDirName, SPDFileName), spd.Bytes(), 0644)
s := createSPD(nil)
SPDFileName := "ddr4-spd-empty.hex"
ioutil.WriteFile(filepath.Join(SPDDirName, SPDFileName), []byte(s), 0644)
}
func readMemoryParts(memParts *memParts, memPartsFileName string) error {