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>
This commit is contained in:
committed by
Patrick Georgi
parent
e10efa3a03
commit
f23794cf04
@ -3,6 +3,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@ -637,20 +638,14 @@ 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++ {
|
||||
b := getSPDByte(i, memAttribs)
|
||||
|
||||
if (i + 1) % 16 == 0 {
|
||||
s += fmt.Sprintf("%02X\n", b)
|
||||
} else {
|
||||
s += fmt.Sprintf("%02X ", b)
|
||||
}
|
||||
spd.WriteByte(getSPDByte(i, memAttribs))
|
||||
}
|
||||
|
||||
return s
|
||||
return spd
|
||||
}
|
||||
|
||||
func dedupeMemoryPart(dedupedParts []*memPart, memPart *memPart) bool {
|
||||
@ -665,9 +660,9 @@ func dedupeMemoryPart(dedupedParts []*memPart, memPart *memPart) bool {
|
||||
}
|
||||
|
||||
func generateSPD(memPart *memPart, SPDId int, SPDDirName string) {
|
||||
s := createSPD(&memPart.Attribs)
|
||||
memPart.SPDFileName = fmt.Sprintf("lp4x-spd-%d.hex", SPDId)
|
||||
ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), []byte(s), 0644)
|
||||
spd := createSPD(&memPart.Attribs)
|
||||
memPart.SPDFileName = fmt.Sprintf("lp4x-spd-%d.bin", SPDId)
|
||||
ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), spd.Bytes(), 0644)
|
||||
}
|
||||
|
||||
func readMemoryParts(memParts *memParts, memPartsFileName string) error {
|
||||
|
Reference in New Issue
Block a user